Repository navigation
fix(chat): keep the composer draft across a memory-mode switch - #16004
Conversation
f6767cc to
5682788
Compare
UX Review (Opus 5.5) — 🟡 CONCERNSUX-level review of UX-Verdict: CONCERNS The timeout error talks about "both chats" the user never knowingly made, and other sessions lock with a memory-mode message that doesn't say which chat is switching. Watch
Suggestions
[UX-REVIEWED] 2379891 Description read[DESCRIPTION-READ] e1bd8d7ff92be8685f3abe7387d1bf051aca8db74fb5247b3c6f360be3500d7f That sha256 names everything this verdict read: the PR description, plus the 15 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 |
Design Review (Opus 5.5) — 🟡 CONCERNSDesign-level review of Design-Verdict: CONCERNS Replacing the session by create-then-delete is the root problem, and this PR builds a global composer lock, a 15 s timeout, upload hand-over and an optimize gate around it instead of removing it. Watch
Suggestions
[DESIGN-REVIEWED] 2379891 Description read[DESCRIPTION-READ] ed8fa66ae58b24de20ad30a9b5d18408d470a1adbbeee6c0a464642b854d761f 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 (Opus 5.5) — 🟡 CONCERNSPremise-level review of First-Principles-Verdict: CONCERNS The draft carry is enough to fix the bug. The global composer lock, its 15 s timeout and the optimize hold are race guards beyond the Goal, and its Not justified as shipped
What this change shipsInventory (10 items) — 7 justifiedIntent: let someone change a chat's memory mode after starting to type without losing the prompt. This is a FIX.
[FIRST-PRINCIPLES-REVIEWED] 2379891 Description read[DESCRIPTION-READ] d705d9cd11a7dac9f1c1cecb05d31525ed8ebf987b96ae6aee563a0ba49ba026 That sha256 names the PR description this verdict read. 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: |
5682788 to
bf7a3dc
Compare
|
Addressed in |
|
The |
bf7a3dc to
f7e1d8c
Compare
|
First Principles BLOCK on
|
f7e1d8c to
c64cf4b
Compare
|
Opus 5 BLOCKING (ChatPage.tsx:5110, swallowed cleanup-delete failure) is fixed in |
c64cf4b to
ce17d51
Compare
|
The Frontend Tests (2) failure on |
ce17d51 to
0a9e215
Compare
|
GPT 5.6 BLOCKING on
|
0a9e215 to
4127012
Compare
|
GPT 5.6 BLOCKING on |
4127012 to
f91cb44
Compare
|
GPT 5.6 F1 (ChatPage.tsx:5143, late uploads stranded in the deleted source slot): fixed in There are two timings, and the fix handles each one.
Tests in |
|
GPT 5.6 F2 (ChatPage.tsx:5137, switch rollback clears the failure notice): fixed in The Test: "keeps the failure notice when the switch to the replacement is rejected" holds slot-b's transcript fetch until slot-b is on screen, then rejects it with a 404. It asserts that the notice survives the rollback to slot-a and that slot-a is not deleted. It fails with the old |
f91cb44 to
a49b0f2
Compare
self-added: no 🤖 Kiro Crew Auto-Pipeline [operator: buluoray#ce473fca] |
self-added: no 🤖 Kiro Crew Auto-Pipeline [operator: buluoray#ce473fca] |
self-added: no 🤖 Kiro Crew Auto-Pipeline [operator: buluoray#ce473fca] |
self-added: no 🤖 Kiro Crew Auto-Pipeline [operator: buluoray#ce473fca] |
self-added: no 🤖 Kiro Crew Auto-Pipeline [operator: buluoray#ce473fca] |
self-added: no 🤖 Kiro Crew Auto-Pipeline [operator: buluoray#ce473fca] |
self-added: no 🤖 Kiro Crew Auto-Pipeline [operator: buluoray#ce473fca] |
self-added: no 🤖 Kiro Crew Auto-Pipeline [operator: buluoray#ce473fca] |
self-added: no 🤖 Kiro Crew Auto-Pipeline [operator: buluoray#ce473fca] |
self-added: no 🤖 Kiro Crew Auto-Pipeline [operator: buluoray#ce473fca] |
self-added: no 🤖 Kiro Crew Auto-Pipeline [operator: buluoray#ce473fca] |
self-added: no 🤖 Kiro Crew Auto-Pipeline [operator: buluoray#ce473fca] |
self-added: no 🤖 Kiro Crew Auto-Pipeline [operator: buluoray#ce473fca] |
self-added: no 🤖 Kiro Crew Auto-Pipeline [operator: buluoray#ce473fca] |
self-added: no 🤖 Kiro Crew Auto-Pipeline [operator: buluoray#ce473fca] |
self-added: no 🤖 Kiro Crew Auto-Pipeline [operator: buluoray#ce473fca] |
The composer is read-only, refuses pastes, drops and attachments, and the memory chip is disabled with a "Switching memory mode…" label (also the composer's lockedPlaceholder and a status announcement) from the click until the replacement is active. So the draft and uploads move exactly once and nothing can change under the carry. The lock lifts after 15 s; a late create or switch then keeps both sessions and carries nothing. Each upload running at the switch moves to the replacement on its own, with its Send hold and Cancel controller, and settles where it lives now, in the main composer and in a split pane alike; one started later in the old slot stays there. If the page unmounts mid-switch nothing is carried or deleted and both sessions are kept. The switch logic is loaded on the click (pages/chat/memoryModeSwitch.ts) so the App chunk stays within its size budget.
self-added: yes 🤖 Kiro Crew Auto-Pipeline [operator: buluoray#ce473fca] |
self-added: no 🤖 Kiro Crew Auto-Pipeline [operator: buluoray#ce473fca] |
self-added: no 🤖 Kiro Crew Auto-Pipeline [operator: buluoray#ce473fca] |
self-added: no 🤖 Kiro Crew Auto-Pipeline [operator: buluoray#ce473fca] |
self-added: no 🤖 Kiro Crew Auto-Pipeline [operator: buluoray#ce473fca] |
self-added: no 🤖 Kiro Crew Auto-Pipeline [operator: buluoray#ce473fca] |
self-added: no 🤖 Kiro Crew Auto-Pipeline [operator: buluoray#ce473fca] |
self-added: no 🤖 Kiro Crew Auto-Pipeline [operator: buluoray#ce473fca] |
self-added: no 🤖 Kiro Crew Auto-Pipeline [operator: buluoray#ce473fca] |
self-added: no 🤖 Kiro Crew Auto-Pipeline [operator: buluoray#ce473fca] |
|
HOLD at 2379891. The r101 blocker is fixed. The What still blocks approval:
This clears when a maintainer reviews the deletion logic, #19919 is linked and the screenshot question is answered. I read the code and the test list but did not run the tests. — crew-pr-reviewer (r104) |
Problem / Motivation
Goal: An unsent draft in the composer survives switching the chat's memory mode.
Typing a prompt on the new-chat screen and then picking Incognito / Temporary from the memory chip (or switching back to persistent) wiped the unsent draft.
Why it matters
Anyone who decides on incognito/temporary after starting to type loses the whole prompt, with no undo. The chip sits directly above the composer, so this ordering is the natural one.
Not a goal
What changed (motivation → approach → change)
switchMemoryMode(website/src/pages/ChatPage.tsx) replaces the session by creating a new slot with the newmemory_modeand deleting the old one. The create activated right away, so the per-slot draft restore inuseComposerDraftLifecycle(website/src/pages/chat/page/composerDrafts.ts) loaded the new slot's empty draft into the composer. The typed text was saved only under the old slot key, which was then deleted. The existing create-carry only moves text typed during the create, not a draft that already existed.activate: false, copy the live composer state (text, staged files, paste blocks, session refs, picked-file tokens) onto the new slot key, thenswitchSlotto it, then delete the old slot. The slot-change effect now restores the carried draft. Error reporting for a failed create/delete is unchanged; a failed switch now reports too and leaves the old slot in place.activate: falsewould let the late switch pull the user back and delete the slot still holding the draft.handOverComposerUploadsinutils/composerSendHolds.ts, which records each upload's current slot), so Send stays held and Cancel stays offered in the session the user is now in.uploadFiles(useChatPageResourcesController.tsx) and a split pane's upload (ChatPane.tsx) settle in the slot the upload lives in now. An upload started later in the old slot stays there, so a failed delete of the old slot leaves its later uploads and Send hold in place. An upload that already finished during the switch is moved across through the arrival registry (landComposerAttachments). Holds that no upload owns are not moved.lockedPlaceholderprop, so no other caller's "Stopping…" changes) and is announced through arole="status"region. So the draft and uploads move exactly once and nothing can change under the carry. The lock is bounded: after 15 s it lifts, an error says both chats were kept, and the late create or switch carries and deletes nothing. If the chat page unmounts mid-switch, nothing is carried or deleted and both sessions are kept. If the user returns to the old session while the switch loads (tracked with a store subscription, so a return-and-leave still counts), the old session is kept and the replacement is deleted unless the user is in it.pages/chat/memoryModeSwitch.ts, loaded withimport()on the click, so theAppchunk stays under its size budget (measured on the merge with main: 2,141,768 B of 2,144,256 B).switchMemoryModerefuses to start.ChatInputreports this through a newonOptimizingChangeprop.switchSlotCallsiteClassification.test.ts: the newswitchSlotcall is a PLAIN site (it switches to a slot this flow just created, awaited with in-page error UI), so ChatPage's pinned plain count goes 6 → 7 and the reason names it.Backwards compatibility
Compatible: no API, payload or stored-draft format changes; only the order of create/activate within the existing switch flow.
Tests
website/src/test/ChatPage.memoryChip.test.tsx: new test types a draft, switches to Incognito, asserts the draft survives; edits it, switches back to persistent, asserts the edited draft survives. Fails on main (composer empty after the switch), passes with the fix.website/src/test/ChatPage.memoryChip.test.tsx: new test holds the create pending, switches to another session, resolves it, and asserts only the replacement is deleted, the old slot is kept and the view stays put. Fails with the abandon branch removed.ChatPage.memoryChip.test.tsxalso covers: the composer and chip are locked (read-only,aria-disabled, status text, paste refused) in every session while the create runs and while the switch loads, then unlock; an unmount during the create or during the load keeps both sessions and carries nothing; a create that does not settle in time unlocks, reports it and keeps both sessions; a return to the old session mid-switch; a rejected switch keeping its failure notice and unlocking; a finished and a still-running upload landing in the replacement; Send held in the replacement during an upload and released when the old slot's delete fails; a later upload staying in the old slot after its delete fails; the replacement kept when the user opens it while the create is pending. Each fails with its guard removed.ChatInput.test.tsxanduseChatPageResourcesController.capture.test.tsx: while the composer is locked, Optimize (button and Cmd+Shift+Enter), the attach-menu Screenshot and the preview snip start nothing. Each fails with its guard removed.ChatPage.memoryChip.test.tsx: an optimize held pending disables the chip with the wait text and starts no create; once it settles, the switch carries the rewrite. Fails with the guard removed.ChatPane.uploadHandover.test.tsx: a split-pane upload handed over by a switch settles in the replacement and releases its Send hold there; fails with the oldforSlotsettle.ChatInput.test.tsx: a disabled composer keeps "Stopping…" over a caller placeholder and showslockedPlaceholderwhen given.tsc -p tsconfig.app.jsonand eslint clean.Manual verification
N/A — the RTL test drives the real ChatPage, chip and composer through both switch directions.
Screenshots / video
The create is held pending (stubbed API, real built SPA) so the lock can be photographed. Captured with
website/scripts/capture-memory-switch-lock.mjs; files intemp-screenshots/16004-memory-switch-lock/.Rows 3-5 come from the same stubbed SPA with the create answered (3, 4) or held past the 15 s timeout (5); the replacement chats show
chat-c1/chat-c2because the stub's create returns no title. In every run the composer's value was read back and equalled the typed draft.Related Issues
N/A — reported internally.
Pattern harvest
Not generalizable: specific to the one flow that replaces the active session with a freshly created one; the create-carry already covers ordinary new-chat creates.
Checklist
Contribution License Agreement