diff --git a/src/components/layout/AppShell.tsx b/src/components/layout/AppShell.tsx index 055ff86..81537d3 100644 --- a/src/components/layout/AppShell.tsx +++ b/src/components/layout/AppShell.tsx @@ -115,12 +115,11 @@ export function AppShell({ children }: { children: React.ReactNode }) { }, []); // Auto-open panel on chat detail routes, close on others + // Also close doc preview when navigating away or switching sessions useEffect(() => { setPanelOpenRaw(isChatDetailRoute); - if (!isChatDetailRoute) { - setPreviewFileRaw(null); - } - }, [isChatDetailRoute]); + setPreviewFileRaw(null); + }, [isChatDetailRoute, pathname]); const setPanelOpen = useCallback((open: boolean) => { setPanelOpenRaw(open); diff --git a/src/components/layout/DocPreview.tsx b/src/components/layout/DocPreview.tsx index 06cea04..c2a6503 100644 --- a/src/components/layout/DocPreview.tsx +++ b/src/components/layout/DocPreview.tsx @@ -93,8 +93,9 @@ export function DocPreview({ }; }, [filePath]); - const handleCopyPath = async () => { - await navigator.clipboard.writeText(filePath); + const handleCopyContent = async () => { + const text = preview?.content || filePath; + await navigator.clipboard.writeText(text); setCopied(true); setTimeout(() => setCopied(false), 2000); }; @@ -126,13 +127,13 @@ export function DocPreview({ )} -