From 8747464c2fbb62d0cc895858118460b3a4c00a8a Mon Sep 17 00:00:00 2001 From: 7418 <7418@openclaw.ai> Date: Wed, 11 Feb 2026 23:26:29 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20doc=20preview=20bugs=20=E2=80=94=20close?= =?UTF-8?q?=20on=20chat=20switch,=20copy=20content,=20filter=20binary=20fi?= =?UTF-8?q?les?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Close doc preview when switching between chats (pathname change) - Copy button now copies file content instead of file path - Skip preview for images, videos, audio, archives, and other binary files Co-Authored-By: Claude Opus 4.6 --- src/components/layout/AppShell.tsx | 7 +++---- src/components/layout/DocPreview.tsx | 9 +++++---- src/components/layout/RightPanel.tsx | 13 +++++++++++++ 3 files changed, 21 insertions(+), 8 deletions(-) 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({ )} -