Repository navigation
[perf] assistant: insert chat references without the project-wide catalog - #594
Merged
princepride merged 2 commits intoNov 29, 2026
Merged
Conversation
…alog Typing @ in the assistant chat showed only "loading" until the whole reference catalog arrived, although the chat lists the visible canvas nodes it already has. Choosing a node then re-read the canvas, read the whole catalog again (every asset's file checked, plus a scan of the commit history) and downloaded and SHA-256 hashed each referenced file in the browser, all before the reference appeared. - The chat picker no longer waits on the catalog, as the generation composer's picker already does; opening it still prefetches the catalog for draft references in the background. - reference-catalog accepts nodeId filters. Scoped to the chosen nodes it reads only the head snapshot and checks only those nodes' files, with the same rows and availability as the full catalog. The browser reads it in the foreground instead of behind other background reads. - A pick uses that read and drops the canvas re-read and the browser download and hash: the canvas is saved before the pick, the server checks each file against its fingerprint, and media reads refuse changed bytes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
github-actions
Bot
requested review from
FayeSpica,
kunkunblueberry and
wuzhf9
November 29, 2026 16:14
Review of this PR found that the node-scoped catalog read accepts at most 64 nodeId values and answers more with a generic validation error. Through the chat UI a selection is already refused above 64 nodes before any read (pendingReferenceInsertion, unchanged from main), so no current caller sends more. loadNodeReferences now splits longer lists into reads of 64 anyway, so the function is correct for any caller. The browser test now also selects 65 canvas nodes and checks that the chat shows its own limit message, inserts nothing and reads no node references; a unit test covers the batching. 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.
Summary
Referencing canvas media in the assistant chat (AI 对话) waited on the project-wide reference catalog twice, and the second wait came with extra work:
Typing
@showed only "loading" until/reference-catalogarrived, even though the chat's options are the visible canvas nodes it already has. The generation composer's picker already passesloading={false}for this reason.Choosing a node:
All of this ran before the reference chip appeared, and its cost grows with project history, asset count and file size.
This PR:
The chat picker no longer waits on the catalog. Opening it still prefetches the catalog in the background, for refreshing draft references and pasting.
GET /reference-catalog?nodeId=…(up to 64) returns only the chosen nodes' media. It reads the head snapshot (no history scan) and checks only those files. For a node's own media the rows and availability match the full catalog's rows for that node; the full catalog withoutnodeIdis unchanged. The browser sends this read in the foreground rather than queueing it behind other background project reads.A pick uses that read only. It no longer re-reads the canvas, downloads the files, or hashes them in the browser:
onPrepareReferences) before the pick, so the server resolves the nodes' current media itself;/contentalso refuses bytes that don't match.The now-unused
assistant.error.referenceChangedBatchmessage is removed in both locales.The server accepts at most 64
nodeIdvalues per read, soloadNodeReferencessplits longer lists into batches of 64. In the chat, a selection of more than 64 nodes is already refused before any read, bypendingReferenceInsertion(unchanged frommain), so no current caller sends more.Paste of a copied reference (
onPasteReference) is unchanged.Linked issue
Labels
type:bug,area:agent,area:assets,area:performance)Test plan
npx tsc --noEmitnpm test(1033 passed, including the newtests/nodeReferences.test.tsfor the batching)npm run check:i18nnode scripts/check-browser-manifest.mjspytest tests/test_creation_history_service.py tests/test_creation_node_versions.py tests/test_creation_api.py(66 passed), including the newtest_node_reference_catalog_reads_only_the_chosen_nodes_media, which checks for that node:New
tests/browser/assistant_chat_references.mjs(extendedFixture and production lanes), run againstcreation_server.py --assistant-fixture+ Vite with Chrome for Testing. It holds the full catalog the whole time and checks that:nodeIdread, with no/contentor/canvasrequest;It passes on this branch and times out on
main, where the picker waits for the held catalog.tests/browser/reference_picker.mjs,tests/browser/canvas_reference_sources.mjsandtests/browser/assistant_sessions.mjspass.Evidence that it works
--assistant-fixtureservices, withmainand this branch side by side. Each run used a fresh project: 30 distinct ~7 MB videos and 10 images on the canvas, plus 300 text assets for a longer history. Values are from two runs each.main@→ options shownnodeIdcatalog read (~40 ms)On
mainthe per-pick cost grows with history length, asset count (each catalog read checks every file) and the size of the chosen files (download plus browser hash). With this PR it depends only on the chosen nodes.Provider verification
Bilingual UI
zh-CNanden-US.🤖 Generated with Claude Code