Skip to content

feat(composer): stash a draft with Cmd/Ctrl+S and bring it back - #14767

Open
Pearcekieser wants to merge 1 commit into
kirodotdev:mainfrom
Pearcekieser:feat/composer-prompt-stash
Open

Pearcekieser wants to merge 1 commit into
kirodotdev:mainfrom
Pearcekieser:feat/composer-prompt-stash

Conversation

@Pearcekieser

@Pearcekieser Pearcekieser commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

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

  • A picker for several drafts. The chord restores the latest.
  • Stashing attachments. That ships in a follow-up PR.
  • Sharing a stash between sessions.

What changed

Action Composer Result
Cmd/Ctrl+S or + menu has a draft saved, composer cleared, confirmation on the status line
same stash holds 10 refused, draft kept, warning that names discard
Cmd/Ctrl+S or + menu empty latest draft restored
either attachment present refused with a note
Cmd/Ctrl+S empty, nothing stashed neutral note; browser save dialog stays closed
+ menu "Discard stashed draft" holds a just-restored, unedited draft that draft deleted, composer cleared, Undo offered
same anything else latest stashed draft deleted, composer untouched, Undo offered

Each draft is its own localStorage entry (mc-prompt-stash:<slot>:<id>) with its PasteBlocks, 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 an ErrorNotice.

A restored draft keeps its entry until the server confirms the send. ChatInputProps.onSend/onSteer may return Promise<boolean>, ChatInput routes every send through the hook's trackSend, and only true deletes the entry. doSend/doSteer in components/useChatPaneSend.ts return true for a dispatched or queued receipt; ChatPage's send() reports the same through a reportConfirmed callback, and its mid-turn steer (pages/chat/page/busyTurnControls.ts) resolves from steerMutation.mutateAsync's receipt or a correlated echo. Anything else keeps the entry, so at worst a sent draft stays stashed as a duplicate.

deleteHistorySession in store/chat/lifecycle.ts clears a slot's stash after the gateway answers ok: true, removing only keys listed under the stash lock before the DELETE. It finds the slot with stripDashboardSessionPrefixes, split out of dashboardAutomationSlotKey in monitoring/automation.ts. A stacked alias or a dashboard row whose stem is a channel slot (slotChannelNamespace) owns no stash. The size refusal in hooks/usePromptStash.ts offers 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 the composer-more-trigger overflow on a pointer desktop too, so the discard row is always reachable. Every add and remove in utils/promptStash.ts also dispatches mc-prompt-stash-changed on window, because storage never 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 as stash-prompt in lib/shortcutRegistry.ts. Stash and restore reseed the undo history through a new reseed in chat-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 no onUploadFiles) do they move to the composer-more-trigger overflow. The side chat passes promptStash={false}. Copy is in all 13 catalogs and pluralKeys.json; the feature is in docs/feature-map/README.md.

Bundle size

