Fix duplicate project worktree registration (#1024)

* Fix duplicate project worktree registration

* Update archive redirect test for project-aware routes
This commit is contained in:
Mohamed Boudra
2026-05-14 20:57:32 +08:00
committed by GitHub
parent 7e255a5249
commit fbeda4510e
16 changed files with 415 additions and 43 deletions
+4 -1
View File
@@ -358,7 +358,7 @@ export function buildHostOpenProjectRoute(serverId: string) {
export function buildHostNewWorkspaceRoute(
serverId: string,
sourceDirectory: string,
options?: { displayName?: string },
options?: { displayName?: string; projectId?: string },
) {
const base = buildHostRootRoute(serverId);
if (base === "/") {
@@ -369,6 +369,9 @@ export function buildHostNewWorkspaceRoute(
if (options?.displayName) {
params.set("name", options.displayName);
}
if (options?.projectId) {
params.set("projectId", options.projectId);
}
return `${base}/new?${params.toString()}` as const;
}
@@ -47,7 +47,7 @@ describe("buildWorkspaceArchiveRedirectRoute", () => {
archivedWorkspaceId: "/repo/.paseo/worktrees/feature",
workspaces,
}),
).toBe("/h/server-1/new?dir=%2Frepo&name=Project");
).toBe("/h/server-1/new?dir=%2Frepo&name=Project&projectId=project-1");
});
it("redirects to the new workspace route when no sibling workspace target exists", () => {
@@ -65,7 +65,7 @@ describe("buildWorkspaceArchiveRedirectRoute", () => {
archivedWorkspaceId: "/repo/.paseo/worktrees/feature",
workspaces,
}),
).toBe("/h/server-1/new?dir=%2Frepo&name=Project");
).toBe("/h/server-1/new?dir=%2Frepo&name=Project&projectId=project-1");
});
it("redirects to the new workspace route instead of another workspace", () => {
@@ -85,7 +85,7 @@ describe("buildWorkspaceArchiveRedirectRoute", () => {
archivedWorkspaceId: "/notes",
workspaces,
}),
).toBe("/h/server-1/new?dir=%2Fnotes&name=Project");
).toBe("/h/server-1/new?dir=%2Fnotes&name=Project&projectId=notes");
});
});
@@ -132,6 +132,8 @@ describe("redirectIfArchivingActiveWorkspace", () => {
}),
).toBe(true);
expect(replaceMock).toHaveBeenCalledWith("/h/server-1/new?dir=%2Frepo&name=Project");
expect(replaceMock).toHaveBeenCalledWith(
"/h/server-1/new?dir=%2Frepo&name=Project&projectId=project-1",
);
});
});
@@ -24,5 +24,6 @@ export function buildWorkspaceArchiveRedirectRoute(input: {
return buildHostNewWorkspaceRoute(input.serverId, sourceDirectory, {
displayName: archivedWorkspace.projectDisplayName,
projectId: archivedWorkspace.projectId,
});
}