The open-source app everyone uses to manage agents at work
TypeScript acpxagent-orchestrationagent-skillsagentic-aiai-agentsai-engineeringai-governanceai-toolsautonomous-agentsclaudeclaude-codeclaude-skillscodexhermesllmmcpmulti-agentopenclawproject-managementworkflow-automation
fix(apps): restore action test picker scrolling and agent eligibility (#13414)
Devin Foleyc0fda8fac541
diff --git a/server/src/__tests__/tool-access-service.test.ts b/server/src/__tests__/tool-access-service.test.tsindex 48b694029f..11c1ec3f79 100644--- a/server/src/__tests__/tool-access-service.test.ts+++ b/server/src/__tests__/tool-access-service.test.ts@@ -3242,6 +3242,36 @@ describeEmbeddedPostgres("tool access service", () => {});});+ it.each(["local_implicit", "session"] as const)("excludes unassignable agents from tests even for a %s instance admin", async (source) => {+ const company = await createCompany(db);+ const userId = `admin-tool-tester-${randomUUID()}`;+ await grantBoardUser(db, company.id, userId, ["tools:use"]);+ const active = await createAgent(db, company.id);+ const terminated = await createAgent(db, company.id, "terminated");+ const pending = await createAgent(db, company.id, "pending_approval");+ const otherCompany = await createCompany(db);+ const foreign = await createAgent(db, otherCompany.id);+ const { connection } = await createRemoteToolFixture(db, company.id);+ const gateway = createToolGatewayService(db, { toolActionSigningSecret: "test-secret" });+ const execute = vi.spyOn(gateway, "executeTestCall");+ const summarize = vi.spyOn(gateway, "summarizeConnectionAccessForAgent");+ const app = createRouteApp(db, {+ ...boardSessionActor(company.id, "operator", userId),+ isInstanceAdmin: true, source,+ }, gateway);++ const res = await request(app).get(`/api/tool-connections/${connection.id}/test-agents`).expect(200);+ expect(res.body.agents.map((agent: { id: string }) => agent.id)).toEqual([active.id]);+ // A stale picker or a direct request must not bypass the same lifecycle guard.+ for (const agent of [terminated, pending, foreign]) {+ await request(app).get(`/api/tool-connections/${connection.id}/test-agents/${agent.id}/access`).expect(403);+ await request(app).post(`/api/tool-connections/${connection.id}/test-calls`)+ .send({ agentId: agent.id, toolName: "send_email", parameters: { to: "[email protected]" } }).expect(403);+ }+ expect(execute).not.toHaveBeenCalled();+ expect(summarize).not.toHaveBeenCalled();+ });+it("lists only writable agents and ranks the highest accessible agent first", async () => {const company = await createCompany(db);const userId = `scoped-tool-tester-${randomUUID()}`;diff --git a/server/src/routes/tool-access.ts b/server/src/routes/tool-access.tsindex fffa85af70..8d327bb8ba 100644--- a/server/src/routes/tool-access.ts+++ b/server/src/routes/tool-access.ts@@ -6,6 +6,7 @@ import {APP_STORE_DEFINITIONS,GITHUB_CONNECTOR_PROFILES,GOOGLE_WORKSPACE_CONNECTOR_PROFILES,+ isAgentStatusAssignableToWork,isGitHubConnectorProfileId,isGoogleWorkspaceConnectorProfileId,TOOL_ACTION_REQUEST_STATUSES,@@ -709,7 +710,16 @@ function connectorEnrollmentPrincipal(req: Request): string {throw forbidden(`Missing one of permissions: ${permissionKeys.join(", ")}`);}- async function assertCanTestAsAgent(req: Request, companyId: string, agentId: string) {+ async function assertCanTestAsAgent(req: Request, companyId: string, agentId: string, knownAgent?: { id: string; status: string }) {+ const agent = knownAgent ?? (await db+ .select({ id: agents.id, status: agents.status })+ .from(agents)+ .where(and(eq(agents.id, agentId), eq(agents.companyId, companyId)))+ .limit(1))[0];+ // Admin permission bypasses must not make unassignable agents testable.+ if (!agent || agent.id !== agentId || !isAgentStatusAssignableToWork(agent.status)) {+ throw forbidden("This agent is not available for testing");+ }const decision = await access.decide({actor: req.actor,action: "tasks:assign",@@ -1992,7 +2002,7 @@ function connectorEnrollmentPrincipal(req: Request): string {const candidates = [];for (const agent of rows) {try {- await assertCanTestAsAgent(req, connection.companyId, agent.id);+ await assertCanTestAsAgent(req, connection.companyId, agent.id, agent);} catch {continue;}diff --git a/tests/e2e/action-test-agent-picker.spec.ts b/tests/e2e/action-test-agent-picker.spec.tsnew file mode 100644index 0000000000..c26bdc2081--- /dev/null+++ b/tests/e2e/action-test-agent-picker.spec.ts@@ -0,0 +1,46 @@+import { expect, test, type APIResponse } from "@playwright/test";+import { startReviewProvider } from "../fixtures/connection-review-provider";++async function json(response: APIResponse) {+ expect(response.ok(), `${response.status()}: ${await response.text()}`).toBe(true);+ return response.json();+}++test("action-test agent picker scrolls with the wheel and omits terminated agents", async ({ page, request }, testInfo) => {+ test.setTimeout(120_000);+ const provider = await startReviewProvider();+ try {+ const company = await json(await request.post("/api/companies", { data: { name: `Agent picker QA ${Date.now()}` } }));+ for (let i = 0; i < 24; i++) {+ await json(await request.post(`/api/companies/${company.id}/agents`, {+ data: { name: `Picker agent ${String(i).padStart(2, "0")}`, role: "qa", adapterType: "process", adapterConfig: { command: "true" } },+ }));+ }+ const terminated = await json(await request.post(`/api/companies/${company.id}/agents`, {+ data: { name: "Terminated picker agent", role: "qa", adapterType: "process", adapterConfig: { command: "true" } },+ }));+ await json(await request.post(`/api/agents/${terminated.id}/terminate`));+ const connection = await json(await request.post(`/api/companies/${company.id}/tools/connections`, {+ data: { name: "Picker fixture", transport: "mcp_remote", config: { url: provider.url }, status: "active", enabled: true },+ }));+ await json(await request.post(`/api/tool-connections/${connection.id}/catalog/refresh`));+ await page.goto(`/${company.issuePrefix}/apps/${connection.id}/permissions`, { waitUntil: "domcontentloaded" });+ await page.getByRole("button", { name: "Test", exact: true }).click();+ const dialog = page.getByRole("dialog", { name: "Test List fixture pages" });+ await dialog.getByRole("button", { name: "Choose which agent to test as" }).click();+ const picker = page.locator('[data-slot="popover-content"]');+ const list = picker.locator(".overflow-y-auto");+ await expect(picker.getByRole("button", { name: "Terminated picker agent" })).toHaveCount(0);+ await expect.poll(() => list.evaluate((element) => element.scrollHeight > element.clientHeight)).toBe(true);+ await list.hover();+ const start = await list.evaluate((element) => element.scrollTop);+ await page.mouse.wheel(0, 500);+ await expect.poll(() => list.evaluate((element) => element.scrollTop)).toBeGreaterThan(start);+ await picker.getByRole("textbox", { name: "Search agents" }).fill("Picker agent 23");+ await picker.getByRole("button", { name: /Picker agent 23/ }).click();+ await expect(dialog.getByRole("button", { name: "Choose which agent to test as" })).toHaveText("Picker agent 23");+ await expect(dialog).toBeVisible();+ expect(provider.captures.filter((capture) => capture.method === "tools/call")).toHaveLength(0);+ await page.screenshot({ path: testInfo.outputPath("agent-picker.png") });+ } finally { await provider.close(); }+});diff --git a/ui/src/pages/apps/app-detail/TestPanel.tsx b/ui/src/pages/apps/app-detail/TestPanel.tsxindex 34e4db180c..c9cd9d2b95 100644--- a/ui/src/pages/apps/app-detail/TestPanel.tsx+++ b/ui/src/pages/apps/app-detail/TestPanel.tsx@@ -585,7 +585,7 @@ function AgentPicker({<ChevronsUpDown className={cn("text-muted-foreground", inline ? "h-3.5 w-3.5" : "h-4 w-4")} /></button></PopoverTrigger>- <PopoverContent align="start" className="w-80 p-0">+ <PopoverContent align="start" className="w-80 p-0" disablePortal={inline}><div className="border-b border-border p-2"><div className="relative"><Search className="pointer-events-none absolute left-2.5 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-muted-foreground" />