File previews read once and then froze: visited tabs stay mounted-but-hidden (LRU in useMountedTabSet), so refetchOnMount never re-fired and the only way to see fresh content was to close and reopen the tab. Gate the file query's `enabled` on tab + app visibility so React Query refetches on the disabled->enabled transition — and only when the cached read is stale (keeping the existing 5s staleTime), so a quick flip away and back doesn't re-read. Covers switching between tabs and backgrounding/reopening the whole app to the same tab. Adds a wiring test covering the stale-revisit refetch, the fresh-revisit debounce, the app-foreground refetch, and the read-error path. Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.8
parent
99643ad085
commit
daf7042cd2
@@ -0,0 +1,17 @@
|
||||
/**
|
||||
* Whether `FilePane` should read its file right now.
|
||||
*
|
||||
* The read is gated on visibility so a revisited tab refetches instead of showing
|
||||
* the frozen first-load snapshot (#445): React Query refetches on the
|
||||
* disabled→enabled transition (stale-gated by the query's staleTime). The file is
|
||||
* read only when there is something to read AND the pane can actually show it —
|
||||
* the tab is the active one (not a hidden, mounted-but-offscreen tab) and the
|
||||
* whole app is in the foreground.
|
||||
*/
|
||||
export function isFileQueryEnabled(input: {
|
||||
hasReadTarget: boolean;
|
||||
isTabActive: boolean;
|
||||
isAppVisible: boolean;
|
||||
}): boolean {
|
||||
return input.hasReadTarget && input.isTabActive && input.isAppVisible;
|
||||
}
|
||||
Reference in New Issue
Block a user