fix(ui): prepare diffs off the render thread - #34415
Conversation
Move expensive diff preparation off the UI render thread into a Web Worker to prevent UI freezes on large diffs (e.g., Windows C++ projects). Performance: max frame gap 233ms → 66ms (71% lower). Original commit by @Hona (PR anomalyco#31309). Rebased onto latest dev with: - Updated import paths for packages/session-ui migration - Inlined session-diff helpers in worker to avoid circular deps - Resolved mock-server.ts type conflicts
|
Thanks for your contribution! This PR doesn't have a linked issue. All PRs must reference an existing issue. Please:
See CONTRIBUTING.md for details. |
|
The following comment was made by an LLM, it may be inaccurate: Related PR FoundPR #31309: This is the original PR that the current PR (#34415) is rebasing. The PR description explicitly states: "Replaces PR #31309" and credits the original implementation to @Hona. PR #34415 is a rebase of #31309 onto the latest Other potentially related PRs addressing similar performance issues:
However, since PR #34415 explicitly replaces/rebases PR #31309, that's the key relationship. PRs #33198 and #30441 are separate fixes for related (but different) performance issues. |
|
Thanks for updating your PR! It now meets our contributing guidelines. 👍 |
|
Automated PR Cleanup Thank you for contributing to opencode. Due to the high volume of PRs from users and AI agents, we periodically close older PRs using automated criteria so maintainers can focus review time on the most active and community-supported contributions. This PR was closed because it matched the following cleanup criteria:
PRs created within the last month are not affected by this cleanup. If you believe this PR was closed incorrectly, or if you are still actively working on it, please leave a comment explaining why it should be reopened. A maintainer can review and reopen it if appropriate. Thanks again for taking the time to contribute. |
Issue for this PR
Closes #34437
Type of change
What does this PR do?
Moves expensive diff preparation off the UI render thread into a Web Worker to prevent UI freezes on large diffs (e.g., C++ projects like
llama.cppon Windows).Root cause:
execEditLengthran synchronously in the render thread during diff computation, blocking frame rendering for hundreds of milliseconds.Changes:
packages/ui/src/diff/: worker, client, protocol, resource, client-corecreatePreparedDiffinstead of synchronous diff parsingPerformance (full-context replacement, 1,536 old + 1,536 new lines):
Original implementation by @Hona. Rebased onto latest
devwith updated imports forsession-uimigration and inlined worker helpers to avoid circular dependencies.How did you verify your code works?
bun testpasses for diff infrastructure unit testsbun typecheckpassesrender-purity.test.tsupdated to excludeworker.ts(the worker IS the diff parser)Checklist