perf(server): merge separate staged/unstaged numstat calls into single diff HEAD --numstat - #4843
Conversation
… diff HEAD --numstat
|
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 |
There was a problem hiding this comment.
Effect service conventions review: one finding — a backend behavior change in GitVcsDriverCore.statusDetails lands without focused test coverage.
Posted via Macroscope — Effect Service Conventions
| const [numstatStdout, defaultRefResult, hasPrimaryRemote] = yield* Effect.all( | ||
| [ | ||
| runGitStdout("GitVcsDriver.statusDetails.numstat", cwd, ["diff", "HEAD", "--numstat"]), |
There was a problem hiding this comment.
This changes statusDetails backend behavior (staged+unstaged line counts are now a single diff HEAD instead of summed diff + diff --cached), so it should come with focused tests in GitVcsDriverCore.test.ts rather than none. Two cases worth covering:
- a file that is staged and then modified again in the working tree, asserting the counts are no longer double-counted;
- a repository with no commits yet (unborn
HEAD):git diff HEAD --numstatexits non-zero there, and becauserunGitStdoutis called withoutallowNonZeroExit,statusDetailswould now fail where the previousdiff/diff --cachedpair succeeded. If that case is reachable, handle it (e.g.allowNonZeroExitplus an empty-stat fallback, or diff against the empty tree) and pin it with a test.
Posted via Macroscope — Effect Service Conventions
ApprovabilityVerdict: Approved 2b56da6 Performance optimization that merges two git diff calls into one, with appropriate fallback handling for edge cases (unborn HEAD) and new test coverage addressing both scenarios raised in review feedback. You can customize Macroscope's approvability policy. Learn more. |
There was a problem hiding this comment.
Follow-up on the numstat consolidation: the new unborn-HEAD fallback now hides genuine git diff failures, and the changed counting behavior is still untested.
Posted via Macroscope — Effect Service Conventions
…e diff HEAD --numstat
b3650f8 to
41277f6
Compare
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.
Reviewed by Cursor Bugbot for commit 66de31a. Configure here.
…e unborn HEAD detection
Dismissing prior approval to re-evaluate 812b47c
There was a problem hiding this comment.
One residual finding on the new unborn-HEAD fallback in readStatusDetailsLocal. The classification via isUnbornHeadStderr addresses the earlier concern; the remaining issue is the suppressed failure channel in the fallback commands.
Posted via Macroscope — Effect Service Conventions
Both git diff --numstat and git diff --cached --numstat exit 0 on an unborn HEAD (empty output), so the allowNonZeroExit relaxation is unnecessary. Dropping it lets genuine failures propagate as typed GitCommandError instead of silently reporting zero changes.
…e diff HEAD --numstat (pingdotgg#4843)
## What's Changed * fix(server): detect repositories after initialization by @StiensWout in pingdotgg/t3code#4848 * perf(server): merge separate staged/unstaged numstat calls into single diff HEAD --numstat by @UtkarshUsername in pingdotgg/t3code#4843 * fix(git): disable external diff for review diff previews by @ohbentos in pingdotgg/t3code#4854 * Fix editable file focus and live syntax highlighting by @jakeleventhal in pingdotgg/t3code#3979 * fix(web): remember the rendered-markdown choice across threads by @Sy-D in pingdotgg/t3code#4853 ## New Contributors * @ohbentos made their first contribution in pingdotgg/t3code#4854 * @Sy-D made their first contribution in pingdotgg/t3code#4853 **Full Changelog**: pingdotgg/t3code@v0.0.31-nightly.20260729.946...v0.0.31-nightly.20260729.948 Upstream release: https://github.com/pingdotgg/t3code/releases/tag/v0.0.31-nightly.20260729.948
## What's Changed * Fix Connect sign-in settings label by @juliusmarminge in pingdotgg/t3code#4806 * fix(desktop): restore T3 Connect sign-in by @PixPMusic in pingdotgg/t3code#4809 * Simplify files panel header by @juliusmarminge in pingdotgg/t3code#4828 * build(desktop): reduce installed app size by ~300MB by @wukko in pingdotgg/t3code#4824 * Update model version from claude-opus-4-8 to claude-opus-5 by @juliusmarminge in pingdotgg/t3code#4832 * Preserve the thread shell while detail loads by @juliusmarminge in pingdotgg/t3code#4830 * Reduce idle work and disk churn with native resource diagnostics by @juliusmarminge in pingdotgg/t3code#2679 * fix(server): detect repositories after initialization by @StiensWout in pingdotgg/t3code#4848 * perf(server): merge separate staged/unstaged numstat calls into single diff HEAD --numstat by @UtkarshUsername in pingdotgg/t3code#4843 * fix(git): disable external diff for review diff previews by @ohbentos in pingdotgg/t3code#4854 * Fix editable file focus and live syntax highlighting by @jakeleventhal in pingdotgg/t3code#3979 * fix(web): remember the rendered-markdown choice across threads by @Sy-D in pingdotgg/t3code#4853 ## New Contributors * @wukko made their first contribution in pingdotgg/t3code#4824 * @ohbentos made their first contribution in pingdotgg/t3code#4854 * @Sy-D made their first contribution in pingdotgg/t3code#4853 **Full Changelog**: pingdotgg/t3code@v0.0.30...v0.0.31 ## What's Changed * Fix Connect sign-in settings label by @juliusmarminge in pingdotgg/t3code#4806 * fix(desktop): restore T3 Connect sign-in by @PixPMusic in pingdotgg/t3code#4809 * Simplify files panel header by @juliusmarminge in pingdotgg/t3code#4828 * build(desktop): reduce installed app size by ~300MB by @wukko in pingdotgg/t3code#4824 * Update model version from claude-opus-4-8 to claude-opus-5 by @juliusmarminge in pingdotgg/t3code#4832 * Preserve the thread shell while detail loads by @juliusmarminge in pingdotgg/t3code#4830 * Reduce idle work and disk churn with native resource diagnostics by @juliusmarminge in pingdotgg/t3code#2679 * fix(server): detect repositories after initialization by @StiensWout in pingdotgg/t3code#4848 * perf(server): merge separate staged/unstaged numstat calls into single diff HEAD --numstat by @UtkarshUsername in pingdotgg/t3code#4843 * fix(git): disable external diff for review diff previews by @ohbentos in pingdotgg/t3code#4854 * Fix editable file focus and live syntax highlighting by @jakeleventhal in pingdotgg/t3code#3979 * fix(web): remember the rendered-markdown choice across threads by @Sy-D in pingdotgg/t3code#4853 ## New Contributors * @wukko made their first contribution in pingdotgg/t3code#4824 * @ohbentos made their first contribution in pingdotgg/t3code#4854 * @Sy-D made their first contribution in pingdotgg/t3code#4853 **Full Changelog**: pingdotgg/t3code@v0.0.30...v0.0.31 Upstream release: https://github.com/pingdotgg/t3code/releases/tag/v0.0.31

What Changed
Merged two separate
git diff --numstatandgit diff --cached --numstatcalls into a singlegit diff HEAD --numstatcall. Also simplified the parsing loop from merging staged+unstaged entries into a single flat iteration.Why
The separate staged/unstaged breakdown was never used individually. Both were immediately summed together per file path into a combined total.
git diff HEAD --numstatproduces the same combined total directly, eliminating one git subprocess per status refresh.Benchmark (20 runs each):
Checklist
Note
Medium Risk
Behavior change to how line stats are computed for
statusDetails(net vs HEAD, not summed staged+unstaged); low blast radius but UI/commit flows that show those numbers may differ for mixed-index files.Overview
readStatusDetailsLocalinGitVcsDriverCorenow loads working-tree line stats with a singlegit diff HEAD --numstatinstead of parallelgit diff --numstatandgit diff --cached --numstat, cutting one Git subprocess per status refresh.Per-file insertions/deletions are taken directly from that output (net vs HEAD), which fixes double-counting when the same path has both staged and unstaged edits; parsing no longer merges two numstat maps by summing.
When
git diff HEADfails on a repo with no commits (unborn HEAD), the driver detects that stderr viaisUnbornHeadStderrand falls back to the previous two-diff merge; other numstat failures surface asGitCommandError.Integration tests cover combined staged/unstaged edits on one file and staged counts on unborn HEAD.
Reviewed by Cursor Bugbot for commit 2b56da6. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Merge separate staged/unstaged
git diff --numstatcalls into a singlegit diff HEAD --numstatinstatusDetailsgit diff --numstat(unstaged) andgit diff --cached --numstat(staged) calls with a singlegit diff HEAD --numstat, so per-file insertion/deletion counts reflect combined staged and unstaged changes relative to HEAD.git diff HEAD --numstatexits non-zero with an unborn-HEAD stderr, bothgit diff --numstatandgit diff --cached --numstatare run and their results merged per file.GitCommandErrorinstead of being silently ignored.Macroscope summarized 2b56da6.