Repository navigation
feat(composer): stash a draft with Cmd/Ctrl+S and bring it back - #14767
Pearcekieser wants to merge 1 commit into
Conversation
|
Intent: Let a user set a half-written composer draft aside with Cmd/Ctrl+S and restore it with the same keys, per chat session and across reloads, without ever losing the draft. |
UX Review (Opus 5.5, fork) — ✅ PASSUX-level review of UX-Verdict: PASS Nothing blocks, as far as the screenshots go: the 25 attachments cover every new menu row, status-line state, the confirm step, Undo, the touch overflow and the Shortcuts entry. No first-time reader has looked at them, because this is the fork lane; pushing the branch to this repository runs that blind read. Notes
[UX-REVIEWED] 3d60204 Description read[DESCRIPTION-READ] b4b660d42ade84a4a59146a69490374df6960cc43d7c8fbbd2a5f6de4f48c67d That sha256 names everything this verdict read: the PR description, plus the 28 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, fork) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Nothing blocks. One mechanism goes further than the Goal needs: a restored draft stays stashed until the server confirms delivery, and that rule changes the send contract of every composer host. Notes
What this change shipsInventory (10 items) — 9 justifiedIntent: let a user park a half-written prompt and bring it back in the same session, without losing collapsed pastes. This is an ADDITION.
[FIRST-PRINCIPLES-REVIEWED] 3d60204 Description read[DESCRIPTION-READ] 97e87089e34aa8562dced1387948ec008a9117ab0c8b54ef5ddded689a012e1c That sha256 names the PR description this verdict read. Recompute it with |
Design Review (Opus 5.5, fork) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing blocks: the change adds a client-only feature with nothing taken away, and the screenshots for this revision downloaded. Notes
[DESIGN-REVIEWED] 3d60204 Description read[DESCRIPTION-READ] 02efe13ed4617d7f80811dce162c13845484eccce6158f0a717fff2cee30900f 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 (fork) — ✅ no blocking findingsReviewed Review detailsNo findings. |
Opus 5.5 Review (fork) — ✅ no blocking findingsReviewed |
20363a8 to
34f32a4
Compare
|
issue (blocking): Cap refusal is now visible
|
|
issue (blocking): Chord is listed in the shortcuts reference, and the badge is a button
|
|
issue (blocking): Badge wording is now shown in the evidence
|
|
issue (blocking): Badge is a button that restores the latest draft
|
|
issue (non-blocking): Chord registered in the shortcut registry
|
|
issue (non-blocking): Stash store no longer expires or evicts
|
|
issue (blocking): Store-wide caps no longer delete stashed drafts
|
|
issue (blocking): No-op press is no longer prevented
|
|
issue (non-blocking): No-op press is no longer prevented
|
|
issue (non-blocking): Stash error and note are width-bounded
|
|
issue (non-blocking): Chord label follows the platform in every composer
|
|
note (non-blocking): Backend Tests (Windows) (4) red is inherited from main
|
34f32a4 to
ebc626e
Compare
|
note (non-blocking): follow-up push ebc626e after an independent re-check of 34f32a4 The re-check found that leaving a no-op press (nothing typed, nothing stashed) fully unclaimed let the browser open its Save page dialog from the composer. The press now reaches document-level save handlers unprevented, so a side-panel editor still saves, and its browser default is cancelled afterwards at |
ebc626e to
225c3e8
Compare
|
issue (blocking): Refusal note no longer truncated
|
|
note (non-blocking): stills and copy stay deferred to Pearcekieser/KiroCrew#38 The size-limit stills and the shorter |
|
note (non-blocking): one owner for the prefix fold is already deferred to Pearcekieser/KiroCrew#38 The two folds match on this head, so a delete clears the right session's entries. Making |
|
note (non-blocking): the Naming the target ("Deletes the restored draft" while one is restored, otherwise "Deletes the latest stashed draft") is now a checkbox in #38, next to re-capturing attachment-15 and attachment-16 with the shipped |
|
chore (non-blocking): rebased on main d42544f, no behaviour change. Head is 559a286, one commit, and it merges clean on 6b5beda. #25574 now sends the steer's tsc, eslint and i18n:check pass. The PR's tests, every test that touches steer or the composer dock, and the i18n tests pass: 79 files, 1,732 tests. |
|
note (non-blocking): all three notes deferred to the copy pass in Pearcekieser/KiroCrew#38 Re-shooting attachment-15 and attachment-16 with the shipped |
|
note (non-blocking): item 4 kept, for the reason given on earlier heads
|
|
note (non-blocking): both notes deferred to Pearcekieser/KiroCrew#38 Having |
|
chore (non-blocking): rebased on main 7afcc3a. Head is c33dd19, one commit. #25183 wrapped tsc, eslint and i18n:check pass. The PR's tests, every test that touches the composer dock, steer or crew mode, and the i18n tests pass: 94 files, 1,981 tests. |
|
note (non-blocking): the evidence gaps are stills to re-capture, tracked in Pearcekieser/KiroCrew#38 The desktop ⋯ overflow on a composer with no "+" menu is now a checkbox in #38. The stash rows in the touch "+" menu, and re-capturing 03, 04, 08, 21 and 23 with the always-rendered Discard row, were already there. The stills live on fork issue 38, so closing these needs no code change. Advisory, so no push for these notes. |
|
chore (non-blocking): rebased on main 4d36177, no behaviour change. Head is 056aac4, one commit. #25715 moved the ⋯ overflow's Sketch row onto tsc, eslint and i18n:check pass. The PR's tests, the ChatInput tests, every test that touches the overflow or Sketch, and the i18n tests pass: 148 files, 3,092 tests. |
|
note (non-blocking): all three notes are tracked in Pearcekieser/KiroCrew#38 Re-capturing attachment-15 and attachment-16, and adding a still of the touch "+" menu with the |
|
chore (non-blocking): rebased on main 0f2fbcf, no behaviour change. Head is a443c7e, one commit. Two things changed since 056aac4. Main's #25487 put tsc, eslint and i18n:check pass. The PR's tests, the ChatInput tests, every test that touches the overflow, the stash, steer or the composer dock, and the i18n tests pass: 153 files, 3,128 tests. |
|
chore (non-blocking): Frontend Lint fix in 45e104f, no behaviour change. On a443c7e the restyle ratchet failed because the menu's one restyle site ( |
|
note (non-blocking): items 6 and 7 kept, for the reasons given on earlier heads Item 6: Undo after Discard answers an earlier UX BLOCK. Discard deletes the only copy of the draft, so a mis-tap with no Undo loses the text. Item 7: entries have no expiry, and entries left by sessions deleted elsewhere count toward the 512 KB budget with nothing in one session able to free them. The two-step Clear is the only recovery after a size refusal in that case. Both are among the deletion rules waiting on a maintainer's acceptance. Advisory, so no push for these notes. |
|
note (non-blocking): all three notes were already checkboxes in Pearcekieser/KiroCrew#38 Re-capturing screenshots 15 and 16 with the shipped |
|
chore (non-blocking): rebased on main c5d3289, no behaviour change. Head is 9119bb4, one commit. #26003 and #26004 added keys to 11 locale catalogs. Each catalog keeps main's file with this PR's own keys applied on top, and en-XA is regenerated; no line main has is removed. tsc, eslint, i18n:check, lint:phantom-classes and lint:restyle-ratchet pass. The PR's tests, the stash, overflow and i18n tests pass: 124 files, 2,716 tests. This push also replaces the Internal Content Scan that was cancelled on 45e104f. |
|
span=113490572bd7 issue (blocking): fixed in 11a8df4, the new allowance is gone The ⋯ menu's |
|
chore (non-blocking): rebased on main 477c91a, no behaviour change. Head is 693e972, one commit. The only conflict was On 11a8df4, Frontend Tests (3) failed one case, |
|
chore (non-blocking): rebased on main d062b8f, no behaviour change. Head is 435b633, one commit, replacing 693e972. Main gained about 1,700 commits since the last push, so this rebase kept both sides in six code files:
The locale catalogs and
tsc, eslint, i18n:check, lint:restyle-ratchet, lint:phantom-classes and the line cap pass. The PR's tests and the i18n tests pass on this head (82 files, 1,771 tests). On the first rebase, the PR's tests plus every test that touches steer, send, the composer menus or the typing lock also passed (171 files, 3,040 tests). The Bundle Size Gate is likely to fail on |
|
chore (non-blocking): rebased on main ab93e79, no behaviour change. Head is c6788e9, one commit. Only the 13 locale catalogs conflicted. Each keeps main's file with this PR's own keys applied, and en-XA is regenerated; no line main has is removed. tsc, eslint on the PR's 41 files, i18n:check, lint:restyle-ratchet, lint:phantom-classes and the line cap pass, and the PR's tests plus the i18n tests pass (83 files, 1,772 tests). |
|
span=10f93377d1b3 issue (blocking): Stash shortcut bypasses the typing lock. Fixed in c3d107b. ChatInput now passes I checked the two hook actions that skip the Tests: two new cases in |
|
note (non-blocking): Attachments 15 and 16 now show the current size-limit copy. I captured both screens again from the built SPA of this branch and replaced them in the description. They show the "Clear 2 drafts stashed in other sessions" offer and its "Delete 2 stashed drafts for good" step, under the current I did not add stills for |
|
span=de7b852e75fc issue (blocking): Concurrent writes are mistaken for a full stash. Fixed in acb4895. Without Web Locks, The new test "keeps an unlocked stash when a concurrent tab adds a draft below the cap" removes |
Cmd/Ctrl+S in the composer moves the current draft (text plus the paste blocks behind its tokens) onto a per-session stash and clears the composer; the same chord on an empty composer restores the latest entry. The stash persists in localStorage per chat slot, holds up to 10 drafts and refuses a further stash at the cap instead of dropping one. A count badge sits beside the mic button and a polite live region reports each action. The chord is claimed only inside the composer, so the browser's save dialog and document-level save handlers never see it there.
|
[operator: bolichen97] Continuing this in #36727; thanks for the start. |
Problem / Motivation
Goal: Let a user park a half-written prompt with Cmd/Ctrl+S, ask something else in the same session, and bring the draft back with the same keys.
Today a user interrupted mid-prompt must send the unfinished text or cut it elsewhere, and cutting a collapsed paste leaves its
[ Paste #N ]token without content. The Side chat (/btw) answers in a separate session, so the main agent never sees the question. The stash keeps the draft, in turn order and through a reload.Why it matters
Long prompts carry the most typing and are the ones most often interrupted by a quick question. Losing one, or the collapsed pastes inside it, to ask something small is a real cost.
Not a goal
What changed
Each draft is its own localStorage entry (
mc-prompt-stash:<slot>:<id>) with itsPasteBlocks, so two tabs never overwrite each other. The caps are 10 per session and 512 KB overall (PROMPT_STASH_MAX_BYTES); nothing expires. Each write is read back before the composer clears, and a refused write shows anErrorNotice.A restored draft keeps its entry until the server confirms the send.
ChatInputProps.onSend/onSteermay returnPromise<boolean>, ChatInput routes every send through the hook'strackSend, and onlytruedeletes the entry.doSend/doSteerincomponents/useChatPaneSend.tsreturntruefor adispatchedorqueuedreceipt; ChatPage'ssend()reports the same through areportConfirmedcallback, and its mid-turnsteer(pages/chat/page/busyTurnControls.ts) resolves fromsteerMutation.mutateAsync's receipt or a correlated echo. Anything else keeps the entry, so at worst a sent draft stays stashed as a duplicate.deleteHistorySessioninstore/chat/lifecycle.tsclears a slot's stash after the gateway answersok: true, removing only keys listed under the stash lock before the DELETE. It finds the slot withstripDashboardSessionPrefixes, split out ofdashboardAutomationSlotKeyinmonitoring/automation.ts. A stacked alias or a dashboard row whose stem is a channel slot (slotChannelNamespace) owns no stash. The size refusal inhooks/usePromptStash.tsoffers a two-step "Clear N drafts stashed in other sessions" only when clearing makes room, and a draft over the budget gets its own message. Every stash, restore, discard and clear runs inside one Web Lock (mc-prompt-stash).Discard never deletes text that exists only in the composer: an edited restored draft keeps its entry, and the row then drops the latest other entry. Undo re-adds the same entry with its id and time, so it returns to its place; it lasts until the next edit or slot change, and a refused Undo keeps the draft and the button. A composer with no "+" menu (no
onUploadFiles) gets thecomposer-more-triggeroverflow on a pointer desktop too, so the discard row is always reachable. Every add and remove inutils/promptStash.tsalso dispatchesmc-prompt-stash-changedonwindow, becausestoragenever fires in the writing document; a second composer in the same tab refreshes its count from it.The chord is handled on the composer wrapper, matches the physical S key (
eventKeyToken), and is registered asstash-promptinlib/shortcutRegistry.ts. Stash and restore reseed the undo history through a newreseedinchat-core/composer/undoHistory.ts. The rows sit in the "+" menu, touch included, so the row never gains a control. Only where "+" cannot hold them (the collapsible touch host, where "+" is a bare file picker, or a host with noonUploadFiles) do they move to thecomposer-more-triggeroverflow. The side chat passespromptStash={false}. Copy is in all 13 catalogs andpluralKeys.json; the feature is indocs/feature-map/README.md.Bundle size
No budget change. Main now carries
ModelEffortDropdown: 558 KBinwebsite/scripts/check-bundle-size.mjs. With the stash this branch builds that chunk at 565,994 B (552.7 KB) on an analyze build of main 0f2fbcf, andcheck-bundle-size.mjspasses for all 959 chunks. Animport()boundary would not shrink the first load: the hook and storage run on every composer mount to show the stashed-draft count.Backwards compatibility
New i18n keys, new localStorage keys and an unused chord; nothing existing is renamed or rejected. One change has readers:
onSend/onSteeracceptPromise<boolean>, and ChatPage'ssteernow returns one.SideChat.tsxandCrewChatWindowpasspromptStash={false}: their sends report no receipt, so a delivered restored draft could not be consumed there.Tests
promptStash.test.ts: physical-key matcher, registry entry, decisions, per-entry keys, slot prefix isolation, no eviction across 80 sessions, corrupt entries, refused writes.ChatInput.promptStash.test.tsx: stash and restore in both composers, paste blocks, remount, notes, failed write, Ctrl+Z, menu rows, attachments, cross-tab count, chord propagation, entry kept until delivery is confirmed, discard at the cap, discard of a restored draft with Undo, an edited restored draft kept, and a same-tab clear refreshing another composer (fails without themc-prompt-stash-changedlistener).ChatPane.promptStashDelivery.test.tsx: split-pane refused or unconfirmed sends keep the entry; failed on 126ad60.ChatPage.sendResponseLate.test.tsx: main-chat send at the deadline keeps the entry (failed on a398ec1); a confirmed mid-turn steer removes it (fails on the void-returningsteer) and an unconfirmed one keeps it.ChatInput.promptStash.test.tsxalso: a refused Undo keeps the draft and retries, and a pointer composer with no "+" menu reaches the discard row through the overflow (both fail on 60bc3bb).CrewChatWindow.test.tsx: Ctrl+S writes no stash entry in a crew window (fails withoutpromptStash={false}).ChatSliceCoverage.promptStash.test.tsx: delete keeps a reopened slot's draft (failed on 5f91036) and a channel slot's stash (failed on d3243ea).ChatInput.promptStashTouch.test.tsx: stash rows in "+" on a non-collapsible touch host with no extra control and "+ menu" copy, the overflow on the collapsible host, and one menu per host.Manual verification
Built SPA with a stubbed API in Chromium, desktop dark and light and iPhone 13 at 390px: stash, restore, fill to 10 and refuse, overflow menu on touch, discard at the cap, discard of a restored draft, Undo.
Screenshots / video
Related Issues
Fixes #14766
Deferred review follow-ups are tracked one per checkbox in Pearcekieser/KiroCrew#38: the copy pass, stale-stash cleanup, naming sessions in the Clear confirm, the owner taken from the DELETE response, and disarming the armed delete.
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)