Compare commits

...
Author SHA1 Message Date
paseo-bot[bot] fe1762ae45 fix(server): preserve the non-Git checkout diff error
The legacy checkout diff adapter treated a missing Git worktree as an unknown error. Preserve the diff engine’s code so callers can distinguish this case.
2026-12-03 21:14:01 +00:00
3 changed files with 30 additions and 2 deletions
@@ -2,7 +2,7 @@ import type pino from "pino";
import type { SubscribeCheckoutDiffRequest, SessionOutboundMessage } from "./messages.js";
import type { WorkspaceGitService } from "./workspace-git-service.js";
import type { WorkspaceRuntimeStore } from "./workspace-runtime-store/index.js";
import { DiffSubscriptions, type CommitFileRead } from "./diff/index.js";
import { DiffReadError, DiffSubscriptions, type CommitFileRead } from "./diff/index.js";
import {
DiffOpcode,
materializeDiffFile,
@@ -169,7 +169,11 @@ export class CheckoutDiffManager {
await subscription.start();
return { initial: await initial, unsubscribe };
} catch (error) {
return { initial: { cwd, files: [], error: toCheckoutError(error) }, unsubscribe() {} };
const checkoutError =
error instanceof DiffReadError && error.code === "NOT_GIT_REPO"
? { code: error.code, message: error.message }
: toCheckoutError(error);
return { initial: { cwd, files: [], error: checkoutError }, unsubscribe() {} };
}
}
scheduleRefreshForCwd(cwd: string): Promise<void> {
@@ -70,6 +70,29 @@ afterEach(async () => {
await ctx.cleanup();
}, 60000);
test("preserves the non-git directory error in legacy checkout diff subscriptions", async () => {
const cwd = tmpCwd();
const subscription = ctx.client.observeCheckoutDiff(cwd, { mode: "uncommitted" });
try {
expect(
await ctx.client.readDiff({
cwd,
base: { kind: "rev", rev: "HEAD" },
head: { kind: "worktree" },
}),
).toMatchObject({ phase: "error", error: { code: "NOT_GIT_REPO" } });
expect(await subscription.ready).toMatchObject({
files: [],
error: { code: "NOT_GIT_REPO" },
});
} finally {
await subscription.release();
rmSync(cwd, { recursive: true, force: true });
}
});
test("pushes file-level checkout diff updates with deterministic path order", async () => {
const cwd = tmpCwd();
+1
View File
@@ -488,6 +488,7 @@ function diffError(error: unknown): DiffError {
};
}
export { DiffReadError } from "./git.js";
export { DiffSession } from "./session.js";
function endpointKey(endpoint: DiffEndpoint): string[] {