Repository navigation
Conversation
There was a problem hiding this comment.
Works as described. With the session-find experiment on, I drove the TUI with the simulated model: /find opens the bar, the counter goes 1/4 → 2/4, and matches are highlighted in the prompt, bold markdown, plain text and a fenced code block. The base has none of this. test/session-find.test.tsx and the group-view test pass (10/10), and tsc passes for packages/tui and packages/theme.
Public API: all additions, backwards compatible. They are the session.find keybind (<leader>f,super+f), the experimental["session-find"] config key, an optional find theme token group (find.text.current, find.background.match, find.background.current, falling back to existing tokens), and ResolvedThemeTokens.find. Existing themes and configs keep working.
Two things are worth fixing, both inline. First, the markdown chunk-callback override runs even when the experiment is off. Second, paint walks the whole markdown tree before checking whether a search is active.
|
|
||
| function paint(block: CodeRenderable, chunks: TextChunk[], context: ChunkRenderContext) { | ||
| const pattern = ctx.find.pattern() | ||
| const start = markdown && sourceStart(markdown, part().text, block) |
There was a problem hiding this comment.
sourceStart walks the whole markdown tree and runs indexOf per block before the !pattern check. So every chunk callback of every prose block pays for it, even with find closed or the experiment off. While a long reply streams, that is roughly quadratic in the number of blocks. Returning early on !pattern before computing start avoids it.
| // oxlint-disable-next-line no-restricted-globals -- OpenTUI has no public option for the markdown chunk callback. | ||
| links = Reflect.get(renderable, "_linkifyMarkdownChunks") | ||
| // oxlint-disable-next-line no-restricted-globals -- OpenTUI has no public option for the markdown chunk callback. | ||
| Reflect.set(renderable, "_linkifyMarkdownChunks", prose) |
There was a problem hiding this comment.
This replaces OpenTUI's private _linkifyMarkdownChunks on every assistant text part, whatever the session-find setting; only the command checks it. Per packages/tui/AGENTS.md, experiment behavior should be gated by its config key. Could this ref (and FindText) be a no-op unless the experiment is on? Then users who haven't opted in never run code that depends on the private field.
|
thanks, fixed both in 91987ac
the |
There was a problem hiding this comment.
Both earlier points are addressed. prose/paint now return early when no search is active or the part has no matches, before walking the tree. Find's markdown hook is only installed when session-find is on. The tests and tsc still pass, and find works as before when I drove it (2/4, highlights in the prompt, markdown and the code block). The public API is unchanged since the last review: all additions, backwards compatible. Nothing new to flag.
There was a problem hiding this comment.
Both earlier points (the early return before the tree walk, and gating the markdown hook on the experiment) were fixed in the previous push. This commit makes find take the prompt's place. I found nothing new worth flagging. The updated test passes, tsc passes, and I drove it with the simulated model: the find field replaces the prompt with a 2/4 counter and the key hints, and highlights still appear in the prompt, the markdown and the code block. The public API is unchanged since the last review: all additions, backwards compatible.
81eee37 to
0b24d30
Compare
There was a problem hiding this comment.
Both earlier points are addressed. The private _linkifyMarkdownChunks override is replaced by OpenTUI 0.9's public inlineHook/inlineHookFilter. The hook is installed whatever the experiment setting again, but with no search active it only checks for matches and returns the session links' spans as they are. code/prose return early when the part has no matches.
One new problem in the inline-hook rewrite: prose blocks can mark the wrong match as current (inline). Driving it with the simulated model, a reply with **banana** and then a table cell banana shows both highlighted as the current match at "2 of 5". The tests (16 pass across the find, session-link, reasoning-body and plugin-markdown tests) and tsc pass. The PR's own test misses this because its table cell text doesn't repeat any earlier block.
The public API is unchanged since the last review: all additions, backwards compatible.
| const linked = links ? links(spans, context) : spans | ||
| const matches = findRanges(part().text, ctx.find.pattern()) | ||
| if (matches.length === 0) return linked | ||
| const start = part().text.indexOf(context.source) |
There was a problem hiding this comment.
indexOf(context.source) returns the first copy of the block's source anywhere in the part. A table cell or short paragraph whose text also appears earlier gets numbered from the wrong place. With The **banana** is yellow… followed by a table cell banana, the cell resolves to the first paragraph's offset. At "2 of 5" both the paragraph match and the cell are painted as current (see the screenshot). Searching from the end of the previous block, as sourceStart does for code, or using a source offset from OpenTUI if the hook context has one, would fix it. Relatedly, matching on the linked text rather than the source means a session link label (or an ID it hides) can shift first + index the same way.
There was a problem hiding this comment.
The doubled current highlight is fixed: with a table cell that repeats earlier text, only one match is painted as current now. I checked by driving it with the simulated model (**banana**, then a table cell banana, then a code block, at "2 of 5"), and with a link whose URL contains the query. The updated find test and tsc pass. The earlier points were already addressed. The public API is unchanged since the last review: all additions, backwards compatible. Nothing new to flag.
|
Thanks for working on this — really nice, clean implementation! I tested it both with an agent (full Here are 2 bugs and 5 smaller code/efficiency findings from testing, with repros, suggested fixes, and criticality/usefulness ratings: Bugs1. Code fence language tags cause off-by-one / ghost matches
2. Concealed markdown syntax causes counter/highlight mismatches
Code & Efficiency Findings1. Quadratic
|
|
One quick follow-up question on searchable message types in Right now Find searches user prompts and assistant text (matching desktop), and skips
|






Issue for this PR
Closes #4714
Type of change
What does this PR do?
adds find in session to the tui. it works like the desktop app's find bar:
<leader>f(alsosuper+f) or/find. a one-line bar shows up above the prompt3/12, or0/0when nothing matchesenter/↓next,shift+enter/↑previous (wraps around),esccloses and clears the highlightshow it works:
find.ts), so the counter also covers rows that aren't mounted yet. a jump mounts every row first (ensureAllRows), like timeline jumps do**are handled, and fenced code blocks get the callback too. tables are counted but not painted for nowoffsetRowturns that into the exact wrapped row to scroll tofindkeymap mode only while its field has focus, so the prompt keeps enter/esc/arrows if you click back into itfindtheme token (find.background.match,find.background.current,find.text.current). it's optional and falls back tobackground.raised.maxand the focused primary action colors, so existing themes need no changesbehind the
session-findtui experiment (experimental: { "session-find": true }or the Experiments dialog)How did you verify your code works?
test/session-find.test.tsx: unit tests for matching, concealed markdown mapping, chunk painting and wrapped rows, plus an app test that opens find with<leader>f, types, checks the highlights in a prompt, bold markdown and a code block, moves with enter/↑ (wrapping to 4/4) and closes with esc. passes 10/10 with--rerun-each 10, and fails fast if highlighting is turned offbun run checkpasses**bold**,/find,0/0, wrap-around, esc clearing everything and focus going back to the promptScreenshots / recordings
no screenshots yet. the ones I took show private session content, I'll add ones from a fixture session
Checklist
Added by the opencode bot (AI-generated).
Public API: adds the session.find keybind, the experimental session-find key and an optional find theme token group (backwards compatible)