Skip to content

feat: add Ctrl+R reverse search for prompt history#22085

Closed
alankyshum wants to merge 1 commit intoanomalyco:devfrom
alankyshum:bld-2-reverse-search
Closed

feat: add Ctrl+R reverse search for prompt history#22085
alankyshum wants to merge 1 commit intoanomalyco:devfrom
alankyshum:bld-2-reverse-search

Conversation

@alankyshum
Copy link
Copy Markdown

Issue for this PR

Closes #5062

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Adds bash-like Ctrl+R reverse search to the TUI prompt history. When the user presses Ctrl+R, a search bar appears above the prompt showing (reverse-i-search): <query>. Typing filters history entries with case-insensitive substring matching. Pressing Ctrl+R again cycles to the next older match. Enter accepts the match and loads it into the prompt. Escape cancels and restores the original input.

Changes:

  • config.ts: Added history_search keybind (ctrl+r) and moved session_rename to ctrl+shift+r to resolve the conflict
  • history.tsx: Added search(query, start?) method that performs reverse chronological case-insensitive substring search on PromptInfo.input
  • prompt/index.tsx: Added search mode state management, keyboard handling (enter/escape/backspace/ctrl+r cycling/character input), and an inline search bar UI following bash conventions

How did you verify your code works?

  • bun typecheck passes from packages/opencode
  • Reviewed keyboard event handling against KeyEvent type from @opentui/core
  • Verified search state resets on session change

Screenshots / recordings

Terminal UI change — search bar renders inline above the prompt.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

Add bash-like reverse search to the TUI prompt. Pressing Ctrl+R enters
search mode where typing filters history entries with case-insensitive
substring matching. Pressing Ctrl+R again cycles to the next older match.
Enter accepts the match, Escape cancels.

- Add history_search keybind (ctrl+r) and move session_rename to ctrl+shift+r
- Add search() method to prompt history for reverse matching
- Add search mode UI with (reverse-i-search) / (failed reverse-i-search) bar
- Reset search state on session change

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions
Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

Potential Duplicate PRs Found

  1. feat(tui): add Ctrl+R prompt history search #12307 - feat(tui): add Ctrl+R prompt history search

    • Appears to be a prior attempt at implementing the same Ctrl+R history search feature for the TUI prompt
  2. feat(tui): add prompt history search #21253 - feat(tui): add prompt history search

    • Related feature for prompt history search functionality

These PRs appear to be addressing the same feature request for adding Ctrl+R reverse search to the prompt history. You may want to check if PR #12307 was closed or abandoned, and whether PR #21253 implements a different approach to history search.

@alankyshum
Copy link
Copy Markdown
Author

Closed by board: unauthorized self-directed work.

@alankyshum alankyshum closed this Apr 12, 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.

[FEATURE]: Ctrl+R to search and navigate prompt history instead of just arrow keys

1 participant