mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-11-09 16:02:36 +01:00
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - The task page tells the user what an agent is doing and what needs their attention > - When another task uses the same workspace, the agent waits and Paperclip starts the work automatically > - A tester reported that the "Waiting for workspace" notice is not helpful, because the user cannot do anything about it > - On `master`, the task page shows this wait four times: a pinned top banner, a conversation banner, the composer strip and the Workspace property row > - This pull request removes the two banners and keeps the two quiet status surfaces > - The benefit is that a transient system wait no longer looks like something that needs the user ## Linked Issues or Issue Description Refs #19369 **What happened?** During new-user onboarding tests on Paperclip Cloud staging (Claude subscription path), the tester saw a "Waiting for workspace" notice and reported: "this isn't helpful and the user can't do anything about it." **Steps to reproduce** 1. Start work on a task while another task uses the same workspace. 2. Open the waiting task. 3. See the pinned "Waiting for workspace" banner under the title and a second "Waiting for workspace" banner in the conversation. **Expected behavior** A busy workspace is a transient system wait with no user action. It shows only as a quiet status on the task. It does not show as a banner or notice. **Investigation** - No server inbox, Needs-you item or activity entry is created for a workspace wait. The live-updates toast already skips `workspace_busy` (`LiveUpdatesProvider.tsx`), and the chat thread already hides the cancelled admission attempt. - The remaining notices are UI banners: `IssueMonitorBanner` (pinned top banner) and `IssueScheduledRetryCard` (conversation banner). - #19369 stopped showing resource waits as failed attempts, but it kept these banners. ## What Changed - `IssueMonitorBanner`: render nothing for a workspace wait. The composer strip still shows "Waiting for workspace" and "You can keep sending instructions while the agent waits." - `IssueScheduledRetryCard`: render nothing for `workspace_busy`. The Workspace property row still shows "Waiting for workspace". - `DESIGN.md`: add the rule that a busy-workspace wait is a quiet status only, never a pinned banner, conversation notice or toast. - Tests: replace the old "shows the banner" assertions with N-14 regression tests. ## Verification Red on `master` (`819420a60a`), test change only: ``` cd ui && npx vitest run src/components/IssueMonitorBanner.test.tsx src/components/IssueScheduledRetryCard.test.tsx × does not raise a pinned banner for a workspace wait the user cannot act on (N-14) 7ms ⎯⎯⎯⎯⎯⎯⎯ Failed Tests 2 ⎯⎯⎯⎯⎯⎯⎯ FAIL src/components/IssueMonitorBanner.test.tsx > IssueMonitorBanner / IssueMonitorComposerStrip rendering > does not raise a pinned banner for a workspace wait the user cannot act on (N-14) AssertionError: expected 'Waiting for workspaceAnother task is …' to be '' // Object.is equality FAIL src/components/IssueScheduledRetryCard.test.tsx > IssueScheduledRetryCard > raises no conversation notice for workspace contention the user cannot act on (N-14) AssertionError: expected 'Waiting for workspaceAnother task is …' to be '' // Object.is equality Tests 2 failed | 32 passed (34) ``` Green after the fix, same command: ``` Test Files 2 passed (2) Tests 34 passed (34) ``` Neighbouring suites: ``` cd ui && npx vitest run src/components/TaskChatThread.test.tsx src/pages/IssueDetail src/components/issue-properties src/lib/issue-monitor Test Files 7 passed (7) Tests 687 passed | 1 skipped (688) ``` - `pnpm check:token-gates`: all gates clean. - `tsc --noEmit -p ui`: no errors in the changed files. Local errors come only from unbuilt workspace packages (`@paperclipai/plugin-sdk/ui`, Storybook feature map). CI typecheck covers the full build. ## Risks - Low risk. UI-only change. Two banners no longer render for `workspace_busy`. Other scheduled-retry reasons (failures, pool exhaustion, continuations) are unchanged. - A long workspace wait now has no prominent notice. No actionable next step exists in the current data (the API does not name the task that holds the workspace). A persist-past-threshold escalation with a link to that task can follow when the data exists. ## Model Used - Claude Opus 5.5 (`claude-opus-5-5`), Anthropic, via Claude Code with tool use (shell, file edit, browser for read-only staging evidence). ## 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 - [ ] 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>
204 lines
8.0 KiB
TypeScript
204 lines
8.0 KiB
TypeScript
import { Clock, RotateCcw, AlertCircle, Loader2, CheckCircle2 } from "lucide-react";
|
|
import { Link } from "@/lib/router";
|
|
import { Button } from "@/components/ui/button";
|
|
import { cn, formatDateTime } from "@/lib/utils";
|
|
import { formatMonitorOffset } from "@/lib/issue-monitor";
|
|
import { formatRetryReason } from "@/lib/runRetryState";
|
|
import type { IssueScheduledRetry } from "@paperclipai/shared";
|
|
import { useRetryNowMutation, type RetryNowError } from "../hooks/useRetryNowMutation";
|
|
import { Badge } from "@/components/ui/badge";
|
|
import { describeError } from "@/api/errors";
|
|
|
|
const MAX_TURN_CONTINUATION = "max_turns_continuation";
|
|
|
|
function isContinuationReason(reason: string | null | undefined) {
|
|
return reason === MAX_TURN_CONTINUATION;
|
|
}
|
|
|
|
function shortRunId(runId: string | null | undefined) {
|
|
return typeof runId === "string" && runId.length >= 8 ? runId.slice(0, 8) : runId ?? "";
|
|
}
|
|
|
|
interface IssueScheduledRetryCardProps {
|
|
issueId: string | null | undefined;
|
|
scheduledRetry: IssueScheduledRetry | null | undefined;
|
|
}
|
|
|
|
export function IssueScheduledRetryCard({
|
|
issueId,
|
|
scheduledRetry,
|
|
}: IssueScheduledRetryCardProps) {
|
|
const retryNow = useRetryNowMutation(issueId);
|
|
|
|
if (!scheduledRetry || !issueId) return null;
|
|
if (scheduledRetry.status !== "scheduled_retry") return null;
|
|
|
|
// Workspace contention is a transient wait with nothing for the user to do.
|
|
// The composer strip and properties row carry the quiet status instead.
|
|
if (scheduledRetry.scheduledRetryReason === "workspace_busy") return null;
|
|
|
|
const continuation = isContinuationReason(scheduledRetry.scheduledRetryReason);
|
|
const dueAtIso = scheduledRetry.scheduledRetryAt
|
|
? new Date(scheduledRetry.scheduledRetryAt).toISOString()
|
|
: null;
|
|
const relative = dueAtIso ? formatMonitorOffset(dueAtIso) : null;
|
|
const absolute = scheduledRetry.scheduledRetryAt
|
|
? formatDateTime(scheduledRetry.scheduledRetryAt)
|
|
: null;
|
|
const reason = formatRetryReason(scheduledRetry.scheduledRetryReason);
|
|
const attempt =
|
|
typeof scheduledRetry.scheduledRetryAttempt === "number"
|
|
&& Number.isFinite(scheduledRetry.scheduledRetryAttempt)
|
|
&& scheduledRetry.scheduledRetryAttempt > 0
|
|
? scheduledRetry.scheduledRetryAttempt
|
|
: null;
|
|
|
|
const badgeLabel = continuation ? "Continuation scheduled" : "Retry scheduled";
|
|
const titleAction = continuation ? "Automatic continuation" : "Automatic retry";
|
|
let titleSuffix: string;
|
|
if (relative === "now") {
|
|
titleSuffix = "due now";
|
|
} else if (relative) {
|
|
titleSuffix = relative;
|
|
} else {
|
|
titleSuffix = "pending schedule";
|
|
}
|
|
const title = `${titleAction} ${titleSuffix}`;
|
|
|
|
const helperIdle = continuation
|
|
? "Pulls continuation forward immediately"
|
|
: "Pulls retry forward immediately";
|
|
const isError = retryNow.isError || retryNow.lastError !== null;
|
|
const isSuccessTransient = retryNow.isSuccess
|
|
&& (retryNow.data?.outcome === "promoted" || retryNow.data?.outcome === "already_promoted");
|
|
|
|
return (
|
|
<div
|
|
data-testid="issue-scheduled-retry-card"
|
|
className="mb-3 rounded-lg border border-blue-500/30 bg-blue-500/5 px-3 py-3"
|
|
>
|
|
<div className="flex flex-col gap-2 sm:flex-row sm:items-start sm:justify-between">
|
|
<div className="min-w-0 flex-1">
|
|
<div className="flex flex-wrap items-center gap-2 text-xs">
|
|
<Badge variant="outline" className="border-blue-500/30 bg-blue-500/10 text-blue-700 dark:text-blue-300">
|
|
<Clock className="h-3 w-3" aria-hidden="true" />
|
|
{badgeLabel}
|
|
</Badge>
|
|
{attempt !== null ? (
|
|
<span className="text-muted-foreground">Attempt {attempt}</span>
|
|
) : null}
|
|
{reason ? (
|
|
<span className="text-muted-foreground">{reason}</span>
|
|
) : null}
|
|
</div>
|
|
<div className="mt-1 text-sm font-medium text-foreground">{title}</div>
|
|
{(absolute || scheduledRetry.retryOfRunId) ? (
|
|
<div className="mt-0.5 text-xs text-muted-foreground">
|
|
{absolute ? <span>{absolute}</span> : null}
|
|
{absolute && scheduledRetry.retryOfRunId ? <span>{" · "}</span> : null}
|
|
{scheduledRetry.retryOfRunId ? (
|
|
<span>
|
|
Replaces run{" "}
|
|
<Link
|
|
to={`/agents/${scheduledRetry.agentId}/runs/${scheduledRetry.retryOfRunId}`}
|
|
className="font-mono text-foreground hover:underline"
|
|
>
|
|
{shortRunId(scheduledRetry.retryOfRunId)}
|
|
</Link>
|
|
</span>
|
|
) : null}
|
|
</div>
|
|
) : null}
|
|
{scheduledRetry.error ? (
|
|
<div className="mt-1 text-xs text-muted-foreground">
|
|
Last attempt failed: {scheduledRetry.error}{/[.!?]$/.test(scheduledRetry.error.trim()) ? "" : "."} Paperclip will retry automatically.
|
|
</div>
|
|
) : null}
|
|
{isError ? ( // query-error-ok: mutation result
|
|
|
|
<RetryErrorBand
|
|
error={retryNow.lastError}
|
|
onRetry={() => {
|
|
retryNow.reset();
|
|
retryNow.mutate();
|
|
}}
|
|
/>
|
|
) : null}
|
|
</div>
|
|
<div className="flex flex-col items-stretch gap-1 sm:items-end">
|
|
<Button
|
|
type="button"
|
|
variant="outline"
|
|
size="sm"
|
|
className="shrink-0 shadow-none"
|
|
onClick={() => retryNow.mutate()}
|
|
disabled={retryNow.isPending || isSuccessTransient}
|
|
data-testid="issue-scheduled-retry-card-retry-now"
|
|
>
|
|
{retryNow.isPending ? (
|
|
<span className="inline-flex items-center gap-1.5">
|
|
<Loader2 className="h-3.5 w-3.5 animate-spin" aria-hidden="true" />
|
|
Retrying…
|
|
</span>
|
|
) : isSuccessTransient ? (
|
|
<span className="inline-flex items-center gap-1.5">
|
|
<CheckCircle2 className="h-3.5 w-3.5" aria-hidden="true" />
|
|
{retryNow.data?.outcome === "already_promoted" ? "Already promoted" : "Promoted"}
|
|
</span>
|
|
) : (
|
|
<span className="inline-flex items-center gap-1.5">
|
|
<RotateCcw className="h-3.5 w-3.5" aria-hidden="true" />
|
|
Retry now
|
|
</span>
|
|
)}
|
|
</Button>
|
|
<span className="text-right text-xs text-muted-foreground sm:max-w-(--sz-12rem)">
|
|
{retryNow.isPending
|
|
? "Promoting scheduled retry"
|
|
: isSuccessTransient
|
|
? retryNow.data?.outcome === "already_promoted"
|
|
? "Already promoted — run starting"
|
|
: "Promoted — run starting"
|
|
: retryNow.data?.outcome === "waiting" && retryNow.data.scheduledRetry?.runId === scheduledRetry.runId
|
|
? retryNow.data.message
|
|
: helperIdle}
|
|
</span>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
);
|
|
}
|
|
|
|
interface RetryErrorBandProps {
|
|
error: RetryNowError | null;
|
|
onRetry: () => void;
|
|
className?: string;
|
|
}
|
|
|
|
export function RetryErrorBand({ error, onRetry, className }: RetryErrorBandProps) {
|
|
if (!error) return null;
|
|
return (
|
|
<div
|
|
className={cn(
|
|
"mt-2 flex items-start gap-2 rounded-md border border-rose-500/30 bg-rose-500/5 px-2 py-1.5 text-xs text-rose-700 dark:text-rose-300",
|
|
className,
|
|
)}
|
|
role="alert"
|
|
data-testid="issue-scheduled-retry-error-band"
|
|
>
|
|
<AlertCircle className="mt-0.5 h-3.5 w-3.5 shrink-0" aria-hidden="true" />
|
|
<div className="min-w-0 flex-1">
|
|
<div className="font-medium">Couldn't retry now</div>
|
|
<div className="mt-0.5 text-muted-foreground">{describeError({ status: error.status, body: { message: error.message } }).body}</div>
|
|
</div>
|
|
<button
|
|
type="button"
|
|
onClick={onRetry}
|
|
className="shrink-0 font-medium text-rose-700 hover:underline dark:text-rose-300"
|
|
>
|
|
Try again
|
|
</button>
|
|
</div>
|
|
);
|
|
}
|