Repository navigation
fix(session-ui): render large diffs as plain text in the worker pool - #46772
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
The change is narrowly scoped, aligns worker-pool behavior with the existing large-diff fallback intent, and includes a dedicated benchmark plus correctness validation.
Pull request overview
This PR fixes session diff rendering for large patches by ensuring Pierre’s "none" worker pool uses the same plain-text fallback render options that File already intends for diffs over ~500 KB, preventing expensive Shiki tokenization on every mount. It also adds a reproducible performance/correctness harness under packages/session-ui/performance/highlighting to benchmark and validate the behavior.
Changes:
- Update the Pierre worker pool creation so the
"none"pool applies{ maxLineDiffLength: 0, tokenizeMaxLineLength: 1 }in addition tolineDiffType: "none". - Add a Vite + Playwright-based benchmark/correctness suite for diff highlighting performance and verification.
- Add
vite-plugin-solidto support the new benchmark build pipeline.
File summaries
| File | Description |
|---|---|
| packages/session-ui/src/pierre/worker.ts | Ensures the "none" worker pool uses plain-text fallback render options for large diffs. |
| packages/session-ui/performance/highlighting/viewer.tsx | Adds an in-browser production-fixture viewer to measure worker/render timings and verify output. |
| packages/session-ui/performance/highlighting/viewer.bench.ts | Adds Playwright benchmark runner to collect timing stats and report them consistently. |
| packages/session-ui/performance/highlighting/plain.correctness.ts | Adds correctness coverage for “large diff is plain text” while preserving ordinary highlighting. |
| packages/session-ui/performance/highlighting/playwright.config.ts | Configures Playwright execution for bench vs correctness modes and local web server. |
| packages/session-ui/performance/highlighting/build.ts | Adds Vite build script to generate an external artifact bundle and build metadata for comparisons. |
| packages/session-ui/performance/highlighting/serve.ts | Adds a minimal Bun static server for serving the built benchmark bundle. |
| packages/session-ui/performance/highlighting/index.html | Adds the benchmark entry HTML that loads the viewer module. |
| packages/session-ui/performance/highlighting/README.md | Documents how to build and run the benchmark/correctness suite. |
| packages/session-ui/package.json | Adds vite-plugin-solid to devDependencies for the benchmark build. |
| bun.lock | Updates the lockfile to include vite-plugin-solid. |
Review details
- Files reviewed: 10/11 changed files
- Comments generated: 0
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Hona
force-pushed
the
large-diff-plain
branch
from
September 2, 2026 09:38
6e00f90 to
902ace3
Compare
jinhuang712
pushed a commit
to jinhuang712/opencode
that referenced
this pull request
Sep 26, 2026
1 task done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
DiffViewerasks for a plain-text fallback above 500 KB (largeOptions:lineDiffType: "none",maxLineDiffLength: 0,tokenizeMaxLineLength: 1), but Pierre'sDiffHunksRenderer.getRenderOptionsuses the worker pool's render options whenever the pool works. The dedicated"none"pool only carriedlineDiffType, so every >500 KB diff was still fully Shiki-tokenized (1000-char line cap) on each mount, about 6 s in the worker for a 625 KB patch."none"pool now carries the plain-text options the viewer requests. It only serves diffs above the large-file threshold (file.tsxpicks it vialarge()), so ordinary diffs keepword-altintra-line diffs and full highlighting on the default pool.largeOptionsinfile.tsxstays as the no-pool fallback.Benchmark
packages/session-ui/performance/highlighting: productionFile(diff mode, virtualized),normalize,getWorkerPool, bundled Pierre worker. TypeScript route-handler file, one edited line per ten handlers. Each isolated page: cold mount, unmount and remount, then an edited patch.ready= productiononRendered, pool idle, and the final worker result committed byonPostRenderwith the expected edit visible. Chromium 147 headless, 1280x800, 20 serial pages per case, medians (p95). Baseline32d4375b39(benchmark commits only) vs candidate6e00f90629.word-altpool; its deltas are run-to-run variance on a shared machine (the same shift appears in an unrelated candidate run), not an effect of this change.file.tsxalready intended.