Repository navigation
feat(composer): stash a draft with Cmd/Ctrl+S and bring it back - #36727
Conversation
GPT 6.1 Review — ✅ no blocking findings (all downgraded on adjudication)GPT 6.1 flagged blocking issues on This comment is updated in place on each push. Review detailsBLOCKING -- website/src/hooks/usePromptStash.ts:643 -- Preserve stash ownership through failed-steer recovery Adjudication (Opus 5.5) — is blocking on each finding proportionate?F1 is low harm, so I'm downgrading it. The required chain is rare, and the result is visible and fixable by the user.
False positive or not applicable? A repository writer can comment: |
|
[operator: bolichen97] note (non-blocking): what landing #14767's commit (3d60204) on current main took, beyond resolving the conflicts as unions. The feature, copy and keys are unchanged.
Size: 56 files, all from #14767's scope (PR Size limit 80). |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing blocks: it fixes a real loss (an interrupted prompt and its collapsed pastes), the stash lives in the frontend only, the send verdict it needs is opt-in, and screenshots of this revision are attached. Notes
[DESIGN-REVIEWED] 632a947 Description read[DESCRIPTION-READ] 3ac12d204468c4057199e07f56d9bb72b5b14b583fa494f4daa8014269b62458 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) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Nothing blocks. The stash adds a new capability beside existing ones and changes no existing default. One mechanism goes further than the Goal needs. Notes
What this change shipsInventory (8 items) — 6 justifiedIntent: let a user set a half-written prompt aside, ask something else in the same session, then bring the draft back. ADDITION.
[FIRST-PRINCIPLES-REVIEWED] 632a947 Description read[DESCRIPTION-READ] fba920c1c98d0f349d3a4237ad369c167e2d097947e5209c690a673c230de45f That sha256 names the PR description this verdict read. Recompute it with |
UX Review (Opus 5.5) — ✅ PASSUX-level review of UX-Verdict: PASS Nothing blocks. The main path is Ctrl+S, the Stash, Restore and Discard menu rows, and Undo. All of it appears in the screenshots, and the blind reader understood every step and would use it. The only confusion is on the rare size-limit recovery path. Notes
[UX-REVIEWED] 632a947 Description read[DESCRIPTION-READ] c977152cf74f1120e1611dbcf6feaabc451de2b185a2685fce7d86ba87a07507 That sha256 names everything this verdict read: the PR description, plus the 21 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 |
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: |
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.
042eca6 to
632a947
Compare
|
[operator: bolichen97] Rebased onto current main to resolve the merge conflict in website/src/i18n/pluralKeys.json. |
|
self-added: no
|
|
self-added: no
|
|
self-added: no
|
|
self-added: no
|
KiroCrewCaptain
left a comment
There was a problem hiding this comment.
Approving. On this head the review traced every path that deletes a stash entry. It also checked that the send and steer verdicts (confirmed, refused, late and echoed receipts) leave a restored draft stashed until delivery is confirmed, and that the history-delete cleanup clears keys only on an ok: true answer and skips aliases and channel slots. It checked the blocking frontend rules too (ErrorNotice, lucide icons with labels, two buttons per row, ratchet only tightening, deterministic tests), and found nothing that breaks.
Done well: the store refuses at its count and byte limits instead of evicting, and it reads every write back before the composer clears, so no draft is lost silently.
Optional:
- Add a SideChat test like the new CrewChatWindow one. Today, removing
promptStash={false}at SideChat.tsx:1142 turns no test red, and off-record text would then land in the main session's stash. - Keeping the entry until delivery is confirmed brings in most of the claim machinery in usePromptStash.ts and the
Promise<boolean>widening of onSend/onSteer. Deleting the entry on restore would still meet the Goal, so consider that in a follow-up. - The commit body still describes a count badge beside the mic button. The feature-map row leaves out the crew-window opt-out and the Discard row. When this lands, close #14767 as superseded.
Code change approver recommendation: A person should decideWhy: the decider thinks the change is probably fine but estimates a 20% chance that this change introduces a defect, above the 12% limit for approving on its own. This PR adds a per-session prompt stash on Cmd/Ctrl+S: a draft is set aside with its paste blocks and brought back later. Drafts are kept in localStorage, capped at 10 per session and 512 KB overall, with no eviction. The send and steer verdicts were verified on every host. They return true only for dispatched/queued receipts or a matching echo, which are the only accepted results sendTurn produces. Hosts with no verdict keep the entry, and the crew window and side chat opt out. Deleting a session clears its stash only after the gateway answers ok:true, which matches the backend's {"ok": ok} reply. The overflow-menu refactor keeps the same mount conditions on the existing hosts, and the mutate→mutateAsync switch keeps the same success/error handling. Tests are extensive and CI is green. The one confirmed gap (a steer refused and then retried with a paste leaves a delivered draft stashed) is rare, visible and loses nothing, so it is a note, not a blocker. Tier: 2, held for a person: design-doc-gate: D. An automated recommendation, not a review: a maintainer still decides. It approves on its own only when the estimated chance of a defect is at most 12% and the change has at most 400 changed lines. Decider v3c (217fe607) · commit |
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.Builds on #14767 by @Pearcekieser.
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 (motivation → approach → change)
A half-written prompt can now wait while you ask something else in the same session: press Cmd/Ctrl+S in the message input and the draft is set aside; press it again in an empty input and the draft comes back. This is the feature from #14767, on current
main.Each draft is its own localStorage entry (
mc-prompt-stash:<slot>:<id>) inutils/promptStash.ts: at most 10 per session and 512 KB overall, nothing evicted, every write read back before the input clears, all writes under one Web Lock.hooks/usePromptStash.tsholds the actions and copy;components/ChatInput.tsxandcomponents/chat-input/wire the chord, the menu rows (PromptStashBadge.tsx), the status line (PromptStashStatusLine.tsx) and an undo-historyreseed(chat-core/composer/undoHistory.ts). On touch hosts where "+" cannot hold the rows they sit in the "⋯" overflow, which moves out of ChatInput intoComposerMoreMenu.tsx; ChatInput keeps no restyled primitive, so its row leaveswebsite/scripts/restyle-baseline.json.A restored draft keeps its entry until the server confirms the send, even after it is edited, sent and refused, or carried through a switch to another session and back.
onSend/onSteermay returnPromise<boolean>;components/useChatPaneSend.tsand ChatPage'ssend(pages/chat/page/composerSend.ts, a trailingreportConfirmedargument) saytrueonly for adispatchedorqueuedreceipt or a correlated echo, and the mid-turn steer (pages/chat/page/busyTurnControls.ts) resolves fromsteerMutation.mutateAsync. Permanently deleting a session (store/chat/lifecycle.ts, withstripDashboardSessionPrefixesfrommonitoring/automation.ts) clears its stash once the gateway answersok: true. The side chat and crew windows passpromptStash={false}.The chord is
stash-promptinlib/shortcutRegistry.ts, claimed only while the input has focus. Copy is in all 13 catalogs andpluralKeys.json; the feature is listed indocs/feature-map/README.md.Backwards compatibility
Compatible: new i18n keys, new localStorage keys and a chord nothing used inside the message input; nothing existing is renamed or rejected.
onSend/onSteermay returnPromise<boolean>, a widening, andsend'sreportConfirmedis an optional last argument.Removes nothing: the change adds a stash, menu rows and a shortcut row; every existing send, steer and delete path keeps its behaviour and return value for its current callers.
Tests
promptStash.test.ts: physical-key matcher, registry entry, 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 (edited and resent after a refusal, or after a round trip through a session with its own draft), Discard and Undo, the overflow on a host without "+".ChatInput.promptStashTouch.test.tsx,ChatInput.promptStashVoice.test.tsx: touch hosts' menus; no stash while dictation runs.ChatPane.promptStashDelivery.test.tsx,ChatPage.sendResponseLate.test.tsx: refused, late or unconfirmed sends and steers keep the entry; a confirmed steer, or a send or steer echoed before its late receipt, removes it.ChatSliceCoverage.promptStash.test.tsx,ChatSlicePromptStashDelete.test.tsx: delete clears only the deleted slot's stash, never a reopened slot's or a channel slot's.CrewChatWindow.test.tsx: Ctrl+S writes no stash entry in a crew window.monitoring/automation.test.ts:stripDashboardSessionPrefixes, the slot a history delete reads its stash owner from.ChatPageDrafts,ChatPane.composerParity,busyTurnControls.steerFiles,busyTurnControls.steerSessionRefs(awaits the now-asyncsteer()),dashboardSlice,ChatSliceCoverageSecondPass,ChatInput.collapse,ChatInput.inlineToolbarWhileFits.Determinism: those 18 files (533 tests) passed 3 times in a row, then with
--sequence.shuffleunder seed 935775390.Manual verification
Ubuntu Linux 24.04, Chromium from Playwright, an isolated gateway (
KIROCREW_HOMEin a fresh temp dir, a free loopback port, the fake ACP backend) serving the SPA built from this change.Before (
main): a two-line draft plus Ctrl+S left the draft in the input, showed no status line or count, and wrote nomc-prompt-stash:key.After (smoke script, every check PASS):
The size limit was driven the same way: four drafts seeded under two other sessions, 524,224 of 524,288 code units, then a short draft refused with "Clear 4 drafts stashed in other sessions"; after the confirm all four keys were gone and the draft stayed in the input.
The chat and composer Playwright specs (
chat,chat-form-switch-anchor,composer-mention-atomic-delete,composer-paste-highlight,composer-paste-highlight-scrollbar,new-session-draft-carry,optimize-cancel-mobile) ran against the same kind of gateway: 40 passed; 5 Soft-Stop and draft-carry cases failed on this branch and on a cleanmaincheckout alike (a first-run notice intercepts the click).Screenshots / video
Every state
Related Issues
Part of #14766
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)Contribution License Agreement
Contributions are accepted under the project's Apache-2.0 license; see the Licensing section of CONTRIBUTING.md.