feat(tui): add interactive session search#36526
Open
albertdbio wants to merge 5 commits into
Open
Conversation
Adds readline-style incremental search over the session transcript, bound to ctrl+r (session_rename moves to none; still in the palette). - Inline search bar above the prompt: typing live-jumps to the nearest match at-or-above the viewport (reverse-i-search), ctrl+r/up cycles older, ctrl+s/down newer with wraparound and a match counter - esc restores the original scroll position (sticky-bottom aware), enter accepts and keeps position; empty-bar ctrl+r recalls the last query; refining a query stays on the current match when it still matches - Occurrence-level matches over user text, assistant text, and reasoning parts, with smartcase and literal-escaped unicode-aware matching - Substring highlights in user messages (active match accented), background tint on the active assistant part, and a clipped context preview line in the bar - Also available as /search and /find plus command palette entries; search state resets on session switch
Contributor
|
The following comment was made by an LLM, it may be inaccurate: Found related PR:
These are related but not duplicates; they represent different design choices for the same underlying feature (session search). |
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.
Issue for this PR
Closes #4714
Type of change
What does this PR do?
Adds interactive incremental search over the current session transcript — readline/less-style rather than a modal prompt.
Press
ctrl+rand a search bar attaches to the top of the prompt input:Behavior
ctrl+r/up= older match,ctrl+s/down= newer, wraparound with a3/17counter; bar turns red on zero matchesesc/ctrl+ccancels and restores the exact scroll position (sticky-bottom aware);enteraccepts and keeps position;ctrl+ron an empty bar recalls the last query/search,/find, and command palette entries; search state resets on session switchIn-place highlighting (including inside markdown)
Markdown prose and code blocks render through
CodeRenderable, so this uses its publiconHighlighthook to append match spans to the tree-sitter highlights — no opentui changes needed. Non-active matches render in a neutral tone, the active match inwarning(bold), via two new syntax scopes (search.match,search.match.active). User messages get the same treatment with text spans. Highlighting only engages when total hits <= 200 so broad one-letter queries don't re-highlight every part per keystroke.Keybind note (deliberate, happy to change)
messages_searchdefaults toctrl+r, andsession_renamemoves tonone(still available in the command palette and remappable). Rationale: reverse-search muscle memory is strong, and rename felt like a lower-frequency action to hold a prime binding. If you'd rather keep rename onctrl+r, I can default search to<leader>/or anything else — one-line change.Related prior art: #34297 takes a dialog-based approach with message-level granularity; this PR went inline/incremental after reading the feedback in #4714 about UI placement.
How did you verify your code works?
bun testfrompackages/tui(25 new unit tests over the pure search core: unit collection mirroring rendered content, occurrence offsets/lines, smartcase, regex-literal escaping, astral unicode offsets, wraparound, viewport-relative initial-match selection, highlight tuples, soft-wrap row estimation) — 217 passbun typecheckfrompackages/tui— cleanScreenshots / recordings
Happy to attach a recording if useful.
Checklist