Skip to content

[Bug]: Diff panel truncates any diff over ~117 KB — REVIEW_DIFF_PATCH_MAX_OUTPUT_BYTES is 70x smaller than every sibling budget #7431

Description

@anymaniax

Before submitting

  • I searched existing issues and did not find a duplicate.
  • I included enough detail to reproduce or investigate the problem.

Area

apps/server

Summary

The Diff panel truncates any branch or working-tree diff larger than ~117 KB, showing "This diff was truncated because it exceeded the preview limit. The changes shown are incomplete."

The cap is REVIEW_DIFF_PATCH_MAX_OUTPUT_BYTES = 120_000 (apps/server/src/vcs/GitVcsDriverCore.ts:48), applied to the whole patch at :2196 and :2231. Untracked files get REVIEW_UNTRACKED_DIFF_MAX_OUTPUT_BYTES = 80_000 (:49, used at :2145).

120 KB is far out of line with every other diff budget in the codebase, on the same transport:

Budget Value Where
REVIEW_DIFF_PATCH_MAX_OUTPUT_BYTES 120 KB whole local review diff
REVIEW_DIFF_FILE_MAX_OUTPUT_BYTES 1 MB one file's expansion, GitVcsDriverCore.ts:50
DEFAULT_MAX_OUTPUT_BYTES 1 MB any uncapped git call, :42
CHECKPOINT_DIFF_MAX_OUTPUT_BYTES 10 MB turn / full-thread diffs, GitVcsDriver.ts:324
DIFF_MAX_OUTPUT_BYTES 8 MB remote PR diffs, pullRequest/GitHubPullRequestCli.ts:256

A single expanded file is allowed 8x more than the entire diff it belongs to, and a remote PR diff — which crosses the network before it crosses the WebSocket — is allowed 70x more.

There is no config or env knob for any of these (nothing in apps/server/src/config.ts or apps/server/src/cli/config.ts).

Steps to reproduce

  1. In any git repo, produce a branch diff over ~120 KB of patch text. A lockfile update or a dependency bump alone is usually enough.
  2. Open the Diff panel on that thread, scope "Branch changes" (or "Working tree").
  3. The truncation banner appears and later files are missing from the patch.

Expected behavior

The Diff panel shows the complete diff, or at minimum applies a budget consistent with the rest of the codebase.

Actual behavior

The patch is byte-sliced at 120 KB by collectOutput (GitVcsDriverCore.ts:622-698), with "\n\n[truncated]" appended. Two consequences:

  1. The cut lands mid-line, mid-hunk (:669-673), so the tail of the patch can also fail to parse cleanly.
  2. Truncation is order-dependent, not size-dependent. Because it is one budget for the whole patch, a large early file (a lockfile, a generated bundle) consumes it before git emits later files, so real source changes disappear entirely rather than appearing truncated. PR Support per-file review diff truncation #3945 made this same argument.

Impact

Major degradation or frequent failure

Version or commit

main @ 3b5d476

Additional notes

Some context on the value, since there is no rationale recorded anywhere for it:

  • It was introduced on main by T3 Code Mobile [WIP] #2013 (T3 Code Mobile [WIP], +55,249/−6,840), together with getReviewDiffPreview and the mobile review sheet. The PR body describes the Expo client and the client-runtime move; every comment on it is from a bot, and Macroscope's read is "Needs human review / 7 blocking correctness issues / diff too large".
  • It has not been changed by any merged PR since.
  • The whole ReviewService pipeline was built for the mobile review sheet, which parses and highlights the patch natively on a phone over a possibly-cellular connection. The web and desktop Diff panel consumes the same RPC and inherits that budget.

Two adjacent things worth folding in, if you want them here rather than as separate issues:

  • getReviewDiffPreview always returns both sources (working-tree and branch-range, :2259-2286) while the UI renders only one (DiffPanel.tsx:437-440). Half of every payload is discarded.
  • Checkpoint diffs truncate silently. GitVcsDriver.ts:862-873 passes maxOutputBytes but not appendTruncationMarker, VcsProcess.ts:122-124 hardcodes truncatedMarker: "", and :884 drops stdoutTruncated. ThreadTurnDiff has no truncated field, so an oversized turn diff renders as a silently incomplete patch — the truncated flag that Truncate oversized git diffs instead of failing #1499 introduced never reaches the UI on that path.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions