Keep the active project when switching workspace hosts (#3051)
* fix(app): preserve projects across host switches New workspace entry context retained only a host-local placement, so switching hosts could replace the selected project with the destination's first project. Hydrate that placement against canonical project identity while keeping exact clone placement separate. * fix(app): preserve manual project choice during hydration Keep the raw route placement key as stable selection context while hydrating the routed project to its canonical identity.
This commit is contained in:
@@ -71,7 +71,7 @@ export function hostProjectFromWorkspace(input: {
|
||||
serverId: input.serverId,
|
||||
projectId,
|
||||
}),
|
||||
projectKey: null,
|
||||
projectKey: input.workspace.project?.projectKey ?? null,
|
||||
projectName: input.workspace.projectDisplayName || projectId,
|
||||
projectKind: input.workspace.projectKind,
|
||||
iconWorkingDir,
|
||||
|
||||
@@ -6,7 +6,9 @@ import {
|
||||
getHostProjectSourceDirectory,
|
||||
getWorktreeSupportForHostProject,
|
||||
hostProjectFromRoute,
|
||||
hostProjectFromWorkspace,
|
||||
} from "./host-project-model";
|
||||
import { normalizeWorkspaceDescriptor } from "@/stores/session-store";
|
||||
|
||||
function project(): HostProjectListItem {
|
||||
return {
|
||||
@@ -95,4 +97,42 @@ describe("host project lookups", () => {
|
||||
hosts: [{ serverId: "host-a", projectId: "prj_a" }],
|
||||
});
|
||||
});
|
||||
|
||||
test("keeps canonical equivalence identity separate from host placement identity", () => {
|
||||
const workspace = normalizeWorkspaceDescriptor({
|
||||
id: "workspace-a",
|
||||
projectId: "project-a",
|
||||
projectDisplayName: "App",
|
||||
projectRootPath: "/repo/app",
|
||||
workspaceDirectory: "/repo/app",
|
||||
projectKind: "git",
|
||||
workspaceKind: "local_checkout",
|
||||
name: "main",
|
||||
archivingAt: null,
|
||||
status: "done",
|
||||
statusEnteredAt: null,
|
||||
activityAt: null,
|
||||
diffStat: null,
|
||||
scripts: [],
|
||||
project: {
|
||||
projectKey: "remote:github.com/acme/app",
|
||||
projectName: "App",
|
||||
checkout: {
|
||||
cwd: "/repo/app",
|
||||
isGit: true,
|
||||
currentBranch: "main",
|
||||
remoteUrl: "https://github.com/acme/app.git",
|
||||
worktreeRoot: "/repo/app",
|
||||
isPaseoOwnedWorktree: false,
|
||||
mainRepoRoot: null,
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
expect(hostProjectFromWorkspace({ serverId: "host-a", workspace })).toMatchObject({
|
||||
viewKey: JSON.stringify(["host-a", "project-a"]),
|
||||
projectKey: "remote:github.com/acme/app",
|
||||
hosts: [{ serverId: "host-a", projectId: "project-a" }],
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user