fix(session-ui): render large diffs as plain text in the worker pool (#46772)

This commit is contained in:
Luke Parker
2026-09-02 20:12:20 +10:00
committed by GitHub
Unverified
parent 651cdd257a
commit 6ea388a206
3 changed files with 25 additions and 2 deletions
@@ -25,8 +25,9 @@ mechanism, not CPU time or desktop memory. Full reconstructed content is checked
separately after timing. No forced GC or machine-dependent thresholds are used.
`HIGHLIGHT_CORRECTNESS=1` runs the deterministic `*.correctness.ts` checks against
the same fixture instead of the timed benchmarks: cache reuse across remounts and
invalidation on content, theme, and worker option changes.
the same fixture instead of the timed benchmarks: cache reuse across remounts,
invalidation on content, theme, and worker option changes, and plain rendering of
large diffs with complete reconstructed content.
Optional output settings: `HIGHLIGHT_RESULTS`, `HIGHLIGHT_SCREENSHOTS`,
`OPENCODE_PERFORMANCE_RUN_ID`, and `OPENCODE_PERFORMANCE_TRACE_DIR` (separate
@@ -0,0 +1,19 @@
import { expect, test } from "@playwright/test"
import type {} from "./viewer"
test("renders large diffs as plain text without changing ordinary highlighting", async ({ page }) => {
await page.goto("/?large")
await page.waitForFunction(() => !!window.highlighting)
const large = await page.evaluate(() => window.highlighting.mount(1))
expect(large.options).toMatchObject({ lineDiffType: "none", maxLineDiffLength: 0, tokenizeMaxLineLength: 1 })
expect(large.syntaxSpans).toBe(0)
await expect(page.locator('[data-line="11"][data-line-type="change-addition"]')).toContainText("status: 201")
expect(await page.evaluate(() => window.highlighting.contents()!.after === window.highlighting.input.after[0])).toBe(true)
await page.goto("/")
await page.waitForFunction(() => !!window.highlighting)
const ordinary = await page.evaluate(() => window.highlighting.mount(1))
expect(ordinary.options).toMatchObject({ lineDiffType: "word-alt", maxLineDiffLength: 1000, tokenizeMaxLineLength: 1000 })
expect(ordinary.syntaxSpans).toBeGreaterThan(0)
await expect(page.locator('[data-line="11"][data-line-type="change-addition"]')).toContainText("status: 201")
})
+3
View File
@@ -22,6 +22,9 @@ function createPool(lineDiffType: "none" | "word-alt") {
{
theme: "OpenCode",
lineDiffType,
// Pierre renders with the pool's options, not the viewer's, whenever the pool works. The "none" pool only
// serves diffs above the large-file threshold, so it carries the plain-text fallback the viewer requests.
...(lineDiffType === "none" && { maxLineDiffLength: 0, tokenizeMaxLineLength: 1 }),
preferredHighlighter: "shiki-wasm",
},
)