Repository navigation
[fix] canvas: open node versions without copying every commit - #410
Merged
Merged
Conversation
Listing a node's versions read history(), which deep-copies every commit snapshot. On a 500-commit project that took about 7 s per open, while the listing itself needs well under 0.1 s. Scan the shared read-only records instead, as version counts already do, and copy only the small listing out so callers never hold shared records. Applying a version reuses the same read-only scan. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
github-actions
Bot
requested review from
Probiotics5333,
allendyu and
kunkunblueberry
November 19, 2026 15:15
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.
Summary
GET /api/creation/projects/{id}/items/{item}/versions) calledhistory(), which deep-copies every commit snapshot. On a real 500-commit project (108 MB of commit JSON) one open took about 7 s; the listing itself needs well under 0.1 s.node_versionsandversion_familynow scan the shared read-onlyrecords(), the same approachversion_countsalready uses. Only the small listing is deep-copied out, so callers never hold shared records.canvas.applyVersion) goes throughversion_familytoo, so it also skips the full copy. The rarer path that restores an edited image document still readshistory().Linked issue
Labels
type:bug,area:canvas,area:performanceTest plan
pytest tests/test_creation_*.py: 483 passed.test_listing_scans_shared_records_without_copying_or_exposing_them: fails ifhistory()is called, if a returned object is shared with the commit records, or if the records change. It fails onmainand passes with this change.node_versionsfor all 9 nodes that have more than one version: identical JSON output, commit records byte-identical before and after. Mean time per call went from 6.83 s to 0.066 s.Evidence that it works
GET .../items/{item}/versionsThe first request after a server restart still reads all commits from disk (5.9 s here). Opening a project already warms that cache through
version-counts.Provider verification
Bilingual UI
🤖 Generated with Claude Code