A file switched to shows itself, says it is loading, and is not re-read per render - #85
Merged
Merged
Conversation
…ad per render Three bugs in useFilesState, two reported and one found on the way. Switching files showed the previous file under the new one's name for as long as the read took: file, media and refusal were read as the answer for whatever was open, which held only once a read had landed. They are now exposed only for the path they were read for (readFor), and meanwhile the panel says Loading... -- held back 150ms by a CSS step, since most reads land in a few milliseconds. A file with unsaved edits was never read at all. The draft check that keeps the poll from rewriting what you are typing also skipped the first read, so edit B, click A, click B left A's text on screen under B's name, and the rev held was A's, which a save of B would have been checked against. The first read now always happens; the editor opens on the draft whenever there is one, so it is safe. And the tree and the open file were re-read on every render of the row. onToggleDir and onOpen are inline arrows there, so as effect dependencies they tore the reads down and restarted them on every socket update -- the flood of /tree?path= reported from the network panel. They are read through refs now. Measured on a scratch instance, 12s of clicking between Claude and the tree: 94 tree and 90 file reads before, 4 and 6 after, which is the 3s and 2s polls exactly. Checked with file reads delayed 800ms: at 50ms nothing is shown and the note is still hidden, at 400ms it reads Loading..., then the new file's own text -- never the old one. Each of the three new tests in web/test/filesState.test.ts fails with its fix reverted. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Three bugs in useFilesState, two reported and one found on the way.
Switching files showed the previous file under the new one's name for
as long as the read took: file, media and refusal were read as the
answer for whatever was open, which held only once a read had landed.
They are now exposed only for the path they were read for (readFor),
and meanwhile the panel says Loading... -- held back 150ms by a CSS
step, since most reads land in a few milliseconds.
A file with unsaved edits was never read at all. The draft check that
keeps the poll from rewriting what you are typing also skipped the
first read, so edit B, click A, click B left A's text on screen under
B's name, and the rev held was A's, which a save of B would have been
checked against. The first read now always happens; the editor opens
on the draft whenever there is one, so it is safe.
And the tree and the open file were re-read on every render of the
row. onToggleDir and onOpen are inline arrows there, so as effect
dependencies they tore the reads down and restarted them on every
socket update -- the flood of /tree?path= reported from the network
panel. They are read through refs now. Measured on a scratch instance,
12s of clicking between Claude and the tree: 94 tree and 90 file reads
before, 4 and 6 after, which is the 3s and 2s polls exactly.
Checked with file reads delayed 800ms: at 50ms nothing is shown and
the note is still hidden, at 400ms it reads Loading..., then the new
file's own text -- never the old one. Each of the three new tests in
web/test/filesState.test.ts fails with its fix reverted.
🤖 Generated with Claude Code