* fix(projects): restore cross-host grouping Random host-local project IDs replaced the remote-derived value that had also served as grouping identity. Persist a separate opaque group key and let normal boot reconciliation backfill older records without a migration. * fix(projects): keep ambiguous clones separate A shared remote can identify a project across hosts, but it cannot distinguish two independent clones on one host. Treat those keys as ambiguous so host-local project IDs remain separate. * fix(projects): preserve host-local project identity * fix(projects): strengthen grouping identity * test(app): update project host shape contract * fix(projects): preserve selected host identity * fix(projects): close grouped routing gaps * fix(projects): stabilize legacy subproject grouping * fix(projects): preserve selected project identity * fix(projects): isolate legacy host identity * fix(projects): preserve symlinked bootstrap roots * fix(projects): reconcile grouped custom names * fix(projects): stabilize settings and path identity * fix(projects): normalize default remote ports * fix(projects): harden host and remote identity * fix(projects): preserve host-scoped actions * fix(projects): preserve remote path semantics * fix(projects): model SCP remote semantics * fix(projects): keep settings on routed host * fix(projects): preserve SSH URL path semantics * fix(projects): separate identity from presentation * test(projects): use grouped identity in UI specs * fix(projects): harden grouped project routing * test(projects): expect framed settings route * fix(projects): preserve exact placement identity * fix(projects): harden grouping identity and routing * fix(projects): restore project key as grouping identity Random host-local project IDs had replaced the persisted cross-host value carried by projectKey. Keep projectId for routing while reconciliation owns and persists projectKey for grouping. * fix(projects): prevent project key collisions Preserve platform path semantics and generic remote transports in cross-host keys, and compare legacy checkout roots using filesystem equivalence before materializing ownership. * test(projects): assert host-scoped project keys * fix(projects): preserve project key compatibility Resolve legacy workspace project references at the daemon boundary while keeping projectKey as the cross-host identity. Complete generic SSH normalization without collapsing distinct repositories. * fix(projects): harden project reference identity * fix(projects): retain archived reference errors * fix(projects): scope legacy paths to hosts * test(app): model persisted project keys * fix(projects): retain absolute scp users * fix(projects): resolve legacy mutation aliases * fix(projects): preserve conservative identity boundaries * fix(projects): preserve legacy placement identity * test(projects): assert legacy placement identity * test(projects): expect canonical Windows keys * fix(projects): separate bootstrap identity fields * fix(projects): scope legacy paths by host * fix(projects): stabilize opaque project identity * fix(projects): preserve remaining opaque identities * fix(projects): classify forward-slash UNC roots * fix(projects): preserve opaque selection keys * fix(projects): frame host-local project keys * fix(projects): canonicalize framed identities * test(projects): isolate repeated remote fixtures * fix(projects): keep project key as UI identity * fix(projects): reconcile hydrated project references * fix(projects): preserve archived project identity * refactor(projects): group projects from project records, not workspaces Cross-host grouping had been built by hanging a projectKey off every workspace descriptor. That scoped the key to the wrong entity: the app then had to reconstruct project identity per workspace in six modules, which forced projectKey fallbacks into RPC arguments and a server-side resolver that turned grouping keys back into project ids. A workspace has a projectId. The key belongs to the project, and grouping is a display concern, so the daemon now publishes projects over project.list plus the existing project.update channel and the app groups them in one place. Projects are addressed by host-local projectId everywhere, including the settings route. Projects persisted without a key are backfilled by ordinary boot reconciliation, with no migration. Old daemons advertise no projectList capability and simply do not group. * test(projects): seed projects alongside workspaces in fixtures Sidebar fixtures seeded workspaces without their projects, which the daemon cannot produce now that projects arrive on their own channel, so nothing rendered. Adds a seeding helper that supplies both. Also drops the provisioning test for accepting a project key where a project id belongs; that resolver was removed deliberately. * fix(projects): keep derived project identity stable Four gaps left by shrinking the key derivation: Local keys used a bare path resolve, so one directory reached by a different spelling produced a different key and reset grouped identity. Windows CI caught this with the 8.3 and long-name forms of one temp path. Canonicalize through the shared realpath-aware normalization. Subproject display names lost their selected-path input, so every subproject of a monorepo rendered under the same remote-derived name. Reconciliation only ever backfilled a missing key, so a project whose remote changed stayed grouped with hosts on the old remote. Project settings kept a disconnected host selected and rendered a dead end with no way back to an editable host. * fix(projects): read scheme remotes as URLs, not scp form An `ssh://user@host:22/org/repo` remote matched the scp-form pattern first, because `[^@]+` happily eats `ssh://git`, so the port landed in the path and the project keyed as `remote:host/22/org/repo`. Two spellings of one remote therefore never grouped. Try scp form only when there is no scheme, and drop protocol-default ports so an explicitly written `:22` matches the same remote without it.
227 lines
8.2 KiB
TypeScript
227 lines
8.2 KiB
TypeScript
import { test, expect, type Page } from "./fixtures";
|
|
import { gotoAppShell } from "./helpers/app";
|
|
import { gotoWorkspace } from "./helpers/launcher";
|
|
import {
|
|
assertNewWorkspaceSidebarAndHeader,
|
|
connectNewWorkspaceDaemonClient,
|
|
openGlobalNewWorkspaceComposer,
|
|
selectNewWorkspaceProject,
|
|
selectWorkspaceIsolation,
|
|
submitNewWorkspaceEmpty,
|
|
} from "./helpers/new-workspace";
|
|
import { seedWorkspace, type SeededWorkspace } from "./helpers/seed-client";
|
|
import { expectExplorerEntryVisible } from "./helpers/file-explorer";
|
|
import { getServerId } from "./helpers/server-id";
|
|
import { waitForSidebarHydration } from "./helpers/workspace-ui";
|
|
|
|
// Model B reshape: a workspace is the unit, its isolation (local checkout or
|
|
// worktree) is a CHOICE at creation, and creation NEVER dedupes by
|
|
// directory. These specs drive the real creation UI (workspace-create-* test
|
|
// IDs) to prove a single directory can back any number of workspaces.
|
|
|
|
function workspaceRowTestId(workspaceId: string): string {
|
|
return `sidebar-workspace-row-${getServerId()}:${workspaceId}`;
|
|
}
|
|
|
|
// On desktop the file explorer is pinned open; on narrower layouts it must be
|
|
// toggled first. Open it either way, then select the Files tab.
|
|
async function openFilesTab(page: Page): Promise<void> {
|
|
const openButton = page.getByRole("button", { name: "Open explorer" }).first();
|
|
if (await openButton.isVisible().catch(() => false)) {
|
|
await openButton.click();
|
|
}
|
|
await page.getByTestId("explorer-tab-files").click();
|
|
await expect(page.getByTestId("file-explorer-tree-scroll")).toBeVisible({ timeout: 30_000 });
|
|
}
|
|
|
|
async function createWorkspaceViaUi(
|
|
page: Page,
|
|
input: {
|
|
project: { projectKey: string; projectDisplayName: string };
|
|
// null when the project has no git checkout: there is no Isolation control to
|
|
// touch, the isolation is implicitly local.
|
|
isolation: "local" | "worktree" | null;
|
|
previousWorkspaceId: string;
|
|
client: Awaited<ReturnType<typeof connectNewWorkspaceDaemonClient>>;
|
|
},
|
|
): Promise<{ workspaceId: string; workspaceName: string; workspaceDirectory: string }> {
|
|
await openGlobalNewWorkspaceComposer(page);
|
|
await selectNewWorkspaceProject(page, input.project);
|
|
if (input.isolation !== null) {
|
|
await selectWorkspaceIsolation(page, input.isolation);
|
|
}
|
|
await submitNewWorkspaceEmpty(page);
|
|
|
|
return assertNewWorkspaceSidebarAndHeader(page, {
|
|
serverId: getServerId(),
|
|
client: input.client,
|
|
previousWorkspaceId: input.previousWorkspaceId,
|
|
projectDisplayName: input.project.projectDisplayName,
|
|
assertSidebarRow: false,
|
|
assertHeader: false,
|
|
});
|
|
}
|
|
|
|
test.describe("Workspace multiplicity creation flow", () => {
|
|
let client: Awaited<ReturnType<typeof connectNewWorkspaceDaemonClient>>;
|
|
|
|
test.describe.configure({ timeout: 240_000 });
|
|
|
|
test.beforeEach(async () => {
|
|
client = await connectNewWorkspaceDaemonClient();
|
|
});
|
|
|
|
test.afterEach(async () => {
|
|
await client?.close().catch(() => undefined);
|
|
});
|
|
|
|
test("two Local workspaces share one git checkout and both are independently selectable", async ({
|
|
page,
|
|
}) => {
|
|
const seeded: SeededWorkspace = await seedWorkspace({
|
|
repoPrefix: "multiplicity-local-git-",
|
|
});
|
|
|
|
try {
|
|
const project = {
|
|
projectKey: seeded.projectKey,
|
|
projectDisplayName: seeded.projectDisplayName,
|
|
};
|
|
|
|
await gotoAppShell(page);
|
|
await waitForSidebarHydration(page);
|
|
await expect(page.getByTestId(workspaceRowTestId(seeded.workspaceId))).toBeVisible({
|
|
timeout: 30_000,
|
|
});
|
|
|
|
const second = await createWorkspaceViaUi(page, {
|
|
project,
|
|
isolation: "local",
|
|
previousWorkspaceId: seeded.workspaceId,
|
|
client,
|
|
});
|
|
|
|
// A second workspace was minted on the SAME checkout — creation did not
|
|
// dedupe the directory away.
|
|
expect(second.workspaceId).not.toBe(seeded.workspaceId);
|
|
expect(second.workspaceDirectory).toBe(seeded.workspaceDirectory);
|
|
|
|
// Both rows live under the same project and are distinct.
|
|
const firstRow = page.getByTestId(workspaceRowTestId(seeded.workspaceId));
|
|
const secondRow = page.getByTestId(workspaceRowTestId(second.workspaceId));
|
|
await expect(firstRow).toBeVisible({ timeout: 30_000 });
|
|
await expect(secondRow).toBeVisible({ timeout: 30_000 });
|
|
await expect(secondRow).toContainText(second.workspaceName);
|
|
|
|
// Selecting the second workspace shows the shared checkout's files.
|
|
await gotoWorkspace(page, second.workspaceId);
|
|
await openFilesTab(page);
|
|
await expectExplorerEntryVisible(page, "README.md");
|
|
|
|
// Selecting the first workspace shows the SAME shared directory data.
|
|
await gotoWorkspace(page, seeded.workspaceId);
|
|
await openFilesTab(page);
|
|
await expectExplorerEntryVisible(page, "README.md");
|
|
} finally {
|
|
await seeded.cleanup();
|
|
}
|
|
});
|
|
|
|
test("New worktree isolation creates a worktree-backed workspace in a distinct directory", async ({
|
|
page,
|
|
}) => {
|
|
const seeded: SeededWorkspace = await seedWorkspace({
|
|
repoPrefix: "multiplicity-worktree-",
|
|
});
|
|
|
|
try {
|
|
const project = {
|
|
projectKey: seeded.projectKey,
|
|
projectDisplayName: seeded.projectDisplayName,
|
|
};
|
|
|
|
await gotoAppShell(page);
|
|
await waitForSidebarHydration(page);
|
|
await expect(page.getByTestId(workspaceRowTestId(seeded.workspaceId))).toBeVisible({
|
|
timeout: 30_000,
|
|
});
|
|
|
|
const worktree = await createWorkspaceViaUi(page, {
|
|
project,
|
|
isolation: "worktree",
|
|
previousWorkspaceId: seeded.workspaceId,
|
|
client,
|
|
});
|
|
|
|
// The worktree row appears, pointing at a directory distinct from the
|
|
// local checkout.
|
|
const worktreeRow = page.getByTestId(workspaceRowTestId(worktree.workspaceId));
|
|
await expect(worktreeRow).toBeVisible({ timeout: 30_000 });
|
|
expect(worktree.workspaceId).not.toBe(seeded.workspaceId);
|
|
expect(worktree.workspaceDirectory).not.toBe(seeded.workspaceDirectory);
|
|
|
|
// The daemon descriptor confirms the worktree kind (○ row).
|
|
const descriptor = (await client.fetchWorkspaces()).entries.find(
|
|
(entry) => entry.id === worktree.workspaceId,
|
|
);
|
|
expect(descriptor?.workspaceKind).toBe("worktree");
|
|
|
|
await client
|
|
.archivePaseoWorktree({ worktreePath: worktree.workspaceDirectory })
|
|
.catch(() => undefined);
|
|
} finally {
|
|
await seeded.cleanup();
|
|
}
|
|
});
|
|
|
|
test("two Local workspaces appear under the same non-git project", async ({ page }) => {
|
|
const seeded: SeededWorkspace = await seedWorkspace({
|
|
repoPrefix: "multiplicity-local-nongit-",
|
|
git: false,
|
|
});
|
|
|
|
try {
|
|
const project = {
|
|
projectKey: seeded.projectKey,
|
|
projectDisplayName: seeded.projectDisplayName,
|
|
};
|
|
|
|
await gotoAppShell(page);
|
|
await waitForSidebarHydration(page);
|
|
// Model B: a non-git project is an expandable parent like any other, with
|
|
// its single workspace already rendered as its own row underneath.
|
|
await expect(page.getByTestId(`sidebar-project-row-${seeded.projectKey}`)).toBeVisible({
|
|
timeout: 30_000,
|
|
});
|
|
await expect(page.getByTestId(workspaceRowTestId(seeded.workspaceId))).toBeVisible({
|
|
timeout: 30_000,
|
|
});
|
|
|
|
const second = await createWorkspaceViaUi(page, {
|
|
project,
|
|
// Non-git project: no Isolation control, isolation is implicitly local.
|
|
isolation: null,
|
|
previousWorkspaceId: seeded.workspaceId,
|
|
client,
|
|
});
|
|
|
|
expect(second.workspaceId).not.toBe(seeded.workspaceId);
|
|
expect(second.workspaceDirectory).toBe(seeded.workspaceDirectory);
|
|
|
|
// Both the original and the new workspace render as distinct rows under
|
|
// the same expandable parent.
|
|
await expect(page.getByTestId(`sidebar-project-row-${seeded.projectKey}`)).toBeVisible({
|
|
timeout: 30_000,
|
|
});
|
|
await expect(page.getByTestId(workspaceRowTestId(seeded.workspaceId))).toBeVisible({
|
|
timeout: 30_000,
|
|
});
|
|
const secondRow = page.getByTestId(workspaceRowTestId(second.workspaceId));
|
|
await expect(secondRow).toBeVisible({ timeout: 30_000 });
|
|
await expect(secondRow).toContainText(second.workspaceName);
|
|
} finally {
|
|
await seeded.cleanup();
|
|
}
|
|
});
|
|
});
|