mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-11-21 10:52:06 +01:00
fix(apps): restore action test picker scrolling and agent eligibility (#13414)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work. > - Apps action tests let operators use an agent's permissions. > - The agent picker must scroll inside the test dialog. > - Its body portal sits outside the dialog's scroll boundary and blocks wheel input. > - Admin permission bypasses also skip agent lifecycle checks. > - This PR fixes scrolling and rejects agents that cannot receive assignments. ## Linked Issues or Issue Description **What happened?** The Act as picker does not scroll with the mouse wheel inside an action test dialog. Admins can also see terminated agents. **Expected behavior** The list scrolls normally. Terminated and pending-approval agents are absent. Direct requests cannot test an action as one of those agents. **Steps to reproduce** 1. Create enough agents to overflow the list. Terminate one agent. 2. Open a connected app's Permissions tab. Click Test on an action. 3. Open Act as and use the mouse wheel over the list. 4. Check whether the terminated agent appears as an admin. **Paperclip version or commit** Reproduced on master atf2c5e54dc. Rebased ontod351e08de. **Deployment mode** Local dev, built from source. This is a shared Apps bug and does not require Railway credentials. Related search result: #9918 added search to a separate secrets picker. It does not cover this action test dialog. No duplicate action-test picker PR was found. ## What Changed - Keep the action tester's agent popover inside its dialog's scroll boundary. - Check company membership and the shared agent lifecycle policy before assignment permission bypasses. - Reject terminated and pending-approval agents in lists, previews, and test calls. - Reuse company-scoped rows during listing to avoid extra per-agent queries. - Add route tests for both admin modes and a browser wheel-scroll regression. ## Verification - 335 focused tool-access and TestPanel tests passed after rebase. After the review cleanup, both admin regressions and writable-agent selection passed again (3 tests). - The browser regression failed before the fix because wheel input left scrollTop at zero. It passed after the fix, including search and selection. It executes no provider tools. - Full typecheck, build, and token gates passed during implementation. Token gates passed again after rebase. - The full test run reported a failure in the GitHub installation recovery chat test. That test passed in isolation. The full run was stopped after the failure, so later groups were not completed. Manual check: open an action's Test dialog, open Act as, scroll, search, and select an agent. Terminated agents must be absent. ## Risks The portal change affects only the picker inside the action test dialog. The browser test covers scrolling and selection. Paused agents remain eligible under existing assignment rules. There is no migration or provider policy change. ## Model Used OpenAI Codex, based on GPT-6, with code execution and browser testing. The exact serving model ID and context window were not exposed in this session. ## Checklist - [x] I have included a thinking path that traces from project context to this change - [x] I have specified the model used (with version and capability details) - [x] I have checked ROADMAP.md and confirmed this PR does not duplicate planned core work - [x] I have searched GitHub for duplicate or related PRs and linked them above - [x] I have either (a) linked existing issues with `Fixes: #` / `Closes #` / `Refs #` OR (b) described the issue in-PR following the relevant issue template - [x] I have not referenced internal/instance-local Paperclip issues or links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip` URLs) - [x] My branch name describes the change (e.g. `docs/...`, `fix/...`) and contains no internal Paperclip ticket id or instance-derived details - [x] I have run tests locally and they pass - [x] I have added or updated tests where applicable - [x] I have updated relevant documentation to reflect my changes - [x] I have considered and documented any risks above - [ ] All Paperclip CI gates are green - [x] Greptile is 5/5 with no open P2s, recommendations, or follow-ups - [x] I will address all Greptile and reviewer comments before requesting merge --------- Co-authored-by: Paperclip <noreply@paperclip.ing>
This commit is contained in:
1 parent
b64469e403
commit
c0fda8fac5
4 files changed
+89
-3
No files matched your search
@@ -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: "fixture@example.com" } }).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()}`;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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(); }
|
||||
});
|
||||
@@ -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" />
|
||||
|
||||
Reference in new issue
Block a user