fix(server): report line counts for untracked files - #7289
RakshithBhat03 wants to merge 8 commits into
Conversation
Co-authored-by: GPT-5.6 Sol <noreply@openai.com>
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
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. Comment |
ApprovabilityVerdict: 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 You can customize Macroscope's approvability policy. Learn more. |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.
❌ 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.

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=2can collapse nested untracked paths, andgit diff --numstatexcludes untracked content.statusDetailsnow lists non-ignored untracked paths withgit ls-files --others, adds them withgit add -Nto a scoped temporary index viaGIT_INDEX_FILE, and runsgit diff --numstatagainst it. Those counts are merged with tracked counts without touching the real index or changing the existingstatusDetailscontract.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.src/app.tsat+75 / -20,README.mdat+30 / -0, and an untrackednew/directory containing a 100-line file and a 42-line file.Not run in the web or desktop clients. They consume the same
statusDetailscontract, but only mobile was exercised end to end.Screenshots
Commit sheet, same fixture in both columns.
3 selected · +105 / -20,new/at+0 / -04 selected · +247 / -20,new/nested.txtat+100,new/second.txtat+423 selected · +105 / -20,new/at+0 / -04 selected · +247 / -20, same per-file splitThe expanded Android captures show the full file list with
src/app.tsunchanged at+75 / -20in both states.Built by GPT-5.6 Sol in T3 Code through the Codex harness.
Note
Medium Risk
Changes core
statusDetailsaggregation 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
statusDetailsnow includes insertion/deletion line counts for untracked files when the probe succeeds, so Commit-sheet totals and per-file rows no longer show+0 / -0for 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 rungit diff --numstatand merge that output with the existing trackeddiff 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
statusDetailsreadUntrackedNumstatin GitVcsDriverCore.ts which builds a temporary git index, adds untracked files via intent-to-add, then runsgit diff --numstatto get insertion/deletion counts.workingTree.files,insertions, anddeletionsinstatusDetailsnow include untracked file line counts when within limits, changing previously zero-only untracked entries.Macroscope summarized 0b76f68.