mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-12-05 14:35:17 +01:00
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - Plugins can show an agent detail tab in the task side panel, next to a task > - The board mounts only the active side panel tab, and it unmounts a plugin view in the same way when the person switches tabs and when the person closes the tab > - Thus a plugin that shows a live view in a task panel tab cannot know when the person is done with it, and it cannot release the view > - A component callback does not solve this, because a background tab is not mounted when the person clicks its close control > - This pull request adds an optional declarative `taskSidePanel.closePath`, symmetric with the existing `availabilityPath` > - The benefit is that a plugin can release a live view when the person closes its tab, and plugins that do not declare the path see no change ## Linked Issues or Issue Description Refs #17796 (added plugin panels in task side panels). Related: #23609. **Subsystem affected** Plugin UI slots: `detailTab` slots with a `taskSidePanel` declaration, and the task side panel in the board UI. **Problem or motivation** A plugin panel in the task side panel gets no signal when the person closes its tab. The board unmounts the view on a close and on a tab switch in the same way, so the plugin cannot tell the two apart. A plugin that holds a live view for the panel cannot release it when the person closes the tab. **Proposed solution** Add an optional `closePath` to `taskSidePanel`. When the person closes the tab, the board sends a fire-and-forget POST to that plugin route, with the same agent, run and task as the availability request. The manifest must declare the path as a board POST route scoped to agent `:entityId`. **Alternatives considered** A callback on the mounted plugin component. It does not work for a background tab, because only the active tab is mounted. **Roadmap alignment** This extends the plugin system. It adds no product-specific behaviour to the control plane. ## What Changed - `taskSidePanel` accepts an optional `closePath`. It uses the same path rules as `availabilityPath`: a plugin-relative path with one `:entityId` segment. - Manifest validation requires a declared `POST` API route at `closePath` with `auth: "board"`, no transport, and `companyResolution: { from: "agent", param: "entityId" }`. These are the same rules as the `GET` availability route. - When the person closes a plugin panel tab in the task side panel, the board sends `POST /plugins/<pluginId>/api<closePath>?runId=<run>&issueId=<task>`, with `:entityId` replaced by the panel's agent. The board leaves out `runId` when the task has no active run. This applies to the active tab and to background tabs. - The board does not wait for the request. A failed request does not block the close, and the board logs a console warning. - The board sends no request on a tab switch, when the panel unmounts, when the person leaves the task, or when the board removes a panel that is no longer available. - A slot without `closePath` behaves as before. - The plugin SDK README and the plugin spec document the new field. A plugin declares: ```ts ui: { slots: [{ type: "detailTab", id: "screen", displayName: "Live view", exportName: "LiveView", entityTypes: ["agent"], taskSidePanel: { availabilityPath: "/agents/:entityId/view/availability", closePath: "/agents/:entityId/view/close", }, }] }, apiRoutes: [ { routeKey: "view.availability", method: "GET", path: "/agents/:entityId/view/availability", auth: "board", capability: "api.routes.register", companyResolution: { from: "agent", param: "entityId" } }, { routeKey: "view.close", method: "POST", path: "/agents/:entityId/view/close", auth: "board", capability: "api.routes.register", companyResolution: { from: "agent", param: "entityId" } }, ], ``` ## Verification - `packages/shared`: `npx vitest run src/validators/plugin.test.ts` passes (85 tests). New cases accept a valid close route and a close path equal to the availability path. They reject unsafe paths, a missing POST route, the wrong method (`GET`, `DELETE`), non-board auth, a non-agent company resolution, and the wrong agent parameter. - `ui`: `npx vitest run src/components/task-side-panel/TaskSidePanel.pluginClose.test.tsx` passes (6 tests). The tests render the task side panel and check that a close of the active tab and of a background tab sends exactly one POST to the correct URL. They also check that a tab switch, an unmount, a removal of an unavailable panel, and a slot without `closePath` send nothing, and that an idle task omits `runId` and a failed request still closes the tab. - Red check: with the board call removed, the three close tests fail. - `ui`: `npx vitest run src/hooks/useTaskPluginPanels.test.tsx` passes (56 tests). - `tsc --noEmit` passes for `packages/shared` and for `ui` source files. ## Risks - Low risk. The field is optional, and slots without it keep their current behaviour. - A plugin receives a close POST only for a person's close of the tab. The plugin must treat the request as a hint, because the request can fail or arrive late. - Existing manifests continue to validate. The availability route error message has the same text as before. > For core feature work, check [`ROADMAP.md`](ROADMAP.md) first and discuss it in `#dev` before opening the PR. Feature PRs that overlap with planned core work may need to be redirected — check the roadmap first. See `CONTRIBUTING.md`. ## Model Used - Claude Opus 5.5 (Anthropic), model ID `claude-opus-5-5`, run in Claude Code with tool use (file edits, shell, test runs) and extended reasoning. ## 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 - [x] 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 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>