From 918949c7fa421d1a7b764c1f153d0b299b597b59 Mon Sep 17 00:00:00 2001 From: Li Mu Zhi Date: Wed, 15 Apr 2026 13:24:14 +0800 Subject: [PATCH] fix: file preview shows stale content when re-opening a file (#411) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix: file preview shows stale content when re-opening a file The file content query inherits `refetchOnMount: false` and `gcTime: Infinity` from the global QueryClient defaults, so re-opening a previously viewed file never re-fetches its content. Set `staleTime: 0` and `refetchOnMount: true` on the file preview query so it always fetches the latest content when the component mounts. Fixes #351 * fix: keep original staleTime, only add refetchOnMount staleTime: 5_000 is reasonable — avoids redundant fetches when quickly toggling the same file. The actual fix only needs refetchOnMount: true to override the global default of false. --------- Co-authored-by: muzhi1991 --- packages/app/src/components/file-pane.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/app/src/components/file-pane.tsx b/packages/app/src/components/file-pane.tsx index d65a34cbe..e11419e57 100644 --- a/packages/app/src/components/file-pane.tsx +++ b/packages/app/src/components/file-pane.tsx @@ -264,6 +264,7 @@ export function FilePane({ return { file: payload.file ?? null, error: payload.error ?? null }; }, staleTime: 5_000, + refetchOnMount: true, }); return (