Repository navigation
feat(edit): read only the requests added since an earlier read - #336
Merged
Merged
Conversation
editor.getModelRequests() copies the whole request log out of the worker. Code that follows the log after each edit (to map the ids of created items, or to see what changed) copies it again every time, so each read costs more the longer a session goes without saving, especially when requests carry large data such as metadata updates. editor.getModelRequestsSince(modelId, from, generation) returns the requests from `from` on, the request count and a generation of the log. The generation changes when the log changes other than by appending (undo, selectRequest, setRequests, reset); a read with an older generation, or a `from` the log does not have, returns all requests from 0. SingleThreadedFragmentsModel gets the same getRequestsSince().
agviegas
added a commit
that referenced
this pull request
Oct 11, 2026
A model saved or loaded again under the same id started its request log generation at 0 again, so a reader holding the old generation was handed an empty tail and missed the edits made after the save. Each model instance now starts its generation at a random 32-bit integer. 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.
Description
Closes #333.
editor.getModelRequests()copies the whole request log out of the worker. Code that follows the log after each edit copies it again every time, which grows with every unsaved edit. This addseditor.getModelRequestsSince(modelId, from = 0, generation = -1), which returns{ generation, from, count, requests }: only the requests fromfromon.VirtualFragmentsModel.getRequestsSince(from, generation)returns the requests afterfromif the log only grew sincegeneration. If not, it returns all of them from 0, so a caller never misses a change.undo,selectRequest,setRequestsandreset. Appends (edit,redo,save) keep it.Editor.getModelRequestsSince→EditHelper.getRequestsSince→FragmentsModel._getRequestsSince→_invoke("getRequestsSince").SingleThreadedFragmentsModel.getRequestsSince(from?, generation?).EditRequestsSincetype inUtils/edit/edit-types.ts.virtual-model/requests-since.test.tscovers:selectRequest,setRequestsandresetreturn everything;fromthe log does not have returns everything.getModelRequestsis unchanged. History panels that also needundoneRequestskeep using it.Additional context
In an authoring app that reads the log after every edit, this cut an edit at 40 unsaved steps from 339 ms to about 165 ms (see #333).
yarn test(all 29 files),tsc -p tsconfig-build.jsonandyarn build-corepass.What is the purpose of this pull request?
Before submitting the PR, please make sure you do the following:
feat(examples): add hello-world example).fixes #123).