Repository navigation
fix(files): Refresh re-reads the open file, and the agent's edits to it show - #300
Conversation
…it show With a file open, Refresh listed the folder again, which is not drawn while the file is, so it did nothing anyone could see: the text, the saved copy and the time it was read at stayed as they were. And the agent's write or edit of the file that is open showed only while the panel was following and had no unsaved changes. - Refresh acts on what is on screen. With a file open it reads the file again where it is (rereadFile): the text stays until the new text is here, with no "Loading…" between, and the view it is shown in, the page or the source, is kept; emptied, it is the source, as an empty file opens. Unsaved changes are never replaced: if the file changed under them, the bar about a changed file asks, as a save does. The icon turns while the file is read, as it does for the folder, which Refresh still lists again when no file is open. - A write or edit by this chat's agent of the file that is open gets the same, whether the panel follows or not; following, it is no longer opened anew with "Loading…" between, and an edit in the way is asked about instead of left with an old copy. - The guide says what Refresh does, and that a change made outside the chat is not noticed by itself. Closes #292 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 34 minutes. View limit details
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Merge Risk: ⚪ Minimal · up to
|
…lists the folder too - A read of the open file asked before a save answered (Refresh, or the agent's change) found the file as it was before the save. Answered after it, there were no unsaved changes any more, so its old text went on screen as saved, with the time from before: the next save was refused, and "Save mine anyway" would have written the old text over the saved one. The save's answer now makes such a read not the answer, as opening another file does. - With a file open, Refresh read only the file, so Back showed the folder as it was when the file was opened. It lists the folder again as well, as it did before, and as the agent's activity does. - The guide says which changes Files notices by itself: only the agent's write and edit tools. Its shell commands are not noticed either. Part of #292 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
What was seen
In a chat's Files panel, open a file, then let it change on disk. The panel keeps showing the old text. Clicking Refresh changes nothing either, so it looks broken.
Why
loadDir(dir)). The panel draws the file instead of the folder at that point, so the new listing was never shown. The file's text, its saved copy and the time it was read at were never read again.latestFileActivity→ the activity effect inFilesPanel.tsx). That effect stopped early when the panel was not following, and also when there were unsaved changes. So the agent editing the open file showed nothing in either case.The change
All of it is in
extensions/files/src/FilesPanel.tsx.rereadFile. That reads the file again without blanking the view to "Loading…". The old text stays until the new text is here, and the view stays as it was (the source or the rendered page). Opening the file withloadFilewould have reset that view. One exception, the same rule as opening a file: a page that becomes empty is shown as the source, because a blank page cannot be typed into. The icon spins while the folder or the file is read.fileAsk, the same way opening another file or going back does.rereadFiletoo, whether or not the panel is following. With unsaved changes it shows the bar and keeps the draft. When following, this also means the open file is no longer reopened with "Loading…" in between. A read by the agent, or a change to a different file, works as before.docs/guide/files.mdnow describes Refresh, how the agent's edits to the open file show up, and that the agent's write and edit tools are the only changes Files notices by itself.No new UI text, so there are no new German strings.
Left for later
Files still does not refresh by itself for any change that is not the agent's write or edit tool: the agent's own shell commands (
sed -i, a formatter,git checkout, a build), another chat, a terminal, another device, a cron job. That needs a server-side watch or a stat route and a stream to the panel. The docs extension's server half (watchDirsinextensions/docs/server.js:fs.watchplus a stream to the page) is a model for it. Until then, Refresh is how such a change shows. This is the first part of #292 ("No auto-refresh"), so this PR does not close the issue.Tests
New browser specs in
extensions/files/test/browser/refresh.spec.mts(11 tests). The mock takes the file's contents when a read arrives, as the server reads it then, so a read that is held answers with the file as it was before.Results:
npx playwright test extensions/files/test/browser extensions/git/test/browser/chat.spec.mts: 44 passed.FilesPanel.tsx.origin/main'sFilesPanel.tsx, the first commit's new specs gave 8 failed and 1 passed (the folder-view guard).loadFile; no dirty branch; asking without comparing the mtime; the activity line removed; reads counted as changes; any file counted; the empty-page rule removed; the bar or the save error not cleared; a failed read with unsaved changes kept silent; the draft not reset; no spinner; the spinner never stopping; the folder view's Refresh doing nothing; a failed read always asking.node --import tsx --test extensions/files/test/*.test.mts: 21 passed.npm run buildinextensions/files(build plustsc --noEmit) is clean, andnpm run check:boundariespasses.Part of #292
Note for merging: the first commit's message still ends with the keyword line that closes the issue, and that cannot change without a force-push. Squash-merge and take that line out of the squash message. A merge commit would keep it and close the issue.
🤖 Generated with Claude Code
Summary by CodeRabbit