No budget change. Main now carries ModelEffortDropdown: 558 KB in website/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, and check-bundle-size.mjs passes for all 959 chunks. An import() 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/onSteer accept Promise<boolean>, and ChatPage's steer now returns one. SideChat.tsx and CrewChatWindow pass promptStash={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 the mc-prompt-stash-changed listener).
  • 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-returning steer) and an unconfirmed one keeps it.
  • ChatInput.promptStash.test.tsx also: 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 without promptStash={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

Desktop dark, stashed
Desktop light, stashed
+ menu
+ menu with a draft
Restored
Empty press
Attachment refused
Attachment menu
Stash full
+ menu at the cap with Discard
Discarded, Undo offered
Restored draft, + menu with Discard
Restored draft discarded
Undo done
Clear other sessions offer
Clear confirm step
Cleared
Stashed after clear
Shortcuts row
Storage error
Phone overflow
Phone stashed
Touch overflow with a draft stashed
Touch at the cap with Discard
Touch discarded, Undo offered

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

  • At most two commits (one is the norm), with a Conventional Commits title (feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)
  • Existing tests pass and new tests added for new functionality
  • Self-review completed; code follows project style guidelines
  • Documentation updated (if applicable)
  • No secrets, credentials, or internal references in the diff

@Pearcekieser
Pearcekieser requested a review from a team September 28, 2026 17:05
@Pearcekieser
Pearcekieser requested a review from a team as a code owner September 28, 2026 17:05
@Pearcekieser

Copy link
Copy Markdown
Contributor Author

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.
Not a goal: A list for picking among several stashed drafts, stashing attachments (both follow-up PRs under #14766), or a stash shared across sessions.

@github-actions github-actions Bot added fork Pull request from a fork (external contributor) readiness: checking Automated validation is still running labels Sep 28, 2026
@github-actions

github-actions Bot commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5, fork) — ✅ PASS

UX-level review of 3d60204d87052ee59e0a34a352ea41e6479b022c via the fork AI-review pipeline — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

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

  • PromptStashStatusLine: the notice repeats the count that sits right next to it. Attachment 11 shows "Stashed draft discarded. 9 drafts are still stashed." beside "9 drafts stashed", and attachment 5 shows the same for restore. Drop the count from discarded_* and restored_* so they read "Stashed draft discarded." and "Stashed draft restored."
  • menu_discard_desc, "Deletes the draft you just restored, or else the latest stashed one. You can undo it.", makes the user work out which draft will go. Show which one instead, for example the first few words of the draft or a label like "Discard restored draft" / "Discard latest stashed draft".
  • too_large_single, discard_failed, undo_failed and the plural menu_restore_desc_other ("the latest comes back") appear in no screenshot. They are copy variants of rows the screenshots do show, so they are not gaps, but a shot of each would complete the set.

[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 .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 Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5, fork) — ✅ PASS

Premise-level review of 3d60204d87052ee59e0a34a352ea41e6479b022c via the fork AI-review pipeline — 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. 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

  • Item 5 — oversized: this rests on "until the draft is safely elsewhere the entry is its only durable copy". On the base, the composer draft already persists per slot through mc-chat-drafts (utils/draftConstants.ts), so a restored draft already has a durable copy. Because of this rule, ChatInputProps.onSend/onSteer now return Promise<boolean>, send gains a reportConfirmed callback, composerSend and an async steer are added, and CrewChatWindow has to drop the stash entirely ("This peer's send reports no receipt").
    Subtraction: remove the entry when the draft is restored, so restore is a pop. Then delete trackSend, inFlightRef, returnedClaimRef, parkedClaimsRef, reportConfirmed, composerSend, the Promise<boolean> widening of onSend/onSteer and the CrewChatWindow opt-out.

What this change ships

Inventory (10 items) — 9 justified

Intent: let a user park a half-written prompt and bring it back in the same session, without losing collapsed pastes. This is an ADDITION.

  1. Cmd/Ctrl+S in the composer stashes the draft and its paste blocks, then clears the composer — justified
  2. Cmd/Ctrl+S in an empty composer restores the latest stashed draft — justified
  3. Stash, Restore and Discard rows in the "+" menu, or in the ⋯ overflow where "+" can't hold them — justified
  4. A status line above the buttons shows the stash count, notices and Undo — justified
  5. A restored draft stays stashed until the server confirms delivery, which changes the send contract of every composer host — oversized
  6. Caps of 10 drafts per session and 512 KB in total; writes past a cap are refused and nothing expires — justified
  7. A two-step "Clear N drafts stashed in other sessions" offer when a stash is refused for size — justified
  8. Permanently deleting a session from history clears its stash once the gateway confirms — justified
  9. Side chat and crew windows opt out of the stash — justified
  10. A ⋯ overflow appears on pointer composers that have no upload, and stash-prompt is listed in the shortcuts reference — justified

[FIRST-PRINCIPLES-REVIEWED] 3d60204

Description read

[DESCRIPTION-READ] 97e87089e34aa8562dced1387948ec008a9117ab0c8b54ef5ddded689a012e1c

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 Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5, fork) — ✅ PASS

Design-level review of 3d60204d87052ee59e0a34a352ea41e6479b022c via the fork AI-review pipeline — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

Design-Verdict: PASS

Nothing blocks: the change adds a client-only feature with nothing taken away, and the screenshots for this revision downloaded.

Notes

  • Any ChatInput host whose onSend returns nothing still has the stash turned on, so a restored draft stays stashed after it is sent and the user can send it twice. Only SideChat and CrewChatWindow opt out, so check the other embedders (for example app-sdk) and set promptStash={false} where a send gives no receipt.
  • deleteHistorySession now has to know how stash slots are named. It works out the owning slot with a second copy of the prefix-stripping logic, in stashOwnerSlot. If dashboard key naming changes and only one copy is updated, deleting a session will quietly leave its stash entries behind or remove the wrong ones.

[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 .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 Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review (fork) — ✅ no blocking findings

Reviewed 3d60204d87052ee59e0a34a352ea41e6479b022c via the fork AI-review pipeline; updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 3d60204

@github-actions

github-actions Bot commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review (fork) — ✅ no blocking findings

Reviewed 3d60204d87052ee59e0a34a352ea41e6479b022c via the fork AI-review pipeline; updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] 3d60204

@Pearcekieser
Pearcekieser force-pushed the feat/composer-prompt-stash branch from 20363a8 to 34f32a4 Compare September 28, 2026 18:50
@Pearcekieser

Copy link
Copy Markdown
Contributor Author

issue (blocking): Cap refusal is now visible

  • Cap refusal is now visible

Disposition: fixed.
fixed in 34f32a4: a press refused at the cap shows the full-stash sentence as visible text beside the "N stashed" button (PromptStashBadge prompt-stash-notice), not only in the live region.
The note clears on the next edit; ChatInput.promptStash.test.tsx "refuses at the cap" asserts it appears and clears. Screenshot 5 in the body shows it.

@Pearcekieser

Copy link
Copy Markdown
Contributor Author

issue (blocking): Chord is listed in the shortcuts reference, and the badge is a button

  • Chord is listed in the shortcuts reference, and the badge is a button

Disposition: fixed.
fixed in 34f32a4: stash-prompt is a SHORTCUT_REGISTRY entry (dispatch: 'code', like optimize-prompt) with a label in SHORTCUT_LABEL_KEY, so the shortcuts modal lists it.
Mouse users get the "N stashed" button, which restores the latest draft (see cfdd7ad9337a).

@Pearcekieser

Copy link
Copy Markdown
Contributor Author

issue (blocking): Badge wording is now shown in the evidence

  • Badge wording is now shown in the evidence

Disposition: fixed.
addressed in 34f32a4: the body carries five captures of the badge in both themes ("1 stashed", "2 stashed", "10 stashed" with the refusal note).
The label sits next to an archive icon and its tooltip reads "Restore the latest stashed draft. ⌘S in an empty composer does the same.", which names drafts explicitly.

@Pearcekieser

Copy link
Copy Markdown
Contributor Author

issue (blocking): Badge is a button that restores the latest draft

  • Badge is a button that restores the latest draft

Disposition: fixed.
fixed in 34f32a4: PromptStashBadge renders a <button>; a click calls restoreLatest, the same action as the chord on an empty composer.
With a draft already in the composer, the click swaps: the draft goes into the stash, so nothing is lost. Tested in "restores the latest draft from the badge button, swapping".

@Pearcekieser

Copy link
Copy Markdown
Contributor Author

issue (non-blocking): Chord registered in the shortcut registry

  • Chord registered in the shortcut registry

Disposition: fixed.
fixed in 34f32a4: website/src/lib/shortcutRegistry.ts gains stash-prompt (dispatch: 'code', default mod+S on both platforms) next to optimize-prompt, with a label key.
promptStash.test.ts pins that the registry default is the chord isStashChord claims, so the two cannot drift.

@Pearcekieser

Copy link
Copy Markdown
Contributor Author

issue (non-blocking): Stash store no longer expires or evicts

  • Stash store no longer expires or evicts

