Skip to content

fix(server): report line counts for untracked files - #7289

Open
RakshithBhat03 wants to merge 8 commits into
pingdotgg:mainfrom
RakshithBhat03:fix/untracked-line-counts
Open

RakshithBhat03 wants to merge 8 commits into
pingdotgg:mainfrom
RakshithBhat03:fix/untracked-line-counts

Conversation

@RakshithBhat03

@RakshithBhat03 RakshithBhat03 commented Aug 17, 2026 •

Copy link
Copy Markdown
Contributor

Untracked files appear in the Commit sheet with +0 / -0, so the per-file rows and totals undercount work that is waiting to be committed.

Create a new directory and add a file, or add a new file inside an existing directory: the Commit sheet shows zero counts. The issue is untracked files generally, not directory creation.

git status --porcelain=2 can collapse nested untracked paths, and git diff --numstat excludes untracked content. statusDetails now lists non-ignored untracked paths with git ls-files --others, adds them with git add -N to a scoped temporary index via GIT_INDEX_FILE, and runs git diff --numstat against it. Those counts are merged with tracked counts without touching the real index or changing the existing statusDetails contract.

The probe is bounded and best-effort: at most 1,000 files, 128 KiB of path/diff output, 1 MiB of total file size, and two seconds. If enumeration, filesystem inspection, temporary-index setup, or Git diffing fails—including for nested repositories or required clean filters—status preserves the original zero-count entries and tracked counts instead of failing or showing partial totals. Ignored files remain excluded, binaries keep their existing numstat behavior, and tracked and untracked work starts in parallel.

Verification

  • vp test run apps/server/src/vcs/GitVcsDriverCore.test.ts — 54 passed, including the nested-directory count and fallback cases.
  • git diff --check — passed.
  • Server typecheck and formatting checks — passed; remaining diagnostics are pre-existing and outside this change.
  • Drove the Commit sheet end to end on an iOS Simulator and an Android Emulator against a disposable backend. The fixture had src/app.ts at +75 / -20, README.md at +30 / -0, and an untracked new/ directory containing a 100-line file and a 42-line file.

Not run in the web or desktop clients. They consume the same statusDetails contract, but only mobile was exercised end to end.

Screenshots

Commit sheet, same fixture in both columns.

Before After
iOS — 3 selected · +105 / -20, new/ at +0 / -0
iOS before
iOS — 4 selected · +247 / -20, new/nested.txt at +100, new/second.txt at +42
iOS after
Android — 3 selected · +105 / -20, new/ at +0 / -0
Android before
Android — 4 selected · +247 / -20, same per-file split
Android after

The expanded Android captures show the full file list with src/app.ts unchanged at +75 / -20 in both states.

Android expanded before Android expanded after
Android expanded before Android expanded after

Built by GPT-5.6 Sol in T3 Code through the Codex harness.


Note

Medium Risk
Changes core statusDetails aggregation and runs extra Git commands with a temporary index; behavior is bounded and best-effort with fallbacks, but clients now see different working-tree totals when limits are met.

Overview
statusDetails now includes insertion/deletion line counts for untracked files when the probe succeeds, so Commit-sheet totals and per-file rows no longer show +0 / -0 for new paths that only appear as untracked.

The driver adds readUntrackedNumstat: enumerate non-ignored untracked paths (git ls-files --others), intent-to-add them on a scoped temporary index (GIT_INDEX_FILE + git add -N), then run git diff --numstat and merge that output with the existing tracked diff HEAD --numstat. The untracked pass runs in parallel with tracked numstat (forked fiber, 2s timeout). Limits are ≤1000 files, ≤1 MiB total size, and capped stdout; on timeout, truncation, nested repos, broken filters, or huge file sets it falls back to the prior behavior (zero counts or directory-level entries) without failing status or mutating the real index.

Integration tests cover nested new files, nested empty repos, undiffable untracked files, oversized single files, and >1000-file sets.

Reviewed by Cursor Bugbot for commit 0b76f68. Bugbot is set up for automated code reviews on this repo. Configure here.

Note

Report line counts for untracked files in statusDetails

  • Adds readUntrackedNumstat in GitVcsDriverCore.ts which builds a temporary git index, adds untracked files via intent-to-add, then runs git diff --numstat to get insertion/deletion counts.
  • Untracked numstat runs concurrently with the tracked diff, subject to limits: ≤1000 files, total size ≤1 MiB, stdout ≤128 KiB, and a 2s timeout. Any failure or exceeded limit falls back to an incomplete sentinel.
  • When the untracked numstat completes, zero-count fallback entries for those paths are suppressed; when it does not complete, untracked items appear with zero counts (or as directory-level entries).
  • Behavioral Change: workingTree.files, insertions, and deletions in statusDetails now include untracked file line counts when within limits, changing previously zero-only untracked entries.

Macroscope summarized 0b76f68.

Co-authored-by: GPT-5.6 Sol <noreply@openai.com>
@coderabbitai

coderabbitai Bot commented Aug 17, 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: 95c247f5-b613-4145-89ad-39ff70c8a520

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

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added vouch:unvouched PR author is not yet trusted in the VOUCHED list. size:L 100-499 changed lines (additions + deletions). labels Aug 17, 2026
@RakshithBhat03
RakshithBhat03 marked this pull request as ready for review August 17, 2026 05:13
@macroscopeapp

macroscopeapp Bot commented Aug 17, 2026 •

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Needs human review

This PR adds significant new capability for computing line counts on untracked files, introducing ~80 lines of new logic with file system operations, temporary git index creation, and concurrent fiber execution. The runtime behavior change and complexity warrant human review.

No code changes detected at a973695. Prior analysis still applies.

You can customize Macroscope's approvability policy. Learn more.

@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 a973695. Configure here.

Comment thread apps/server/src/vcs/GitVcsDriverCore.ts
@github-actions github-actions Bot added vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. and removed vouch:unvouched PR author is not yet trusted in the VOUCHED list. labels Aug 21, 2026

This branch has not been deployed

No deployments
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:trusted PR author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant