mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-12-02 19:08:33 +01:00
## Thinking Path > - Paperclip helps people manage work that agents do. > - The inbox tells a person which tasks need a decision. > - A provider usage limit can stop several attempts on one task or affect several tasks. > - Separate failure cards made it hard to tell which tasks still needed attention. > - This change groups failures using the account, reset time, or retry links that Paperclip can verify. > - A person can now see which task to retry, which tasks are waiting, and which ones recovered. ## Linked Issues or Issue Description **What existing behavior does this improve?** It improves the Coordinator inbox when a provider limits usage. **Current behavior** Repeated run failures can fill the inbox. Resolved failures can still appear beside open decisions. **Proposed behavior** Show personal actions in Needs you, automatic retries and snoozes in Waiting, and past events in History. Keep an archived retry chain hidden during automatic attempts. Return it to Needs you when a person must act. **Additional context** Related work includes #18020 on completed tasks, #9704 on archive behavior, and #21570 on usage limits in chat. ## What Changed - Group verified account and reset windows. When that evidence is missing, count linked attempts per task and show the tasks in a collapsible group. - Separate the reported reset time from each task’s retry schedule. Keep unresolved ownership recoveries visible after task closure. Use persisted native retry requests to preserve the original archive and increment the attempt count. - Keep personal archive in the card menu. Put decision receipts and run logs in History. - Align inbox filters, tabs, and history. Share empty-state artwork and placement across Inbox, Goals, Routines, and Secrets. - Index run-history pages and resumed-work lookups, and rate-limit history requests per company and viewer. Add synthetic fixtures for both grouping paths and a manual walkthrough. ## Verification - The author and a human tester completed the synthetic retry-chain walkthrough. Chromium also verified archive, repeat failure, exhaustion, and recovery. - The 64 focused server tests and the UI and server typechecks passed before rebasing. See `doc/testing/coordinator-inbox-test-drive.md` to repeat the manual checks. - The shared SDK input check and all 64 focused server tests passed after rebasing. The OpenAPI suite (59 tests), API catalog suite (2,309 tests), and both demo seed paths passed locally after the CI fixes. - The affected inbox and native-runtime suites passed locally after merging the upstream conformance test fix in #22854. The browser access-denial scenarios passed three runs each for 403 and 404. - The migration checks and 79 focused tests passed, including an index-plan regression with 5,000 unrelated runs. The migration and query plan were reverified after renumbering. [Full CI on `cf52b80161`](https://github.com/paperclipai/paperclip/actions/runs/45529834793) passed after rerunning a timed-out server shard. ## Risks The attention feed reads retry ancestry. Long chains can increase query cost. Task and company checks bound the traversal, and cycle detection stops repeated visits. Providers that omit the reset time leave the card with an unknown reset. Migration 0508 adds two indexes concurrently. Each run-history page returns at most 100 records. ## Model Used OpenAI Codex, GPT-6 family, with repository editing, local test execution, and browser verification. ## 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 --------- Co-authored-by: Scott Tong <scott@scotts-mbp-m5-max.local> Co-authored-by: Paperclip <noreply@paperclip.ing>
82 lines
4.9 KiB
TypeScript
82 lines
4.9 KiB
TypeScript
import type { ReactNode } from "react";
|
|
import type { AttentionItem, AttentionProviderLimit } from "@paperclipai/shared";
|
|
import { Link } from "@/lib/router";
|
|
import { Button } from "@/components/ui/button";
|
|
import { formatDateTime } from "@/lib/utils";
|
|
|
|
function RetryStatus({ limit }: { limit: AttentionProviderLimit }) {
|
|
if (limit.state === "needs_retry") return "Needs retry";
|
|
if (limit.state === "retry_requested") return "Retry requested";
|
|
return <>Retry scheduled
|
|
{limit.retryAt && <> for <time dateTime={limit.retryAt}>{formatDateTime(limit.retryAt)}</time></>}
|
|
</>;
|
|
}
|
|
|
|
/** This disclosure has no dismissal or retry action. Both belong to the child cards. */
|
|
export function InboxLimitCards({ items, renderCard }: {
|
|
items: readonly AttentionItem[];
|
|
renderCard: (item: AttentionItem) => ReactNode;
|
|
}) {
|
|
const chains = items.filter(item => item.providerLimit?.grouping === "retry_chain" && item.relatedIssue);
|
|
const taskCount = new Set(chains.map(item => item.relatedIssue!.id)).size;
|
|
if (taskCount < 2) return items.map(renderCard);
|
|
const grouped = new Set(chains);
|
|
return items.map(item => {
|
|
if (!grouped.has(item)) return renderCard(item);
|
|
if (item !== chains[0]) return null;
|
|
return <details key="usage-limits" className="coordinator-decision-card">
|
|
<summary className="cursor-pointer font-medium">{taskCount} tasks hit usage limits</summary>
|
|
<div className="mt-3 space-y-3">{chains.map(renderCard)}</div>
|
|
</details>;
|
|
});
|
|
}
|
|
|
|
export function InboxProviderLimit({ item, evidence }: { item: AttentionItem; evidence: readonly AttentionItem[] }) {
|
|
const state = item.providerLimit!;
|
|
if (state.grouping === "retry_chain" && item.relatedIssue) {
|
|
const task = item.relatedIssue;
|
|
return <div className="space-y-2">
|
|
<h2><Link to={task.href!}>{task.identifier} {task.title}</Link></h2>
|
|
<p className="text-sm"><RetryStatus limit={state} /></p>
|
|
<p className="text-sm text-muted-foreground">{state.attempts} {state.attempts === 1 ? "attempt" : "attempts"} · {state.resetAt
|
|
? <>Provider reset at <time dateTime={state.resetAt}>{formatDateTime(state.resetAt)}</time></>
|
|
: "Reset time unknown"}</p>
|
|
<div className="flex flex-wrap items-center gap-3">
|
|
{state.state === "needs_retry" && <Button size="sm" asChild><Link to={task.href!}>Open task to retry</Link></Button>}
|
|
<Link to={`/agents/${state.agentId}/runs/${state.runId}`} className="text-sm underline">{state.agentName} run log</Link>
|
|
</div>
|
|
</div>;
|
|
}
|
|
const members = [item, ...evidence].filter(member => member.providerLimit && member.relatedIssue);
|
|
const tasks = [...new Map(members.map(member => [member.relatedIssue!.id, member])).values()];
|
|
const manual = tasks.filter(task => task.providerLimit!.state === "needs_retry");
|
|
const title = manual.length
|
|
? `${manual.length} ${manual.length === 1 ? "task needs" : "tasks need"} a retry after the usage limit`
|
|
: `${tasks.length} ${tasks.length === 1 ? "task paused" : "tasks paused"} by the provider usage limit`;
|
|
const taskLabel = (count: number) => count === 1 ? "task" : "tasks";
|
|
const scheduled = tasks.filter(task => task.providerLimit!.state === "scheduled");
|
|
const firstRetry = scheduled[0]?.providerLimit?.retryAt;
|
|
const sharedRetryAt = firstRetry && scheduled.every(task => task.providerLimit!.retryAt === firstRetry) ? firstRetry : null;
|
|
return <div className="space-y-3">
|
|
<h2>{title}</h2>
|
|
{state.resetAt && <p className="text-sm text-muted-foreground">Provider reset at <time dateTime={state.resetAt}>{formatDateTime(state.resetAt)}</time>.</p>}
|
|
{scheduled.length > 0 && <p className="text-sm text-muted-foreground">Retry scheduled for {scheduled.length} {taskLabel(scheduled.length)}
|
|
{sharedRetryAt && <> at <time dateTime={sharedRetryAt}>{formatDateTime(sharedRetryAt)}</time></>}.
|
|
</p>}
|
|
{!scheduled.length && !manual.length && <p className="text-sm text-muted-foreground">Retry requested. Waiting for work to resume.</p>}
|
|
{manual.length > 0 && <p className="text-sm text-muted-foreground">Open the affected task to retry it when capacity is available.</p>}
|
|
<details><summary className="cursor-pointer text-sm">View {tasks.length} {taskLabel(tasks.length)}</summary>
|
|
<ul className="mt-2 space-y-2">{tasks.map(member => {
|
|
const task = member.relatedIssue!;
|
|
const limit = member.providerLimit!;
|
|
return <li key={task.id} className="flex flex-wrap items-center gap-2 text-sm">
|
|
<Link to={task.href!} className="underline">{task.identifier} {task.title}</Link>
|
|
<span>{limit.agentName} · <RetryStatus limit={limit} /></span>
|
|
<Link to={`/agents/${limit.agentId}/runs/${limit.runId}`} className="underline">Run log</Link>
|
|
</li>;
|
|
})}</ul>
|
|
</details>
|
|
{manual.length === 1 && <Button size="sm" asChild><Link to={manual[0]!.relatedIssue!.href!}>Open task to retry</Link></Button>}
|
|
</div>;
|
|
}
|