Surface cross-workspace subagents in their workspaces (#2061)
* fix(workspaces): show provider subagent activity Provider subagent lifecycle lives outside managed agent snapshots, so workspace aggregation dropped it after the parent turn finished. Count running provider subagents against the delegation root and emit workspace updates when their status changes. * fix(workspaces): surface cross-workspace subagents
This commit is contained in:
@@ -14,6 +14,17 @@ export interface SeededSubagentPair {
|
||||
workspaceId: string;
|
||||
}
|
||||
|
||||
export interface SeededCrossWorkspaceSubagentPair {
|
||||
parent: {
|
||||
id: string;
|
||||
workspaceId: string;
|
||||
};
|
||||
child: {
|
||||
id: string;
|
||||
workspaceId: string;
|
||||
};
|
||||
}
|
||||
|
||||
export async function seedParentWithSubagent(
|
||||
workspace: Pick<SeededWorkspace, "client" | "repoPath" | "workspaceId">,
|
||||
input: { parentTitle: string; childTitle: string },
|
||||
@@ -51,6 +62,60 @@ export async function seedParentWithSubagent(
|
||||
};
|
||||
}
|
||||
|
||||
export async function seedParentWithCrossWorkspaceSubagent(
|
||||
workspace: Pick<SeededWorkspace, "client" | "repoPath" | "workspaceId" | "projectId">,
|
||||
input: { parentTitle: string; childTitle: string },
|
||||
): Promise<SeededCrossWorkspaceSubagentPair> {
|
||||
const parent = await workspace.client.createAgent({
|
||||
provider: "mock",
|
||||
cwd: workspace.repoPath,
|
||||
workspaceId: workspace.workspaceId,
|
||||
title: input.parentTitle,
|
||||
modeId: "load-test",
|
||||
model: "ten-second-stream",
|
||||
});
|
||||
const createdWorkspace = await workspace.client.createWorkspace({
|
||||
source: {
|
||||
kind: "directory",
|
||||
path: workspace.repoPath,
|
||||
projectId: workspace.projectId,
|
||||
},
|
||||
title: "Subagent workspace",
|
||||
});
|
||||
if (!createdWorkspace.workspace) {
|
||||
throw new Error(createdWorkspace.error ?? "Failed to create subagent workspace");
|
||||
}
|
||||
|
||||
const child = await workspace.client.createAgent({
|
||||
provider: "mock",
|
||||
cwd: workspace.repoPath,
|
||||
workspaceId: createdWorkspace.workspace.id,
|
||||
title: input.childTitle,
|
||||
modeId: "load-test",
|
||||
model: "five-minute-stream",
|
||||
initialPrompt: "stay running",
|
||||
labels: {
|
||||
[PARENT_AGENT_ID_LABEL]: parent.id,
|
||||
},
|
||||
});
|
||||
await workspace.client.waitForAgentUpsert(
|
||||
child.id,
|
||||
(snapshot) => snapshot.status === "running",
|
||||
15_000,
|
||||
);
|
||||
|
||||
return {
|
||||
parent: {
|
||||
id: parent.id,
|
||||
workspaceId: workspace.workspaceId,
|
||||
},
|
||||
child: {
|
||||
id: child.id,
|
||||
workspaceId: createdWorkspace.workspace.id,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
export async function openSubagentsTrack(page: Page): Promise<void> {
|
||||
await page.getByTestId("subagents-track-header").click();
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { test, expect } from "./fixtures";
|
||||
import { expectWorkspaceTabVisible } from "./helpers/archive-tab";
|
||||
import { expectComposerEditable, expectComposerVisible, submitMessage } from "./helpers/composer";
|
||||
import { clickNewChat, gotoWorkspace } from "./helpers/launcher";
|
||||
import {
|
||||
@@ -12,6 +13,11 @@ import {
|
||||
} from "./helpers/new-workspace";
|
||||
import { getServerId } from "./helpers/server-id";
|
||||
import { seedWorkspace, type SeededWorkspace } from "./helpers/seed-client";
|
||||
import {
|
||||
expectSubagentRowVisible,
|
||||
openSubagentsTrack,
|
||||
seedParentWithCrossWorkspaceSubagent,
|
||||
} from "./helpers/subagents";
|
||||
import { expectWorkspaceHeader, waitForSidebarHydration } from "./helpers/workspace-ui";
|
||||
import { getVisibleWorkspaceAgentTabIds } from "./helpers/workspace-tabs";
|
||||
|
||||
@@ -527,4 +533,39 @@ test.describe("Workspace model regressions", () => {
|
||||
await seeded.cleanup();
|
||||
}
|
||||
});
|
||||
|
||||
test("cross-workspace subagent opens in its workspace and keeps its parent relationship", async ({
|
||||
page,
|
||||
}) => {
|
||||
const serverId = getServerId();
|
||||
const seeded = await seedWorkspace({ repoPrefix: "workspace-cross-subagent-" });
|
||||
|
||||
try {
|
||||
const agents = await seedParentWithCrossWorkspaceSubagent(seeded, {
|
||||
parentTitle: "Parent agent",
|
||||
childTitle: "Cross-workspace subagent",
|
||||
});
|
||||
|
||||
await gotoWorkspace(page, agents.child.workspaceId);
|
||||
await waitForSidebarHydration(page);
|
||||
await expectWorkspaceTabVisible(page, agents.child.id);
|
||||
|
||||
const parentRowTestId = `sidebar-workspace-row-${serverId}:${agents.parent.workspaceId}`;
|
||||
const childRowTestId = `sidebar-workspace-row-${serverId}:${agents.child.workspaceId}`;
|
||||
await expectWorkspaceRowHasOnlyIndicator(page, {
|
||||
rowTestId: childRowTestId,
|
||||
indicator: "running",
|
||||
});
|
||||
await expectWorkspaceRowHasOnlyIndicator(page, {
|
||||
rowTestId: parentRowTestId,
|
||||
indicator: "done",
|
||||
});
|
||||
|
||||
await gotoWorkspace(page, agents.parent.workspaceId);
|
||||
await openSubagentsTrack(page);
|
||||
await expectSubagentRowVisible(page, agents.child.id);
|
||||
} finally {
|
||||
await seeded.cleanup();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user