Skip to content

fix(native-chat): recall every sent prompt with Up/Down in the composer - #26044

Merged
brennanb2025 merged 3 commits into
stablyai:mainfrom
AmoabaKelvin:composer-prompt-recall
Oct 7, 2026
Merged

brennanb2025 merged 3 commits into
stablyai:mainfrom
AmoabaKelvin:composer-prompt-recall

Conversation

@AmoabaKelvin

@AmoabaKelvin AmoabaKelvin commented Oct 7, 2026 •

Copy link
Copy Markdown
Collaborator
Files Added Deleted Net
Test 18 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​551 $\color{#cf222e}{\Huge{\mathbf{−}}}$​88 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​463
Prod 18 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​266 $\color{#cf222e}{\Huge{\mathbf{−}}}$​125 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​141

ELI5

Pressing Up in the chat composer now brings back every message you have sent in that chat, one at a time, like a terminal's history. Down walks forward again. Before, it only remembered what you had typed since the composer last appeared, so after a reload or a tab switch you usually got back just the message you had sent a moment ago.

What Changed

Before

  • Up on an empty composer recalled only messages sent since the composer was last mounted. A reload, a tab switch, toggling between terminal and chat view, or a question card replacing the composer all wiped it.
  • Messages already in the chat, or sent from another client, were never recalled.
  • While a recalled message was showing, Up and Down always jumped to the next one, so you could not move the caret inside a recalled multi-line message.
  • Recalling a slash command reopened the command picker, and the next Up or Down moved through suggestions instead of sent messages.

After

  • Up on an empty composer recalls your newest message in the chat. Each further Up goes one older and stops at the oldest loaded message. Down walks forward, and past the newest it clears the composer.
  • It works after a reload or remount and includes messages sent from another client.
  • Inside a recalled multi-line or wrapped message the arrows move the caret; recall only continues from the first line (Up) or last line (Down).
  • Shift, Alt, Cmd or Ctrl with an arrow never recalls, and neither does a composer holding an attachment.
  • No command picker opens over an untouched recalled message. Edit it and it becomes a normal draft, picker included.
  • The same message sent back to back counts as one stop.

Mechanism

  • The composer no longer keeps its own history list. On each arrow press it derives the list from the conversation the chat draws, using the same projection as the transcript. That projection drops harness-injected turns (task notifications, system reminders, command output) and prompts a parent agent gave a subagent, so those are not recallable. Messages another agent sent into the chat are skipped too.
  • In terminal-backed chats, slash commands are not transcript turns. They are read from the record the pane already keeps for its "Ran /compact" rows and placed by when they were sent.
  • The recall position is tracked by message id, so a new message arriving mid-recall cannot shift it. Recall ends as soon as the composer stops holding the recalled text, whatever changed it: an edit, a send, a returned message.
  • The old history state and its plumbing through the send paths are deleted.

Why

The old list lived in the composer's memory, which made it a second, weaker copy of something the chat already knows. Reading the conversation directly fixes the reload and remount cases with no new storage and nothing to keep in sync.

Alternatives considered:

  • Keep the composer's list and merge it with the transcript. Built first and dropped. Matching the two by text produced duplicate entries whenever an agent recorded a prompt differently from what was typed.
  • Load older pages when recall reaches the oldest loaded message. Dropped. A keypress in the composer would silently grow the loaded transcript, and the press that triggers the load appears to do nothing. The chat loads the most recent 300 messages up front; anything older is reachable by scrolling.
  • A separate store so more than the last 8 slash commands are recallable, or so they survive a reload. Declined. It would bring back the second source of truth. Commands did not survive a reload before either.

Known narrowing: in structured chats, a command that only changes a setting (such as /model) is not recorded in the conversation, so it is no longer recalled there. /compact is recorded and still is.

Visual Proof

CleanShot.2026-10-07.at.2.15.04.AM.mp4

Testing

  • native-chat-composer-prompt-recall.test.tsx drives the real composer, editor and draft store: walking up and down, a recalled /model not handing the arrows to its picker, and an edited recall.

  • native-chat-sent-prompt-history.test.ts covers which messages count as sent prompts (harness turns, subagent prompts and other agents' messages are skipped), back-to-back duplicates, command placement, and keeping position when a message id changes or a new message lands.

  • use-native-chat-composer-keydown.test.tsx covers modifier keys, attachments, and the first/last-line rule.

  • use-native-chat-recall-position.test.tsx and use-native-chat-picker-state.test.tsx cover recall ending and the picker staying closed.

  • I manually tested these changes locally

  • Automated tests added/updated, or explained why not below

Review

Agent skill upstream boundary

  • Not applicable, or this change follows docs/reference/agent-skill-sharing-upstream-boundary.md and copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

Renderer-only. No wire, storage, or shared-type change, so SSH, mixed versions and mobile are unaffected; the web client picks it up through the shared renderer. Plain arrow keys only, no platform-specific modifier. The list is derived once per arrow press over the loaded messages.

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

@coderabbitai

coderabbitai Bot commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 020d6e5b-b1e5-40e8-badc-bf031c204498
📥 Commits

Reviewing files that changed from the base of the PR and between ad241e9 and 36c81d0.

📒 Files selected for processing (7)
  • src/renderer/src/components/native-chat/NativeChatComposer.tsx
  • src/renderer/src/components/native-chat/native-chat-sent-prompt-history.ts
  • src/renderer/src/components/native-chat/use-native-chat-composer-keydown.test.tsx
  • src/renderer/src/components/native-chat/use-native-chat-composer-keydown.ts
  • src/renderer/src/components/native-chat/use-native-chat-composer-recall.test.tsx
  • src/renderer/src/components/native-chat/use-native-chat-composer-recall.ts
  • tests/e2e/native-chat-prompt-recall.spec.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 7 remain after this review.


📝 Walkthrough

Walkthrough

Native chat composers now derive prompt recall from displayed conversation messages and command markers instead of local history state. Up and Down navigate prompts when the caret is at the corresponding visual edge and recall conditions are met. The change adds recall-position tracking, prompt extraction and stepping, and editor support for detecting visual edges. It removes history updates from send, command, and typed-insertion paths. Unit and end-to-end tests cover prompt ordering, navigation, draft changes, and caret behavior.

Priority: ⬇️ Low

Merge Risk: 🔵 Low · up to 36c81

Up can recall a failed submission as though it were sent. Exclude unsent rows before merging, or explicitly accept this limited behavior.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 40.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 30 functions across 29 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ⚠️ Warning The description covers the user-visible behavior, implementation, rationale, visual proof, testing, and impact. However, the required Linked Issue section contains only “Fixes #” and no issue link. Add an actual linked issue after “Fixes #”. If the author is a maintainer covered by the template exception, remove the empty placeholder or clarify that the exception applies.
✅ Passed checks (3 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly and concisely describes the main change: prompt recall with Up and Down in the native chat composer.
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Commit to this branch
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Recall read a list kept in the composer, so it forgot everything on reload or remount.
It now reads the prompts the chat shows.
@AmoabaKelvin
AmoabaKelvin force-pushed the composer-prompt-recall branch from b044b32 to ad241e9 Compare October 7, 2026 11:52

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: cc31479c-4eb4-4903-886c-7ea380be14ac
📥 Commits

Reviewing files that changed from the base of the PR and between b044b3266fcf23cf4a2ec9951b63438f146dc504 and ad241e9.

📒 Files selected for processing (11)
  • src/renderer/src/components/native-chat/NativeChatComposer.tsx
  • src/renderer/src/components/native-chat/NativeChatContextUsageRing.test.tsx
  • src/renderer/src/components/native-chat/NativeChatStructuredSession.tsx
  • src/renderer/src/components/native-chat/native-chat-composer-state.test.ts
  • src/renderer/src/components/native-chat/native-chat-composer-state.ts
  • src/renderer/src/components/native-chat/native-chat-composer-types.ts
  • src/renderer/src/components/native-chat/use-native-chat-composer-catalog.test.tsx
  • src/renderer/src/components/native-chat/use-native-chat-composer-keydown.steer.test.tsx
  • src/renderer/src/components/native-chat/use-native-chat-composer-keydown.test.tsx
  • src/renderer/src/components/native-chat/use-native-chat-composer-keydown.ts
  • src/renderer/src/components/native-chat/use-native-chat-structured-composer-send.ts
💤 Files with no reviewable changes (3)
  • src/renderer/src/components/native-chat/use-native-chat-structured-composer-send.ts
  • src/renderer/src/components/native-chat/native-chat-composer-state.ts
  • src/renderer/src/components/native-chat/native-chat-composer-state.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

It stayed where the last prompt had it, so Up skipped past a recalled multi-line prompt.
@brennanb2025
brennanb2025 merged commit 726eaf1 into stablyai:main Oct 7, 2026
23 of 25 checks passed
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.

2 participants