Fix workspace-owned Playwright flows

This commit is contained in:
Mohamed Boudra
2026-06-16 18:57:00 +07:00
parent 3cf3a63423
commit 37de9ea796
9 changed files with 22 additions and 2 deletions
+4 -2
View File
@@ -2,7 +2,8 @@ import { expect, type Page } from "@playwright/test";
import { buildHostWorkspaceRoute } from "@/utils/host-routes"; import { buildHostWorkspaceRoute } from "@/utils/host-routes";
import { createTempGitRepo } from "./workspace"; import { createTempGitRepo } from "./workspace";
import { connectSeedClient, type SeedDaemonClient } from "./seed-client"; import { connectSeedClient, type SeedDaemonClient } from "./seed-client";
import { connectWorkspaceSetupClient, openHomeWithProject } from "./workspace-setup"; import { gotoAppShell } from "./app";
import { connectWorkspaceSetupClient } from "./workspace-setup";
import { selectWorkspaceInSidebar } from "./sidebar"; import { selectWorkspaceInSidebar } from "./sidebar";
import { getServerId } from "./server-id"; import { getServerId } from "./server-id";
import { waitForTabBar } from "./launcher"; import { waitForTabBar } from "./launcher";
@@ -164,6 +165,7 @@ export async function startRunningMockAgent(
const agent = await client.createAgent({ const agent = await client.createAgent({
provider: "mock", provider: "mock",
cwd: repo.path, cwd: repo.path,
workspaceId: opened.workspace.id,
model: opts.model, model: opts.model,
}); });
const agentUrl = `${buildHostWorkspaceRoute(serverId, opened.workspace.id)}?open=${encodeURIComponent(`agent:${agent.id}`)}`; const agentUrl = `${buildHostWorkspaceRoute(serverId, opened.workspace.id)}?open=${encodeURIComponent(`agent:${agent.id}`)}`;
@@ -188,7 +190,7 @@ export async function openGithubWorkspace(
const client = await connectWorkspaceSetupClient(); const client = await connectWorkspaceSetupClient();
const opened = await client.openProject(repoPath); const opened = await client.openProject(repoPath);
if (!opened.workspace) throw new Error(opened.error ?? `Failed to open project ${repoPath}`); if (!opened.workspace) throw new Error(opened.error ?? `Failed to open project ${repoPath}`);
await openHomeWithProject(page, repoPath); await gotoAppShell(page);
await selectWorkspaceInSidebar(page, opened.workspace.id); await selectWorkspaceInSidebar(page, opened.workspace.id);
await waitForTabBar(page); await waitForTabBar(page);
return { cleanup: () => client.close().catch(() => undefined) }; return { cleanup: () => client.close().catch(() => undefined) };
+3
View File
@@ -12,6 +12,9 @@ function pinToggle(page: Page, target: PinnedTabTarget) {
} }
function menuItemFor(page: Page, target: PinnedTabTarget) { function menuItemFor(page: Page, target: PinnedTabTarget) {
if (target.kind === "draft") {
return page.getByTestId("workspace-new-tab-menu-agent");
}
return page.getByTestId(`workspace-new-tab-menu-${target.kind}`); return page.getByTestId(`workspace-new-tab-menu-${target.kind}`);
} }
+1
View File
@@ -178,6 +178,7 @@ export async function launchAgent(input: {
const agent = await client.createAgent({ const agent = await client.createAgent({
...fullAccessConfig(input.provider), ...fullAccessConfig(input.provider),
cwd: input.cwd, cwd: input.cwd,
workspaceId: opened.workspace.id,
title: `rewind-flow-${input.provider}-${randomUUID()}`, title: `rewind-flow-${input.provider}-${randomUUID()}`,
}); });
const handle = { const handle = {
@@ -139,6 +139,7 @@ async function measureAppBurstEcho(input: {
: await input.harness.client.createAgent({ : await input.harness.client.createAgent({
provider: "mock", provider: "mock",
cwd: input.harness.tempRepo.path, cwd: input.harness.tempRepo.path,
workspaceId: input.harness.workspaceId,
title: "Large WebSocket payload", title: "Large WebSocket payload",
modeId: "load-test", modeId: "load-test",
}); });
@@ -77,6 +77,7 @@ function buildHistoricalAgentDetail(agent: AggregatedAgent): Agent {
}, },
title: agent.title, title: agent.title,
cwd: agent.cwd, cwd: agent.cwd,
workspaceId: agent.workspaceId,
model: null, model: null,
thinkingOptionId: null, thinkingOptionId: null,
requiresAttention: agent.requiresAttention, requiresAttention: agent.requiresAttention,
@@ -101,6 +102,7 @@ function rememberArchivedAgentDetail(agent: AggregatedAgent) {
...existing, ...existing,
archivedAt: existing?.archivedAt ?? agent.archivedAt, archivedAt: existing?.archivedAt ?? agent.archivedAt,
cwd: existing?.cwd ?? agent.cwd, cwd: existing?.cwd ?? agent.cwd,
workspaceId: existing?.workspaceId ?? agent.workspaceId,
}); });
return next; return next;
}); });
@@ -60,6 +60,7 @@ export async function fetchAgentHistoryPage(input: {
status: agent.status, status: agent.status,
lastActivityAt: agent.lastActivityAt, lastActivityAt: agent.lastActivityAt,
cwd: agent.cwd, cwd: agent.cwd,
workspaceId: agent.workspaceId,
provider: agent.provider, provider: agent.provider,
pendingPermissionCount: agent.pendingPermissions.length, pendingPermissionCount: agent.pendingPermissions.length,
requiresAttention: agent.requiresAttention, requiresAttention: agent.requiresAttention,
@@ -78,6 +78,7 @@ export function useAggregatedAgents(options?: {
status: agent.status, status: agent.status,
lastActivityAt: agent.lastActivityAt, lastActivityAt: agent.lastActivityAt,
cwd: agent.cwd, cwd: agent.cwd,
workspaceId: agent.workspaceId,
provider: agent.provider, provider: agent.provider,
pendingPermissionCount: agent.pendingPermissions.length, pendingPermissionCount: agent.pendingPermissions.length,
requiresAttention: agent.requiresAttention, requiresAttention: agent.requiresAttention,
@@ -8,6 +8,7 @@ export type AgentDirectoryEntry = Pick<
| "status" | "status"
| "lastActivityAt" | "lastActivityAt"
| "cwd" | "cwd"
| "workspaceId"
| "provider" | "provider"
| "requiresAttention" | "requiresAttention"
| "attentionReason" | "attentionReason"
+8
View File
@@ -31,6 +31,14 @@ export const usePinnedTargetsStore = create<PinnedTargetsState>()(
{ {
name: "pinned-tab-targets", name: "pinned-tab-targets",
version: 1, version: 1,
merge: (persistedState, currentState) => {
const persisted = persistedState as Partial<PinnedTargetsState> | null;
return {
...currentState,
...persisted,
pinned: persisted?.pinned ?? applyDefaultPinnedTargets([]),
};
},
storage: createJSONStorage(() => AsyncStorage), storage: createJSONStorage(() => AsyncStorage),
partialize: (state) => ({ pinned: state.pinned }), partialize: (state) => ({ pinned: state.pinned }),
migrate: (persistedState, version) => { migrate: (persistedState, version) => {