Disposition: fixed.
fixed in 34f32a4: the stash no longer uses createSlotDraftStore; it keeps its own mc-prompt-stash blob with no TTL, no slot cap and no byte eviction, written via safeSetItem with a read-back check.
An entry leaves only on restore or delete; a refused write keeps the draft in the composer with an ErrorNotice. Tested across 80 sessions of 40 KB each.

@Pearcekieser

Copy link
Copy Markdown
Contributor Author

issue (blocking): Store-wide caps no longer delete stashed drafts

  • Store-wide caps no longer delete stashed drafts

Disposition: fixed.
fixed in 34f32a4: website/src/utils/promptStash.ts replaced the createSlotDraftStore instance (TTL, maxEntries, maxStoreBytes) with a plain per-slot blob that never expires or evicts.
Quota exhaustion now fails the write (safeSetItem returns false), the read-back check reports it and the composer keeps the draft. Test: "never expires or evicts one session's stash".

@Pearcekieser

Copy link
Copy Markdown
Contributor Author

issue (blocking): No-op press is no longer prevented

  • No-op press is no longer prevented

Disposition: fixed.
fixed in 34f32a4: usePromptStash calls preventDefault and stopPropagation only when the plan acts (stash, restore, refusal at the cap); an empty composer with an empty stash leaves the event untouched.
Test "leaves a no-op press unclaimed" asserts a document listener receives it with defaultPrevented === false.

@Pearcekieser

Copy link
Copy Markdown
Contributor Author

issue (non-blocking): No-op press is no longer prevented

  • No-op press is no longer prevented

Disposition: fixed.
fixed in 34f32a4: preventDefault moved inside the plan !== 'none' branch of usePromptStash, so a press the stash declines reaches MarkdownPanel's document save un-prevented.
Covered by the "leaves a no-op press unclaimed" test (defaultPrevented false on the document listener).

@Pearcekieser

Copy link
Copy Markdown
Contributor Author

issue (non-blocking): Stash error and note are width-bounded

  • Stash error and note are width-bounded

Disposition: fixed.
fixed in 34f32a4: the ErrorNotice and the refusal note in PromptStashBadge carry max-w-[16rem] and truncate, with the full error in messageTooltip.
The shrink-0 action cluster can no longer grow past that bound, so the mic and send buttons stay in view; screenshot 5 shows the truncated note beside the buttons.

@Pearcekieser

Copy link
Copy Markdown
Contributor Author

issue (non-blocking): Chord label follows the platform in every composer

  • Chord label follows the platform in every composer

Disposition: fixed.
fixed in 34f32a4: promptStashChord now reads isMac from website/src/utils/platform.ts instead of the optional isMac prop, so ChatPane and SideChat show ⌘S on macOS too.
Only the label changed; the chord matcher already accepted ⌘ and Ctrl.

@Pearcekieser

Copy link
Copy Markdown
Contributor Author

note (non-blocking): Backend Tests (Windows) (4) red is inherited from main

test/test_pid_reader_ratchet.py::test_pid_reader_sites_match_the_recorded_count_exactly fails on main too (CI run 36453125742 at b5dcaaa, same shard). The ratchet scans *.py only and this PR changes no Python file, so no change here.

@Pearcekieser
Pearcekieser force-pushed the feat/composer-prompt-stash branch from 34f32a4 to ebc626e Compare September 28, 2026 19:05
@Pearcekieser

Copy link
Copy Markdown
Contributor Author

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 window by a one-shot listener. Tests cover both halves and that no cancellation leaks into a later keydown. The refusal note also clears when a paste block changes, not only the text. Nothing else changed.

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Sep 28, 2026
@Pearcekieser
Pearcekieser force-pushed the feat/composer-prompt-stash branch from ebc626e to 225c3e8 Compare September 28, 2026 21:34
@Pearcekieser

Copy link
Copy Markdown
Contributor Author

issue (blocking): Refusal note no longer truncated

  • Refusal note no longer truncated

