Skip to content

A file switched to shows itself, says it is loading, and is not re-read per render - #85

Merged
andrin-n-dream merged 1 commit into
masterfrom
files
Sep 30, 2026
Merged

andrin-n-dream merged 1 commit into
masterfrom
files

Conversation

@andrin-n-dream

Copy link
Copy Markdown
Contributor

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

…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>
@andrin-n-dream
andrin-n-dream merged commit a7b1e57 into master Sep 30, 2026
1 check passed
@andrin-n-dream
andrin-n-dream deleted the files branch September 30, 2026 15:07
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