Skip to content

fix(chat): new-chat composer alias bookkeeping for picked files (#14571) - #22593

Merged
KiroCrewCaptain merged 1 commit into
mainfrom
fix/14571-noslot-alias-bucket
Oct 30, 2026
Merged

KiroCrewCaptain merged 1 commit into
mainfrom
fix/14571-noslot-alias-bucket

Conversation

@dodgeblaster

@dodgeblaster dodgeblaster commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

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.current is null). The picked-file alias map (pickedFileTokens in ChatPage) is per-slot, so with no slot currentSlotTokens() returned null and every alias write, reconciliation and strip no-op'd. Two consequences, in that composer only:

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

  • No change to the existing-chat composer, which already has this bookkeeping via its real slot.
  • No new alias mechanism: the fix reuses the existing per-slot plumbing through one reserved bucket.

What changed (motivation → approach → change)

  • Symptom: in the new-chat (slotless) composer, chip-remove leaves the @mention, and a hand-edit does not unstage the chip.
  • Root cause: currentSlotTokens() returns null when composerSlotRef.current is null, so recordSlotToken / reconcileFileChips / removeFileChip all short-circuit — the slotless composer has no alias bookkeeping at all.
  • Change: 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 when uiSlot is 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 is chat-<counter>-<timestamp>, so no collision) and is dropped by loadFileTokenDrafts/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 real handleAddToContext (pick) → removeFileChip (remove) handlers with composerSlotRef.current = null and asserts (a) a picked file is recorded under the reserved bucket, and (b) removing the chip strips the @mention from 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 from sessionStorage, while real slots round-trip unchanged.
  • Existing composer/file-mention suites stay green (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.json and 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.

@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Oct 20, 2026
@github-actions

github-actions Bot commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ✅ PASS

UX-level review of 627a519cfe7d9579a567c507b279faf1071d6f63 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

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 @-mention, the same as it already does in an existing chat, so the missing screenshot is not an evidence gap.

[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 .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

Premise-level review of 627a519cfe7d9579a567c507b279faf1071d6f63 — why this exists and whether the shipped surface is the smallest honest version. Updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

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

  • Item 5 — rides along: the save path already drops the reserved key (store.save(withoutNoSlot(map))), so no build ever writes it to storage. That leaves the load filter, "A reserved bucket that somehow reaches storage is dropped on load too", with nothing to drop. Subtraction: make loadFileTokenDrafts plain store.load again and delete the second half of the new chatFileTokenDrafts test.
  • Item 6 — rides along: currentSlotTokens() can no longer return null, but composerFileMentions.ts still guards for null in 6 places (if (!slotTokens) return at :55, :832; if (!known) return at :492; ?? {} at :277, :360, :621). I counted these by grepping currentSlotTokens(). Subtraction: delete those 6 dead guards.

What this change ships

Inventory (6 items) — 4 justified

Intent: removing a picked file in the new-chat composer also removes its @-mention from the message text. FIX.

  1. In the new-chat composer, ✕ on a picked-file chip now strips its @-mention — justified
  2. In the new-chat composer, deleting a mention by hand now unstages its chip — justified
  3. Sending from the new-chat composer clears that composer's file aliases — justified
  4. The new-chat composer's aliases are never saved to sessionStorage — justified
  5. Loading drafts drops a reserved bucket that nothing ever writes — rides along, already covered by the save filter
  6. The null guards on the alias accessor are now dead code — rides along, undeclared

[FIRST-PRINCIPLES-REVIEWED] 627a519

Description read

[DESCRIPTION-READ] 2e69aff8593b171812cd74a2e8d4f7c97121d163be5998b493d96515ce7eafe8

That sha256 names the PR description this verdict read. Recompute it with .github/scripts/pr-description-capture.sh; if it differs, the description changed after this verdict was formed and any finding drawn from the description is unproven.

@github-actions

github-actions Bot commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

Design-level review of 627a519cfe7d9579a567c507b279faf1071d6f63 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

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

  • The description says the reserved key is "\^@-prefixed", but the code ships 'noSlotComposerBucket'. Correct the description; collision safety rests only on the chat-<counter>-<timestamp> slot-key convention.
  • The bucket is cleared on send only. A new-chat draft abandoned by switching to an existing slot keeps its aliases in memory until the next slotless send, so confirm that reconcile never re-stages a file from a stale alias when the user returns to new chat.

[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 .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

GPT 6.1 completed its review of 627a519cfe7d9579a567c507b279faf1071d6f63 and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 627a519

False positive or not applicable? A repository writer can comment:
/ai-review override gpt 627a519cfe7d9579a567c507b279faf1071d6f63 false-positive: <reason, 20 to 500 characters>

@github-actions

github-actions Bot commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

Reviewed 627a519cfe7d9579a567c507b279faf1071d6f63 — this comment is updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] 627a519

Verdict parsed from the review's SHA-scoped output markers for commit 627a519cfe7d9579a567c507b279faf1071d6f63.

False positive or not applicable? A repository writer can comment:
/ai-review override fable 627a519cfe7d9579a567c507b279faf1071d6f63 false-positive: <reason, 20 to 500 characters>

@dodgeblaster
dodgeblaster force-pushed the fix/14571-noslot-alias-bucket branch from 47a38cf to 6af3f4d Compare October 20, 2026 22:24
@dodgeblaster
dodgeblaster force-pushed the fix/14571-noslot-alias-bucket branch from 6af3f4d to c78b1f7 Compare October 29, 2026 22:38
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
@dodgeblaster
dodgeblaster force-pushed the fix/14571-noslot-alias-bucket branch from c78b1f7 to 627a519 Compare October 29, 2026 23:30
@dodgeblaster
dodgeblaster marked this pull request as ready for review October 30, 2026 00:32
@dodgeblaster
dodgeblaster requested review from a team and KiroCrewCaptain as code owners October 30, 2026 00:32
@github-actions github-actions Bot added readiness: passed Eligible automated validation passed for the current revision and removed readiness: checking Automated validation is still running labels Oct 30, 2026
@KiroCrewCaptain
KiroCrewCaptain enabled auto-merge (squash) October 30, 2026 01:08

@KiroCrewCaptain KiroCrewCaptain left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@KiroCrewCaptain
KiroCrewCaptain merged commit 5fc243b into main Oct 30, 2026
97 checks passed
@KiroCrewCaptain
KiroCrewCaptain deleted the fix/14571-noslot-alias-bucket branch October 30, 2026 01:09
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Oct 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

New-chat composer keeps no alias bookkeeping for picked files (remove leaves the mention)

2 participants