From 33197c590f15d8ffdc2d5243fde84c6db3e68d1a Mon Sep 17 00:00:00 2001 From: Botong Wu <2048400180@qq.com> Date: Thu, 26 Nov 2026 19:19:42 +0800 Subject: [PATCH] fix: reset file availability when switching viewer tabs --- web/components/chat/home/SessionViewerPanel.tsx | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/web/components/chat/home/SessionViewerPanel.tsx b/web/components/chat/home/SessionViewerPanel.tsx index 176882516..dd6c7602e 100644 --- a/web/components/chat/home/SessionViewerPanel.tsx +++ b/web/components/chat/home/SessionViewerPanel.tsx @@ -1354,12 +1354,14 @@ function SessionViewerPanelInner( const probeUrl = sourceUrl && isChatFileLink(sourceUrl) ? previewUrl : null; const fileTabId = fileTab?.id; const [fileCheck, setFileCheck] = useState<{ - tabId: string; - url: string; - available: boolean; - }>(); + tabId: string | undefined; + url: string | null; + available: boolean | null; + }>({ tabId: fileTabId, url: probeUrl, available: null }); + if (fileCheck.tabId !== fileTabId || fileCheck.url !== probeUrl) { + setFileCheck({ tabId: fileTabId, url: probeUrl, available: null }); + } useEffect(() => { - setFileCheck(undefined); if (!fileTabId || !probeUrl) return; const controller = new AbortController(); void apiFetch(probeUrl, { @@ -1395,8 +1397,8 @@ function SessionViewerPanelInner( return () => controller.abort(); }, [fileTabId, probeUrl, sourceUrl]); - const checkingFile = Boolean(probeUrl && (fileCheck?.tabId !== fileTabId || fileCheck?.url !== probeUrl)); - const fileAvailable = probeUrl ? !checkingFile && fileCheck?.available === true : Boolean(previewUrl); + const checkingFile = Boolean(probeUrl && fileCheck.available === null); + const fileAvailable = probeUrl ? fileCheck.available === true : Boolean(previewUrl); const fileUnavailable = !fileAvailable && (Boolean(probeUrl) || fileSource?.extractedText === undefined); const openLocalFile = useCallback(