Skip to content

fix(chat): stop Up at the top line of a non-empty composer instead of recalling history - #31852

Merged
bolichen97 merged 1 commit into
mainfrom
fix/composer-up-keeps-draft
Nov 16, 2026
Merged

bolichen97 merged 1 commit into
mainfrom
fix/composer-up-keeps-draft

Conversation

@cruisercohen

@cruisercohen cruisercohen commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: when the composer holds any text or a paste chip, Up only moves the caret and stops at the top line. It never recalls history. An empty composer still recalls past messages.

With a draft typed, Up jumped to history once the caret reached the very start of the draft. On a multi-line draft that is one press too many from line 1: the user presses Up to reach the top line, overshoots, and the draft is swapped for an old prompt.

Builds on #31488 (bolichen97), which fixed the lost-paste half of #31851 by carrying paste blocks through recall and back to the draft. This PR keeps all of that code unchanged.

Why it matters

Anyone who writes multi-line prompts uses Up to move around them. One extra press replaces their work.

Not a goal

What changed (motivation → approach → change)

This is a UX change to an existing keyboard behavior, so it may need a maintainer's UX look.

Root cause: promptHistoryKeyEngages (website/src/components/composerPromptHistory.ts), the one rule both composers (textarea and rich-text) use, let Up engage history outside browsing when the caret was at position 0 of a non-empty draft.

Change: outside browsing, Up engages history only when the composer is empty. A paste chip counts as content, because its marker is part of the composer text. With a draft, Up returns without claiming the key, so the browser moves the caret and it stops on line 1.

Up pressed with Before After
empty composer recalls newest recalls newest (unchanged)
draft, caret mid-text or lower line moves caret moves caret (unchanged)
draft, caret at position 0 (fresh press) replaced draft with newest prompt moves caret, draft kept
draft with only a paste chip replaced by newest prompt chip kept
a recalled prompt, caret on line 1 steps older steps older (unchanged)

