From e784335e71ccdfdcd3cc0dd14a160356d5d18b2b Mon Sep 17 00:00:00 2001 From: Luke Parker <10430890+Hona@users.noreply.github.com> Date: Tue, 24 Nov 2026 21:16:33 +1000 Subject: [PATCH] fix(app): probe a Find seek in the match's own part A seek now probes on every one of its 12 frames. Each probe read the text of every mounted row to find one match, which cost 35% to 39% more main-thread work in the find in session bench. --- packages/app/src/session/timeline/search-controller.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/packages/app/src/session/timeline/search-controller.ts b/packages/app/src/session/timeline/search-controller.ts index c954b1ef37d..612e801aafd 100644 --- a/packages/app/src/session/timeline/search-controller.ts +++ b/packages/app/src/session/timeline/search-controller.ts @@ -93,6 +93,14 @@ function collectRanges( return { hits, active } } +// The active match alone. A seek probes on every one of its frames, so the probe reads the match's own part and not +// the text of every mounted row. +function activeRange(root: HTMLElement, query: string, partID: string, occurrence: number) { + const part = root.querySelector(`[data-timeline-part-id="${CSS.escape(partID)}"]`) + + return part ? collectRanges(part, query, partID, occurrence).active[0] : undefined +} + function applyHighlights( root: HTMLElement, query: string, @@ -285,7 +293,7 @@ export function createTranscriptSearch( const root = input.scrollRef() if (!root) return { type: "seek.missing", attempt: effect.attempt } - const range = collectRanges(root, effect.query, effect.partID, effect.occurrence).active[0] + const range = activeRange(root, effect.query, effect.partID, effect.occurrence) if (!range) return { type: "seek.missing", attempt: effect.attempt } const rect = range.getBoundingClientRect()