Uh oh!
There was an error while loading. Please reload this page.
feat(tui): add interactive session search - #36526
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
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). |
Automated PR Cleanup Thank you for contributing to opencode. Due to the high volume of PRs from users and AI agents, we periodically close older PRs using automated criteria so maintainers can focus review time on the most active and community-supported contributions. This PR was closed because it matched the following cleanup criteria:
PRs created within the last month are not affected by this cleanup. If you believe this PR was closed incorrectly, or if you are still actively working on it, please leave a comment explaining why it should be reopened. A maintainer can review and reopen it if appropriate. Thanks again for taking the time to contribute. |
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