fix(tui): capture keystrokes in search input mode - #337
Merged
Conversation
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>
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Search mode in
ralph-tuiwas non-functional: pressing/setsearch_state.search_mode = truebut no key-interception block existed, so typed query characters fell through tomap_keyand dispatched as normal keybindings. Concretely:efired the new export action (added today in3454c62).N/Mmatch counter.n/N/Escwere inert no-ops.The state layer (
search,next_match,clear_search) and footer rendering were already correct and unit-tested — the snapshot harness callsstate.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
handle_search_input, a testable helper invoked from the event loop right after the guidance interception block:Char/Backspaceedit the query and live-update matchesEntercommits a non-empty query (keepingquery/matchesson/Nnavigate) or clears an empty oneEsccancels and clears the searchStartSearchseeds an empty query so the footer shows theSearch:prompt immediately; the footer omits the match count while the query is empty.with_urgent_steer_pathinto theguidance_testexample so the!urgent-steer path is exercisable in-process.Tests
app.rsdrive 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-uxtmux workflow and re-verified live:No export file is written while typing
reviewing(provingeno longer leaks to the export action).🤖 Generated with Claude Code