fix(flow-chat): report and navigate every search keyword occurrence - #1786
Merged
bobleer merged 1 commit intoJul 26, 2026
Merged
Conversation
The chat search deduplicated matches by dialog turn, so a session with many occurrences of the query reported a single result and next/prev skipped everything else inside a turn. Every occurrence in every searchable source is now its own navigable match, DOM navigation lands on the exact Nth occurrence, and non-current occurrences in the focused text root get a faint highlight.
1688mengdie
pushed a commit
to 1688mengdie/BitFun
that referenced
this pull request
Jul 26, 2026
…CWing#1786) The chat search deduplicated matches by dialog turn, so a session with many occurrences of the query reported a single result and next/prev skipped everything else inside a turn. Every occurrence in every searchable source is now its own navigable match, DOM navigation lands on the exact Nth occurrence, and non-current occurrences in the focused text root get a faint highlight.
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
FlowChat's in-chat search deduplicated matches by dialog turn: a session containing many occurrences of the keyword reported a single result ("1/1"), and the next/prev controls skipped every other occurrence inside a turn. This PR makes every occurrence of the query its own navigable match, teaches DOM navigation to land on the exact Nth occurrence, and adds a faint highlight for the non-current occurrences in the focused text root.
useFlowChatSearch:buildFlowChatSearchMatchesno longer keeps only the first match per turn; it enumerates every non-overlapping, case-insensitive occurrence in every searchable source and records itsoccurrenceIndex.flowChatSearchDom: newfindFlowChatSearchTextRangesreturns all match ranges in document order (still tolerant of Markdown splitting a match across text nodes);setFlowChatSearchHighlightnow maintains a second::highlightregistry (bitfun-flowchat-search-match) for non-current occurrences.VirtualMessageList.scrollToSearchMatchacceptsoccurrenceIndex, picks the Nth rendered range (clamped, since raw Markdown can contain occurrences the rendered DOM does not), highlights the current one strongly and its siblings faintly.ModernFlowChatContainerthreadsoccurrenceIndexthrough to the list so stepping between occurrences inside the same message re-triggers navigation.Type and Areas
Type: bug fix
Areas: web UI (FlowChat search)
Motivation / Impact
Searching a session for a keyword now reports the true occurrence count (e.g. "3/17"), and next/prev/Enter walk through every occurrence — including several inside one long model reply — instead of jumping one-per-turn. All occurrences in the current message are visibly highlighted, with the active one emphasized.
Verification
node node_modules/typescript/bin/tsc --noEmitinsrc/web-ui: clean.vitest run src/flow_chat: 148 files, 1156 tests passed, including new cases for multiple occurrences in one source, per-item matches within one turn, non-overlapping counting, and document-order multi-range DOM lookup.Reviewer Notes
The occurrence count comes from raw message content while navigation resolves against rendered text, so Markdown syntax (e.g. link URLs) can make the raw count exceed the rendered one; navigation clamps to the last rendered occurrence in that case. Scroll/expand retry machinery in
scrollToSearchMatchis unchanged, consistent withFLOWCHAT_SCROLL_STABILITY.md.Checklist