@devries-cameron20 / t3code-1 / commits / 716e1c071c
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

fix(web): Changes row no longer shows +0 while Diff has edits (#28439)

William Sedlacek committed Nov 1, 2026 at 13:52 UTC 716e1c071cd2030203d93f6f3ded7738f32db3a7
3 files changed +87 -9
apps/web/src/components/GitActionsControl.logic.test.ts
+51
@@ -5,6 +5,7 @@ import { assert, describe, it } from "vite-plus/test";
5 import {
6 buildMenuItems,
7 requiresDefaultBranchConfirmation,
8 + resolveChangesTotals,
9 resolveDefaultBranchActionDialogCopy,
10 resolveLiveThreadBranchUpdate,
11 resolveQuickAction,
@@ -247,3 +248,53 @@ describe("resolveAutoFeatureBranchName", () => {
248 assert.equal(ref, "feature/ticket-1-2");
249 });
250 });
251 +
252 +describe("resolveChangesTotals", () => {
253 + it("does not let an empty branchChanges hide a dirty working tree", () => {
254 + assert.deepEqual(
255 + resolveChangesTotals(
256 + status({
257 + hasWorkingTreeChanges: true,
258 + branchChanges: { baseRef: "main", insertions: 0, deletions: 0 },
259 + workingTree: {
260 + files: [{ path: "a.ts", insertions: 5, deletions: 1 }],
261 + insertions: 5,
262 + deletions: 1,
263 + },
264 + }),
265 + ),
266 + { insertions: 5, deletions: 1 },
267 + );
268 + });
269 +
270 + it("keeps non-zero branchChanges over the working tree", () => {
271 + assert.deepEqual(
272 + resolveChangesTotals(
273 + status({
274 + branchChanges: { baseRef: "main", insertions: 20, deletions: 3 },
275 + workingTree: {
276 + files: [{ path: "a.ts", insertions: 1, deletions: 0 }],
277 + insertions: 1,
278 + deletions: 0,
279 + },
280 + }),
281 + ),
282 + { insertions: 20, deletions: 3 },
283 + );
284 + });
285 +
286 + it("falls back to the working tree when branchChanges is omitted", () => {
287 + assert.deepEqual(
288 + resolveChangesTotals(
289 + status({
290 + workingTree: {
291 + files: [{ path: "a.ts", insertions: 2, deletions: 0 }],
292 + insertions: 2,
293 + deletions: 0,
294 + },
295 + }),
296 + ),
297 + { insertions: 2, deletions: 0 },
298 + );
299 + });
300 +});
apps/web/src/components/GitActionsControl.logic.ts
+25
@@ -425,3 +425,28 @@ export function resolveLiveThreadBranchUpdate(input: {
425 branch: input.gitStatus.refName,
426 };
427 }
428 +
429 +export type ChangesLineTotals = {
430 + readonly insertions: number;
431 + readonly deletions: number;
432 +};
433 +
434 +// `branchChanges ?? workingTree` treats `{0,0}` as present, so a zero branch total hid a dirty
435 +// working tree and the Changes row read +0 while Diff still showed the work.
436 +export function resolveChangesTotals(
437 + status: VcsStatusResult | null | undefined,
438 +): ChangesLineTotals | null {
439 + if (!status) return null;
440 + const branch = status.branchChanges;
441 + const tree = status.workingTree;
442 + if (branch && (branch.insertions > 0 || branch.deletions > 0)) {
443 + return { insertions: branch.insertions, deletions: branch.deletions };
444 + }
445 + if (tree.insertions > 0 || tree.deletions > 0) {
446 + return { insertions: tree.insertions, deletions: tree.deletions };
447 + }
448 + if (branch) {
449 + return { insertions: branch.insertions, deletions: branch.deletions };
450 + }
451 + return { insertions: tree.insertions, deletions: tree.deletions };
452 +}
apps/web/src/components/GitActionsControl.tsx
+11 -9
@@ -52,6 +52,7 @@ import {
52 type GitQuickAction,
53 type DefaultBranchConfirmableAction,
54 requiresDefaultBranchConfirmation,
55 + resolveChangesTotals,
56 resolveDefaultBranchActionDialogCopy,
57 resolveFeatureBranchUnavailableReason,
58 resolveGitActionProgressPresentation,
@@ -1048,7 +1049,10 @@ export default function GitActionsControl({
1049 const isRepo = gitStatus?.isRepo ?? true;
1050 const hasPrimaryRemote = gitStatus?.hasPrimaryRemote ?? false;
1051 const gitStatusForActions = gitStatus;
1051 - const changesTotals = gitStatusForActions?.branchChanges ?? gitStatusForActions?.workingTree;
1052 + const changesTotals = resolveChangesTotals(gitStatusForActions) ?? {
1053 + insertions: 0,
1054 + deletions: 0,
1055 + };
1056
1057 const allFiles = gitStatusForActions?.workingTree.files ?? [];
1058 // Changed-file paths are repository-relative, so they must resolve against
@@ -1118,8 +1122,8 @@ export default function GitActionsControl({
1122 gitActionProgress === null &&
1123 !gitStatusError &&
1124 quickAction.disabled &&
1121 - !changesTotals?.insertions &&
1122 - !changesTotals?.deletions;
1125 + !changesTotals.insertions &&
1126 + !changesTotals.deletions;
1127 const pendingDefaultBranchActionCopy = pendingDefaultBranchAction
1128 ? resolveDefaultBranchActionDialogCopy({
1129 action: pendingDefaultBranchAction.action,
@@ -1636,19 +1640,17 @@ export default function GitActionsControl({
1640 <span className="flex items-center gap-1.5 font-mono text-xs tabular-nums">
1641 <span
1642 className={
1639 - changesTotals?.insertions
1640 - ? "text-diff-addition-foreground"
1641 - : "text-muted-foreground"
1643 + changesTotals.insertions ? "text-diff-addition-foreground" : "text-muted-foreground"
1644 }
1645 >
1644 - +{formatDiffCount(changesTotals?.insertions ?? 0)}
1646 + +{formatDiffCount(changesTotals.insertions)}
1647 </span>
1648 <span
1649 className={
1648 - changesTotals?.deletions ? "text-diff-deletion-foreground" : "text-muted-foreground"
1650 + changesTotals.deletions ? "text-diff-deletion-foreground" : "text-muted-foreground"
1651 }
1652 >
1651 - -{formatDiffCount(changesTotals?.deletions ?? 0)}
1653 + -{formatDiffCount(changesTotals.deletions)}
1654 </span>
1655 </span>
1656 </ThreadDetailsControl>