Skip to content

fix(flow-chat): report and navigate every search keyword occurrence - #1786

Merged
bobleer merged 1 commit into
GCWing:mainfrom
bobleer:bob/bitfun-search-keyword-fix-8a38d8
Jul 26, 2026
Merged

fix(flow-chat): report and navigate every search keyword occurrence#1786
bobleer merged 1 commit into
GCWing:mainfrom
bobleer:bob/bitfun-search-keyword-fix-8a38d8

Conversation

@bobleer

@bobleer bobleer commented Jul 26, 2026

Copy link
Copy Markdown
Collaborator

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: buildFlowChatSearchMatches no longer keeps only the first match per turn; it enumerates every non-overlapping, case-insensitive occurrence in every searchable source and records its occurrenceIndex.
  • flowChatSearchDom: new findFlowChatSearchTextRanges returns all match ranges in document order (still tolerant of Markdown splitting a match across text nodes); setFlowChatSearchHighlight now maintains a second ::highlight registry (bitfun-flowchat-search-match) for non-current occurrences.
  • VirtualMessageList.scrollToSearchMatch accepts occurrenceIndex, 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.
  • ModernFlowChatContainer threads occurrenceIndex through 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 --noEmit in src/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 scrollToSearchMatch is unchanged, consistent with FLOWCHAT_SCROLL_STABILITY.md.

Checklist

  • This PR is focused and does not include secrets, temporary prompts, generated scratch files, or unrelated artifacts.
  • Relevant verification is recorded above, or skipped checks are explained.
  • User-facing strings, docs, and locales are updated where applicable.

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.
@bobleer
bobleer merged commit 346f94a into GCWing:main Jul 26, 2026
5 checks passed
@bobleer
bobleer deleted the bob/bitfun-search-keyword-fix-8a38d8 branch July 26, 2026 17:48
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant