Skip to content

fix(tui): capture keystrokes in search input mode - #337

Merged
mikeyobrien merged 2 commits into
mainfrom
fix/tui-search-input-capture
Jun 22, 2026
Merged

fix(tui): capture keystrokes in search input mode#337
mikeyobrien merged 2 commits into
mainfrom
fix/tui-search-input-capture

Conversation

@mikeyobrien

Copy link
Copy Markdown
Owner

Summary

Search mode in ralph-tui was non-functional: pressing / set search_state.search_mode = true but no key-interception block existed, so typed query characters fell through to map_key and dispatched as normal keybindings. Concretely:

  • Typing a query containing e fired the new export action (added today in 3454c62).
  • The footer never showed the query or an N/M match counter.
  • n / N / Esc were inert no-ops.

The state layer (search, next_match, clear_search) and footer rendering were already correct and unit-tested — the snapshot harness calls state.search() directly, so it bypassed the broken interactive path, which is why CI stayed green. Today's export keybindings (e/E) are what made the orphaned search-input path visibly collide.

Fix

  • Add handle_search_input, a testable helper invoked from the event loop right after the guidance interception block:
    • Char/Backspace edit the query and live-update matches
    • Enter commits a non-empty query (keeping query/matches so n/N navigate) or clears an empty one
    • Esc cancels and clears the search
  • StartSearch seeds an empty query so the footer shows the Search: prompt immediately; the footer omits the match count while the query is empty.
  • Wire with_urgent_steer_path into the guidance_test example so the ! urgent-steer path is exercisable in-process.

Tests

  • 7 new regression tests in app.rs drive the full interactive path the snapshot harness bypassed (typing, backspace, commit, navigate, cancel, no-op-when-inactive).
  • cargo test -p ralph-tui: all pass (242 unit + snapshots/integration). Full workspace builds clean.

Verification

Found by the verify-tui-ux tmux workflow and re-verified live:

/reviewing -> "Search: reviewing 1/20"
n          -> "Search: reviewing 2/20"
Esc        -> search cleared, normal footer restored

No export file is written while typing reviewing (proving e no longer leaks to the export action).

🤖 Generated with Claude Code

rookopenclaw and others added 2 commits June 21, 2026 20:24
Pressing `/` only set `search_state.search_mode = true` but no key
interception existed, so typed query characters fell through to
`map_key` and dispatched as normal keybindings. Typing a query
containing `e` fired the new export action, the footer never showed
the query or an N/M match counter, and `n`/`N`/`Esc` were inert.
The state layer (`search`, `next_match`, `clear_search`) and footer
rendering were already correct and unit-tested — only the interactive
key path in `app.rs` was missing.

Add `handle_search_input`, a testable helper invoked from the event
loop right after the guidance interception block:
- Char/Backspace edit the query and live-update matches
- Enter commits a non-empty query (keeping query/matches so n/N
  navigate) or clears an empty one
- Esc cancels and clears the search

`StartSearch` now seeds an empty query so the footer shows the
`Search: ` prompt immediately; the footer omits the match count while
the query is still empty.

Adds 7 regression tests driving the full interactive path (the path
the snapshot harness bypassed). Also wires `with_urgent_steer_path`
into the guidance_test example so the `!` steer path is exercisable.

Verified live via tmux: `/reviewing` -> "Search: reviewing 1/20",
`n` -> 2/20, Esc clears, and no export file is written.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@mikeyobrien
mikeyobrien merged commit 317266f into main Jun 22, 2026
16 checks passed
@mikeyobrien
mikeyobrien deleted the fix/tui-search-input-capture branch June 22, 2026 01:45
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