From 31e6eed96fe52e8626fedc3645d267df6df9aa87 Mon Sep 17 00:00:00 2001 From: tusharmagar Date: Mon, 12 Jan 2026 12:11:08 +0530 Subject: [PATCH] TipTap improvements --- apps/x/apps/renderer/src/App.tsx | 11 +++++++++-- .../apps/renderer/src/components/markdown-editor.tsx | 1 + apps/x/apps/renderer/src/contexts/sidebar-context.tsx | 11 +++++++++-- 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/apps/x/apps/renderer/src/App.tsx b/apps/x/apps/renderer/src/App.tsx index 40bceae4..7c76ec3d 100644 --- a/apps/x/apps/renderer/src/App.tsx +++ b/apps/x/apps/renderer/src/App.tsx @@ -11,7 +11,7 @@ import { MarkdownEditor } from './components/markdown-editor'; import { useDebounce } from './hooks/use-debounce'; import { SidebarIcon } from '@/components/sidebar-icon'; import { SidebarContentPanel } from '@/components/sidebar-content'; -import { SidebarSectionProvider } from '@/contexts/sidebar-context'; +import { SidebarSectionProvider, type ActiveSection } from '@/contexts/sidebar-context'; import { Conversation, ConversationContent, @@ -538,6 +538,13 @@ function App() { setExpandedPaths(newExpanded) } + // Handle sidebar section changes - switch to chat view for ask-ai and agents + const handleSectionChange = useCallback((section: ActiveSection) => { + if (section === 'ask-ai' || section === 'agents') { + setSelectedPath(null) + } + }, []) + // Knowledge quick actions const collectDirPaths = (nodes: TreeNode[]): string[] => nodes.flatMap(n => n.kind === 'dir' ? [n.path, ...(n.children ? collectDirPaths(n.children) : [])] : []) @@ -697,7 +704,7 @@ function App() { return ( - +
{/* Icon sidebar - always visible, fixed position */} diff --git a/apps/x/apps/renderer/src/components/markdown-editor.tsx b/apps/x/apps/renderer/src/components/markdown-editor.tsx index ec2bf47f..ccb993f1 100644 --- a/apps/x/apps/renderer/src/components/markdown-editor.tsx +++ b/apps/x/apps/renderer/src/components/markdown-editor.tsx @@ -35,6 +35,7 @@ export function MarkdownEditor({ content, onChange, placeholder = 'Start writing }), Markdown.configure({ html: false, + breaks: true, transformCopiedText: true, transformPastedText: true, }), diff --git a/apps/x/apps/renderer/src/contexts/sidebar-context.tsx b/apps/x/apps/renderer/src/contexts/sidebar-context.tsx index 1f89b7f4..066fadba 100644 --- a/apps/x/apps/renderer/src/contexts/sidebar-context.tsx +++ b/apps/x/apps/renderer/src/contexts/sidebar-context.tsx @@ -21,19 +21,26 @@ export function useSidebarSection() { export function SidebarSectionProvider({ defaultSection = "ask-ai", + onSectionChange, children, }: { defaultSection?: ActiveSection + onSectionChange?: (section: ActiveSection) => void children: React.ReactNode }) { - const [activeSection, setActiveSection] = React.useState(defaultSection) + const [activeSection, setActiveSectionState] = React.useState(defaultSection) + + const setActiveSection = React.useCallback((section: ActiveSection) => { + setActiveSectionState(section) + onSectionChange?.(section) + }, [onSectionChange]) const contextValue = React.useMemo( () => ({ activeSection, setActiveSection, }), - [activeSection] + [activeSection, setActiveSection] ) return (