Skip to content

feat(app): refresh open sidebar files when they change on disk - #57426

Closed
jlongster wants to merge 1 commit into
betafrom
live-file-reload
Closed

jlongster wants to merge 1 commit into
betafrom
live-file-reload

Conversation

@jlongster

Copy link
Copy Markdown
Contributor

Issue for this PR

Closes #

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Files open in the right-hand sidebar now update when they change on disk, whether the agent, your editor, or git changed them.

The app already rereads open files on filesystem.changed. But since #41096 the server only watches the VCS HEAD file, so in practice that event never fires for workspace files. This PR doesn't add a server watcher. It refreshes from the client instead:

  • Shown file: SessionFileView rereads the visible file tab every 2s, but only while the tab is visible in its pane and the window isn't hidden. It also rereads once when the tab becomes visible. The interval is cleared when the tab is hidden or closed, the window is hidden, or the view unmounts. fs.read sends ETag/no-cache, so most of these rereads come back as 304s.
  • Agent edits: session.tool.success and session.tool.failed on the directory's event stream trigger one reread of every open file tab. A 250ms debounce collapses a burst of tool calls into a single reread. This covers background tabs, not just the shown one.
  • In-place updates: a reread whose bytes match what's already loaded leaves the store alone, so the viewer doesn't re-render. A reread of a file that's already loaded or not found no longer sets loading, so the viewer keeps showing the old content (or its existing not-found message) until the new reply lands. No more "Loading…" flash. The code view already keeps its scroll position and selection when the content object changes (see the existing "rereads a file each time an artifact link opens it" e2e test).
  • Deleted files: a deleted file shows the existing not-found state. A re-created file is picked up on the next reread.

Limits:

  • External edits show up within about 2s, and only for the file that's currently shown. Background tabs update on agent tool calls or when you switch back to them.
  • Binary files aren't polled. After a tool call, binaries over 8 MiB aren't reread either, so large media keeps what it loaded until it's reopened.
  • This is polling. Instant external-edit updates would need a bounded per-file watch on the server, which this PR doesn't add.

How did you verify your code works?

  • bun typecheck in packages/app and packages/gui-extensions
  • bun run lint:changed origin/beta
  • Added sameFileContent cases to packages/app/src/workspaces/files/artifact.test.ts and ran that file
  • Otherwise relying on CI. I did not test this manually in the GUI.

Screenshots / recordings

N/A. The content updates in place, with no other UI change.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

@jlongster

Copy link
Copy Markdown
Contributor Author

Replaced by #57915 (server-side file watches instead of polling).

@jlongster jlongster closed this Oct 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant