Repository navigation
A write names the files it changed; the Studio reads those, not the root (#599) - #600
Merged
Merged
Conversation
…oot (#599) After every write the Worker told the root's room `changed`, and every open Studio read the whole root again (list and bin, about 1,200 D1 rows for a project of 110 files), the saving window twice. With editors saving every 400 to 700 ms that came to 4.4 million rows read in a day by one person. - Worker: a write that changed nothing but some files' own records names them, `{ type: "changed", files }` (PUT /api/files/:id, property values, a canvas's render, a photo and its images; at most 16, one root). A changed property definition, a new file others already point at, and every wider route stay unnamed. - Studio: `loadFiles` reads named files one by one and puts them into the root's list; reads of a root run one after the other, a waiting root read answers every call, and a heard change is skipped when a read that began after it covers it (the window's own change no longer reads twice). - Autosaves, renames, bodies, new files, values and the import's preview step read their file instead of the root. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…599) - Worker route test (live-root.test.ts): every kind of named write is checked against the whole root, read before and after: nothing but the named files may differ. The writes that reach further (a new file something points at, a changed definition, move, copy, bin, restore, more than 16 files) must stay unnamed. - Studio unit test (files.test.ts): the store's reads with fetch, WebSocket and the debounce timer stood in: named and plain changes, bursts, the window's own change read once, a change heard after a read began, a late answer of an earlier read, the fallbacks to the root, the socket coming back. - files.ts imports ./api.ts by its file name so node --test can load it, and exports `watch`. Co-Authored-By: Claude Fable 5.2 <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.
Closes #599
What changed
Worker
{ type: "changed", files: [ids] }. Routes say so withchangedOnly(ctx, …ids)(files.ts);index.tspasses the ids on when one root was touched and at most 16 files are named.PUT /api/files/:id(with the parent when an internal file is saved under its lock),PUT /api/files/:id/properties,POST /api/properties/set,PUT /api/canvases/:id/:part,PUT /api/photos/:idandPUT /api/photos/:id/:part(every photo that shares the image).Studio (
files.ts)loadFiles(root, ids)reads the named files withGET /api/files/:idand puts them into the root's list, kept in the server's order. What it cannot place (a file that left the list, not found, another root's, more than 16) reads the root.Decisions
changedOnlybehaves as before.changed).updated_atand the body right for the other windows on the page.Checked
make checkran through.live-root.test.ts: every kind of named write is checked against the whole root read before and after (nothing but the named files may differ); the wider writes must stay unnamed.apps/studio/src/files.test.ts: the store's reads withfetch,WebSocketand the timer stood in (12 cases); deliberate breaks of the store (never skipping a heard change, reads not in line) each made a test fail.projects.test.tsnow checks which changes are named (a new file, a rename) and which are not (bin, move, a new file a shortcut already points at).GET /api/files/:ideach, shown in the list;PUTand oneGET /api/files/:id;Not clicked through
🤖 Generated with Claude Code