mirror of
https://github.com/anomalyco/opencode.git
synced 2026-11-14 12:10:45 +03:00
fix(session-ui): render large diffs as plain text in the worker pool (#46772)
This commit is contained in:
committed by
GitHub
Unverified
parent
651cdd257a
commit
6ea388a206
@@ -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")
|
||||
})
|
||||
@@ -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",
|
||||
},
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user