[PR #6276] feat(tui): add inline Ctrl+R reverse-i-search for prompt history #11812

Open
opened 2026-02-16 18:16:45 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/6276

State: open
Merged: No


Summary

Implements bash-style inline reverse-i-search for prompt history, as an alternative approach to #5775's modal dialog. This addresses #5062 and #1701.

As @ShpetimA suggested in #5062:

Maybe just simple search style like bash where you search and it shows on the input instantly instead of opening history modal.

Demo

The search works inline in the prompt textarea with a status line in the footer:

(reverse-i-search)'git co': 2/5    ctrl+r next    esc cancel    enter select

Features

  • Inline preview: Matches display directly in the prompt textarea (no modal)
  • Incremental search: Real-time substring matching as you type
  • Full keyboard controls:
    • Ctrl+R / Up: Cycle to older matches
    • Down: Cycle to newer matches
    • Enter: Accept current match
    • Esc / Ctrl+G: Cancel and restore original prompt
  • Complete state preservation: Prompt text, file/agent parts, extmarks, mode, and cursor position
  • Configurable keybind: history_search (default: ctrl+r)

Implementation Details

  • Added historySearch state to Prompt store tracking: active, query, matchIndex, originalPrompt, originalMode, originalCursorOffset
  • Exposed history.items getter for direct access to prompt history
  • History search handler takes precedence over shell-mode and other key handlers when active
  • Preview updates parts/extmarks consistently with normal history navigation
  • Paste blocked during search mode
  • Supports space character in search queries (e.name === "space" handling)

Why Inline vs Modal?

Aspect Inline (this PR) Modal (#5775)
UX Convention Matches bash/zsh/fish exactly IDE-style picker
Context Stays in prompt, see full content Separate overlay
State Management Reuses existing textarea/extmarks Needs separate rendering
Complexity Localized to one component Additional dialog component

For a terminal TUI that already uses shell-like behaviors, inline Ctrl+R is the more cohesive choice.

Closes #5062
Related to #1701, #5775

**Original Pull Request:** https://github.com/anomalyco/opencode/pull/6276 **State:** open **Merged:** No --- ## Summary Implements bash-style inline reverse-i-search for prompt history, as an alternative approach to #5775's modal dialog. This addresses #5062 and #1701. As @ShpetimA suggested in #5062: > Maybe just simple search style like bash where you search and it shows on the input instantly instead of opening history modal. ## Demo The search works inline in the prompt textarea with a status line in the footer: ``` (reverse-i-search)'git co': 2/5 ctrl+r next esc cancel enter select ``` ## Features - **Inline preview**: Matches display directly in the prompt textarea (no modal) - **Incremental search**: Real-time substring matching as you type - **Full keyboard controls**: - `Ctrl+R` / `Up`: Cycle to older matches - `Down`: Cycle to newer matches - `Enter`: Accept current match - `Esc` / `Ctrl+G`: Cancel and restore original prompt - **Complete state preservation**: Prompt text, file/agent parts, extmarks, mode, and cursor position - **Configurable keybind**: `history_search` (default: `ctrl+r`) ## Implementation Details - Added `historySearch` state to Prompt store tracking: `active`, `query`, `matchIndex`, `originalPrompt`, `originalMode`, `originalCursorOffset` - Exposed `history.items` getter for direct access to prompt history - History search handler takes precedence over shell-mode and other key handlers when active - Preview updates parts/extmarks consistently with normal history navigation - Paste blocked during search mode - Supports space character in search queries (`e.name === "space"` handling) ## Why Inline vs Modal? | Aspect | Inline (this PR) | Modal (#5775) | |--------|------------------|---------------| | UX Convention | Matches bash/zsh/fish exactly | IDE-style picker | | Context | Stays in prompt, see full content | Separate overlay | | State Management | Reuses existing textarea/extmarks | Needs separate rendering | | Complexity | Localized to one component | Additional dialog component | For a terminal TUI that already uses shell-like behaviors, inline Ctrl+R is the more cohesive choice. Closes #5062 Related to #1701, #5775
yindo added the pull-request label 2026-02-16 18:16:45 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#11812