Repository navigation
fix(chat): new-chat composer alias bookkeeping for picked files (#14571) - #22593
Conversation
UX Review (Opus 5.5) — ✅ PASSUX-level review of UX-Verdict: PASS Nothing to check. The PR adds no new control, string or rendered state. The ✕ on a new-chat file chip now strips its [UX-REVIEWED] 627a519 Description read[DESCRIPTION-READ] 5f812d9244bed4e12f95cbba883c2cd28b0de1d27440df71b4af730dbdd2e518 That sha256 names everything this verdict read: the PR description, plus the 3 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
First Principles Review (Opus 5.5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Nothing blocks: the fallback bucket fixes the accessor that returned null, and each guard it adds has a named harm. Two leftovers can be deleted. Notes
What this change shipsInventory (6 items) — 4 justifiedIntent: removing a picked file in the new-chat composer also removes its
[FIRST-PRINCIPLES-REVIEWED] 627a519 Description read[DESCRIPTION-READ] 2e69aff8593b171812cd74a2e8d4f7c97121d163be5998b493d96515ce7eafe8 That sha256 names the PR description this verdict read. Recompute it with |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS No design-level concern: the slotless composer now reuses the existing per-slot alias path through one reserved in-memory bucket, which fixes the root cause, and the send path clears that bucket. Notes
[DESIGN-REVIEWED] 627a519 Description read[DESCRIPTION-READ] 2558e015c5db9bac0d62fb961e705a15ca94a524ac46dfccf0d483059662b3dc That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
GPT 6.1 Review — ✅ no blocking findingsGPT 6.1 completed its review of This comment is updated in place on each push. Review detailsNo findings. False positive or not applicable? A repository writer can comment: |
Opus 5.5 Review — ✅ no blocking findingsReviewed Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
47a38cf to
6af3f4d
Compare
6af3f4d to
c78b1f7
Compare
The new-chat composer has no slot yet (composerSlotRef.current is null), so the per-slot picked-file alias map (pickedFileTokens) recorded nothing there: currentSlotTokens() returned null and every record/reconcile/remove no-op'd. Two user-visible consequences in that composer only (#14571): removing a picked file's chip left its @-mention in the text, and a hand-edit of the mention never unstaged the chip. Give the slotless composer a reserved in-memory bucket (NO_SLOT_TOKEN_KEY) that currentSlotTokens() falls back to when there is no slot, reusing the exact same mention plumbing every real slot already has. The send path clears that bucket when there is no slot (uiSlot is null), and the bucket is never persisted (loadFileTokenDrafts/saveFileTokenDrafts drop the reserved key), so an abandoned new-chat draft's aliases cannot revive a file later. Fixes #14571
c78b1f7 to
627a519
Compare
KiroCrewCaptain
left a comment
There was a problem hiding this comment.
Tier 1 auto-approve: fix (5 files). Criteria: no conflict, no requested changes, security path denylist clean, design-doc gate clean, security checklist all-NO, no reviewer-lane findings, readiness signal fresh for this head SHA, declared category matches the diff. Category: the new-chat composer records picked-file aliases in an in-memory no-slot bucket that is never persisted, with tests.
Problem / Motivation
Goal: Removing a picked file's chip in the new-chat composer now also strips its
@-mention from the text, the same as in an existing chat.The new-chat composer has no slot yet (
composerSlotRef.currentis null). The picked-file alias map (pickedFileTokensinChatPage) is per-slot, so with no slotcurrentSlotTokens()returnednulland every alias write, reconciliation and strip no-op'd. Two consequences, in that composer only:@…mention behind in the text when there was no project to derive the rel from (the pre-fix(chat): insert file/folder mentions at caret and unstage edited-out chips #6511 path-keyed map used to strip it).Why it matters
A file the user explicitly removed from the new-chat composer kept its
@-mention in the message, so the agent received a file reference the user thought they had taken out — on the very first message of a session, before any slot exists. This is the composer path most new users hit first.Not a goal
What changed (motivation → approach → change)
@mention, and a hand-edit does not unstage the chip.currentSlotTokens()returnsnullwhencomposerSlotRef.currentis null, sorecordSlotToken/reconcileFileChips/removeFileChipall short-circuit — the slotless composer has no alias bookkeeping at all.currentSlotTokens()now falls back to one reserved in-memory bucket (NO_SLOT_TOKEN_KEY) when there is no slot, so the slotless composer runs the identical record/reconcile/remove path every real slot already has. The send path clears that bucket whenuiSlotis null, so an abandoned-then-resent new-chat draft's aliases cannot revive a file later. The reserved key is\u0000-prefixed (a real slot key ischat-<counter>-<timestamp>, so no collision) and is dropped byloadFileTokenDrafts/saveFileTokenDrafts, keeping it in memory only — matching how the no-slot text/file drafts are themselves never persisted.Backwards compatibility
Compatible: real slots are untouched (their keys never equal the reserved sentinel); the reserved bucket is additive and in-memory only. Nothing that works today stops working.
Removes nothing: no capability, record, key, validator or public function is removed, renamed or narrowed — this only adds a fallback bucket and clears it on send.
Tests
website/src/test/composerNoSlotAliasBucket.test.tsx(new): drives the realhandleAddToContext(pick) →removeFileChip(remove) handlers withcomposerSlotRef.current = nulland asserts (a) a picked file is recorded under the reserved bucket, and (b) removing the chip strips the@mentionfrom the composer text — the exact bug, which failed before the fix.website/src/test/chatFileTokenDrafts.test.ts: added a case proving the reserved no-slot bucket is never written to or read fromsessionStorage, while real slots round-trip unchanged.ChatPage.dirStaging,ChatPageDrafts,ChatInput.paste,slotDraftStore: 161 tests).Manual verification
N/A — unit coverage is sufficient. The change is a pure behavioral fix on the slotless alias path, exercised end-to-end through the real handlers in the new test;
tsc -p tsconfig.app.jsonand eslint are clean, and the diff-scoped frontend local-gate passes.Screenshots / video
Why no screenshot: this is a behavioral fix on the file-mention bookkeeping path — the new-chat composer, its file chip and its ✕ render identically before and after; only what the ✕ does to the mention text changes, and that is pinned by the new unit test rather than any rendered delta.
Related Issues
Fixes #14571
Pattern harvest
Rule candidate: review-prompt
Pattern: a per-key store accessor (
currentSlotTokens) returns null when the key is absent, so every caller short-circuits and the keyless surface (here the slotless new-chat composer) silently loses a whole behaviour; the sibling draft stores had already special-cased the no-slot case, this one had not. Worth a review-prompt line: when an accessor keyed by an optional id returns a null/empty sentinel on a missing key, check whether the keyless surface still needs the behaviour and either reserve a bucket or document why it is intentionally dropped.