Repository navigation
fix(assistant): stop restaging references the composer already holds - #588
Open
Zhangbo-cn wants to merge 10 commits into
Open
Zhangbo-cn wants to merge 10 commits into
Zhangbo-cn wants to merge 10 commits into
Conversation
Clicking a node bumps the assistant selection request, which stages the node again even after its reference chip was inserted. The tray then drew a second copy of the same title under the chip (two boxes for one reference). Filter the staged batch against the references already present in the draft content and attachments, cancel the tray when nothing is left, and keep the insert path on the filtered batch.
Zhangbo-cn
requested review from
hsliuustc0106 and
princepride
as code owners
November 29, 2026 14:27
The strip repeated every reference the editor already shows as a chip and, after an insert, added a collapsible 'collapsed attachments' block under the input. Keep the chip as the single representation; sent messages keep their own strip.
Co-Authored-By: Claude Code <noreply@anthropic.com>
Filter the pending batch by the same source identity visibility uses, derive node ids from the reference catalog instead of the reduced attachment list, and cover mixed selections in unit and browser tests. Co-Authored-By: Claude Code <noreply@anthropic.com>
The dedupe browser test only exercised image nodes. Upload a text note and check the staged/inserted/restaged cycle on the text composer. Co-Authored-By: Claude Code <noreply@anthropic.com>
Zhangbo-cn
pushed a commit
to Zhangbo-cn/OpenDirector
that referenced
this pull request
Dec 4, 2026
Co-Authored-By: Claude Code <noreply@anthropic.com>
…ce-dedupe Co-Authored-By: Claude Code <noreply@anthropic.com>
Open the chat panel only once it is actually visible, and lay the uploaded nodes out before clicking them, so the gate exercises reference staging instead of node overlap. Co-Authored-By: Claude Code <noreply@anthropic.com>
Zhangbo-cn
pushed a commit
to Zhangbo-cn/OpenDirector
that referenced
this pull request
Dec 4, 2026
Co-Authored-By: Claude Code <noreply@anthropic.com>
Zhangbo-cn
pushed a commit
to Zhangbo-cn/OpenDirector
that referenced
this pull request
Dec 4, 2026
Co-Authored-By: Claude Code <noreply@anthropic.com>
Co-Authored-By: Claude Code <noreply@anthropic.com>
Zhangbo-cn
added a commit
to Zhangbo-cn/OpenDirector
that referenced
this pull request
Dec 4, 2026
Zhangbo-cn
added a commit
to Zhangbo-cn/OpenDirector
that referenced
this pull request
Dec 4, 2026
Zhangbo-cn
added a commit
to Zhangbo-cn/OpenDirector
that referenced
this pull request
Dec 4, 2026
Zhangbo-cn
added a commit
to Zhangbo-cn/OpenDirector
that referenced
this pull request
Dec 4, 2026
This branch has not been deployed
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.
Problem
When a node's reference is already in the assistant composer, selecting that node again renders the same reference twice: the pending "1 reference to insert" tray appears next to the inserted chip. The reported path uses a text node: upload a note, click the node, click the composer, then click the node again.
Root cause:
WorkspaceViewbumpsassistantSelectionRequeston every node click, sousePendingCanvasReferencesrestages the selected node from the selection change alone. It does not know that the composer already holds that reference, andAssistantPanelrendered every pending item.A mixed selection exposed a second defect in the first fix: when part of the selection was already referenced, the composer kept the filtered item visible but the insertion freshness check compared the filtered batch with the unfiltered selection. The check failed and the staged item was silently dropped, so clicking the composer did nothing.
Refs #587
Changes
src/canvas/chatReferenceContent.ts: addreferenceNodeId(part, asset)andreferencedCanvasNodeIds(content, assets). They resolve a draft reference to its canvas source from the matched reference asset: a canvas part uses itsnodeId, a pinned (binding: "asset") part uses the asset'slogicalNodeId ?? nodeId.referenceIsOffCanvasnow shares the same resolution instead of duplicating it.src/canvas/pendingCanvasReferences.ts: addunreferencedPendingItems(items, referenced)andsameStagedPendingReferences(selected, referenced, batch), which compares the batch with the same filtered projection the tray renders.src/canvas/AssistantPanel.tsx: derive referenced node ids fromvalue.draftContentandchat.referenceAssets(the assets the assistant retains for the draft, a superset of the reduced attachment list) instead of the current attachment list, filter the staged items, cancel pending and hide the tray when nothing remains, and use the filtered freshness check before insertion.tests/chatReferenceContent.test.tsandtests/pendingCanvasReferences.test.ts; new gate workflowtests/browser/assistant_reference_dedupe.mjs, registered intests/browser/manifest.jsonandscripts/run-browser-suite.mjs. The browser test covers the reported text-node path and the image-node mixed selection. It opens the assistant only when the workspace has it closed and arranges the uploaded nodes before selecting them, so the gate exercises reference staging instead of node overlap on the current workspace.No user-visible copy was added; existing
zh-CNanden-USstrings are reused. The composer attachment strip is unchanged.Evidence
Reproduction (isolated fixture API and Vite dev server; no real projects, models, or paid calls):
note.txt, click the new text node, and click the composer. The reference is inserted as a chip and the tray closes.reference.png, click it, and insert it the same way.reference-2.png, click the first image node, then Shift-click the second image node.Before (
728b4077, current base), step 3 brings the tray back with the already-inserted text reference, next to the chip:After (
9732c497, current head), step 3 leaves the tray absent and keeps exactly one chip:Before (
35dccfe0, the pushed first-fix head, same final script), step 6 leaves the filtered item staged and inserts nothing: the tray still reads "1 reference to insert" forreference-2.pngafter the composer click, with two chips:After (
9732c497, current head), step 6 inserts the remaining unreferenced node, closes the tray, and leaves three chips:Failing before, passing after:
tests/browser/assistant_reference_dedupe.mjsasserts tray and chip counts at each step.728b40774628307f315a2b29c466237a8c434a11, with the final script copied onto that tree, the reported path fails first:35dccfe0f2ebd917368dc06fcae0ab6bf37e18ec, the same script reaches step 6 and fails there (chips 2,tray 1):{"passed":true,"checks":["text node staged once","text node inserted once","text node re-select stays filtered","stage once","insert once","re-select stays filtered","mixed selection filtered","no duplicate chip","no paid job"]}.Ran
On the current head (
9732c497f6349fffe9136f1c08928d6a8b6dfa77):npx tsc --noEmit— passednpm test— 1114/1114 passednpm run check:i18n— 3839 keys, 0 problemsnpm run check:browser-manifest— 110 entries, gate=38npm run check:browser-locale— 102 pages, 0 problemsnode tests/browser/assistant_reference_dedupe.mjs— passed six consecutive runs against the isolated fixture API and Vite728b4077— failed with1 !== 0(above)35dccfe0— failed waiting for the third chip (above)Not run
9732c497passed every lane —checks / browser (isolated)(10m3s),checks / browser (assistant),checks / browser (voice),checks / frontend,checks / python,checks / static,checks / desktop / macos,checks / desktop / windows, and the aggregatechecks / checks; CodeQL and thetestsworkflow are green too. These lanes covernpm run buildand the other browser lanes that were not run locally.binding: "asset"references restored from a saved conversation without retained asset metadata are not covered by the new tests: without a resolvable canvas node id the staged item is not filtered. The reported canvas-node paths are covered; this bounded case is unchanged by the PR.Checks note
The previous head (
ca602748) failed Releasechecks / static: the branch was 39 commits behindmain, andpre-commit --from-ref <base> --to-ref HEADflagged a pre-existing trailing space inREADME.zh-CN.md, a file this PR does not touch. The branch is now merged withmain(728b4077), which refreshes the base and removes that stale file from the scan; the PR's own files have no whitespace findings.Review
728b40774628307f315a2b29c466237a8c434a11(origin/main)9732c497f6349fffe9136f1c08928d6a8b6dfa77opendirector-review, candidate mode): PASS, 93/100.tsc,npm test(1114/1114),check:i18n(3839/0),check:browser-manifest(110, gate=38),check:browser-locale(102/0), and the targeted unit tests, and inspected the four screenshots and both failing-before logs.binding: "asset"reference restored without retained asset metadata cannot be resolved to a canvas node id, so it is not filtered; the same gap could allow a duplicate if that metadata resolved asynchronously after a click, which was not observed. The reported canvas-node paths derive their id frompart.nodeIdand are safe.9732c497(run 47319253270), resolving that blocking condition.npm run build, the other browser lanes, desktop jobs, and the Python suites were not run locally; the green Release checks cover the build, browser, and desktop lanes, and the diff does not touch backend code.🤖 Generated with Claude Code