Disposition: fixed.
fixed in 225c3e8: the visible notes use separate short strings (notice_full "Stash full (10). Restore one first.", notice_stashed, notice_empty, notice_attachments) that fit the 16rem bound; the longer sentences stay in the live region.
Screenshot 5 shows the full refusal text beside "10 stashed".

@Pearcekieser

Copy link
Copy Markdown
Contributor Author

note (non-blocking): stills and copy stay deferred to Pearcekieser/KiroCrew#38

The size-limit stills and the shorter restored_* copy are checkboxes in #38. The touch "+" still now has its own checkbox there too. The copy change touches 13 catalogs, so it goes in the copy pass. Advisory, so no push for these notes.

@Pearcekieser

Copy link
Copy Markdown
Contributor Author

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 stashOwnerSlot call stripDashboardSessionPrefixes is a checkbox in #38. Advisory, so no push for this note.

@Pearcekieser

Copy link
Copy Markdown
Contributor Author

note (non-blocking): the menu_discard_desc note is deferred to the copy pass in Pearcekieser/KiroCrew#38

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 too_large copy. The copy change touches 13 catalogs, so it goes in the copy pass. Advisory, so no push for this note.

@Pearcekieser

Copy link
Copy Markdown
Contributor Author

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 meta.files with the POST. This PR steers through mutateAsync to read the server's verdict, so SteerVars gained files?: string[] and that call passes files: steerFiles. #25574's new busyTurnControls.steerFiles.test.ts now mocks mutateAsync and awaits each steer, the same change #24503's test got.

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.

@Pearcekieser

Copy link
Copy Markdown
Contributor Author

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 too_large copy was already a checkbox in #38. Shortening menu_restore_desc_touch and menu_discard_desc to the suggested strings are now checkboxes too. The copy change touches 13 catalogs, so it goes in the copy pass. Advisory, so no push for these notes.

@Pearcekieser

Copy link
Copy Markdown
Contributor Author

note (non-blocking): item 4 kept, for the reason given on earlier heads

utils/chatDrafts.ts saves the composer text, but the composer clears that draft when the send starts, before the server answers. On a refused send the saved draft is already gone, so popping the entry at restore would lose the text. reportConfirmed, composerSend and the mutateAsync steer are how a host reports that the server holds it. Advisory, so no push for this note.

@Pearcekieser

Copy link
Copy Markdown
Contributor Author

note (non-blocking): both notes deferred to Pearcekieser/KiroCrew#38

Having send return one combined verdict instead of the reportConfirmed callback is now a checkbox in #38. The single owner for the prefix fold was already one; the two folds match on this head, so a delete clears the right session's entries. Advisory, so no push for these notes.

@Pearcekieser

Copy link
Copy Markdown
Contributor Author

chore (non-blocking): rebased on main 7afcc3a. Head is c33dd19, one commit.

#25183 wrapped onSend and onSteer in ComposerDockView.tsx with the crew-worker guards (steerRootClosed, steerFits). The wrappers used braces, which dropped the verdict this PR's composer reads. Both now keep main's guards and return the result: composerSend() and steer(opts) when the guard passes, Promise.resolve(false) when it refuses. A refused send leaves the draft in the box, so "not confirmed" keeps any restored stash entry.

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.

@Pearcekieser

Copy link
Copy Markdown
Contributor Author

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.

@Pearcekieser

Copy link
Copy Markdown
Contributor Author

chore (non-blocking): rebased on main 4d36177, no behaviour change. Head is 056aac4, one commit.

#25715 moved the ⋯ overflow's Sketch row onto useMenuOpensDialog: onCloseAutoFocus on the menu content and moreMenuLayer.openLayer instead of the bare setTimeout. The rebase keeps both, plus this PR's directFilePicker condition on that row and its DROPDOWN_ROW button. ChatInput.tsx is 1,996 lines, under the cap.

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.

@Pearcekieser

Copy link
Copy Markdown
Contributor Author

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 notice_stashed_touch line, were already checkboxes there. Shortening menu_restore_desc_touch_one to "1 draft stashed." is now one too; the copy change touches 13 catalogs, so it goes in the copy pass. Advisory, so no push for these notes.

