fix(core): add diff size limits to prevent UI freeze with large changesets#35546
Open
UR-xiaoyang wants to merge 2 commits into
Open
fix(core): add diff size limits to prevent UI freeze with large changesets#35546UR-xiaoyang wants to merge 2 commits into
UR-xiaoyang wants to merge 2 commits into
Conversation
…ge changesets - Add diff config in packages/core/src/config/diff.ts with max_files (default: 1000) and max_patch_bytes (default: 100KB) - Create truncateDiffs utility in packages/core/src/util/truncate-diff.ts - Apply truncation in TUI diff viewer (packages/tui/src/feature-plugins/system/diff-viewer.tsx) - Apply truncation in Web review panel (packages/app/src/pages/session/v2/review-panel-v2.tsx) - Display truncation warnings in UI when limits are exceeded Fixes anomalyco#31916 (related to anomalyco#35401, anomalyco#33195, anomalyco#29873) When the Git working tree has 10k+ changed files or very large patches, the diff viewer now truncates the data to prevent freezing. Users can increase limits via config: { "diff": { "max_files": 2000, "max_patch_bytes": 204800 } } Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
- Test file truncation when exceeding max_files limit - Test patch truncation when exceeding max_patch_bytes limit - Test default limits are applied correctly - Test handling of diffs without patches - Test combined file and patch truncation Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Contributor
|
The following comment was made by an LLM, it may be inaccurate: Related PRs FoundI found two potentially related PRs addressing similar issues:
These PRs address the same performance issue (UI freeze with large changesets) that PR #35546 is fixing. You may want to review if there's any overlap in implementation or if these previous attempts should be considered in the current solution. |
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.
Issue for this PR
Closes #31916
Related to #35401, #33195, #29873
Type of change
What does this PR do?
This PR fixes the UI freeze/hang issue when opening the Review/Diff panel with large changesets (10,000+ files or large patches).
Root Cause:
The diff viewer was rendering unbounded diffs, causing the event loop to block when processing large changesets. This manifested as:
Solution:
Added configurable size limits with intelligent truncation:
Core changes (
packages/core):ConfigDiff.Infoschema withmax_files(default: 1000) andmax_patch_bytes(default: 100KB)truncateDiffsutility function with truncation logicTUI changes (
packages/tui):Web App changes (
packages/app):Users can customize limits via config:
{ "diff": { "max_files": 2000, "max_patch_bytes": 204800 } }How did you verify your code works?
Unit tests: Created comprehensive tests for
truncateDiffsfunction covering:Integration testing: Verified with standalone test simulating:
All tests passed successfully.
Screenshots / recordings
N/A - This is a performance/stability fix without visual UI changes (only adds warning text when truncation occurs).
Checklist