Skip to content

Commit 7043061

Browse files
donjor-agent[bot]donjor
authored andcommitted
fix(web): an open file re-reads on reopen and window focus
> 🤖 claude/anthropic claude-opus-5-5 (high) ## What Changed - `FilePreviewPanel` calls upstream's `useLiveRefresh` for the open file - Re-reads on reopen and on window focus - Same enable rule as the workspace mutation refresh - Unsaved edits stay in the optimistic file ## Why An edit made outside T3 Code reports no workspace mutation. The cached read outlives a closed tab by five minutes, so a reopened file showed old contents until a reload. Upstream-triage: upstream bug, no upstream fix. Upstream `pingdotgg#6452` (open) covers the file tree listing, not open file contents. Part of #1361; the rich editor half is in a companion pull request. ## Close conditions - [x] **Reopen:** a reopened tab shows disk content - [x] **Unsaved edits:** never silently discarded ## UI Changes Built desktop app on an isolated home; disk edited outside the app. | Case | Capture | | --- | --- | | Reopen, before | ![reopen-before](https://github.com/user-attachments/assets/a833f266-17a5-4b1a-ac6c-db02886fc79e) | | Reopen, after | ![reopen-after](https://github.com/user-attachments/assets/da150452-3aa2-4e41-aa5f-b775d2bc9dc7) | Window focus was checked with a dispatched `focus` event; rich mode showed the new content. ## Verification - `vp run typecheck` (web) → exit 0 - `vp test run apps/web/src/hooks/useLiveRefresh` → exit 0, 14 passed - `vp run build:desktop` → exit 0 - `vp run fork:ci` → exit 0 ## Checklist - [x] This PR is small and focused - [x] I explained what changed and why - [x] I included before/after screenshots for any UI changes - [x] I included a video for animation/interaction changes (n/a) Claude Opus 5.5 via Claude Code in T3 Code. ## Fork trailers Fork-Domain: upstream-fixes Fork-Tier: bugfix Fork-Upstreamable: yes <!-- gh-bot:attest {"v":2,"repo":"RSI-Software/t3code-hyprws","ref":"fix/open-file-reread@6a9eff2","agents":[{"role":"host","iface":"claude","provider":"anthropic","model":"claude-opus-5-5","effort":"high","harness":"[email protected]","session":"f01f8046c783"}],"ts":"2026-09-28T23:04:53Z"} --> Co-authored-by: donjor <[email protected]>
1 parent fed0ac0 commit 7043061

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

‎apps/web/src/components/files/FilePreviewPanel.tsx‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ import { useRemoteOpenState } from "~/remoteOpen";
5959
import { useClientSettings, updateClientSettings } from "~/hooks/useSettings";
6060
import { useTheme } from "~/hooks/useTheme";
6161
import { getLocalStorageItem, setLocalStorageItem, useLocalStorage } from "~/hooks/useLocalStorage";
62+
import { useLiveRefresh } from "~/hooks/useLiveRefresh";
6263
import { resolveDiffThemeName } from "~/lib/diffRendering";
6364
import { PREFERRED_HIGHLIGHTER } from "~/lib/syntaxHighlighting";
6465
import { cn } from "~/lib/utils";
@@ -1175,6 +1176,17 @@ export default function FilePreviewPanel({
11751176
)
11761177
: NO_FILE_REVISION_ATOM,
11771178
);
1179+
// An edit made outside T3 Code reports no mutation, and the cached read
1180+
// outlives a closed tab. Arriving at the file again, by reopening it or
1181+
// focusing the window, re-reads it; unsaved edits stay in the optimistic file.
1182+
useLiveRefresh(file.refresh, {
1183+
enabled:
1184+
attachment === undefined &&
1185+
relativePath !== null &&
1186+
(isFolder || (!isMedia && !isPdf)) &&
1187+
!selectedFilePending,
1188+
key: `file:${environmentId}:${cwd}:${relativePath ?? ""}`,
1189+
});
11781190

11791191
// oxlint-disable-next-line t3code/no-unreasoned-state-sync -- scrolls the breadcrumb DOM so the deepest and current crumbs are in view after commit
11801192
useEffect(() => {

0 commit comments

Comments
 (0)