@Pearcekieser

Copy link
Copy Markdown
Contributor Author

chore (non-blocking): rebased on main 0f2fbcf, no behaviour change. Head is a443c7e, one commit.

Two things changed since 056aac4. Main's #25487 put ChatInput.tsx at 2,044 lines with this PR, over the 2,000-line cap, so the whole ⋯ overflow menu moved unchanged into chat-input/ComposerMoreMenu.tsx and takes its values as props; ChatInput.tsx is 1,968 lines. Main's #25708 raised ModelEffortDropdown to 558 KB, so this PR keeps main's entry and no longer touches check-bundle-size.mjs. An analyze build puts the chunk at 565,994 B and the gate passes for all 959 chunks. The bundle paragraph in the description says the same.

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.

@Pearcekieser

Copy link
Copy Markdown
Contributor Author

chore (non-blocking): Frontend Lint fix in 45e104f, no behaviour change. On a443c7e the restyle ratchet failed because the menu's one restyle site (className="w-[260px] p-2" on DropdownMenuContent) moved with the ⋯ overflow from ChatInput.tsx into chat-input/ComposerMoreMenu.tsx. website/scripts/restyle-baseline.json now carries that entry under the new path at the same count of 1, the hand edit the script's header names for a moved file. The ratchet and its self-test pass, as do eslint, i18n:check and lint:phantom-classes. The Coverage Gate failed only because lint did.

@Pearcekieser

Copy link
Copy Markdown
Contributor Author

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.

@Pearcekieser

Copy link
Copy Markdown
Contributor Author

note (non-blocking): all three notes were already checkboxes in Pearcekieser/KiroCrew#38

Re-capturing screenshots 15 and 16 with the shipped too_large copy, cutting restored_* and discarded_* so the counter carries the number, and shortening menu_restore_desc_touch_one to "1 draft stashed." are tracked there for the copy pass, which touches 13 catalogs. Advisory, so no push for these notes.

@Pearcekieser

Copy link
Copy Markdown
Contributor Author

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.

@Pearcekieser

Copy link
Copy Markdown
Contributor Author

span=113490572bd7

issue (blocking): fixed in 11a8df4, the new allowance is gone

The ⋯ menu's DropdownMenuContent carried className="w-[260px] p-2", and shadcn/no-restyle allows no classes on that primitive. Moving the menu into chat-input/ComposerMoreMenu.tsx carried the restyle with it, and I had moved its baseline entry instead of removing the restyle. The content now takes no className; the width and inset sit on a plain <div className="w-[250px] p-1"> inside it, which with the content's own p-1 and border keeps the menu 260px wide with the same 8px inset. restyle-baseline.json now only shrinks against main: this PR removes ChatInput.tsx: 5, whose sites are gone on this branch, and adds no entry. The ratchet reads 313 sites in 50 files and matches, and eslint with shadcn/no-restyle is clean on the new file.

@Pearcekieser

Copy link
Copy Markdown
Contributor Author

chore (non-blocking): rebased on main 477c91a, no behaviour change. Head is 693e972, one commit.

The only conflict was website/src/i18n/pluralKeys.json: main's list plus this PR's 10 entries. tsc, eslint, i18n:check, lint:restyle-ratchet and lint:phantom-classes pass. The PR's tests, the stash and overflow tests, NavHistoryArrows.test.tsx and the i18n tests pass: 74 files, 1,776 tests.

On 11a8df4, Frontend Tests (3) failed one case, NavHistoryArrows.test.tsx:187 (the draft guard was called 0 times). This PR does not touch page navigation, and the file passes 18 of 18 locally three times in a row; this push re-runs it.

@Pearcekieser

