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
Zhangbo-cn
force-pushed
the
fix/assistant-reference-dedupe
branch
from
December 4, 2026 21:44
18c2fd1 to
ab545fd
Compare
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. After the mixed selection the test asserts the tray's titles are exactly["reference-2.png"], so the filter is pinned to the unreferenced node and not just to an item count.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, the reviewed tree; the final headab545fddkeeps these source files byte-identical), 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, the reviewed tree; the final headab545fddkeeps these source files byte-identical), 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"]}.The tray-title assertion was added in the follow-up commit for the first review round. A focused probe that goes straight to the mixed selection (skipping the earlier reported steps) shows the assertion's before/after precisely:
728b4077the mixed selection stages both nodes:{"trayCount":2,"trayTexts":["reference.png","reference-2.png"],"chipsBeforeClick":2,"chipsAfterClick":3,"trayCountAfterClick":0}. The new assertion would fail here. Screenshot · probe output35dccfe0the same probe stages only the unreferenced node:{"trayCount":1,"trayTexts":["reference-2.png"],"chipsBeforeClick":2,"chipsAfterClick":2,"trayCountAfterClick":1}. The tray-title assertion passes there, while the composer click still inserts nothing — the second defect that9732c497fixes. Screenshot · probe outputRan
On the final head (
ab545fddd6fb8218d9510846c4d2450d98557c53, which merges currentmaininto the reviewed tree; the PR's application source files are byte-identical to the reviewed tree9732c497, and the test file adds only the tray-title assertion):npx tsc --noEmit— passed on this headnpm test— 1117/1117 passed on this headnpm run check:i18n— 3857 keys, 0 problemsnpm run check:browser-manifest— 112 entries, gate=39npm run check:browser-locale— 102 pages, 0 problemsnode tests/browser/assistant_reference_dedupe.mjs— passed against the isolated fixture API and Vite on the same tree (18c2fd13, which differs from this head only by commit hash); the six-run sequence above was on9732c497, which differs by the added assertion and the main mergechecks / browser (isolated), whose log showsPASS assistant reference dedupe (16.1s)and36/36 browser workflows passed728b4077— failed with1 !== 0(above)35dccfe0— failed waiting for the third chip (above)728b4077and35dccfe0— results aboveNot run
checks / browser (isolated)on this head.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.An intermediate push at
18c2fd13(run 47401524048) failedchecks / browser (assistant)and the aggregate inassistant_auxiliary_panels.mjs:305, which timed out waiting for已收到创作要求。; the log shows afilelock._error.Timeouton a creation-publication lock andPUT /assistant/draft409 (the server's conversation-switch guard). That test is not touched by this PR and passed locally on the identical tree. The fresh run onab545fdd— an amended merge commit with the same tree — passed the assistant lane and every other lane.Review
42c5dc3926026384c13f7a6cc633792df44d079d(origin/mainat review time; earlier rounds reviewed against728b4077and104cd9ed, and the tip's merges since then bring only main changes — [ci] python: parallelize suite across three shards and isolate native CLI regressions #692 is a CI test-sharding change — so the PR diff against42c5dc39is the same 8 files, +312/−13)ab545fddd6fb8218d9510846c4d2450d98557c53opendirector-review, candidate mode): PASS, 90/100. Ratings: scope 3/3, correctness 3/3, validation 3/3 (Release checks green on this head, including the isolated lane that runs the new gate test; localtsc, 1117 tests,check:i18n,check:browser-manifest,check:browser-locale, and the browser test), claim evidence 2/3 (the corrected-result screenshots and the mixed-selection capture were taken at9732c497; the tip's three source files are byte-identical and the tip's CI executed the strengthened test), simplicity 3/3 (no comments added; the resolution helper is shared withreferenceIsOffCanvas).binding: "asset"reference restored from a saved conversation without retained asset metadata cannot be resolved to a canvas node id and is not filtered; the filter also depends onchat.referenceAssetsstill containing the referenced asset at render time, and no path was found that drops it before insertion; the tray-title assertion depends on the fixture filenames (reference-2.png).9732c497(non-contributing subagent, same skill and pinned base/head): 93/100, WITHHOLD only because Release checks had not run on the unpushed head; no blocking code defect. It independently reproducedtsc,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 outputs.tsc,npm test(1117/1117),check:i18n(3857/0),check:browser-manifest(112, gate=39),check:browser-locale(102/0), the 12 targeted unit tests, confirmed all 17 checks pass onab545fddincluding the isolated lane (PASS assistant reference dedupe, 36/36 workflows), resolved all eight evidence URLs, and traced selection, draft-edit, insertion, cancellation, and concurrent-confirm paths. Its non-blocking findings: the corrected-result captures are at9732c497(mitigated by byte-identical sources and CI executing the strengthened test); a pinnedbinding: "asset"reference without retained asset metadata is not filtered (unchanged by this PR, disclosed); filtering is node-granular by the issue's identity rule;showSuggestionskeys off!pendingrather than!stagedCount, suppressing suggestions for one effect cycle without a content error.npm run build, the desktop packages, and the Python suites were not run locally; the diff does not touch backend code, and Release checks on this head cover the build, browser, and desktop lanes. The corrected-result captures are at9732c497, mitigated by the byte-identical source files and the tip's CI.🤖 Generated with Claude Code