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:
Mohamed Boudra
2026-08-09 00:51:07 +02:00
committed by GitHub
parent ce7b3a90c0
commit 8f38d04919
6 changed files with 175 additions and 5 deletions
@@ -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" }],
});
});
});