Copy link
Copy Markdown
Contributor Author

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:

  • composerSend.ts: main added a sendNow argument where this PR adds reportConfirmed. send takes both, sendNow first, and the two callers that pass a callback pass sendNow=false.
  • busyTurnControls.ts: this PR now uses main's exported SteerVars from turnActions.ts instead of its own copy, and passes baseAtPress on its mutateAsync steer.
  • attach.tsx and ChatInput.tsx: main's typing-lock banner, its app action rows in "+" and "⋯" and its recording strip stay as main has them, beside this PR's stash rows. "⋯" mounts where main mounts it, on collapsible hosts, and wherever the stash rows need it.
  • lifecycle.ts and ChatInput.inlineToolbarWhileFits.test.tsx keep both sets of imports.

The locale catalogs and pluralKeys.json keep main's files with only this PR's keys added.

ChatInput.tsx came out at 2,022 lines with the merge. The stash setup moved unchanged into chat-input/composerPromptStash.ts, and ChatInput.tsx is now 1,986 lines. The restyle baseline still only removes ChatInput.tsx: 5 against main.

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 SettingsPage at 502.3 KB against a 500 KB budget. An analyze build of main 570db5f fails the same way, and this PR does not touch settings.

@Pearcekieser

Copy link
Copy Markdown
Contributor Author

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).

@Pearcekieser

Copy link
Copy Markdown
Contributor Author

span=10f93377d1b3

issue (blocking): Stash shortcut bypasses the typing lock. Fixed in c3d107b.

ChatInput now passes inert: ... || typingLocked to useComposerPromptStash. Every stash entry point that writes the composer already returns early on inert: the Cmd/Ctrl+S chord, stash, restore, discard, and the canStash/canRestore/canDiscard flags that drive the menu rows. So a typing-locked composer no longer stashes or restores through any path. Blocking the key in lockedKeyDown alone would have left the menu rows open.

I checked the two hook actions that skip the inert guard. undoDiscard adds the discarded entry back to the stack, and clearOtherSessions clears the stacks of other sessions. Neither one calls onChange, onBlocksChange or onReseed, so neither can change a locked draft.

Tests: two new cases in ChatInput.promptStash.test.tsx press the chord under a typing lock. One has a draft to stash, one has an empty composer and a stored entry to restore. Both failed before the fix. Both pass now and check that the draft and the stack are unchanged. The PR's 84 vitest files pass, and tsc, eslint, i18n, the restyle ratchet, phantom classes and the line cap are clean.

@Pearcekieser

Copy link
Copy Markdown
Contributor Author

note (non-blocking): Backend Tests (3.12, 5) fails on main's test_jev_response_reaches_the_assembled_message since #26950, not on this diff. The fix is #29458 for #29457. This PR rebases after it merges.

@Pearcekieser

Copy link
Copy Markdown
Contributor Author

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 too_large text. The first capture also showed an unrelated dock error over the "+" button, because the capture stub answered /api/members with the wrong shape. I corrected the stub, so the new screens show only the composer.

I did not add stills for too_large_single, discard_failed or undo_failed. Each one is a different text on the same status line that the screens already show, as the review says.

@Pearcekieser

Copy link
Copy Markdown
Contributor Author

span=de7b852e75fc

issue (blocking): Concurrent writes are mistaken for a full stash. Fixed in acb4895.

Without Web Locks, stashFrom now rolls back its own write only when the stack after the write, minus the pending restored copy, holds more than PROMPT_STASH_MAX entries. The pending copy does not count because it is removed right after a successful write. A draft another tab adds below the cap no longer rolls the stash back, and after a rollback the count is read again with countStored. The locked path does not change.

The new test "keeps an unlocked stash when a concurrent tab adds a draft below the cap" removes navigator.locks and adds a second tab's draft during this tab's write. It fails on 89ec31f and passes on acb4895, with both drafts stored and a count of 2. The existing over-cap test still rolls back only this tab's write. The other cap checks in the hook read the stack under the lock, so the same defect cannot occur there.

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.
@bolichen97

Copy link
Copy Markdown
Contributor

[operator: bolichen97] Continuing this in #36727; thanks for the start.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fork Pull request from a fork (external contributor) merge conflict Branch has merge conflicts with its base — author must resolve before merge readiness: action required A blocking check or review needs attention

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Composer: stash a draft with Cmd/Ctrl+S and bring it back

3 participants