The best way to control Claude Code, Codex and more from any computer or phone
fix(web): keep thread find working with many matches in one row (#34402)
Co-authored-by: Julius Marminge <julius0216@outlook.com>
Lakshmi Tanmay committed
Nov 15, 2026 at 00:55 UTC
0cf9423d8b1220a435703ff98a2dabbddc1e59ef
3 files changed
+66
-3
apps/web/src/components/chat/threadFindHighlights.browser.test.tsx
+26
-2
@@ -1,6 +1,8 @@
1
-import { describe, expect, it } from "vite-plus/test";
1
+import { describe, expect, it, vi } from "vite-plus/test";
2
3
-import { collectThreadFindRanges } from "./threadFindHighlights";
3
+import { render } from "../../../test/render";
4
+
5
+import { collectThreadFindRanges, useThreadFindHighlights } from "./threadFindHighlights";
6
7
function row(html: string) {
8
const container = document.createElement("div");
@@ -21,3 +23,25 @@ describe("collectThreadFindRanges", () => {
23
]);
24
});
25
});
26
+
27
+function Highlights(props: Parameters<typeof useThreadFindHighlights>[0]) {
28
+ useThreadFindHighlights(props);
29
+ return null;
30
+}
31
+
32
+it("paints every match when one row has more matches than a call can take as arguments", async () => {
33
+ const count = 200_000;
34
+ const onActiveRange = vi.fn<(range: Range | null) => void>();
35
+ await using _screen = await render(
36
+ <Highlights
37
+ container={row("e x".repeat(count))}
38
+ query="e"
39
+ activeRowId="row"
40
+ activeOccurrence={count - 1}
41
+ onActiveRange={onActiveRange}
42
+ />,
43
+ );
44
+ expect(CSS.highlights.get("t3-thread-find")?.size).toBe(count - 1);
45
+ expect(CSS.highlights.get("t3-thread-find-active")?.size).toBe(1);
46
+ expect(onActiveRange.mock.lastCall?.[0]?.startOffset).toBe((count - 1) * 3);
47
+});
apps/web/src/components/chat/threadFindHighlights.ts
+1
-1
@@ -156,7 +156,7 @@ export function useThreadFindHighlights(input: {
156
matches = collectThreadFindRanges(row as HTMLElement, query);
157
cache.set(row, matches);
158
}
159
- ranges.push(...matches);
159
+ for (const match of matches) ranges.push(match);
160
}
161
for (const row of cache.keys()) if (!rows.has(row)) cache.delete(row);
162
rangesRef.current = ranges;
scripts/scenarios/thread-find-large-row.e2e.ts
new
+39
@@ -0,0 +1,39 @@
1
+import { expect } from "e2e";
2
+
3
+import { test, WEB } from "./t3.ts";
4
+
5
+test("Find highlights a row with 200,000 matches", WEB, async ({ t3, app, screen, browser }) => {
6
+ const project = await t3.project("find-proof");
7
+ await t3.thread({ project, title: "Large row proof", messages: ["go"] });
8
+ await t3.open();
9
+ const thread = screen.getByRole("button", /^Large row proof,/);
10
+ await expect(thread).toBeVisible({ timeout: 120_000 });
11
+ await thread.tap();
12
+ await expect(screen.getByText("first fixture turn complete", { exact: false })).toBeVisible();
13
+ await browser.keyboard.press("Control+f");
14
+ const find = screen.getByRole("searchbox", "Find in thread");
15
+ await expect(find).toBeVisible();
16
+ // A DOM fixture reaches the real highlight effect without a giant replay recording.
17
+ await browser.evaluate(`(() => {
18
+ const scope = [...document.querySelectorAll("[data-thread-find-text]")].find((element) =>
19
+ element.textContent.includes("first fixture turn complete"),
20
+ );
21
+ if (!scope) throw new Error("The replayed response is not mounted");
22
+ scope.textContent = "e x".repeat(200_000);
23
+ Object.assign(scope.style, { maxHeight: "180px", overflow: "hidden" });
24
+ return true;
25
+ })()`);
26
+ await find.fill("e");
27
+ try {
28
+ await expect
29
+ .poll(() =>
30
+ browser.evaluate<number>(
31
+ `(CSS.highlights.get("t3-thread-find")?.size ?? 0) +
32
+ (CSS.highlights.get("t3-thread-find-active")?.size ?? 0)`,
33
+ ),
34
+ )
35
+ .toBe(200_000);
36
+ } finally {
37
+ await app.screenshot("large-row-find");
38
+ }
39
+});