TypeScript
fix(server): review keeps tracked changes when untracked files overflow the listing (#29615)
Alex Southwell4461b84a9df3
diff --git a/apps/server/src/vcs/GitVcsDriverCore.test.ts b/apps/server/src/vcs/GitVcsDriverCore.test.tsindex 80d89ca19d4..922d14f2682 100644--- a/apps/server/src/vcs/GitVcsDriverCore.test.ts+++ b/apps/server/src/vcs/GitVcsDriverCore.test.ts@@ -2545,33 +2545,40 @@ it.layer(layerTest)("GitVcsDriver core integration", (it) => {}),);- it.effect("keeps tracked changes visible when untracked discovery fails", () =>- Effect.gen(function* () {- const delegate = yield* ChildProcessSpawner.ChildProcessSpawner;- const failingLsFilesSpawner = ChildProcessSpawner.make((command) => {- if (!ChildProcess.isStandardCommand(command)) {- return Effect.die("expected a standard Git command");- }- return command.args[0] === "ls-files" && command.args[1] === "--others"- ? Effect.succeed(makeNonRepositoryHandle())- : delegate.spawn(command);- });- const driver = yield* makeGitVcsDriverCore().pipe(- Effect.provideService(ChildProcessSpawner.ChildProcessSpawner, failingLsFilesSpawner),- Effect.provide(layerServerConfig),- );- const cwd = yield* makeTmpDir();- yield* initRepoWithCommit(cwd).pipe(- Effect.provideService(GitVcsDriver.GitVcsDriver, driver),- );- yield* writeTextFile(cwd, "README.md", "# tracked change\n");+ it.effect.each(["fails", "exceeds the output limit"] as const)(+ "keeps tracked changes visible when untracked discovery %s",+ (scenario) =>+ Effect.gen(function* () {+ const delegate = yield* ChildProcessSpawner.ChildProcessSpawner;+ const failingLsFilesSpawner = ChildProcessSpawner.make((command) => {+ if (!ChildProcess.isStandardCommand(command)) {+ return Effect.die("expected a standard Git command");+ }+ if (command.args[0] !== "ls-files" || command.args[1] !== "--others") {+ return delegate.spawn(command);+ }+ return Effect.succeed(+ scenario === "fails"+ ? makeNonRepositoryHandle()+ : makeSuccessfulHandle("a".repeat(16 * 1024 * 1024 + 1)),+ );+ });+ const driver = yield* makeGitVcsDriverCore().pipe(+ Effect.provideService(ChildProcessSpawner.ChildProcessSpawner, failingLsFilesSpawner),+ Effect.provide(layerServerConfig),+ );+ const cwd = yield* makeTmpDir();+ yield* initRepoWithCommit(cwd).pipe(+ Effect.provideService(GitVcsDriver.GitVcsDriver, driver),+ );+ yield* writeTextFile(cwd, "README.md", "# tracked change\n");- const preview = yield* driver.getReviewDiffPreview({ cwd, ignoreWhitespace: false });- const diff = preview.sources.find((source) => source.kind === "working-tree")?.diff ?? "";+ const preview = yield* driver.getReviewDiffPreview({ cwd, ignoreWhitespace: false });+ const diff = preview.sources.find((source) => source.kind === "working-tree")?.diff ?? "";- assert.include(diff, "-# test");- assert.include(diff, "+# tracked change");- }),+ assert.include(diff, "-# test");+ assert.include(diff, "+# tracked change");+ }),);it.effect.each([diff --git a/apps/server/src/vcs/GitVcsDriverCore.ts b/apps/server/src/vcs/GitVcsDriverCore.tsindex a1fd6e235cc..7b8d34df8cb 100644--- a/apps/server/src/vcs/GitVcsDriverCore.ts+++ b/apps/server/src/vcs/GitVcsDriverCore.ts@@ -3118,12 +3118,7 @@ export const makeGitVcsDriverCore = Effect.fn("makeGitVcsDriverCore")(function*cwd,["ls-files", "--others", "--exclude-standard", "-z", "--", ...pathArgs],{ maxOutputBytes: REVIEW_METADATA_MAX_OUTPUT_BYTES },- ).pipe(- Effect.catchIf(- (error) => error.outputLength === undefined,- () => Effect.succeed(null),- ),- );+ ).pipe(Effect.orElseSucceed(() => null));if (untracked === null) return null;const paths = splitNullSeparatedGitStdoutPaths(untracked).filter((candidate) => onlyPath === undefined || candidate === onlyPath,