fix(server): prevent worktree creation from failing when Git output exceeds 1 MB#31461

closed3
main
GitHub fork: fix/worktree-output-truncation
opened11d agobyRRusiruSadathana
View on GitHubTwo-way sync enabledPR last imported 4d ago

Problem

Creating a worktree can fail with Git output exceeded 1000000 bytes and was truncated when checkout warnings or a post-checkout hook produce more than 1 MB of output. T3 aborts the checkout because its diagnostic capture limit is exceeded, even when Git could otherwise finish successfully.

Reproduce with a repository whose post-checkout hook emits over 1 MB to stdout or stderr, then create a worktree through T3.

Change

Enable bounded output truncation for git worktree add using the existing Git execution support. Continue draining both streams and delivering checkout progress after truncation, and determine success from Git's exit status. Retained output remains capped at 1 MB per stream.

The fix is in the shared server Git driver, so existing worktree provisioning and setup continue through their normal paths for every client.

Scope and approval

This qualifies as a small, focused fix for an obvious bug: a diagnostic output quota should not abort a successful worktree checkout. It introduces no setting, contract change, or new workflow. Only the Git driver and its regression tests change.

Verification

  • All three new regression cases failed before the fix and passed afterward. They cover stdout and stderr exceeding the limit, creation with and without progress reporting, continued stream draining and progress after truncation, and a nonzero Git exit status remaining an error.
  • vp test run src/vcs/GitVcsDriverCore.test.ts from apps/server: all 240 tests passed with TMPDIR resolved to its canonical path. The default macOS /var alias caused an unrelated existing long-worktree-name test to compare /var against /private/var; the canonical-path run passed without changing that test.
  • vp run check:changed origin/main with canonical TMPDIR: all checks passed, including formatting, lint, knip, GraphQL validation, typechecking of the three affected packages, and 242 tests across two files. Targeted server typecheck also passed.
  • Real Git runtime verification through GitVcsDriver.createWorktree in a disposable repository with a post-checkout hook emitting 1,300,000 bytes each to stdout and stderr:
text
1Hook emitted 1,300,000 bytes each to stdout and stderr.
2T3 createWorktree succeeded; hook completion marker: done
3Worktree branch: noisy-checkout

Written with GPT-6.1 Sol through the Codex harness in T3 Code.

Checks

22 successful · 16 skipped
All checks passed
c3625c3

Added 1 commit

  • fix(server): prevent worktree creation from failing when Git output exceeds 1 MBb68022b
Synced from GitHub

Approvability

Verdict: Approved at b68022b

Macroscope's review found this PR approvable — Worktree creation can now finish despite oversized Git output while retaining bounded diagnostics and continued progress reporting. Git failures still propagate, and unrelated Git operations are unchanged.

You can add or adjust custom eligibility rules. Learn more.

Synced from GitHub

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Worktree creation now keeps line callbacks active after captured Git output reaches its limit. Regression tests cover progress reporting and success or failure handling when checkout output exceeds that limit.

Changes: Worktree output handling

Layer / File(s)Summary
Worktree execution and regression coverage
apps/server/src/vcs/GitVcsDriverCore.ts, apps/server/src/vcs/GitVcsDriverCore.test.ts
ExecuteGitOptions adds an option to keep line callbacks active after output truncation. executeGit forwards the option, and worktree creation enables it with a truncation marker. Tests cover progress callbacks, output limits, and exit-code handling.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Possibly related issues

  • pingdotgg/t3code#25367 reports git worktree add failing when output exceeds 1 MB. This change addresses that failure path.
  • pingdotgg/t3code#26584 reports oversized output failing in the shared Git output collector. This change applies truncation and continued callback processing to worktree creation.

Possibly related PRs

Suggested labels: bugfix

Suggested reviewers: juliusmarminge, saphid

Merge Risk: External image Minimal · up to c3625

No actionable merge-blocking issue remains for noisy worktree checkout output.

Pre-merge checks: Passed 4

Check nameStatusExplanation
Title checkPassedThe title clearly and concisely describes the primary fix: preventing worktree creation from failing when Git output exceeds 1 MB.
Description checkPassedThe description includes all required sections and provides the problem, reproduction context, implementation details, scope justification, focused verification results, runtime verification, and agen…
Linked Issues checkPassedCheck skipped because no linked issues were found for this pull request.
Out of Scope Changes checkPassedCheck skipped because no linked issues were found for this pull request.
Full details: Description check

Explanation

The description includes all required sections and provides the problem, reproduction context, implementation details, scope justification, focused verification results, runtime verification, and agent disclosure.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
External image Recent review info

External image Run configuration

External image Commits

Reviewing files that changed from the base of the PR and between b68022b383c66368b0e6a2d0238f3817c428f361 and c3625c39d3010fd9737933cb1345f3228b6faa45.

External image Files selected for processing: 2

  • apps/server/src/vcs/GitVcsDriverCore.test.ts
  • apps/server/src/vcs/GitVcsDriverCore.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

Added 2 commits

  • Merge remote-tracking branch 'origin/main' into fix/worktree-output-truncation0170ec9
  • test(server): keep only regression cases for noisy worktree checkoutc3625c3

Evidence

Create a committed disposable repository with a successful post-checkout hook emitting 1,300,000 ASCII characters to stdout. Add it as a project, select New worktree, and send the first message.

Real Chromium web client, 1280×800, light theme; fresh synthetic state on each commit. Repository paths are dynamically redacted. Final stills were captured after two identical screenshots 500 ms apart and sidebar regrouping.

Reproduction scenario. scenarios:prove exited 0: base failed and head passed.

AI-assisted; verified with the tests and tools listed above.

Not shown:

  • Independent stderr overflow was not exercised; this reproduction emits to stdout.
  • Retained-output bounds and progress callbacks after truncation are not exposed by this UI scenario and were not measured.
  • Nonzero Git exit handling was not exercised; the reproduction hook exits successfully.

Thanks for this. Main has the change since #34889.

Compared your complete patch with 080b10c408 and main's output collector: main now implements the same bounded truncation, continued stream draining, progress delivery past the cap, and exit-status handling for worktree creation. Your additional regression cases cover those behaviors, but the patch adds no remaining runtime behavior.

Closing as superseded.