Repository navigation
fix(chat): undoing a file chip remove restores its attachment - #14773
Conversation
|
Intent: After a user removes an |
Design Review (Fable 5, fork) — ✅ PASSDesign-level review of Design-Verdict: PASS Verify the remove-time [DESIGN-REVIEWED] dc7fc1d Description read[DESCRIPTION-READ] 5a83bbeffa123a6fdfd2a078e3035e4a29ca9deb23e6235a08226a651c106505 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 |
First Principles Review (Fable 5, fork) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Verify the declared rider: persisted aliases also make a restored chip unstage on a hand-edit after reload — behavior beyond the undo fix itself. Not justified as shipped
What this change shipsInventory (7 items) — 6 justifiedIntent: Ctrl/Cmd+Z after removing an
[FIRST-PRINCIPLES-REVIEWED] dc7fc1d Description read[DESCRIPTION-READ] 97109eeff62cfaef36a7072ca89c97c15a70bf10502e11875739fdfcca3f0790 That sha256 names the PR description this verdict read. Recompute it with |
UX Review (Fable 5, fork) — 🟡 CONCERNSUX-level review of UX-Verdict: CONCERNS No first-time reader has seen the restored-chip undo state; the three screenshots cover pick, remove, and restore, so the cap is this lane's limit, not an author gap. Watch
[UX-REVIEWED] dc7fc1d Description read[DESCRIPTION-READ] 3d28d2b377b8db9a287ced2144d6ed89b932866e3d6c526255a000135a642f94 That sha256 names everything this verdict read: the PR description, plus the 6 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 5.6 Review (fork) — ✅ no blocking findingsReviewed Review detailsNo findings. |
Opus 5 Review (fork) — ✅ no blocking findingsReviewed |
e48fba0 to
24fa235
Compare
issue (fixed): upheld and fixed in 24fa235.
|
issue (fixed): upheld and fixed in 24fa235.
|
issue (rebutted, non-blocking): not a defect this PR introduces; the case falls back to exactly what main does today.
|
issue (rebutted, non-blocking): the chosen trade-off, and no worse than main.
|
issue (rebutted, non-blocking): the outcome is the revival guard's documented residual on main, and it is no worse than main's ✕.
|
24fa235 to
206664e
Compare
|
Rebased onto current main (5d4f173) with no code change. New head is 206664e. Main's #14227 moved the chip reconciliation from an question (blocking): override request for the fenced GPT finding The finding needs a draft restored from storage, two staged files whose names differ only by trailing punctuation ( If you agree after checking it, the override for this head is: |
206664e to
8e6736e
Compare
…ment Removing an @-picked file chip strips its mention from the composer and unstages the file, and it also dropped the file's recorded aliases. The composer undo brought the mention back as plain text, but with the aliases gone the chip reconciliation had nothing to revive, so the message sent without the file. Keep the aliases through the remove, so the existing reconciliation re-stages the file when undo brings the mention back and unstages it on redo. The send-clear still drops them. Drop them at remove time only when a mention of the file survives the strip, so the leftover cannot revive the chip the click removed.
cf29fcd to
dc7fc1d
Compare
|
Rebased onto current main with no code change; the new head is dc7fc1d. This re-runs Backend Tests shard 2. On cf29fcd that shard failed only in On cf29fcd, the GPT, Opus, Design and First Principles reviews passed. The UX review's single Watch item asks a maintainer to press Ctrl+Z once to confirm the chip comes back; the review itself calls that a lane limitation, not an author gap. |
note (acknowledged, non-blocking): the chip returning is the confirmation, the same signal every other chip change uses.
|
note (acknowledged, non-blocking): it comes with the alias persistence, which this PR needs for undo after a reload.
|
iamwhatever
left a comment
There was a problem hiding this comment.
Reviewed. The remove path keeps the file's aliases unless fileChipRevives finds a mention left in the text, reconciliation then handles undo and redo with no new state; drafts share the existing sessionStorage and both send-clear sites delete the alias map; only path strings are kept, keyed by slot; sanitizeTokens rejects malformed entries and paths become attachments only through the existing reconciliation. Tests cover removed-not-undone-not-sent, redo, duplicated mention, prefix pair, old alias and reload.
Non-blocking: aliases now last until the next send, so a hand-typed @src/main.ts after the X re-attaches the file (chip reappears, so nothing is sent unseen), which the table does not mention and no test pins; and ChatPage.tsx:~9030 decides on inputRef.current while the strip runs on setInput(prev).
ChatPage.tsx had grown to 9,468 lines holding every chat-page responsibility inline. It is now the page's facade over 19 cohesive owners under website/src/pages/chat/page/: composer drafts, staging and @-mentions; launch / prefill / error hand-off intake; window and Electron event bridges; busy-turn controls; turn recovery; transcript rows and jumps; composer chips, rosters, session controls, automation, follow-up chips and the welcome screen; the composer dock, the pane notices and the phone top bar. Moved code is copied verbatim from the base by line span; the only hand edits are dependency arrays gaining stable refs and setters, and comment re-pointers. ChatPage keeps its default export, props, shouldAutoFillOlder and the PREFILL_STORAGE_KEY re-export, and calls each owner where its inline code ran, so the effect-bearing hook sequence is unchanged. Code the source-pin tests hold in ChatPage (send, the switchSlot sites, renderers, paging and pins, the model picker, drawers and layout) stays there. Upstream #14773 (chip undo, persisted file-chip aliases) and #14756 (prompt history) are ported into their owners. The owning specs, the feature map, two RFC line cites and one architecture note are re-pointed in the same commit. New tests cover the owners that page suites never exercised and pin the facade, the owners' import graph and their call order.
ChatPage.tsx had grown to 9,468 lines holding every chat-page responsibility inline. It is now the page's facade over 19 cohesive owners under website/src/pages/chat/page/: composer drafts, staging and @-mentions; launch / prefill / error hand-off intake; window and Electron event bridges; busy-turn controls; turn recovery; transcript rows and jumps; composer chips, rosters, session controls, automation, follow-up chips and the welcome screen; the composer dock, the pane notices and the phone top bar. Moved code is copied verbatim from the base by line span; the only hand edits are dependency arrays gaining stable refs and setters, and comment re-pointers. ChatPage keeps its default export, props, shouldAutoFillOlder and the PREFILL_STORAGE_KEY re-export, and calls each owner where its inline code ran, so the effect-bearing hook sequence is unchanged. Code the source-pin tests hold in ChatPage (send, the switchSlot sites, renderers, paging and pins, the model picker, drawers and layout) stays there. Upstream #14773 (chip undo, persisted file-chip aliases) and #14756 (prompt history) are ported into their owners. The owning specs, the feature map, two RFC line cites and one architecture note are re-pointed in the same commit. New tests cover the owners that page suites never exercised and pin the facade, the owners' import graph and their call order.
ChatPage.tsx had grown to 9,468 lines holding every chat-page responsibility inline. It is now the page's facade over 19 cohesive owners under website/src/pages/chat/page/: composer drafts, staging and @-mentions; launch / prefill / error hand-off intake; window and Electron event bridges; busy-turn controls; turn recovery; transcript rows and jumps; composer chips, rosters, session controls, automation, follow-up chips and the welcome screen; the composer dock, the pane notices and the phone top bar. Moved code is copied verbatim from the base by line span; the only hand edits are dependency arrays gaining stable refs and setters, and comment re-pointers. ChatPage keeps its default export, props, shouldAutoFillOlder and the PREFILL_STORAGE_KEY re-export, and calls each owner where its inline code ran, so the effect-bearing hook sequence is unchanged. Code the source-pin tests hold in ChatPage (send, the switchSlot sites, renderers, paging and pins, the model picker, drawers and layout) stays there. Upstream #14773 (chip undo, persisted file-chip aliases) and #14756 (prompt history) are ported into their owners. The owning specs, the feature map, two RFC line cites and one architecture note are re-pointed in the same commit. New tests cover the owners that page suites never exercised and pin the facade, the owners' import graph and their call order.
ChatPage.tsx had grown to 9,468 lines holding every chat-page responsibility inline. It is now the page's facade over 19 cohesive owners under website/src/pages/chat/page/: composer drafts, staging and @-mentions; launch / prefill / error hand-off intake; window and Electron event bridges; busy-turn controls; turn recovery; transcript rows and jumps; composer chips, rosters, session controls, automation, follow-up chips and the welcome screen; the composer dock, the pane notices and the phone top bar. Moved code is copied verbatim from the base by line span; the only hand edits are dependency arrays gaining stable refs and setters, and comment re-pointers. ChatPage keeps its default export, props, shouldAutoFillOlder and the PREFILL_STORAGE_KEY re-export, and calls each owner where its inline code ran, so the effect-bearing hook sequence is unchanged. Code the source-pin tests hold in ChatPage (send, the switchSlot sites, renderers, paging and pins, the model picker, drawers and layout) stays there. Upstream #14773 (chip undo, persisted file-chip aliases) and #14756 (prompt history) are ported into their owners. The owning specs, the feature map, two RFC line cites and one architecture note are re-pointed in the same commit. New tests cover the owners that page suites never exercised and pin the facade, the owners' import graph and their call order.
ChatPage.tsx had grown to 9,468 lines holding every chat-page responsibility inline. It is now the page's facade over 19 cohesive owners under website/src/pages/chat/page/: composer drafts, staging and @-mentions; launch / prefill / error hand-off intake; window and Electron event bridges; busy-turn controls; turn recovery; transcript rows and jumps; composer chips, rosters, session controls, automation, follow-up chips and the welcome screen; the composer dock, the pane notices and the phone top bar. Moved code is copied verbatim from the base by line span; the only hand edits are dependency arrays gaining stable refs and setters, and comment re-pointers. ChatPage keeps its default export, props, shouldAutoFillOlder and the PREFILL_STORAGE_KEY re-export, and calls each owner where its inline code ran, so the effect-bearing hook sequence is unchanged. Code the source-pin tests hold in ChatPage (send, the switchSlot sites, renderers, paging and pins, the model picker, drawers and layout) stays there. Upstream #14773 (chip undo, persisted file-chip aliases) and #14756 (prompt history) are ported into their owners. The owning specs, the feature map, two RFC line cites and one architecture note are re-pointed in the same commit. New tests cover the owners that page suites never exercised and pin the facade, the owners' import graph and their call order.
ChatPage.tsx had grown to 9,468 lines holding every chat-page responsibility inline. It is now the page's facade over 19 cohesive owners under website/src/pages/chat/page/: composer drafts, staging and @-mentions; launch / prefill / error hand-off intake; window and Electron event bridges; busy-turn controls; turn recovery; transcript rows and jumps; composer chips, rosters, session controls, automation, follow-up chips and the welcome screen; the composer dock, the pane notices and the phone top bar. Moved code is copied verbatim from the base by line span; the only hand edits are dependency arrays gaining stable refs and setters, and comment re-pointers. ChatPage keeps its default export, props, shouldAutoFillOlder and the PREFILL_STORAGE_KEY re-export, and calls each owner where its inline code ran, so the effect-bearing hook sequence is unchanged. Code the source-pin tests hold in ChatPage (send, the switchSlot sites, renderers, paging and pins, the model picker, drawers and layout) stays there. Upstream #14773 (chip undo, persisted file-chip aliases) and #14756 (prompt history) are ported into their owners. The owning specs, the feature map, two RFC line cites and one architecture note are re-pointed in the same commit. New tests cover the owners that page suites never exercised and pin the facade, the owners' import graph and their call order.
ChatPage.tsx had grown to 9,468 lines holding every chat-page responsibility inline. It is now the page's facade over 19 cohesive owners under website/src/pages/chat/page/: composer drafts, staging and @-mentions; launch / prefill / error hand-off intake; window and Electron event bridges; busy-turn controls; turn recovery; transcript rows and jumps; composer chips, rosters, session controls, automation, follow-up chips and the welcome screen; the composer dock, the pane notices and the phone top bar. Moved code is copied verbatim from the base by line span; the only hand edits are dependency arrays gaining stable refs and setters, and comment re-pointers. ChatPage keeps its default export, props, shouldAutoFillOlder and the PREFILL_STORAGE_KEY re-export, and calls each owner where its inline code ran, so the effect-bearing hook sequence is unchanged. Code the source-pin tests hold in ChatPage (send, the switchSlot sites, renderers, paging and pins, the model picker, drawers and layout) stays there. Upstream #14773 (chip undo, persisted file-chip aliases) and #14756 (prompt history) are ported into their owners. The owning specs, the feature map, two RFC line cites and one architecture note are re-pointed in the same commit. New tests cover the owners that page suites never exercised and pin the facade, the owners' import graph and their call order.
ChatPage.tsx had grown to 9,468 lines holding every chat-page responsibility inline. It is now the page's facade over 19 cohesive owners under website/src/pages/chat/page/: composer drafts, staging and @-mentions; launch / prefill / error hand-off intake; window and Electron event bridges; busy-turn controls; turn recovery; transcript rows and jumps; composer chips, rosters, session controls, automation, follow-up chips and the welcome screen; the composer dock, the pane notices and the phone top bar. Moved code is copied verbatim from the base by line span; the only hand edits are dependency arrays gaining stable refs and setters, and comment re-pointers. ChatPage keeps its default export, props, shouldAutoFillOlder and the PREFILL_STORAGE_KEY re-export, and calls each owner where its inline code ran, so the effect-bearing hook sequence is unchanged. Code the source-pin tests hold in ChatPage (send, the switchSlot sites, renderers, paging and pins, the model picker, drawers and layout) stays there. Upstream #14773 (chip undo, persisted file-chip aliases) and #14756 (prompt history) are ported into their owners. The owning specs, the feature map, two RFC line cites and one architecture note are re-pointed in the same commit. New tests cover the owners that page suites never exercised and pin the facade, the owners' import graph and their call order.
ChatPage.tsx had grown to 9,468 lines holding every chat-page responsibility inline. It is now the page's facade over 19 cohesive owners under website/src/pages/chat/page/: composer drafts, staging and @-mentions; launch / prefill / error hand-off intake; window and Electron event bridges; busy-turn controls; turn recovery; transcript rows and jumps; composer chips, rosters, session controls, automation, follow-up chips and the welcome screen; the composer dock, the pane notices and the phone top bar. Moved code is copied verbatim from the base by line span; the only hand edits are dependency arrays gaining stable refs and setters, and comment re-pointers. ChatPage keeps its default export, props, shouldAutoFillOlder and the PREFILL_STORAGE_KEY re-export, and calls each owner where its inline code ran, so the effect-bearing hook sequence is unchanged. Code the source-pin tests hold in ChatPage (send, the switchSlot sites, renderers, paging and pins, the model picker, drawers and layout) stays there. Upstream #14773 (chip undo, persisted file-chip aliases) and #14756 (prompt history) are ported into their owners. The owning specs, the feature map, two RFC line cites and one architecture note are re-pointed in the same commit. New tests cover the owners that page suites never exercised and pin the facade, the owners' import graph and their call order.
Problem / Motivation
Goal: Ctrl/Cmd+Z after removing an
@-picked file chip brings the file back, so the message sends with the attachment it had before the remove.Picking a file through the composer's
@picker does two things: it inserts an@src/...token into the text and stages the file as a chip above the composer. The chip's remove button undoes both. The composer's undo history covers only the text, so Ctrl/Cmd+Z brought back@src/main.tsas plain text while the file stayed unstaged. The next send went out without the file.Why it matters
An accidental click on a chip's remove button is recoverable in the text but silently loses the attachment, and nothing on screen says so beyond the missing chip. The agent then answers about a file it never received.
Not a goal
What changed (motivation → approach → change)
The chip reconciliation in
ChatPage.tsxalready keeps a picked file in sync with its@relmention: a hand-edited-out mention unstages the chip, and a mention that comes back re-stages it. The remove button was the one path that also deleted the file's recorded aliases, so after a remove there was nothing left for the reconciliation to revive. The remove now keeps them, so undo and redo work through the existing reconciliation with no new state.It drops them only when a mention of this file survives the strip, since that leftover would re-stage the file the click just removed. That survival check calls the reconciliation's own revival predicate,
fileChipRevives, which this PR extracts so both places share one copy. A staged file whose name extends this one (reportbesidereport,) is therefore not mistaken for this file, and a leftover old-project spelling, which the reconciliation never revives from, does not cost the chip its undo. The aliases are now persisted per slot beside the staged files (website/src/utils/chatFileTokenDrafts.ts, the same sessionStorage store shape and lifetime aschatFileDrafts), and loaded on mount and slot switch. Before this, a reload restored the staged files but not their aliases, so a restored chip could not be unstaged by a hand-edit (a limitation the code documented), and a restoredreport,besidereportmade remove followed by undo losereport. A draft saved before this change has no stored aliases; its remove records the derived one so undo works there too.In
ChatInput.tsx, clicking a file or folder chip's remove now ends the current undo burst first. Without that, a short mention (@a.ts) removed within 400 ms of a keystroke was merged into the typing entry, and undo skipped past the text that still held the mention. Typing, voice dictation, pickers and prompt recall keep their grouping. The file-search spec describes the new remove contract. The file comes back by path, so nothing is uploaded again.Backwards compatibility
Compatible: remove, send and draft behave as before unless the removed mention comes back into the text.
Tests
website/src/test/ChatPage.chipUndo.test.tsx, on the full chat page:reportandreport,)@src/main.tsafter the project moves tosrc/)website/src/test/chatFileTokenDrafts.test.ts: the alias drafts roundtrip through sessionStorage and malformed entries are dropped.website/src/test/ChatInput.chipRemoveUndo.test.tsx: a short mention removed 100 ms after a keystroke is its own undo step, and quick typing still groups into one.The undo, redo, prefix-sibling, old-project-alias, both after-reload and quick-remove cases fail without their fixes. The existing
ChatPage.dirStaging.test.tsxandChatInput.test.tsxcases pass unchanged.Manual verification
Picked a file in the dashboard composer, removed its chip, pressed Ctrl+Z, and saw the token and the chip come back (screenshots below).
Screenshots / video
The chip strip and composer text in the dashboard, built from this branch. Picked, then removed, then Ctrl+Z:
On main, the same Ctrl+Z brings back the
@src/main.tstext without the chip; the undo case in the page test fails there.Related Issues
Fixes #14772
Pattern harvest
Not generalizable: the loss came from the one remove path that discarded the bookkeeping the text-to-chip reconciliation needs; the other paired state, paste blocks, already rides in the undo snapshots.
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)