* 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.
970 lines
32 KiB
TypeScript
970 lines
32 KiB
TypeScript
import { existsSync } from "node:fs";
|
|
import path from "node:path";
|
|
import { buildHostWorkspaceRoute } from "@/utils/host-routes";
|
|
import { expect, test } from "./fixtures";
|
|
import { gotoAppShell } from "./helpers/app";
|
|
import {
|
|
archiveWorkspaceFromDaemon,
|
|
archiveLocalWorkspaceFromDaemon,
|
|
assertNewWorkspaceSidebarAndHeader,
|
|
closeBranchPicker,
|
|
connectNewWorkspaceDaemonClient,
|
|
createWorktreeViaDaemon,
|
|
delayBrowserAgentCreatedStatus,
|
|
expectComposerGithubAttachmentPill,
|
|
expectNewWorkspaceProjectSelected,
|
|
expectPickerClosed,
|
|
expectPickerOpen,
|
|
expectPickerSelected,
|
|
expectStartingRefPickerTriggerPr,
|
|
fillNewWorkspaceDraft,
|
|
openGlobalNewWorkspaceComposer,
|
|
openBranchPicker,
|
|
openNewWorkspaceComposer,
|
|
openProjectViaDaemon,
|
|
openStartingRefPicker,
|
|
pasteGithubPrUrl,
|
|
searchAndSelectBranchInPicker,
|
|
selectBranchInPicker,
|
|
selectGitHubPrInPicker,
|
|
selectPickerOptionByKeyboard,
|
|
selectWorkspaceIsolation,
|
|
submitNewWorkspacePrompt,
|
|
} from "./helpers/new-workspace";
|
|
import { createTempGitRepo, readWorktreeBranchInfo } from "./helpers/workspace";
|
|
import {
|
|
createLocalGithubPrFixture,
|
|
cloneGithubRepoDefaultBranchOnly,
|
|
createTempGithubRepo,
|
|
hasGithubAuth,
|
|
type LocalGhPrFixture,
|
|
} from "./helpers/github-fixtures";
|
|
import { getServerId } from "./helpers/server-id";
|
|
import { getE2EDaemonPort } from "./helpers/daemon-port";
|
|
import { chooseAddProjectMethod, expectAddProjectPage } from "./helpers/add-project-flow";
|
|
import { seedSavedSettingsHosts } from "./helpers/settings";
|
|
import {
|
|
expectSidebarWorkspaceSelected,
|
|
expectWorkspaceHeader,
|
|
switchWorkspaceViaSidebar,
|
|
waitForSidebarHydration,
|
|
waitForWorkspaceInSidebar,
|
|
} from "./helpers/workspace-ui";
|
|
|
|
interface WorkspaceStatusGroupEvent {
|
|
rowTestId: string;
|
|
bucket: string;
|
|
indicatorTestId: string | null;
|
|
label: string;
|
|
at: number;
|
|
}
|
|
|
|
async function switchSidebarToStatusGrouping(page: import("@playwright/test").Page) {
|
|
await page.getByTestId("sidebar-display-preferences-menu").click();
|
|
await page.getByTestId("sidebar-grouping-status").click();
|
|
await expect(page.getByTestId("sidebar-status-group-done")).toBeVisible({ timeout: 30_000 });
|
|
}
|
|
|
|
async function startTrackingSidebarStatusGroups(page: import("@playwright/test").Page) {
|
|
await page.evaluate(() => {
|
|
interface StatusGroupEvent {
|
|
rowTestId: string;
|
|
bucket: string;
|
|
indicatorTestId: string | null;
|
|
label: string;
|
|
at: number;
|
|
}
|
|
const win = window as typeof window & {
|
|
__workspaceStatusGroupEvents?: StatusGroupEvent[];
|
|
__workspaceStatusGroupObserver?: MutationObserver;
|
|
};
|
|
win.__workspaceStatusGroupEvents = [];
|
|
win.__workspaceStatusGroupObserver?.disconnect();
|
|
|
|
const capture = () => {
|
|
const events = win.__workspaceStatusGroupEvents;
|
|
if (!events) return;
|
|
const groups = document.querySelectorAll<HTMLElement>(
|
|
'[data-testid^="sidebar-status-group-"]',
|
|
);
|
|
for (const group of groups) {
|
|
const groupTestId = group.getAttribute("data-testid") ?? "";
|
|
const bucket = groupTestId.replace("sidebar-status-group-", "");
|
|
const label = group.textContent ?? "";
|
|
const block = group.parentElement?.parentElement;
|
|
if (!block) continue;
|
|
const rows = block.querySelectorAll<HTMLElement>('[data-testid^="sidebar-workspace-row-"]');
|
|
for (const row of rows) {
|
|
const rowTestId = row.getAttribute("data-testid");
|
|
if (!rowTestId) continue;
|
|
const indicatorTestId =
|
|
row
|
|
.querySelector<HTMLElement>('[data-testid^="workspace-status-indicator-"]')
|
|
?.getAttribute("data-testid") ?? null;
|
|
const last = events.at(-1);
|
|
if (
|
|
last?.rowTestId === rowTestId &&
|
|
last.bucket === bucket &&
|
|
last.indicatorTestId === indicatorTestId
|
|
) {
|
|
continue;
|
|
}
|
|
events.push({ rowTestId, bucket, indicatorTestId, label, at: performance.now() });
|
|
}
|
|
}
|
|
};
|
|
|
|
capture();
|
|
const observer = new MutationObserver(capture);
|
|
observer.observe(document.body, { childList: true, subtree: true, characterData: true });
|
|
win.__workspaceStatusGroupObserver = observer;
|
|
});
|
|
}
|
|
|
|
async function getTrackedSidebarStatusGroups(
|
|
page: import("@playwright/test").Page,
|
|
): Promise<WorkspaceStatusGroupEvent[]> {
|
|
return page.evaluate(() => {
|
|
const win = window as typeof window & {
|
|
__workspaceStatusGroupEvents?: WorkspaceStatusGroupEvent[];
|
|
};
|
|
return win.__workspaceStatusGroupEvents ?? [];
|
|
});
|
|
}
|
|
|
|
async function waitForWorkspaceStatusGroupEvent(input: {
|
|
page: import("@playwright/test").Page;
|
|
rowTestId: string;
|
|
bucket: string;
|
|
}) {
|
|
await input.page.waitForFunction(
|
|
({ expectedRowTestId, expectedBucket }) => {
|
|
const win = window as typeof window & {
|
|
__workspaceStatusGroupEvents?: WorkspaceStatusGroupEvent[];
|
|
};
|
|
for (const event of win.__workspaceStatusGroupEvents ?? []) {
|
|
if (event.rowTestId === expectedRowTestId && event.bucket === expectedBucket) {
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
},
|
|
{ expectedRowTestId: input.rowTestId, expectedBucket: input.bucket },
|
|
{ timeout: 30_000 },
|
|
);
|
|
}
|
|
|
|
async function expectWorkspaceStatusGroupEvents(input: {
|
|
page: import("@playwright/test").Page;
|
|
rowTestId: string;
|
|
includes: string;
|
|
excludes: string;
|
|
includesIndicator?: string;
|
|
excludesIndicator?: string;
|
|
}) {
|
|
await waitForWorkspaceStatusGroupEvent({
|
|
page: input.page,
|
|
rowTestId: input.rowTestId,
|
|
bucket: input.includes,
|
|
});
|
|
const createdWorkspaceEvents = (await getTrackedSidebarStatusGroups(input.page)).filter(
|
|
(event) => event.rowTestId === input.rowTestId,
|
|
);
|
|
expect(createdWorkspaceEvents.map((event) => event.bucket)).toContain(input.includes);
|
|
expect(createdWorkspaceEvents.filter((event) => event.bucket === input.excludes)).toEqual([]);
|
|
if (input.includesIndicator) {
|
|
expect(createdWorkspaceEvents.map((event) => event.indicatorTestId)).toContain(
|
|
input.includesIndicator,
|
|
);
|
|
}
|
|
if (input.excludesIndicator) {
|
|
expect(
|
|
createdWorkspaceEvents.filter((event) => event.indicatorTestId === input.excludesIndicator),
|
|
).toEqual([]);
|
|
}
|
|
}
|
|
|
|
async function submitNewWorkspaceWithoutPrompt(page: import("@playwright/test").Page) {
|
|
const createButton = page
|
|
.getByTestId("message-input-root")
|
|
.getByRole("button", { name: "Create" });
|
|
await expect(createButton).toBeVisible({ timeout: 30_000 });
|
|
await createButton.click();
|
|
}
|
|
|
|
test.describe("New workspace flow", () => {
|
|
let client: Awaited<ReturnType<typeof connectNewWorkspaceDaemonClient>>;
|
|
const localWorkspaceIds = new Set<string>();
|
|
const localProjectIds = new Set<string>();
|
|
const createdWorktreeDirectories = new Set<string>();
|
|
const localGithubFixtures = new Set<LocalGhPrFixture>();
|
|
|
|
test.describe.configure({ timeout: 240_000 });
|
|
|
|
test.beforeEach(async () => {
|
|
client = await connectNewWorkspaceDaemonClient();
|
|
});
|
|
|
|
test.afterEach(async () => {
|
|
if (client) {
|
|
for (const workspaceDirectory of createdWorktreeDirectories) {
|
|
await archiveWorkspaceFromDaemon(client, workspaceDirectory).catch(() => undefined);
|
|
}
|
|
for (const workspaceId of localWorkspaceIds) {
|
|
await archiveLocalWorkspaceFromDaemon(client, workspaceId).catch(() => undefined);
|
|
}
|
|
for (const projectId of localProjectIds) {
|
|
await client.removeProject(projectId).catch(() => undefined);
|
|
}
|
|
}
|
|
createdWorktreeDirectories.clear();
|
|
localWorkspaceIds.clear();
|
|
localProjectIds.clear();
|
|
await client?.close().catch(() => undefined);
|
|
});
|
|
|
|
test.afterAll(async () => {
|
|
for (const fixture of localGithubFixtures) {
|
|
await fixture.cleanup();
|
|
}
|
|
localGithubFixtures.clear();
|
|
});
|
|
|
|
test("adds a project from the selected empty host", async ({ page }) => {
|
|
const repo = await createTempGitRepo("new-workspace-project-picker-");
|
|
const primaryServerId = getServerId();
|
|
const emptyServerId = "empty-new-workspace-host";
|
|
|
|
try {
|
|
const openedProject = await openProjectViaDaemon(client, repo.path);
|
|
localWorkspaceIds.add(openedProject.workspaceId);
|
|
await seedSavedSettingsHosts(page, [
|
|
{
|
|
serverId: primaryServerId,
|
|
label: "Primary host",
|
|
endpoint: `127.0.0.1:${getE2EDaemonPort()}`,
|
|
},
|
|
{
|
|
serverId: emptyServerId,
|
|
label: "Empty host",
|
|
endpoint: "127.0.0.1:9",
|
|
},
|
|
]);
|
|
|
|
await gotoAppShell(page);
|
|
await waitForSidebarHydration(page);
|
|
await openGlobalNewWorkspaceComposer(page);
|
|
|
|
const projectTrigger = page.getByTestId("new-workspace-project-picker-trigger");
|
|
await projectTrigger.click();
|
|
await page.getByPlaceholder("Search projects").fill("no matching project");
|
|
await expect(page.getByTestId("new-workspace-project-picker-add-project")).toBeVisible();
|
|
await page.keyboard.press("Escape");
|
|
|
|
await page.getByTestId("host-picker-trigger").click();
|
|
await page.getByTestId(`new-workspace-host-picker-option-${emptyServerId}`).click();
|
|
await expect(projectTrigger).toContainText("Choose project");
|
|
await projectTrigger.click();
|
|
|
|
const addProject = page.getByTestId("new-workspace-project-picker-add-project");
|
|
await expect(addProject).toContainText("Add project");
|
|
await expect(addProject).toContainText(/(?:⌘|Ctrl\+)O/);
|
|
await addProject.click();
|
|
|
|
await expectAddProjectPage(page, "method");
|
|
await chooseAddProjectMethod(page, "directory-search");
|
|
} finally {
|
|
await repo.cleanup();
|
|
}
|
|
});
|
|
|
|
test("sidebar workspace navigation updates URL and header", async ({ page }) => {
|
|
const serverId = getServerId();
|
|
|
|
const firstRepo = await createTempGitRepo("workspace-nav-a-");
|
|
const secondRepo = await createTempGitRepo("workspace-nav-b-");
|
|
|
|
try {
|
|
const firstWorkspace = await openProjectViaDaemon(client, firstRepo.path);
|
|
const secondWorkspace = await openProjectViaDaemon(client, secondRepo.path);
|
|
localWorkspaceIds.add(firstWorkspace.workspaceId);
|
|
localWorkspaceIds.add(secondWorkspace.workspaceId);
|
|
|
|
await gotoAppShell(page);
|
|
await waitForSidebarHydration(page);
|
|
|
|
await switchWorkspaceViaSidebar({
|
|
page,
|
|
serverId,
|
|
workspaceId: firstWorkspace.workspaceId,
|
|
});
|
|
await expectWorkspaceHeader(page, {
|
|
title: firstWorkspace.workspaceName,
|
|
subtitle: firstWorkspace.projectDisplayName,
|
|
});
|
|
|
|
await switchWorkspaceViaSidebar({
|
|
page,
|
|
serverId,
|
|
workspaceId: secondWorkspace.workspaceId,
|
|
});
|
|
await waitForWorkspaceInSidebar(page, {
|
|
serverId,
|
|
workspaceId: secondWorkspace.workspaceId,
|
|
});
|
|
await expectWorkspaceHeader(page, {
|
|
title: secondWorkspace.workspaceName,
|
|
subtitle: secondWorkspace.projectDisplayName,
|
|
});
|
|
|
|
await switchWorkspaceViaSidebar({
|
|
page,
|
|
serverId,
|
|
workspaceId: firstWorkspace.workspaceId,
|
|
});
|
|
await expectWorkspaceHeader(page, {
|
|
title: firstWorkspace.workspaceName,
|
|
subtitle: firstWorkspace.projectDisplayName,
|
|
});
|
|
} finally {
|
|
await secondRepo.cleanup();
|
|
await firstRepo.cleanup();
|
|
}
|
|
});
|
|
|
|
test("same-project workspaces switch content without requiring refresh", async ({ page }) => {
|
|
const serverId = getServerId();
|
|
|
|
const repo = await createTempGitRepo("workspace-nav-same-project-");
|
|
|
|
try {
|
|
const rootWorkspace = await openProjectViaDaemon(client, repo.path);
|
|
const worktreeWorkspace = await createWorktreeViaDaemon(client, {
|
|
cwd: repo.path,
|
|
slug: `nav-${Date.now()}`,
|
|
});
|
|
localWorkspaceIds.add(rootWorkspace.workspaceId);
|
|
createdWorktreeDirectories.add(worktreeWorkspace.workspaceDirectory);
|
|
|
|
await gotoAppShell(page);
|
|
await waitForSidebarHydration(page);
|
|
|
|
await switchWorkspaceViaSidebar({
|
|
page,
|
|
serverId,
|
|
workspaceId: rootWorkspace.workspaceId,
|
|
});
|
|
await expectWorkspaceHeader(page, {
|
|
title: rootWorkspace.workspaceName,
|
|
subtitle: rootWorkspace.projectDisplayName,
|
|
});
|
|
await expectSidebarWorkspaceSelected({
|
|
page,
|
|
serverId,
|
|
workspaceId: rootWorkspace.workspaceId,
|
|
});
|
|
|
|
await switchWorkspaceViaSidebar({
|
|
page,
|
|
serverId,
|
|
workspaceId: worktreeWorkspace.workspaceId,
|
|
});
|
|
await expectWorkspaceHeader(page, {
|
|
title: worktreeWorkspace.workspaceName,
|
|
subtitle: worktreeWorkspace.projectDisplayName,
|
|
});
|
|
await expectSidebarWorkspaceSelected({
|
|
page,
|
|
serverId,
|
|
workspaceId: worktreeWorkspace.workspaceId,
|
|
});
|
|
await expectSidebarWorkspaceSelected({
|
|
page,
|
|
serverId,
|
|
workspaceId: rootWorkspace.workspaceId,
|
|
selected: false,
|
|
});
|
|
|
|
await switchWorkspaceViaSidebar({
|
|
page,
|
|
serverId,
|
|
workspaceId: rootWorkspace.workspaceId,
|
|
});
|
|
await expectWorkspaceHeader(page, {
|
|
title: rootWorkspace.workspaceName,
|
|
subtitle: rootWorkspace.projectDisplayName,
|
|
});
|
|
await expectSidebarWorkspaceSelected({
|
|
page,
|
|
serverId,
|
|
workspaceId: rootWorkspace.workspaceId,
|
|
});
|
|
await expectSidebarWorkspaceSelected({
|
|
page,
|
|
serverId,
|
|
workspaceId: worktreeWorkspace.workspaceId,
|
|
selected: false,
|
|
});
|
|
} finally {
|
|
await repo.cleanup();
|
|
}
|
|
});
|
|
|
|
test("global new workspace uses the last active project and creates one agent tab", async ({
|
|
page,
|
|
}) => {
|
|
const serverId = getServerId();
|
|
|
|
const tempRepo = await createTempGitRepo("new-workspace-");
|
|
|
|
try {
|
|
const openedProject = await openProjectViaDaemon(client, tempRepo.path);
|
|
localWorkspaceIds.add(openedProject.workspaceId);
|
|
|
|
await gotoAppShell(page);
|
|
await waitForSidebarHydration(page);
|
|
|
|
await switchWorkspaceViaSidebar({
|
|
page,
|
|
serverId,
|
|
workspaceId: openedProject.workspaceId,
|
|
});
|
|
await expectWorkspaceHeader(page, {
|
|
title: openedProject.workspaceName,
|
|
subtitle: openedProject.projectDisplayName,
|
|
});
|
|
|
|
await openGlobalNewWorkspaceComposer(page);
|
|
await expectNewWorkspaceProjectSelected(page, openedProject.projectDisplayName);
|
|
await submitNewWorkspacePrompt(page);
|
|
|
|
const createdWorkspace = await assertNewWorkspaceSidebarAndHeader(page, {
|
|
serverId,
|
|
client,
|
|
previousWorkspaceId: openedProject.workspaceId,
|
|
projectDisplayName: openedProject.projectDisplayName,
|
|
assertSidebarRow: false,
|
|
assertHeader: false,
|
|
});
|
|
createdWorktreeDirectories.add(createdWorkspace.workspaceDirectory);
|
|
|
|
expect(createdWorkspace.workspaceId).not.toBe(openedProject.workspaceId);
|
|
await expect(page).toHaveURL(
|
|
buildHostWorkspaceRoute(serverId, createdWorkspace.workspaceId),
|
|
{
|
|
timeout: 30_000,
|
|
},
|
|
);
|
|
|
|
const createdWorkspaceRow = page.getByTestId(
|
|
`sidebar-workspace-row-${serverId}:${createdWorkspace.workspaceId}`,
|
|
);
|
|
await expect(createdWorkspaceRow).toBeVisible({ timeout: 30_000 });
|
|
|
|
await expectWorkspaceHeader(page, {
|
|
title: createdWorkspace.workspaceName,
|
|
subtitle: openedProject.projectDisplayName,
|
|
});
|
|
|
|
const activeWorkspaceDeckEntry = page
|
|
.getByTestId(`workspace-deck-entry-${serverId}:${createdWorkspace.workspaceId}`)
|
|
.filter({ visible: true });
|
|
await expect(activeWorkspaceDeckEntry).toBeVisible({ timeout: 30_000 });
|
|
|
|
const agentTabs = activeWorkspaceDeckEntry.locator('[data-testid^="workspace-tab-agent_"]');
|
|
await expect(agentTabs).toHaveCount(1, { timeout: 30_000 });
|
|
|
|
// Workspace setup may auto-open a setup tab that steals focus,
|
|
// hiding the agent panel (display:none removes it from the
|
|
// accessibility tree). Click the agent tab to ensure it's active.
|
|
await agentTabs.first().click();
|
|
|
|
const composer = page.getByRole("textbox", { name: "Message agent..." });
|
|
await expect(composer).toBeVisible({ timeout: 30_000 });
|
|
} finally {
|
|
await tempRepo.cleanup();
|
|
}
|
|
});
|
|
|
|
test("redirects to the optimistic draft tab before agent creation resolves", async ({ page }) => {
|
|
const serverId = getServerId();
|
|
|
|
const tempRepo = await createTempGitRepo("new-workspace-optimistic-");
|
|
const agentCreatedDelay = await delayBrowserAgentCreatedStatus(page);
|
|
|
|
try {
|
|
const openedProject = await openProjectViaDaemon(client, tempRepo.path);
|
|
localWorkspaceIds.add(openedProject.workspaceId);
|
|
|
|
await gotoAppShell(page);
|
|
await waitForSidebarHydration(page);
|
|
|
|
await switchWorkspaceViaSidebar({
|
|
page,
|
|
serverId,
|
|
workspaceId: openedProject.workspaceId,
|
|
});
|
|
await expectWorkspaceHeader(page, {
|
|
title: openedProject.workspaceName,
|
|
subtitle: openedProject.projectDisplayName,
|
|
});
|
|
|
|
await openNewWorkspaceComposer(page, {
|
|
projectKey: openedProject.projectKey,
|
|
projectDisplayName: openedProject.projectDisplayName,
|
|
});
|
|
|
|
const composer = page.getByRole("textbox", { name: "Message agent..." });
|
|
await expect(composer).toBeVisible({ timeout: 30_000 });
|
|
await composer.fill("Hello from e2e");
|
|
|
|
const createButton = page
|
|
.getByTestId("message-input-root")
|
|
.getByRole("button", { name: "Create" });
|
|
await expect(createButton).toBeVisible({ timeout: 30_000 });
|
|
await createButton.click();
|
|
|
|
await agentCreatedDelay.waitForCreateRequest();
|
|
await agentCreatedDelay.waitForDelayedCreatedStatus();
|
|
|
|
const createdWorkspace = await assertNewWorkspaceSidebarAndHeader(page, {
|
|
serverId,
|
|
client,
|
|
previousWorkspaceId: openedProject.workspaceId,
|
|
projectDisplayName: openedProject.projectDisplayName,
|
|
assertSidebarRow: false,
|
|
assertHeader: false,
|
|
});
|
|
createdWorktreeDirectories.add(createdWorkspace.workspaceDirectory);
|
|
|
|
await expect(page).toHaveURL(
|
|
buildHostWorkspaceRoute(serverId, createdWorkspace.workspaceId),
|
|
{
|
|
timeout: 30_000,
|
|
},
|
|
);
|
|
|
|
const activeWorkspaceDeckEntry = page
|
|
.getByTestId(`workspace-deck-entry-${serverId}:${createdWorkspace.workspaceId}`)
|
|
.filter({ visible: true });
|
|
await expect(activeWorkspaceDeckEntry).toBeVisible({ timeout: 30_000 });
|
|
|
|
const draftTabs = activeWorkspaceDeckEntry.locator('[data-testid^="workspace-tab-draft_"]');
|
|
await expect(draftTabs).toHaveCount(1, { timeout: 30_000 });
|
|
await expect(
|
|
activeWorkspaceDeckEntry.locator('[data-testid^="workspace-tab-agent_"]'),
|
|
).toHaveCount(0);
|
|
|
|
agentCreatedDelay.release();
|
|
await expect(
|
|
activeWorkspaceDeckEntry.locator('[data-testid^="workspace-tab-agent_"]'),
|
|
).toHaveCount(1, { timeout: 30_000 });
|
|
} finally {
|
|
agentCreatedDelay.release();
|
|
await tempRepo.cleanup();
|
|
}
|
|
});
|
|
|
|
test("new workspace with initial agent never appears in the Done status group", async ({
|
|
page,
|
|
}) => {
|
|
const serverId = getServerId();
|
|
|
|
const tempRepo = await createTempGitRepo("new-workspace-status-optimistic-");
|
|
|
|
try {
|
|
const openedProject = await openProjectViaDaemon(client, tempRepo.path);
|
|
localWorkspaceIds.add(openedProject.workspaceId);
|
|
|
|
await gotoAppShell(page);
|
|
await waitForSidebarHydration(page);
|
|
|
|
await switchWorkspaceViaSidebar({
|
|
page,
|
|
serverId,
|
|
workspaceId: openedProject.workspaceId,
|
|
});
|
|
await expectWorkspaceHeader(page, {
|
|
title: openedProject.workspaceName,
|
|
subtitle: openedProject.projectDisplayName,
|
|
});
|
|
|
|
await switchSidebarToStatusGrouping(page);
|
|
await startTrackingSidebarStatusGroups(page);
|
|
|
|
await openGlobalNewWorkspaceComposer(page);
|
|
await expectNewWorkspaceProjectSelected(page, openedProject.projectDisplayName);
|
|
await submitNewWorkspacePrompt(page);
|
|
|
|
const createdWorkspace = await assertNewWorkspaceSidebarAndHeader(page, {
|
|
serverId,
|
|
client,
|
|
previousWorkspaceId: openedProject.workspaceId,
|
|
projectDisplayName: openedProject.projectDisplayName,
|
|
assertSidebarRow: false,
|
|
assertHeader: false,
|
|
});
|
|
createdWorktreeDirectories.add(createdWorkspace.workspaceDirectory);
|
|
|
|
const rowTestId = `sidebar-workspace-row-${serverId}:${createdWorkspace.workspaceId}`;
|
|
await expectWorkspaceStatusGroupEvents({
|
|
page,
|
|
rowTestId,
|
|
includes: "running",
|
|
excludes: "done",
|
|
includesIndicator: "workspace-status-indicator-running",
|
|
});
|
|
} finally {
|
|
await tempRepo.cleanup();
|
|
}
|
|
});
|
|
|
|
test("new workspace without an initial agent appears in the Done status group", async ({
|
|
page,
|
|
}) => {
|
|
const serverId = getServerId();
|
|
|
|
const tempRepo = await createTempGitRepo("new-workspace-status-empty-");
|
|
|
|
try {
|
|
const openedProject = await openProjectViaDaemon(client, tempRepo.path);
|
|
localWorkspaceIds.add(openedProject.workspaceId);
|
|
|
|
await gotoAppShell(page);
|
|
await waitForSidebarHydration(page);
|
|
|
|
await switchWorkspaceViaSidebar({
|
|
page,
|
|
serverId,
|
|
workspaceId: openedProject.workspaceId,
|
|
});
|
|
await expectWorkspaceHeader(page, {
|
|
title: openedProject.workspaceName,
|
|
subtitle: openedProject.projectDisplayName,
|
|
});
|
|
|
|
await switchSidebarToStatusGrouping(page);
|
|
await startTrackingSidebarStatusGroups(page);
|
|
|
|
await openGlobalNewWorkspaceComposer(page);
|
|
await expectNewWorkspaceProjectSelected(page, openedProject.projectDisplayName);
|
|
await submitNewWorkspaceWithoutPrompt(page);
|
|
|
|
const createdWorkspace = await assertNewWorkspaceSidebarAndHeader(page, {
|
|
serverId,
|
|
client,
|
|
previousWorkspaceId: openedProject.workspaceId,
|
|
projectDisplayName: openedProject.projectDisplayName,
|
|
});
|
|
createdWorktreeDirectories.add(createdWorkspace.workspaceDirectory);
|
|
|
|
const rowTestId = `sidebar-workspace-row-${serverId}:${createdWorkspace.workspaceId}`;
|
|
await expectWorkspaceStatusGroupEvents({
|
|
page,
|
|
rowTestId,
|
|
includes: "done",
|
|
excludes: "running",
|
|
excludesIndicator: "workspace-status-indicator-loading",
|
|
});
|
|
await expectWorkspaceStatusGroupEvents({
|
|
page,
|
|
rowTestId,
|
|
includes: "done",
|
|
excludes: "running",
|
|
excludesIndicator: "workspace-status-indicator-running",
|
|
});
|
|
} finally {
|
|
await tempRepo.cleanup();
|
|
}
|
|
});
|
|
|
|
test("selected branch becomes the base of a new workspace worktree", async ({ page }) => {
|
|
const serverId = getServerId();
|
|
|
|
const tempRepo = await createTempGitRepo("new-workspace-ref-", {
|
|
branches: ["main", "dev"],
|
|
});
|
|
|
|
try {
|
|
const openedProject = await openProjectViaDaemon(client, tempRepo.path);
|
|
localWorkspaceIds.add(openedProject.workspaceId);
|
|
|
|
await gotoAppShell(page);
|
|
await waitForSidebarHydration(page);
|
|
|
|
await switchWorkspaceViaSidebar({
|
|
page,
|
|
serverId,
|
|
workspaceId: openedProject.workspaceId,
|
|
});
|
|
await expectWorkspaceHeader(page, {
|
|
title: openedProject.workspaceName,
|
|
subtitle: openedProject.projectDisplayName,
|
|
});
|
|
|
|
await openNewWorkspaceComposer(page, {
|
|
projectKey: openedProject.projectKey,
|
|
projectDisplayName: openedProject.projectDisplayName,
|
|
});
|
|
await selectWorkspaceIsolation(page, "worktree");
|
|
await openStartingRefPicker(page);
|
|
await selectBranchInPicker(page, "dev");
|
|
|
|
const createButton = page
|
|
.getByTestId("message-input-root")
|
|
.getByRole("button", { name: "Create" });
|
|
await expect(createButton).toBeVisible({ timeout: 30_000 });
|
|
await createButton.click();
|
|
|
|
const createdWorkspace = await assertNewWorkspaceSidebarAndHeader(page, {
|
|
serverId,
|
|
client,
|
|
previousWorkspaceId: openedProject.workspaceId,
|
|
projectDisplayName: openedProject.projectDisplayName,
|
|
});
|
|
createdWorktreeDirectories.add(createdWorkspace.workspaceDirectory);
|
|
|
|
expect(existsSync(createdWorkspace.workspaceDirectory)).toBe(true);
|
|
|
|
const branchInfo = await readWorktreeBranchInfo({
|
|
worktreePath: createdWorkspace.workspaceDirectory,
|
|
});
|
|
expect(branchInfo.currentBranch).toBe(path.basename(createdWorkspace.workspaceDirectory));
|
|
expect(branchInfo.hasAncestor(tempRepo.branchHeads.main)).toBe(true);
|
|
expect(branchInfo.hasAncestor(tempRepo.branchHeads.dev)).toBe(true);
|
|
} finally {
|
|
await tempRepo.cleanup();
|
|
}
|
|
});
|
|
|
|
test("branch picker opens via keyboard and selects the filtered option on Enter", async ({
|
|
page,
|
|
}) => {
|
|
const tempRepo = await createTempGitRepo("picker-keyboard-", { branches: ["main", "dev"] });
|
|
|
|
try {
|
|
const openedProject = await openProjectViaDaemon(client, tempRepo.path);
|
|
localWorkspaceIds.add(openedProject.workspaceId);
|
|
|
|
await gotoAppShell(page);
|
|
await waitForSidebarHydration(page);
|
|
await openNewWorkspaceComposer(page, {
|
|
projectKey: openedProject.projectKey,
|
|
projectDisplayName: openedProject.projectDisplayName,
|
|
});
|
|
await selectWorkspaceIsolation(page, "worktree");
|
|
|
|
await openBranchPicker(page);
|
|
await expectPickerOpen(page);
|
|
await selectPickerOptionByKeyboard(page, "dev");
|
|
await expectPickerSelected(page, "dev");
|
|
await expectPickerClosed(page);
|
|
} finally {
|
|
await tempRepo.cleanup();
|
|
}
|
|
});
|
|
|
|
test("branch picker closes on Escape without selecting an option", async ({ page }) => {
|
|
const tempRepo = await createTempGitRepo("picker-escape-");
|
|
|
|
try {
|
|
const openedProject = await openProjectViaDaemon(client, tempRepo.path);
|
|
localWorkspaceIds.add(openedProject.workspaceId);
|
|
|
|
await gotoAppShell(page);
|
|
await waitForSidebarHydration(page);
|
|
await openNewWorkspaceComposer(page, {
|
|
projectKey: openedProject.projectKey,
|
|
projectDisplayName: openedProject.projectDisplayName,
|
|
});
|
|
await selectWorkspaceIsolation(page, "worktree");
|
|
|
|
await openBranchPicker(page);
|
|
await expectPickerOpen(page);
|
|
await closeBranchPicker(page);
|
|
await expectPickerClosed(page);
|
|
} finally {
|
|
await tempRepo.cleanup();
|
|
}
|
|
});
|
|
|
|
test("selected GitHub PR shows PR context in the trigger and composer", async ({ page }) => {
|
|
test.skip(!hasGithubAuth(), "Requires GitHub authentication (gh auth login)");
|
|
|
|
const ghRepo = await createTempGithubRepo({
|
|
category: "new-workspace-pr-ref",
|
|
prs: [{ title: "Review selected start ref", state: "open" }],
|
|
});
|
|
const pr = ghRepo.prs[0]!;
|
|
|
|
try {
|
|
const openedProject = await openProjectViaDaemon(client, pr.localPath);
|
|
localWorkspaceIds.add(openedProject.workspaceId);
|
|
|
|
await gotoAppShell(page);
|
|
await waitForSidebarHydration(page);
|
|
await openNewWorkspaceComposer(page, {
|
|
projectKey: openedProject.projectKey,
|
|
projectDisplayName: openedProject.projectDisplayName,
|
|
});
|
|
await selectWorkspaceIsolation(page, "worktree");
|
|
await openStartingRefPicker(page);
|
|
await selectGitHubPrInPicker(page, pr.number);
|
|
|
|
await expectStartingRefPickerTriggerPr(page, {
|
|
number: pr.number,
|
|
title: pr.title,
|
|
headRef: pr.branch,
|
|
});
|
|
await expectComposerGithubAttachmentPill(page, {
|
|
number: pr.number,
|
|
title: pr.title,
|
|
});
|
|
} finally {
|
|
await ghRepo.cleanup();
|
|
}
|
|
});
|
|
|
|
test("pasted GitHub PR replaces a selected branch and creates its worktree", async ({
|
|
page,
|
|
context,
|
|
}) => {
|
|
const fixture = await createLocalGithubPrFixture();
|
|
localGithubFixtures.add(fixture);
|
|
const { pr, mainCheckout } = fixture;
|
|
|
|
const openedProject = await openProjectViaDaemon(client, mainCheckout.path);
|
|
localWorkspaceIds.add(openedProject.workspaceId);
|
|
localProjectIds.add(openedProject.projectId);
|
|
|
|
await gotoAppShell(page);
|
|
await waitForSidebarHydration(page);
|
|
await openNewWorkspaceComposer(page, {
|
|
projectKey: openedProject.projectKey,
|
|
projectDisplayName: openedProject.projectDisplayName,
|
|
});
|
|
await selectWorkspaceIsolation(page, "worktree");
|
|
await openStartingRefPicker(page);
|
|
await selectBranchInPicker(page, "main");
|
|
|
|
await pasteGithubPrUrl(page, context, pr.url);
|
|
|
|
await expect(page.getByTestId("workspace-create-submit")).toBeDisabled();
|
|
await expectComposerGithubAttachmentPill(page, {
|
|
number: pr.number,
|
|
title: pr.title,
|
|
});
|
|
await expectStartingRefPickerTriggerPr(page, {
|
|
number: pr.number,
|
|
title: pr.title,
|
|
headRef: pr.branch,
|
|
});
|
|
|
|
await submitNewWorkspaceWithoutPrompt(page);
|
|
|
|
const worktree = await assertNewWorkspaceSidebarAndHeader(page, {
|
|
serverId: getServerId(),
|
|
client,
|
|
previousWorkspaceId: openedProject.workspaceId,
|
|
projectDisplayName: openedProject.projectDisplayName,
|
|
});
|
|
createdWorktreeDirectories.add(worktree.workspaceDirectory);
|
|
|
|
const branchInfo = await readWorktreeBranchInfo({
|
|
worktreePath: worktree.workspaceDirectory,
|
|
});
|
|
expect(branchInfo.currentBranch).toBe(pr.branch);
|
|
expect(existsSync(path.join(worktree.workspaceDirectory, "pr-1.txt"))).toBe(true);
|
|
});
|
|
|
|
test("branches remain searchable after a pasted PR and determine the created worktree", async ({
|
|
page,
|
|
context,
|
|
}) => {
|
|
const fixture = await createLocalGithubPrFixture();
|
|
localGithubFixtures.add(fixture);
|
|
const { pr, mainCheckout } = fixture;
|
|
|
|
const openedProject = await openProjectViaDaemon(client, mainCheckout.path);
|
|
localWorkspaceIds.add(openedProject.workspaceId);
|
|
localProjectIds.add(openedProject.projectId);
|
|
|
|
await gotoAppShell(page);
|
|
await waitForSidebarHydration(page);
|
|
await openNewWorkspaceComposer(page, {
|
|
projectKey: openedProject.projectKey,
|
|
projectDisplayName: openedProject.projectDisplayName,
|
|
});
|
|
await selectWorkspaceIsolation(page, "worktree");
|
|
await pasteGithubPrUrl(page, context, pr.url);
|
|
await expectStartingRefPickerTriggerPr(page, {
|
|
number: pr.number,
|
|
title: pr.title,
|
|
headRef: pr.branch,
|
|
});
|
|
|
|
await openStartingRefPicker(page);
|
|
await searchAndSelectBranchInPicker(page, "main");
|
|
await expectPickerSelected(page, "main");
|
|
await fillNewWorkspaceDraft(page, `${pr.url}\nKeep this checkout on main`);
|
|
await expectPickerSelected(page, "main");
|
|
await submitNewWorkspaceWithoutPrompt(page);
|
|
|
|
const worktree = await assertNewWorkspaceSidebarAndHeader(page, {
|
|
serverId: getServerId(),
|
|
client,
|
|
previousWorkspaceId: openedProject.workspaceId,
|
|
projectDisplayName: openedProject.projectDisplayName,
|
|
});
|
|
createdWorktreeDirectories.add(worktree.workspaceDirectory);
|
|
|
|
expect(existsSync(path.join(worktree.workspaceDirectory, "pr-1.txt"))).toBe(false);
|
|
});
|
|
|
|
test("selected GitHub PR creates the worktree from the PR head even when the head branch is not fetched", async ({
|
|
page,
|
|
}) => {
|
|
test.skip(!hasGithubAuth(), "Requires GitHub authentication (gh auth login)");
|
|
|
|
const ghRepo = await createTempGithubRepo({
|
|
category: "new-workspace-pr-worktree",
|
|
prs: [{ title: "Checkout PR worktree", state: "open" }],
|
|
});
|
|
const pr = ghRepo.prs[0]!;
|
|
const mainCheckout = await cloneGithubRepoDefaultBranchOnly(ghRepo);
|
|
|
|
try {
|
|
const openedProject = await openProjectViaDaemon(client, mainCheckout.path);
|
|
localWorkspaceIds.add(openedProject.workspaceId);
|
|
|
|
await gotoAppShell(page);
|
|
await waitForSidebarHydration(page);
|
|
await openNewWorkspaceComposer(page, {
|
|
projectKey: openedProject.projectKey,
|
|
projectDisplayName: openedProject.projectDisplayName,
|
|
});
|
|
await selectWorkspaceIsolation(page, "worktree");
|
|
await openStartingRefPicker(page);
|
|
await selectGitHubPrInPicker(page, pr.number);
|
|
await submitNewWorkspaceWithoutPrompt(page);
|
|
|
|
const worktree = await assertNewWorkspaceSidebarAndHeader(page, {
|
|
serverId: getServerId(),
|
|
client,
|
|
previousWorkspaceId: openedProject.workspaceId,
|
|
projectDisplayName: openedProject.projectDisplayName,
|
|
});
|
|
createdWorktreeDirectories.add(worktree.workspaceDirectory);
|
|
|
|
const branchInfo = await readWorktreeBranchInfo({
|
|
worktreePath: worktree.workspaceDirectory,
|
|
});
|
|
expect(branchInfo.currentBranch).toBe(pr.branch);
|
|
expect(existsSync(path.join(worktree.workspaceDirectory, "pr-1.txt"))).toBe(true);
|
|
} finally {
|
|
await mainCheckout.cleanup();
|
|
await ghRepo.cleanup();
|
|
}
|
|
});
|
|
});
|