Skip to content

Commit 6cb6e8d

Browse files
saphidclaude
authored andcommitted
fix(server): review keeps tracked changes when untracked files overflow the listing
Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 60aec28 commit 6cb6e8d

2 files changed

Lines changed: 33 additions & 31 deletions

File tree

‎apps/server/src/vcs/GitVcsDriverCore.test.ts‎

Lines changed: 32 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2308,33 +2308,40 @@ it.layer(layerTest)("GitVcsDriver core integration", (it) => {
23082308
}),
23092309
);
23102310

2311-
it.effect("keeps tracked changes visible when untracked discovery fails", () =>
2312-
Effect.gen(function* () {
2313-
const delegate = yield* ChildProcessSpawner.ChildProcessSpawner;
2314-
const failingLsFilesSpawner = ChildProcessSpawner.make((command) => {
2315-
if (!ChildProcess.isStandardCommand(command)) {
2316-
return Effect.die("expected a standard Git command");
2317-
}
2318-
return command.args[0] === "ls-files" && command.args[1] === "--others"
2319-
? Effect.succeed(makeNonRepositoryHandle())
2320-
: delegate.spawn(command);
2321-
});
2322-
const driver = yield* makeGitVcsDriverCore().pipe(
2323-
Effect.provideService(ChildProcessSpawner.ChildProcessSpawner, failingLsFilesSpawner),
2324-
Effect.provide(layerServerConfig),
2325-
);
2326-
const cwd = yield* makeTmpDir();
2327-
yield* initRepoWithCommit(cwd).pipe(
2328-
Effect.provideService(GitVcsDriver.GitVcsDriver, driver),
2329-
);
2330-
yield* writeTextFile(cwd, "README.md", "# tracked change\n");
2311+
it.effect.each(["fails", "exceeds the output limit"] as const)(
2312+
"keeps tracked changes visible when untracked discovery %s",
2313+
(scenario) =>
2314+
Effect.gen(function* () {
2315+
const delegate = yield* ChildProcessSpawner.ChildProcessSpawner;
2316+
const failingLsFilesSpawner = ChildProcessSpawner.make((command) => {
2317+
if (!ChildProcess.isStandardCommand(command)) {
2318+
return Effect.die("expected a standard Git command");
2319+
}
2320+
if (command.args[0] !== "ls-files" || command.args[1] !== "--others") {
2321+
return delegate.spawn(command);
2322+
}
2323+
return Effect.succeed(
2324+
scenario === "fails"
2325+
? makeNonRepositoryHandle()
2326+
: makeSuccessfulHandle("a".repeat(16 * 1024 * 1024 + 1)),
2327+
);
2328+
});
2329+
const driver = yield* makeGitVcsDriverCore().pipe(
2330+
Effect.provideService(ChildProcessSpawner.ChildProcessSpawner, failingLsFilesSpawner),
2331+
Effect.provide(layerServerConfig),
2332+
);
2333+
const cwd = yield* makeTmpDir();
2334+
yield* initRepoWithCommit(cwd).pipe(
2335+
Effect.provideService(GitVcsDriver.GitVcsDriver, driver),
2336+
);
2337+
yield* writeTextFile(cwd, "README.md", "# tracked change\n");
23312338

2332-
const preview = yield* driver.getReviewDiffPreview({ cwd, ignoreWhitespace: false });
2333-
const diff = preview.sources.find((source) => source.kind === "working-tree")?.diff ?? "";
2339+
const preview = yield* driver.getReviewDiffPreview({ cwd, ignoreWhitespace: false });
2340+
const diff = preview.sources.find((source) => source.kind === "working-tree")?.diff ?? "";
23342341

2335-
assert.include(diff, "-# test");
2336-
assert.include(diff, "+# tracked change");
2337-
}),
2342+
assert.include(diff, "-# test");
2343+
assert.include(diff, "+# tracked change");
2344+
}),
23382345
);
23392346

23402347
it.effect("preserves a staged deletion when the removed path still exists", () =>

‎apps/server/src/vcs/GitVcsDriverCore.ts‎

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3060,12 +3060,7 @@ export const makeGitVcsDriverCore = Effect.fn("makeGitVcsDriverCore")(function*
30603060
cwd,
30613061
["ls-files", "--others", "--exclude-standard", "-z", "--", ...pathArgs],
30623062
{ maxOutputBytes: REVIEW_METADATA_MAX_OUTPUT_BYTES },
3063-
).pipe(
3064-
Effect.catchIf(
3065-
(error) => error.outputLength === undefined,
3066-
() => Effect.succeed(null),
3067-
),
3068-
);
3063+
).pipe(Effect.orElseSucceed(() => null));
30693064
if (untracked === null) return null;
30703065
const paths = splitNullSeparatedGitStdoutPaths(untracked).filter(
30713066
(candidate) => onlyPath === undefined || candidate === onlyPath,

0 commit comments

Comments
 (0)