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
4 changed files with 38 additions and 13 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[] {
+8 -11
View File
@@ -185,7 +185,9 @@ test("filters by search and clears to all plugins", async ({ page }) => {
await submitSearch(page, "graphite");
await expect(page).toHaveURL(/\/plugins\/all\?q=graphite$/);
await expectSearchResultsAfterDirectory(page, "graphite");
await expect(
page.getByRole("heading", { level: 1, name: /^Results for “graphite”/ }),
).toBeVisible();
await expect(page.getByRole("main").getByRole("link", { name: /Graphite/ })).toBeVisible();
await expect(page.getByRole("link", { name: /Dracula/ })).toHaveCount(0);
@@ -215,7 +217,10 @@ test("submits the visible search term when its input event was missed", async ({
await page.keyboard.press("Enter");
await expect(page).toHaveURL(/\/plugins\/all\?q=graphite&window=month$/);
await expectSearchResultsAfterDirectory(page, "graphite");
// The URL changes before the results route finishes loading its data and code.
await expect(
page.getByRole("heading", { level: 1, name: /^Results for “graphite”/ }),
).toBeVisible({ timeout: 10000 });
await expect(page.getByRole("link", { name: "This month" })).toHaveAttribute(
"aria-current",
"true",
@@ -281,7 +286,7 @@ test("searches from the directory on submit, and Back returns to the directory",
await page.keyboard.press("Enter");
await expect(page).toHaveURL(/\/plugins\/all\?q=gra$/);
await expectSearchResultsAfterDirectory(page, "gra");
await expect(page.getByRole("heading", { level: 1, name: /^Results for “gra”/ })).toBeVisible();
expect(await historyLength(page)).toBe(entries + 1);
await page.goBack();
@@ -496,14 +501,6 @@ async function expectDirectorySearch(page: Page, term: string, window: string) {
);
}
// The URL changes as soon as the directory submits, but the results route shows only after
// its registry server call returns. On a loaded CI runner that call has taken over 4 s.
async function expectSearchResultsAfterDirectory(page: Page, term: string) {
await expect(
page.getByRole("heading", { level: 1, name: new RegExp(`^Results for “${term}”`) }),
).toBeVisible({ timeout: 10000 });
}
async function typeSearch(page: Page, term: string) {
await page.getByRole("searchbox", { name: "Search plugins" }).pressSequentially(term);
}