Repository navigation
Conversation
formatPatch(structuredPatch(..., { context: Number.MAX_SAFE_INTEGER }))
blocks the event loop and freezes the TUI on sessions with many file
changes. Replace with git diff subprocess which is non-blocking and
faster for large diffs.
|
Thanks for updating your PR! It now meets our contributing guidelines. 👍 |
|
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. |
|
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. |
|
This PR is still actively maintained. It was closed by the automated cleanup bot due to low reaction count, not due to any conformance issue. The fix addresses a real TUI freeze caused by synchronous Could a maintainer please reopen this PR? Happy to rebase if needed. |
Issue for this PR
Fixes #23362
Type of change
What does this PR do?
Snapshot.diffFull()callsformatPatch(structuredPatch(..., { context: Number.MAX_SAFE_INTEGER }))from the JSdiffpackage synchronously on the main thread. On sessions with many file modifications, this blocks the event loop indefinitely —straceconfirms all threads end up inFUTEX_WAITwith 0% CPU (async deadlock), freezing the TUI completely.The trigger path is:
SessionSummary.summarize()(fire-and-forget inprompt.ts) →computeDiff→snapshot.diffFull()→formatPatch(structuredPatch(...))→ hang.The regression was introduced in
b7fab49b6(refactor(snapshot): store unified patches in file diffs #21244), identified viagit bisect(9 steps betweenv1.3.3and HEAD). Parent commit463318486is the last good commit.This PR replaces the synchronous JS diff call with
git diff --no-ext-diff --no-renamesrun as a subprocess. This produces equivalent unified diff output, runs non-blocking (does not starve the event loop), and is faster for large diffs. Thediffnpm package import is removed from this file as it is no longer needed.Also addresses the main bottleneck (# 2 in the ranking) described in #22650, but only verified on TUI — web/desktop may have additional bottlenecks documented in that issue.
How did you verify your code works?
kill -9.Screenshots / recordings
N/A (not a UI change)
Checklist