The held-key guard (e.repeat over a draft) in draftHistory.ts and LexicalComposerInput.tsx is removed: the rule above already refuses that case, so the lines could no longer run. The dashboard feature list now says recall works from an empty composer, and the Recall Sent Messages with Arrow Keys hint (#31409) drops "or with the cursor at its very start" in every locale; the settings registry and command-palette index are regenerated from it.

Effect on #31488's draft restore path: the keyboard no longer reaches it with a non-empty draft. Browsing now starts only from an empty composer, so Down past the newest entry restores that empty draft. The restore code (draftPastes, composerPastes, stepTo) stays as #31488 wrote it, and its behaviour is still covered by a direct stepPromptHistory test (below).

IME composition, Shift/Alt/Meta/Ctrl+Up, open pickers and send-mode handling are checked before this rule in both composers and are unchanged.

Backwards compatibility

Compatible: nothing that is stored or sent changes; only which keypress recalls history.

Reader: website/src/components/chat-input/draftHistory.ts:usePromptHistory.recall -- chat -- textarea composer; empty-box recall and browsing unchanged (ChatInput.test.tsx prompt history suite)
Reader: website/src/components/LexicalComposerInput.tsx:navigateHistory -- chat -- rich-text composer; same rule (LexicalComposerInput.test.tsx history tests)

Tests

New or changed, all failing on main (16 cases) and passing here:

  • composerPromptHistory.test.ts: promptHistoryKeyEngages refuses Up over a draft (caret at start, on line 1, paste chip only) and keeps walking older on a recalled prompt's first line.
  • ChatInput.test.tsx: Up never recalls over a typed draft (held or fresh); Up past line 1 of a multi-line draft stays; a chip-only draft is kept; an edited recall no longer recalls on Up, and recall works again once cleared.
  • LexicalComposerInput.test.tsx: the same for the rich-text composer, including a real paste chip whose block survives Up.
  • ChatInput.terminalMenus.test.tsx: a literal ! command draft stays as typed on Up.
  • ChatPane.pasteSidecar.test.tsx (fix: keep paste chip content when up/down recalls a prompt #31488's test): its "Down back to the draft restores its paste blocks" case pressed Up over a chip draft to enter history. It now checks that Up keeps the chip draft and that sending it still carries the pasted lines.

Kept coverage of #31488's restore path:

  • composerPromptHistory.test.ts: new "hands the saved draft back with its paste blocks past the newest" calls stepPromptHistory directly. It passes on main too; it is there so the restore code stays tested.

Tests that started browsing from a typed draft now start from an empty composer and expect Down past the newest entry to return to it.

Run locally on this branch: the five files above, 243 tests pass; on main's source with these tests, 16 fail. tsc -p tsconfig.app.json and eslint on the touched files pass.

Manual verification

Not run in a browser. Suggested check: type two lines, press Up three times from the end of line 2; the draft stays. Clear the box, press Up; the last prompt comes back.

Screenshots / video

Why no screenshot: Only which keypress recalls history changes; nothing renders differently.

Related Issues

Fixes #31851

Sibling sweep

Swept: git grep -n "promptHistoryKeyEngages|stepPromptHistory" -- website/src
Sibling: website/src/components/chat-input/draftHistory.ts -- changed here
Sibling: website/src/components/LexicalComposerInput.tsx -- changed here

Pattern harvest

Not generalizable: one shared keyboard rule had a single extra case; it is fixed at that rule.

Checklist

  • At most two commits (one is the norm), with a Conventional Commits title
  • 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

Contribution License Agreement

Contributed under the project's Apache-2.0 license.

@cruisercohen
cruisercohen requested review from a team and KiroCrewCaptain as code owners November 6, 2026 22:23
@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Nov 6, 2026
@github-actions

github-actions Bot commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ✅ PASS

UX-level review of 37aab771eaa9119da368fbe44a751bcf119cce0b — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

UX-Verdict: PASS

Nothing blocks: on screen, the PR only shortens one settings hint, and the new hint matches the new behaviour. No control was added or moved, so there is nothing a screenshot would need to show.

Notes

  • If someone used Up at the very start of a draft to pull back an old prompt, that press now does nothing. The settings hint "In an empty message input, ↑ brings back…" is the only place this is explained, so the release notes should mention it too.

[UX-REVIEWED] 37aab77

Description read

[DESCRIPTION-READ] d9575ca53bc7ad626fd9844b79ac379305d549c59e72c3a438b7a2fc6fb498c8

That sha256 names everything this verdict read: the PR description, plus the 3 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 Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

Design-level review of 37aab771eaa9119da368fbe44a751bcf119cce0b — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

Design-Verdict: PASS

Nothing blocks: this is a reversible keyboard-rule change made at the one rule both composers share, and the description says it changes a deliberate behaviour.

Notes

  • The removed at === 0 branch was a deliberate choice: its old comment says "recalls only… with the caret at the very start of the user's own draft". So the change needs the maintainer UX sign-off the description already asks for, not just green tests.

[DESIGN-REVIEWED] 37aab77

Description read

[DESCRIPTION-READ] 34cb1e399342213e49f321001a1c9268012f02752fe98788c9aed0e919534530

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 Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

Premise-level review of 37aab771eaa9119da368fbe44a751bcf119cce0b — 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

The fix is made where the rule lives, the one shared promptHistoryKeyEngages check. But it leaves #31488's draft-restore plumbing in place, now unreachable from the keyboard, and adds a test only to keep that plumbing tested.

Notes

  • Item 6 — oversized: after this change both callers (draftHistory.ts:53, LexicalComposerInput.tsx:803) pass only '' as the draft when browsing starts. So draft/draftPastes on PromptHistoryCursor and the composerPastes parameter of stepPromptHistory always carry an empty draft. The description says this itself: "the keyboard no longer reaches it with a non-empty draft." Subtraction: delete draft/draftPastes from PromptHistoryCursor and composerPastes from stepPromptHistory, and have Down past newest return ''. Clears when: the mechanism is removed, or a human amends the Goal.
  • Item 7 — rides along: the new test "hands the saved draft back with its paste blocks past the newest" only exists to cover that unreachable path ("it is there so the restore code stays tested"). Subtraction: delete it along with the Item 6 plumbing.

What this change ships

Inventory (7 items) — 5 justified

Intent: stop Up from replacing a multi-line draft with an old prompt when the user is only moving the caret. FIX (#31851).

  1. Up with the caret at the very start of a typed draft no longer recalls history — justified
  2. Up over a draft holding only a paste chip keeps the chip — justified
  3. The held-Up guard is deleted in both composers (it can no longer run) — justified
  4. The "Recall Sent Messages with Arrow Keys" hint drops "or cursor at its very start" in every locale and in the generated registries — justified
  5. The dashboard feature list says recall works only from an empty composer — justified
  6. Down past the newest prompt now only ever restores an empty draft; the draft and paste-restore plumbing stays — oversized
  7. A new direct test pins the restore path the keyboard can no longer reach — rides along

[FIRST-PRINCIPLES-REVIEWED] 37aab77

Description read

[DESCRIPTION-READ] 2f4b4f253d661ec2f947fbb2f9d877bc554520462b7d6e10a37debdcbe024cef

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 Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

Reviewed 37aab771eaa9119da368fbe44a751bcf119cce0b — this comment is updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] 37aab77

Verdict parsed from the review's SHA-scoped output markers for commit 37aab771eaa9119da368fbe44a751bcf119cce0b.

False positive or not applicable? A repository writer can comment:
/ai-review override fable 37aab771eaa9119da368fbe44a751bcf119cce0b false-positive: <reason, 20 to 500 characters>

@github-actions

github-actions Bot commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

GPT 6.1 completed its review of 37aab771eaa9119da368fbe44a751bcf119cce0b and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 37aab77

False positive or not applicable? A repository writer can comment:
/ai-review override gpt 37aab771eaa9119da368fbe44a751bcf119cce0b false-positive: <reason, 20 to 500 characters>

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention merge conflict Branch has merge conflicts with its base — author must resolve before merge and removed readiness: checking Automated validation is still running labels Nov 7, 2026
@cruisercohen
cruisercohen force-pushed the fix/composer-up-keeps-draft branch from fa7496c to b5b6606 Compare November 7, 2026 21:12
@cruisercohen cruisercohen changed the title fix(chat): keep Up in a non-empty composer from jumping to past prompts fix(chat): stop Up at the top line of a non-empty composer instead of recalling history Nov 7, 2026
@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention labels Nov 7, 2026
@cruisercohen
cruisercohen force-pushed the fix/composer-up-keeps-draft branch from b5b6606 to 2985703 Compare November 7, 2026 21:20
@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed merge conflict Branch has merge conflicts with its base — author must resolve before merge readiness: checking Automated validation is still running labels Nov 7, 2026
@cruisercohen
cruisercohen force-pushed the fix/composer-up-keeps-draft branch from 2985703 to f2bfa89 Compare November 13, 2026 18:58

@bolichen97 bolichen97 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving f2bfa89ee5. Sorry this waited a week for a review, @cruisercohen.

  • promptHistoryKeyEngages now recalls on ↑ only from an empty composer or while already browsing, so a draft with text or a paste chip is never replaced. The event.repeat special cases in LexicalComposerInput.tsx and draftHistory.ts are no longer needed and are gone in both places, so the two composers stay in step.
  • The tests cover the empty, draft, paste-chip and browsing cases in both composers, and the frontend shards pass.

The only red is Coverage Gate, on src/kiro_crew/agent_ipc_client.py (75.7%). This PR does not touch that file; it is a main-side gap from when CI ran. I re-ran the failed jobs, and auto merge is on.

@bolichen97
bolichen97 enabled auto-merge (squash) November 14, 2026 21:07
@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Nov 14, 2026
Up recalls a sent prompt only from an empty composer. With a draft (typed text or a paste chip), Up only moves the caret and stops at the top line, so pressing it past the first line no longer replaces the draft. The Recall Sent Messages with Arrow Keys hint no longer promises recall with the cursor at the start of a draft. Builds on #31488, whose paste-block restore path is kept unchanged.

Fixes #31851
@cruisercohen
cruisercohen force-pushed the fix/composer-up-keeps-draft branch from f2bfa89 to 37aab77 Compare November 16, 2026 00:45
@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: passed Eligible automated validation passed for the current revision and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Nov 16, 2026
@bolichen97
bolichen97 merged commit 9ad04fc into main Nov 16, 2026
154 of 156 checks passed
@bolichen97
bolichen97 deleted the fix/composer-up-keeps-draft branch November 16, 2026 02:21
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Nov 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Composer: Up over a typed draft jumps to past messages and can lose paste chips

2 participants