mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-10-28 12:04:41 +01:00
## Thinking Path
> - Paperclip is the open source app people use to manage AI agents for
work.
> - Task side panels keep live work beside the conversation.
> - Plugins can already provide agent detail tabs.
> - Those tabs have no generic way to appear beside the task that is
using the agent.
> - This pull request adds an optional task-side-panel declaration to
agent detail tabs.
> - The plugin owns the label, component and availability. Core supplies
the task's running agent.
## Linked Issues or Issue Description
**What existing behavior does this improve?**
Access to plugin-contributed live views from task chat.
**Subsystem affected**
Plugin manifest validation, slot discovery, and task side-panel
UI/state.
**Current behavior**
Agent detail-tab contributions appear on agent pages. A task cannot
offer the same view through a plugin-owned availability decision.
**Proposed behavior**
An agent detail tab can declare `taskSidePanel: { availabilityPath }`.
Core substitutes the running agent into the plugin-local path. A
declared board GET route scoped to that agent returns `{ available:
boolean }`. Available contributions appear in desktop and mobile task
side panels.
**Reason and benefit**
Keep the task and its live plugin views together. Preserve plugin
ownership of provider protocols and product behavior. Core contains no
concrete plugin identifiers, routes, labels or readiness rules.
**Breaking changes**
None. The field is optional. Existing contributions remain unchanged.
Missing, disabled or unavailable plugins add no panel.
**Additional context**
Related: #17111 established the agent detail-tab and scoped API
extension surfaces. Roadmap and related PR searches found no duplicate
of this extension.
## What Changed
- Extend the manifest with optional task-panel metadata. Validate safe
plugin-local paths and require a declared board GET route with
agent-scoped authorization.
- Discover and load only opted-in agent contributions. Poll their
generic availability responses and mount the existing components with
agent context.
- Add generic panel tabs, launcher entries, dismissal and inactive-view
removal in desktop/mobile task chat.
- Reuse the existing live-run polling guard so idle tasks with a healthy
live connection stop polling.
- Add provider-neutral fixtures, schema/authorization tests, task tests
and SDK/feature documentation.
## Verification
- PASS: 301 focused tests including the full task-detail file, generic
panel discovery, persistence, slot loading and manifest validation.
Regressions cover POST-before-GET route order, mobile drawer dismissal,
recovery without focus and the absence of the hidden desktop task panel
on mobile.
- PASS: UI and shared-package typechecks; production UI build; token
gates, feature-map and module-boundary checks; diff and secrets/PII
review.
- PASS on final head: all 795 UI files / 9,186 tests, and all 95
shared-package files / 1,038 tests. Commands: `node
node_modules/vitest/vitest.mjs run --project @paperclipai/ui
--maxWorkers 3` and the corresponding `--project @paperclipai/shared`
command with local socket access.
- On the final head, server shards 7/12 and 10/12 and workspace shard
a-1/2 were interrupted by runner shutdown/communication loss. GitHub
reported infrastructure failures; no assertion failure was surfaced in
the available diagnostics. The queued summary was cancelled, then `gh
run rerun --failed` successfully requested retries for only those three
jobs. They are currently queued for CI runners; the 50 successful checks
remain passing. Interrupted attempts are not counted as passing.
[Final-head CI and
retry](https://github.com/paperclipai/paperclip/actions/runs/40396870920).
- Earlier verification exposed an empty-panel rerender loop, which was
fixed. The sandboxed combined run also failed five shared port-registry
tests because it could not bind loopback listeners; the full shared
rerun with socket access passed. These earlier failures are retained
here rather than reported as passing runs.
- Full workspace typecheck/build were attempted with pinned pnpm 9 after
resolving the initial local package-manager setup. Both stop at the
unchanged Runner Rust step because `cargo` is not installed. Full local
workspace checks are not reported as passing; final CI must provide
those broader checks.
- No live provider or plugin-specific transport acceptance is claimed by
Core's synthetic fixtures.
## Risks
- Availability is polled every three seconds only while an authorized
running agent exists. Plugins own the side effects and meaning of that
read.
- A view uses the running agent's context. It is not a separate per-task
resource.
- Optional metadata adds no backend endpoint or permission bypass. The
host requires existing board and agent authorization.
- Reverting the optional contract and UI integration removes task panels
without a data migration.
## Model Used
OpenAI Codex (GPT-6), with reasoning, repository tools and code
execution. The exact backend snapshot ID and context window size are not
exposed by 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 described the issue in-PR following the relevant issue
template
- [x] I have not referenced internal/instance-local Paperclip issues or
links
- [x] My branch name describes the change and contains no internal
ticket id
- [x] I have run focused 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>
57 lines
2.7 KiB
TypeScript
57 lines
2.7 KiB
TypeScript
import { useMemo } from "react";
|
|
import { useQueries, useQuery } from "@tanstack/react-query";
|
|
import type { Issue } from "@paperclipai/shared";
|
|
import { api } from "@/api/client";
|
|
import { heartbeatsApi } from "@/api/heartbeats";
|
|
import { useHasCompanyLiveConnection } from "@/context/LiveUpdatesProvider";
|
|
import { liveRunRefetchInterval } from "@/lib/live-runs-cache";
|
|
import { queryKeys } from "@/lib/queryKeys";
|
|
import { usePluginSlots, type ResolvedPluginSlot } from "@/plugins/slots";
|
|
|
|
export interface TaskPluginPanel {
|
|
entityId: string;
|
|
runId: string;
|
|
slot: ResolvedPluginSlot;
|
|
}
|
|
|
|
const EMPTY_PANELS: TaskPluginPanel[] = [];
|
|
|
|
export function taskPluginPanelId(panel: TaskPluginPanel) {
|
|
return `plugin:${panel.slot.pluginKey}:${panel.slot.id}:${panel.entityId}`;
|
|
}
|
|
|
|
/** Plugins own availability and content; the host supplies the running agent. */
|
|
export function useTaskPluginPanels(issue: Issue | null | undefined, enabled = true): TaskPluginPanel[] {
|
|
const savedTask = enabled && !!issue && !issue.id.startsWith("chat:");
|
|
const connected = useHasCompanyLiveConnection(issue?.companyId);
|
|
const { slots, errorMessage } = usePluginSlots({
|
|
slotTypes: ["detailTab"], entityType: "agent", taskSidePanel: true,
|
|
companyId: issue?.companyId, enabled: savedTask,
|
|
});
|
|
const { data: runs, isError: runsError } = useQuery({
|
|
queryKey: queryKeys.issues.liveRuns(issue?.id ?? "pending"),
|
|
queryFn: () => heartbeatsApi.liveRunsForIssue(issue!.id),
|
|
enabled: savedTask && slots.length > 0 && !errorMessage,
|
|
refetchInterval: query => liveRunRefetchInterval(connected, query.state, 3000),
|
|
retry: false,
|
|
});
|
|
const run = runs?.find(run => run.status === "running"
|
|
&& (!issue?.executionRunId || run.id === issue.executionRunId));
|
|
const active = savedTask && slots.length > 0 && !!run && !runsError && !errorMessage;
|
|
const availability = useQueries({ queries: slots.map(slot => ({
|
|
queryKey: ["task-plugin-panel", issue?.companyId, issue?.id, run?.id, run?.agentId, slot.pluginKey, slot.id, slot.pluginVersion],
|
|
queryFn: ({ signal }: { signal: AbortSignal }) => api.get<{ available: boolean }>(
|
|
`/plugins/${encodeURIComponent(slot.pluginId)}/api${slot.taskSidePanel!.availabilityPath.replace(":entityId", encodeURIComponent(run!.agentId))}`,
|
|
{ signal, cache: "no-store" },
|
|
),
|
|
enabled: active,
|
|
refetchInterval: 3000,
|
|
retry: false,
|
|
})) });
|
|
const available = availability.map(result => !result.isError && result.data?.available === true);
|
|
const availableKey = available.join(",");
|
|
return useMemo(() => active && run ? slots.flatMap((slot, index) => available[index]
|
|
? [{ entityId: run.agentId, runId: run.id, slot }] : []) : EMPTY_PANELS,
|
|
[active, run?.agentId, run?.id, slots, availableKey]);
|
|
}
|