The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 21, 13:30 UTC
fix(web): diff file tree shows added and deleted files before their patches load (#33310)
Co-authored-by: Julius Marminge <julius0216@outlook.com>
Baptiste Arnaud committed
Nov 14, 2026 at 18:35 UTC
bef412cff61b1b91ff92aecb313ed1776838c786
8 files changed
+287
-44
apps/mobile/src/features/review/useReviewDiffData.ts
+1
-1
@@ -55,7 +55,7 @@ function getCachedReviewFile(
55
...(loaded ?? {
56
path: stat.path,
57
previousPath: stat.previousPath,
58
- changeType: "change" as const,
58
+ changeType: stat.changeType ?? ("change" as const),
59
languageHint: null,
60
additionLines: [],
61
deletionLines: [],
apps/server/src/git/GitManager.test.ts
+9
-3
@@ -4453,9 +4453,15 @@ it.layer(layerGitManagerTest)("GitManager", (it) => {
4453
4454
const preview = yield* driver.getReviewDiffPreview({ cwd: worktreePath });
4455
const changes = preview.sources.find((source) => source.kind === "branch-range")!;
4456
- expect
4457
- .soft(changes.files)
4458
- .toEqual([{ path: "feature.txt", previousPath: null, additions: 1, deletions: 0 }]);
4456
+ expect.soft(changes.files).toEqual([
4457
+ {
4458
+ path: "feature.txt",
4459
+ previousPath: null,
4460
+ changeType: "new",
4461
+ additions: 1,
4462
+ deletions: 0,
4463
+ },
4464
+ ]);
4465
yield* runGit(worktreePath, ["push", "-u", "origin", "feature/remote-base"]);
4466
4467
const generatedInputs: TextGeneration.PrContentGenerationInput[] = [];
apps/server/src/vcs/GitVcsDriverCore.test.ts
+228
-34
@@ -2972,7 +2972,13 @@ it.layer(layerTest)("GitVcsDriver core integration", (it) => {
2972
});
2973
const source = dirty.sources.find((source) => source.kind === "working-tree")!;
2974
assert.deepStrictEqual(source.files, [
2975
- { path: "untracked.txt", previousPath: null, additions: 1, deletions: 0 },
2975
+ {
2976
+ path: "untracked.txt",
2977
+ previousPath: null,
2978
+ changeType: "new",
2979
+ additions: 1,
2980
+ deletions: 0,
2981
+ },
2982
]);
2983
assert.include(source.diff, "+untracked content");
2984
}),
@@ -3078,7 +3084,13 @@ it.layer(layerTest)("GitVcsDriver core integration", (it) => {
3084
assert.isTrue(metadata.sources[0]!.patchesDeferred);
3085
assert.isEmpty(metadata.sources[0]!.diff);
3086
assert.deepStrictEqual(metadata.sources[0]!.files, [
3081
- { path: "README.md", previousPath: null, additions: 1, deletions: 1 },
3087
+ {
3088
+ path: "README.md",
3089
+ previousPath: null,
3090
+ changeType: "change",
3091
+ additions: 1,
3092
+ deletions: 1,
3093
+ },
3094
]);
3095
}),
3096
);
@@ -3177,7 +3189,13 @@ it.layer(layerTest)("GitVcsDriver core integration", (it) => {
3189
});
3190
const scopedSource = scoped.sources.find((source) => source.kind === "working-tree")!;
3191
assert.deepStrictEqual(scopedSource.files, [
3180
- { path: ":(exclude)after.ts", previousPath: null, additions: 1, deletions: 0 },
3192
+ {
3193
+ path: ":(exclude)after.ts",
3194
+ previousPath: null,
3195
+ changeType: "new",
3196
+ additions: 1,
3197
+ deletions: 0,
3198
+ },
3199
]);
3200
assert.include(scopedSource.diff, "+literal pathspec contents");
3201
assert.notInclude(scopedSource.diff, "ordinary.ts");
@@ -3200,7 +3218,13 @@ it.layer(layerTest)("GitVcsDriver core integration", (it) => {
3218
3219
const source = preview.sources.find((candidate) => candidate.kind === "working-tree")!;
3220
assert.deepStrictEqual(source.files, [
3203
- { path: "excluded/new.ts", previousPath: null, additions: 1, deletions: 0 },
3221
+ {
3222
+ path: "excluded/new.ts",
3223
+ previousPath: null,
3224
+ changeType: "new",
3225
+ additions: 1,
3226
+ deletions: 0,
3227
+ },
3228
]);
3229
assert.include(source.diff, "+outside the cone");
3230
}),
@@ -3243,7 +3267,13 @@ it.layer(layerTest)("GitVcsDriver core integration", (it) => {
3267
3268
const source = preview.sources.find((candidate) => candidate.kind === "working-tree")!;
3269
assert.deepStrictEqual(source.files, [
3246
- { path: "after.ts", previousPath: "before.ts", additions: 1, deletions: 1 },
3270
+ {
3271
+ path: "after.ts",
3272
+ previousPath: "before.ts",
3273
+ changeType: "rename-changed",
3274
+ additions: 1,
3275
+ deletions: 1,
3276
+ },
3277
]);
3278
const scoped = yield* driver.getReviewDiffPreview({
3279
cwd,
@@ -3363,7 +3393,15 @@ it.layer(layerTest)("GitVcsDriver core integration", (it) => {
3393
const preview = yield* driver.getReviewDiffPreview({ cwd });
3394
assert.deepStrictEqual(
3395
preview.sources.find((source) => source.kind === "working-tree")!.files,
3366
- [{ path: "untracked.txt", previousPath: null, additions: 1, deletions: 0 }],
3396
+ [
3397
+ {
3398
+ path: "untracked.txt",
3399
+ previousPath: null,
3400
+ changeType: "new",
3401
+ additions: 1,
3402
+ deletions: 0,
3403
+ },
3404
+ ],
3405
);
3406
assert.strictEqual(yield* fs.readFileString(path.join(cwd, ".git/filter-runs")), "");
3407
assert.deepStrictEqual(yield* fs.readFile(indexPath), originalIndex);
@@ -3403,8 +3441,20 @@ it.layer(layerTest)("GitVcsDriver core integration", (it) => {
3441
const preview = yield* driver.getReviewDiffPreview({ cwd });
3442
const dirty = preview.sources.find((source) => source.kind === "working-tree")!;
3443
assert.deepStrictEqual(dirty.files, [
3406
- { path: "tracked.txt", previousPath: null, additions: 1, deletions: 1 },
3407
- { path: "untracked.txt", previousPath: null, additions: 1, deletions: 0 },
3444
+ {
3445
+ path: "tracked.txt",
3446
+ previousPath: null,
3447
+ changeType: "change",
3448
+ additions: 1,
3449
+ deletions: 1,
3450
+ },
3451
+ {
3452
+ path: "untracked.txt",
3453
+ previousPath: null,
3454
+ changeType: "new",
3455
+ additions: 1,
3456
+ deletions: 0,
3457
+ },
3458
]);
3459
assert.include(dirty.diff, "-before");
3460
assert.include(dirty.diff, "+after!");
@@ -3468,14 +3518,44 @@ it.layer(layerTest)("GitVcsDriver core integration", (it) => {
3518
}
3519
3520
assert.deepStrictEqual(branch.files, [
3471
- { path: "a-large.txt", previousPath: null, additions: 4000, deletions: 0 },
3472
- { path: "untracked.txt", previousPath: null, additions: 4000, deletions: 0 },
3473
- { path: "z-last.txt", previousPath: null, additions: 1, deletions: 0 },
3521
+ {
3522
+ path: "a-large.txt",
3523
+ previousPath: null,
3524
+ changeType: "new",
3525
+ additions: 4000,
3526
+ deletions: 0,
3527
+ },
3528
+ {
3529
+ path: "untracked.txt",
3530
+ previousPath: null,
3531
+ changeType: "new",
3532
+ additions: 4000,
3533
+ deletions: 0,
3534
+ },
3535
+ { path: "z-last.txt", previousPath: null, changeType: "new", additions: 1, deletions: 0 },
3536
]);
3537
assert.deepStrictEqual(dirty.files, [
3476
- { path: "a-large.txt", previousPath: null, additions: 4000, deletions: 4000 },
3477
- { path: "untracked.txt", previousPath: null, additions: 4000, deletions: 0 },
3478
- { path: "z-last.txt", previousPath: null, additions: 1, deletions: 1 },
3538
+ {
3539
+ path: "a-large.txt",
3540
+ previousPath: null,
3541
+ changeType: "change",
3542
+ additions: 4000,
3543
+ deletions: 4000,
3544
+ },
3545
+ {
3546
+ path: "untracked.txt",
3547
+ previousPath: null,
3548
+ changeType: "new",
3549
+ additions: 4000,
3550
+ deletions: 0,
3551
+ },
3552
+ {
3553
+ path: "z-last.txt",
3554
+ previousPath: null,
3555
+ changeType: "change",
3556
+ additions: 1,
3557
+ deletions: 1,
3558
+ },
3559
]);
3560
}),
3561
);
@@ -3486,10 +3566,12 @@ it.layer(layerTest)("GitVcsDriver core integration", (it) => {
3566
const { initialBranch } = yield* initRepoWithCommit(cwd);
3567
const driver = yield* GitVcsDriver.GitVcsDriver;
3568
yield* writeTextFile(cwd, "mode-only.sh", "echo unchanged\n");
3489
- yield* git(cwd, ["add", "mode-only.sh"]);
3569
+ yield* writeTextFile(cwd, "removed.txt", "removed\n");
3570
+ yield* git(cwd, ["add", "mode-only.sh", "removed.txt"]);
3571
yield* git(cwd, ["commit", "-m", "add executable candidate"]);
3572
yield* git(cwd, ["checkout", "-b", "feature/paths"]);
3573
yield* git(cwd, ["mv", "README.md", "renamed.md"]);
3574
+ yield* git(cwd, ["rm", "removed.txt"]);
3575
yield* writeTextFile(cwd, "[literal].txt", "literal\n");
3576
yield* writeTextFile(cwd, " leading.txt", "whitespace path\n");
3577
yield* writeTextFile(cwd, "l.txt", "other\n");
@@ -3529,12 +3611,28 @@ it.layer(layerTest)("GitVcsDriver core integration", (it) => {
3611
assert.deepInclude(branch.files ?? [], {
3612
path: "renamed.md",
3613
previousPath: "README.md",
3614
+ changeType: "rename-pure",
3615
+ additions: 0,
3616
+ deletions: 0,
3617
+ });
3618
+ assert.deepInclude(branch.files ?? [], {
3619
+ path: "removed.txt",
3620
+ previousPath: null,
3621
+ changeType: "deleted",
3622
+ additions: 0,
3623
+ deletions: 1,
3624
+ });
3625
+ assert.deepInclude(branch.files ?? [], {
3626
+ path: "mode-only.sh",
3627
+ previousPath: null,
3628
+ changeType: "change",
3629
additions: 0,
3630
deletions: 0,
3631
});
3632
assert.deepInclude(branch.files ?? [], {
3633
path: "binary.dat",
3634
previousPath: null,
3635
+ changeType: "new",
3636
additions: 0,
3637
deletions: 0,
3638
});
@@ -3542,6 +3640,7 @@ it.layer(layerTest)("GitVcsDriver core integration", (it) => {
3640
assert.deepInclude(branch.files ?? [], {
3641
path: "tab\tand\nnewline.txt",
3642
previousPath: null,
3643
+ changeType: "new",
3644
additions: 1,
3645
deletions: 0,
3646
});
@@ -3560,8 +3659,14 @@ it.layer(layerTest)("GitVcsDriver core integration", (it) => {
3659
const preview = yield* driver.getReviewDiffPreview({ cwd });
3660
const dirty = preview.sources.find((source) => source.kind === "working-tree")!;
3661
assert.deepStrictEqual(dirty.files, [
3563
- { path: "staged.txt", previousPath: null, additions: 1, deletions: 0 },
3564
- { path: "untracked.txt", previousPath: null, additions: 1, deletions: 0 },
3662
+ { path: "staged.txt", previousPath: null, changeType: "new", additions: 1, deletions: 0 },
3663
+ {
3664
+ path: "untracked.txt",
3665
+ previousPath: null,
3666
+ changeType: "new",
3667
+ additions: 1,
3668
+ deletions: 0,
3669
+ },
3670
]);
3671
assert.include(dirty.diff, "b/staged.txt");
3672
assert.include(dirty.diff, "b/untracked.txt");
@@ -3832,7 +3937,13 @@ it.layer(layerTest)("GitVcsDriver core integration", (it) => {
3937
const clean = yield* driver.getReviewDiffPreview({ cwd, baseRef: initialBranch });
3938
assert.deepStrictEqual(sourceFiles(clean, "working-tree"), []);
3939
assert.deepStrictEqual(sourceFiles(clean, "branch-range"), [
3835
- { path: "README.md", previousPath: null, additions: 1, deletions: 0 },
3940
+ {
3941
+ path: "README.md",
3942
+ previousPath: null,
3943
+ changeType: "change",
3944
+ additions: 1,
3945
+ deletions: 0,
3946
+ },
3947
]);
3948
3949
yield* writeTextFile(cwd, "README.md", "# test\ncommitted\ndirty\n");
@@ -3840,14 +3951,26 @@ it.layer(layerTest)("GitVcsDriver core integration", (it) => {
3951
const dirty = yield* driver.getReviewDiffPreview({ cwd, baseRef: initialBranch });
3952
const changes = dirty.sources.find((source) => source.kind === "branch-range")!;
3953
assert.deepStrictEqual(changes.files, [
3843
- { path: "README.md", previousPath: null, additions: 2, deletions: 0 },
3844
- { path: "new.txt", previousPath: null, additions: 1, deletions: 0 },
3954
+ {
3955
+ path: "README.md",
3956
+ previousPath: null,
3957
+ changeType: "change",
3958
+ additions: 2,
3959
+ deletions: 0,
3960
+ },
3961
+ { path: "new.txt", previousPath: null, changeType: "new", additions: 1, deletions: 0 },
3962
]);
3963
assert.strictEqual(changes.diff.match(/^diff --git a\/README\.md /gm)?.length, 1);
3964
assert.include(changes.diff, "+dirty");
3965
assert.deepStrictEqual(sourceFiles(dirty, "working-tree"), [
3849
- { path: "README.md", previousPath: null, additions: 1, deletions: 0 },
3850
- { path: "new.txt", previousPath: null, additions: 1, deletions: 0 },
3966
+ {
3967
+ path: "README.md",
3968
+ previousPath: null,
3969
+ changeType: "change",
3970
+ additions: 1,
3971
+ deletions: 0,
3972
+ },
3973
+ { path: "new.txt", previousPath: null, changeType: "new", additions: 1, deletions: 0 },
3974
]);
3975
}),
3976
);
@@ -3876,7 +3999,13 @@ it.layer(layerTest)("GitVcsDriver core integration", (it) => {
3999
const changes = preview.sources.find((source) => source.kind === "branch-range")!;
4000
assert.strictEqual(changes.baseRef, "origin/main");
4001
assert.deepStrictEqual(changes.files, [
3879
- { path: "unpushed.txt", previousPath: null, additions: 1, deletions: 0 },
4002
+ {
4003
+ path: "unpushed.txt",
4004
+ previousPath: null,
4005
+ changeType: "new",
4006
+ additions: 1,
4007
+ deletions: 0,
4008
+ },
4009
]);
4010
}),
4011
);
@@ -3915,7 +4044,13 @@ it.layer(layerTest)("GitVcsDriver core integration", (it) => {
4044
const changes = preview.sources.find((source) => source.kind === "branch-range")!;
4045
assert.strictEqual(changes.baseRef, baseRef);
4046
assert.deepStrictEqual(changes.files, [
3918
- { path: "feature.txt", previousPath: null, additions: 1, deletions: 0 },
4047
+ {
4048
+ path: "feature.txt",
4049
+ previousPath: null,
4050
+ changeType: "new",
4051
+ additions: 1,
4052
+ deletions: 0,
4053
+ },
4054
]);
4055
}
4056
@@ -3949,8 +4084,20 @@ it.layer(layerTest)("GitVcsDriver core integration", (it) => {
4084
const changes = preview.sources.find((source) => source.kind === "branch-range")!;
4085
assert.strictEqual(changes.baseRef, "refs/remotes/upstream/main");
4086
assert.deepStrictEqual(changes.files, [
3952
- { path: "feature.txt", previousPath: null, additions: 1, deletions: 0 },
3953
- { path: "upstream.txt", previousPath: null, additions: 1, deletions: 1 },
4087
+ {
4088
+ path: "feature.txt",
4089
+ previousPath: null,
4090
+ changeType: "new",
4091
+ additions: 1,
4092
+ deletions: 0,
4093
+ },
4094
+ {
4095
+ path: "upstream.txt",
4096
+ previousPath: null,
4097
+ changeType: "change",
4098
+ additions: 1,
4099
+ deletions: 1,
4100
+ },
4101
]);
4102
const contents = yield* driver.getReviewDiffFileContents(
4103
makeReviewDiffFileContentsInput(cwd, {
@@ -4062,7 +4209,13 @@ it.layer(layerTest)("GitVcsDriver core integration", (it) => {
4209
const changes = preview.sources.find((source) => source.kind === "branch-range")!;
4210
assert.strictEqual(changes.baseRef, baseRef);
4211
assert.deepStrictEqual(changes.files, [
4065
- { path: "README.md", previousPath: null, additions: 1, deletions: 0 },
4212
+ {
4213
+ path: "README.md",
4214
+ previousPath: null,
4215
+ changeType: "change",
4216
+ additions: 1,
4217
+ deletions: 0,
4218
+ },
4219
]);
4220
const scoped = yield* driver.getReviewDiffPreview({
4221
cwd,
@@ -4111,7 +4264,15 @@ it.layer(layerTest)("GitVcsDriver core integration", (it) => {
4264
const explicit = yield* driver.getReviewDiffPreview({ cwd, baseRef: initialBranch });
4265
assert.deepStrictEqual(
4266
explicit.sources.find((source) => source.kind === "branch-range")!.files,
4114
- [{ path: "detached.txt", previousPath: null, additions: 1, deletions: 0 }],
4267
+ [
4268
+ {
4269
+ path: "detached.txt",
4270
+ previousPath: null,
4271
+ changeType: "new",
4272
+ additions: 1,
4273
+ deletions: 0,
4274
+ },
4275
+ ],
4276
);
4277
const implicit = yield* driver.getReviewDiffPreview({ cwd });
4278
assert.deepStrictEqual(
@@ -4141,7 +4302,7 @@ it.layer(layerTest)("GitVcsDriver core integration", (it) => {
4302
const changes = preview.sources.find((source) => source.kind === "branch-range")!;
4303
assert.isNull(changes.baseRef);
4304
assert.deepStrictEqual(changes.files, [
4144
- { path: "new.txt", previousPath: null, additions: 2, deletions: 0 },
4305
+ { path: "new.txt", previousPath: null, changeType: "new", additions: 2, deletions: 0 },
4306
]);
4307
const status = yield* driver.statusDetailsLocal(cwd, { includeBranchChanges: true });
4308
assert.deepStrictEqual(status.branchChanges, {
@@ -4172,7 +4333,15 @@ it.layer(layerTest)("GitVcsDriver core integration", (it) => {
4333
const preview = yield* driver.getReviewDiffPreview({ cwd, baseRef: initialBranch });
4334
assert.deepStrictEqual(
4335
preview.sources.find((source) => source.kind === "branch-range")!.files,
4175
- [{ path: "feature.txt", previousPath: null, additions: 1, deletions: 0 }],
4336
+ [
4337
+ {
4338
+ path: "feature.txt",
4339
+ previousPath: null,
4340
+ changeType: "new",
4341
+ additions: 1,
4342
+ deletions: 0,
4343
+ },
4344
+ ],
4345
);
4346
}
4347
}),
@@ -4298,6 +4467,7 @@ it.layer(layerTest)("GitVcsDriver core integration", (it) => {
4467
{
4468
path: "repeated.txt",
4469
previousPath: null,
4470
+ changeType: "change",
4471
additions: Number(additions),
4472
deletions: Number(removals),
4473
},
@@ -4596,8 +4766,20 @@ it.layer(layerTest)("GitVcsDriver core integration", (it) => {
4766
assert.deepStrictEqual(
4767
preview.sources.find((source) => source.kind === "working-tree")?.files,
4768
[
4599
- { path: "asset.data", previousPath: null, additions: 0, deletions: 1 },
4600
- { path: "ordinary.txt", previousPath: null, additions: 1, deletions: 0 },
4769
+ {
4770
+ path: "asset.data",
4771
+ previousPath: null,
4772
+ changeType: "deleted",
4773
+ additions: 0,
4774
+ deletions: 1,
4775
+ },
4776
+ {
4777
+ path: "ordinary.txt",
4778
+ previousPath: null,
4779
+ changeType: "new",
4780
+ additions: 1,
4781
+ deletions: 0,
4782
+ },
4783
],
4784
);
4785
}),
@@ -8012,7 +8194,13 @@ it.layer(layerTest)("GitVcsDriver core integration", (it) => {
8194
const preview = yield* driver.getReviewDiffPreview({ cwd: worktreePath });
8195
const changes = preview.sources.find((source) => source.kind === "branch-range")!;
8196
assert.deepStrictEqual(changes.files, [
8015
- { path: "feature.txt", previousPath: null, additions: 1, deletions: 0 },
8197
+ {
8198
+ path: "feature.txt",
8199
+ previousPath: null,
8200
+ changeType: "new",
8201
+ additions: 1,
8202
+ deletions: 0,
8203
+ },
8204
]);
8205
assert.include(changes.diff, "+feature work");
8206
assert.notInclude(changes.diff, "upstream-only work");
@@ -8517,7 +8705,13 @@ it.layer(layerTest)("GitVcsDriver core integration", (it) => {
8705
const preview = yield* driver.getReviewDiffPreview({ cwd });
8706
const changes = preview.sources.find((source) => source.kind === "branch-range")!;
8707
assert.deepStrictEqual(changes.files, [
8520
- { path: "feature.txt", previousPath: null, additions: 1, deletions: 0 },
8708
+ {
8709
+ path: "feature.txt",
8710
+ previousPath: null,
8711
+ changeType: "new",
8712
+ additions: 1,
8713
+ deletions: 0,
8714
+ },
8715
]);
8716
assert.equal(
8717
changes.baseRef,
apps/server/src/vcs/GitVcsDriverCore.ts
+26
-2
@@ -28,6 +28,7 @@ import {
28
type GitCommandFailureReason,
29
T3_PROJECT_FILE_NAME,
30
type ReviewBranchCommitsInput,
31
+ type ReviewDiffChangeType,
32
type ReviewDiffFileContentsInput,
33
type ReviewDiffPreviewInput,
34
type ReviewDiffFileStat,
@@ -231,18 +232,41 @@ function parseBranchAb(value: string): { ahead: number; behind: number } {
232
};
233
}
234
235
+function rawChangeType(status: string): ReviewDiffChangeType {
236
+ switch (status[0]) {
237
+ case "A":
238
+ return "new";
239
+ case "D":
240
+ return "deleted";
241
+ case "R":
242
+ return status === "R100" ? "rename-pure" : "rename-changed";
243
+ default:
244
+ return "change";
245
+ }
246
+}
247
+
248
+// Parses `--numstat -z`, optionally preceded by `--raw` records that carry each file's change type.
249
function parseReviewNumstat(stdout: string): ReviewDiffFileStat[] {
250
const fields = stdout.split("\0");
251
+ const changeTypes = new Map<string, ReviewDiffChangeType>();
252
const files: ReviewDiffFileStat[] = [];
253
for (let index = 0; index < fields.length; index++) {
254
const field = fields[index]!;
255
+ if (field.startsWith(":")) {
256
+ const status = field.slice(field.lastIndexOf(" ") + 1);
257
+ if (/^[RC]/.test(status)) index++;
258
+ changeTypes.set(fields[++index]!, rawChangeType(status));
259
+ continue;
260
+ }
261
const match = /^(\d+|-)\t(\d+|-)\t([\s\S]*)$/.exec(field);
262
if (!match) continue;
263
const previousPath = match[3] === "" ? fields[++index]! : null;
264
const path = previousPath !== null ? fields[++index]! : match[3]!;
265
+ const changeType = changeTypes.get(path);
266
files.push({
267
path,
268
previousPath,
269
+ ...(changeType === undefined ? {} : { changeType }),
270
additions: match[1] === "-" ? 0 : Number(match[1]),
271
deletions: match[2] === "-" ? 0 : Number(match[2]),
272
});
@@ -3970,7 +3994,7 @@ export const makeGitVcsDriverCore = Effect.fn("makeGitVcsDriverCore")(function*
3994
const stat = yield* executeGit(
3995
"GitVcsDriver.getReviewDiffPreview.commitStat",
3996
cwd,
3973
- [...diffArgs, "--numstat", "-z", commit.parent, commit.sha, "--", ...pathArgs],
3997
+ [...diffArgs, "--raw", "--numstat", "-z", commit.parent, commit.sha, "--", ...pathArgs],
3998
{ maxOutputBytes: REVIEW_METADATA_MAX_OUTPUT_BYTES },
3999
);
4000
const files = parseReviewNumstat(stat.stdout);
@@ -4020,7 +4044,7 @@ export const makeGitVcsDriverCore = Effect.fn("makeGitVcsDriverCore")(function*
4044
ref: string,
4045
env?: NodeJS.ProcessEnv,
4046
) {
4023
- const args = [...diffArgs, "--numstat", "-z"];
4047
+ const args = [...diffArgs, "--raw", "--numstat", "-z"];
4048
const result = yield* executeGit(
4049
"GitVcsDriver.getReviewDiffPreview.stat",
4050
cwd,
apps/web/src/components/DiffPanel.tsx
+1
-1
@@ -654,7 +654,7 @@ export default function DiffPanel({
654
const renderableFileEntries = renderableFiles.map((fileDiff) => {
655
const entry = getCachedFileEntry(fileDiff);
656
if (!isGitSelection) return entry;
657
- // Metadata has no change type; keep each path's identity when its patch arrives.
657
+ // Metadata's change type can be missing or differ from the patch's; key each path's identity by path.
658
const pathKey = JSON.stringify([fileDiff.prevName ?? fileDiff.name, fileDiff.name]);
659
const occurrence = pathOccurrences.get(pathKey) ?? 0;
660
pathOccurrences.set(pathKey, occurrence + 1);
apps/web/src/components/diffs/useReviewFilePatches.browser.test.tsx
+9
-1
@@ -103,9 +103,17 @@ it("retains automatic and explicitly opened files through metadata insertion, re
103
),
104
);
105
await expect.element(screen.getByText("e.txt:loaded")).toBeVisible();
106
+ const complete = source(["a-new.txt", ...tracked.files!.map((f) => f.path)], "complete");
107
await screen.rerender(
107
- view(source(["a-new.txt", ...tracked.files!.map((f) => f.path)], "complete")),
108
+ view({
109
+ ...complete,
110
+ files: complete.files!.map((file) =>
111
+ file.path === "a-new.txt" ? { ...file, changeType: "new" } : file,
112
+ ),
113
+ }),
114
);
115
+ await expect.element(screen.getByText("a-new.txt:pending")).toBeVisible();
116
+ await expect.element(screen.getByText("new", { exact: true })).toBeVisible();
117
await expect.element(screen.getByText("e.txt:loaded")).toBeVisible();
118
await expect.element(screen.getByText("f.txt:loaded")).toBeVisible();
119
await act(() =>
apps/web/src/components/diffs/useReviewFilePatches.ts
+1
-1
@@ -117,7 +117,7 @@ export function useReviewFilePatches({
117
{
118
name: file.path,
119
...(file.previousPath ? { prevName: file.previousPath } : {}),
120
- type: file.previousPath ? "rename-changed" : "change",
120
+ type: file.changeType ?? (file.previousPath ? "rename-changed" : "change"),
121
hunks: [],
122
additionLines: [],
123
deletionLines: [],
packages/contracts/src/review.ts
+12
-1
@@ -46,9 +46,20 @@ export const ReviewDiffPreviewSourceKind = Schema.Literals([
46
]);
47
export type ReviewDiffPreviewSourceKind = typeof ReviewDiffPreviewSourceKind.Type;
48
49
+export const ReviewDiffChangeType = Schema.Literals([
50
+ "change",
51
+ "rename-pure",
52
+ "rename-changed",
53
+ "new",
54
+ "deleted",
55
+]);
56
+export type ReviewDiffChangeType = typeof ReviewDiffChangeType.Type;
57
+
58
export const ReviewDiffFileStat = Schema.Struct({
59
path: Schema.String,
60
previousPath: Schema.NullOr(Schema.String),
61
+ // Older servers omit it.
62
+ changeType: Schema.optionalKey(ReviewDiffChangeType),
63
additions: Schema.Number,
64
deletions: Schema.Number,
65
});
@@ -72,7 +83,7 @@ export type ReviewDiffPreviewSource = typeof ReviewDiffPreviewSource.Type;
83
export const ReviewDiffFileContentsInput = Schema.Struct({
84
cwd: TrimmedNonEmptyString,
85
sourceKind: ReviewDiffPreviewSourceKind,
75
- changeType: Schema.Literals(["change", "rename-pure", "rename-changed", "new", "deleted"]),
86
+ changeType: ReviewDiffChangeType,
87
baseRef: Schema.NullOr(TrimmedNonEmptyString),
88
headRef: Schema.NullOr(TrimmedNonEmptyString),
89
oldPath: TrimmedNonEmptyString,