Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(server): stage only changed checkpoint paths #8301

ClosedPetrSeifert(GitHub profile, opens in a new tab)wants to merge 2 commits intomain fromrefs/pull/8301/headopened View on GitHub

What Changed

  • Discover checkpoint paths with a scoped, NUL-delimited git status using the real index.
  • Stage only those paths into the temporary checkpoint index through --pathspec-from-file.
  • Preserve raw Git pathname bytes from status -z output through pathspec stdin, including non-UTF-8 names.
  • Preserve workspace-subdirectory scope and leave the user's real index unchanged.
  • Fall back to the existing scoped full add only if status output exceeds the preview limit.
  • Add focused unit and Git integration coverage for staged, unstaged, deleted, and untracked paths.

Why

Checkpoint capture currently builds a temporary index with git add -A -- .. On repositories with hundreds of thousands of tracked files, that can exceed the 30-second process timeout even when only a few files changed. The missing checkpoint then prevents Latest turn diffs and summaries from loading.

This change keeps the checkpoint content equivalent while limiting temporary-index staging to the paths Git already reports as changed.

Related to #3646. This PR targets large repositories with a small changed-file set. It does not claim to add failure backoff, temporary-pack cleanup, or handling for a single oversized untracked file.

Testing

  • vp test run apps/server/src/stream/collectUint8StreamText.test.ts apps/server/src/processRunner.test.ts apps/server/src/vcs/VcsProcess.test.ts apps/server/src/vcs/GitVcsDriver.test.ts
  • vp lint --report-unused-disable-directives apps/server/src/vcs/GitVcsDriver.ts apps/server/src/vcs/GitVcsDriver.test.ts
  • vp run --filter t3 typecheck
  • git diff --check upstream/main...HEAD

Checklist

  • This PR is small and focused
  • I explained what changed and why
  • No UI changes

Note

Medium Risk Changes core checkpoint staging and relies on porcelain v1 byte parsing; a format mismatch could miss paths until the slower add -A fallback runs.

Overview Checkpoint capture no longer runs git add -A -- . on the temporary index for every capture. It runs a scoped, NUL-delimited git status --porcelain=v1 -z (with GIT_OPTIONAL_LOCKS=0), parses changed paths from the raw status bytes, and stages only those paths via git add --literal-pathspecs … --pathspec-from-file=- from the repository root. Repositories without HEAD seed the temp index with read-tree --empty. If status output is truncated or raw bytes are missing, behavior falls back to the previous scoped git add -A -- ..

Process I/O gains optional binary-safe plumbing: stdin can be Uint8Array, captureStdoutBytes returns stdoutBytes alongside decoded text (with stdoutInvalidUtf8), wired through VcsProcess, processRunner, and collectUint8StreamText so NUL-delimited git output and pathspec stdin stay lossless.

New unit and integration tests cover raw byte round-trips, exact git commands for checkpoint staging (including invalid-UTF-8 paths), and that scoped checkpoints match the working tree without mutating the real index.

Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 0f8cb9a34be39a9ff1e76e37bf9700d2d32cc80a. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).

Note

Fix captureCheckpoint to stage only changed paths via binary-safe pathspecs

  • Reworks captureCheckpoint in GitVcsDriver.ts to run git status --porcelain=v1 -z with captureStdoutBytes, parse the raw bytes into a NUL-delimited pathspec, and feed it to git add --pathspec-from-file=- --pathspec-file-nul against a temp index — so only changed paths are staged instead of git add -A
  • Adds parseCheckpointStatusPathspec to extract NUL-terminated paths from porcelain status bytes, handling files with spaces or invalid UTF-8
  • Propagates Uint8Array stdin and captureStdoutBytes through VcsProcess and ProcessRunner so raw bytes flow end-to-end without UTF-8 corruption
  • Uses resolveRepositoryRoot to run the pathspec-based git add at the repo root so paths resolve correctly
  • Risk: captureCheckpoint falls back to git add -A -- . in the scoped cwd when status output is truncated or raw bytes are unavailable; reviewers should confirm the fallback in GitVcsDriver.captureCheckpoint preserves prior behavior under large diffs
Macroscope summarized 0f8cb9a.
    1. coderabbitai[bot](GitHub profile, opens in a new tab)commented

      Important

      Review skipped

      Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

      ⚙️ Run configuration

      Configuration used: Repository UI

      Review profile: CHILL

      Plan: Pro Plus

      Run ID: 1a5acaa5-e0f5-4859-b150-fde492bd681d

      You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

      Use the checkbox below for a quick retry:

      • 🔍 Trigger review

      Comment `@coderabbitai help` to get the list of available commands.
    2. Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

      Fix All in Cursor ❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the [Cursor dashboard](https://www.cursor.com/dashboard/bugbot).

      Want fixes drafted automatically? Bugbot Autofix can create code changes for findings. A team admin can enable Autofix in the Cursor dashboard.

      Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 585a2f87312af1dd978602589e329e521f3d3816. Configure [here](https://www.cursor.com/dashboard/bugbot).
    3. macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      Approvability

      Verdict: Not approved

      Macroscope's review found this PR not approvable — This production bug fix changes the checkpoint-capture pipeline for every Git workspace, replacing full staging with autonomous status-based path selection and adding shared binary process plumbing. The behavior is well tested, but the runtime gate and cross-cutting implementation create enough staging and correctness risk to warrant human review.

      You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).
    4. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched

    5. Superseded by #10792. That merge fixed large-repo checkpoint capture by reusing Git index metadata and keeping native add -A staging, rather than parsing changed paths as this PR does. Closing this alternative approach as leftover wash.

    6. juliusmarminge closed this

Sign in to join this conversation.