Skip to content

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

Open
PetrSeifert wants to merge 2 commits into
pingdotgg:mainfrom
PetrSeifert:fix/checkpoint-changed-files
Open

fix(server): stage only changed checkpoint paths#8301
PetrSeifert wants to merge 2 commits into
pingdotgg:mainfrom
PetrSeifert:fix/checkpoint-changed-files

Conversation

@PetrSeifert

@PetrSeifert PetrSeifert commented Aug 26, 2026

Copy link
Copy Markdown

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 for commit 0f8cb9a. Bugbot is set up for automated code reviews on this repo. Configure here.

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.

@coderabbitai

coderabbitai Bot commented Aug 26, 2026

Copy link
Copy Markdown

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.

Comment thread apps/server/src/vcs/GitVcsDriver.ts Outdated

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

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 for commit 585a2f8. Configure here.

Comment thread apps/server/src/vcs/GitVcsDriver.ts
@macroscopeapp

macroscopeapp Bot commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

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.

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

Labels

size:L 100-499 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant