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
@@ -13,6 +13,7 @@ import {
} from "../support/helpers/new-workspace";
import { connectSeedClient, type SeedDaemonClient } from "../support/helpers/seed-client";
import { getServerId } from "../support/helpers/server-id";
import { addConnectedHostsAndReload } from "../support/helpers/hosts";
import { switchWorkspaceViaSidebar } from "../support/helpers/workspace-ui";
import { createTempGitRepo } from "../support/helpers/workspace";
@@ -29,6 +30,7 @@ interface CreatedProject {
interface CrossHostProjectScenario {
contextWorkspaceId: string;
primarySharedWorkspaceId: string;
selectedProjectViewKey: string;
sharedProjectKey: string;
secondaryHost: {
@@ -149,6 +151,7 @@ const test = base.extend<{ crossHostProject: CrossHostProjectScenario }>({
await provide({
contextWorkspaceId: contextProject.workspaceId,
primarySharedWorkspaceId: primarySharedProject.workspaceId,
selectedProjectViewKey: projectPlacementViewKey(
getServerId(),
primarySharedProject.projectId,
@@ -196,4 +199,33 @@ test.describe("New workspace host project preservation", () => {
await expectNewWorkspaceProjectSelected(page, SHARED_PROJECT_NAME);
});
test("keeps the active workspace project selected when switching hosts", async ({
page,
crossHostProject,
}) => {
await openProjectDirectoryWithHosts(page, {
hosts: [crossHostProject.secondaryHost],
primaryLabel: PRIMARY_HOST_LABEL,
});
await switchWorkspaceViaSidebar({
page,
serverId: getServerId(),
workspaceId: crossHostProject.primarySharedWorkspaceId,
});
await openGlobalNewWorkspaceComposer(page);
await expectNewWorkspaceProjectSelected(page, SHARED_PROJECT_NAME);
await selectNewWorkspaceHost(page, SECONDARY_HOST_LABEL);
await expectNewWorkspaceProjectSelected(page, SHARED_PROJECT_NAME);
await addConnectedHostsAndReload(page, [crossHostProject.secondaryHost], {
primaryLabel: PRIMARY_HOST_LABEL,
});
await expectNewWorkspaceProjectSelected(page, SHARED_PROJECT_NAME);
await selectNewWorkspaceHost(page, SECONDARY_HOST_LABEL);
await expectNewWorkspaceProjectSelected(page, SHARED_PROJECT_NAME);
});
});