mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-11-18 22:54:22 +01:00
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - A task that runs in a sandbox environment first gets a lease from the environment provider (for example Daytona) > - When the provider refuses the lease with a transient error (`environment_provider_unavailable`), Paperclip retries twice, after 30 s and 60 s > - After those two retries the task rests on "Retry when ready". A provider outage longer than about 90 s therefore needs a person to click Retry > - Recovery must just work, and the target for runs that need Retry is 0%. The fix must not multiply automatic runs into a crash loop > - This pull request adds a provider-outage wait after the fast retries. The task stays system-owned, one waiter per environment checks the provider on a capped backoff, and the other waiters continue by themselves once the provider gives out a lease again. A person gets Retry only after a 30-minute ceiling > - The benefit is that a provider outage of up to 30 minutes delays work instead of stranding it, without extra load on the provider ## Linked Issues or Issue Description Refs #22087 (it classifies Daytona connection errors as transient, so they reach this path). **What happened?** In a restart-chaos wave on 2026-11-17, the Daytona API host names did not resolve from 19:40:28Z to 19:52:17Z (182 `ENOTFOUND` errors for the API and proxy hosts). Tasks that started in that window failed with `environment_provider_unavailable`. The two bounded retries (30 s, then 60 s) ran inside the outage, so these tasks rested on "Retry when ready" and needed a person to continue them. **Expected behavior** Paperclip continues the task by itself when the provider is reachable again. The task shows that it waits for the provider. It shows no Retry. Only a long outage hands the task to a person, and then Retry works. **Steps to reproduce** 1. Make lease acquisition fail with a transient provider error (HTTP 502 or a connection errno) for longer than about 90 s. 2. Assign a task to an agent that uses that environment. 3. After the second automatic retry fails, the task is blocked with a Retry button, although the provider becomes available again later. ## What Changed - `server/src/services/environment-provider-wait.ts` (new): the `environment_provider_wait` retry lane. The delays are 1 min, 2 min, then 5 min. The lane stops at 30 minutes after the wait started, with at most 12 attempts. It also builds the task text "Waiting for "<environment name>" to come back. Paperclip continues this task automatically when it does." - `scheduleBoundedRetryForRun` (`heartbeat/retries.ts`): when a run fails with `environment_provider_unavailable` after the fast retries are spent, it schedules the next attempt in the wait lane. The retry context records the environment and the time the wait started. The time is kept across attempts. The lane is uncharged (`execution-recovery-attempt.ts`), so it does not spend the failure budget. Other lanes drop the wait context. - The environment orchestrator puts the environment id on `EnvironmentProviderUnavailableError`, and the setup-failure path saves it in `resultJson.environmentProvider`. - Run dispatch (`run-dispatch/adapters/environment-provider-wait.ts`, new): a due wait stays parked while an earlier waiter for the same environment is still in line or still acquiring its lease, and no lease was acquired in that environment since this waiter last failed. Parked waiters check again every 30 s. This uses database reads only, and it adds no work to the run start path. When a lease is acquired, the parked waiters are promoted in arrival order. The automatic-run brake then meters their starts as before. - The probe must be able to start. A queued earlier waiter blocks later waiters for only 60 s after promotion, and a running one only while it is still acquiring its lease (at most 10 minutes). If the probe's agent is busy, the next runnable waiter becomes the probe. A waiter past the 30-minute ceiling is never parked, so it makes its last attempt and the exhaustion path runs. - The notify-and-update mechanics of parking are in one helper, `parkScheduledRetryInTx` (`run-dispatch/adapters/scheduled-retry-park.ts`). The workspace-busy wait and the provider wait use it and only decide whether to park and until when. - UI: `IssueScheduledRetryCard` shows nothing for `environment_provider_wait` (as for `workspace_busy`). `IssueProperties` shows "Sandbox: Waiting for the provider" instead of the scheduled-retry picker. `IssueMonitorBanner` shows a steady "Waiting for the sandbox provider" with no countdown and no Check now. - Task presentation: a task in the wait lane is "working", system-owned, with no Retry, and shows the wait text. After the ceiling the existing path applies: the task is blocked with the system-owned notice and a Retry that works. The notice and the provider-failure text now say that Paperclip retried for 30 minutes. - The per-task transient cap, the automatic-run brake and the bounded fast retries are unchanged. ## Verification - `pnpm --filter @paperclipai/server exec vitest run src/__tests__/heartbeat-process-recovery.test.ts -t "transient sandbox provider refusal"` (embedded Postgres): - New: "resumes ten tasks by itself when a five-minute provider outage ends, one probe at a time and within the automatic-run brake". Ten tasks in one company share one environment. The provider refuses leases for 5 minutes of simulated time (the test shifts all stored timestamps). All ten tasks complete with no Retry. No task is blocked and no task offers Retry while it waits. At most one waiter per tick is refused by the provider. While the brake is open, at most one automatic start happens per tick. All ten finish within 5 minutes after the outage ends. Red on master: tasks become `blocked` after the fast retries. Green with this change. - New: "lets one waiter per environment probe the provider and releases the others once a lease is acquired". The second waiter stays parked while the first one is queued or running without a lease. It is promoted after a lease is acquired. Red without the park step, green with it. - Updated: "waits for the provider without a Retry, and offers a working Retry only after the 30-minute ceiling". After the fast retries the task is working with the wait text and no Retry. The backoff grows from 1 to 2 minutes. After the ceiling the task is blocked, Retry is offered, and Retry runs the task. - Updated: "rests a provider deadline that never clears on a working Retry, never on a board recovery action". It now reaches the ceiling first. - New: "lets the next waiter probe when the first waiter cannot start because its agent is busy" (red before, green after). - New: "hands a parked task to a person with a working Retry at the 30-minute ceiling even while the leader stays queued" (red before, green after). - `src/services/environment-provider-wait.test.ts`: backoff, ceiling and text. - UI: `IssueScheduledRetryCard.test.tsx` ("offers no Retry while the task waits for the sandbox provider to come back") and `IssueMonitorBanner.test.tsx` ("shows a steady provider wait with no countdown"). `pnpm check:token-gates` is clean. - Also run locally: `heartbeat/retries.test.ts`, `heartbeat/run-completion.test.ts` (all 163 tests pass; the file-level `afterAll` teardown timed out on this loaded machine), `task-interruption-query.test.ts`, `stranded-notice.test.ts`, `execution-recovery-attempt.test.ts`, `environment-provider-unavailable-error.test.ts`, `task-interruption-presentation.test.ts`, the automatic-run brake tests, and `src/modules/run-dispatch`. - Server `tsc --noEmit` passes. ## Risks - **Automatic-run volume:** while a provider is down, each environment has one waiter that calls the provider on the backoff (1, 2, then 5 minutes). The other waiters only read the database every 30 s. Before this change the volume was zero after the second retry, because the task waited for a person. The new volume per environment is at most about 8 provider calls in 30 minutes. It does not grow with the number of tasks. The automatic-run brake still opens after 5 consecutive provider refusals, and it limits the probe to one start per minute. - After the outage, waiting tasks start again as the brake allows (a probe, then a release ramp of 2, 4, 8 and more starts per minute). They do not all start at once. - A run that was in the old fast lane when this deploys continues in the new lane when its second retry fails. A run that is already blocked keeps its Retry. - No migration. The new fields are optional JSON in `resultJson` and `contextSnapshot`. ## Model Used - Claude Opus 5.5 (provider Anthropic, model ID `claude-opus-5-5`), with tool use and code execution in Claude Code. ## 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>
384 lines
15 KiB
TypeScript
384 lines
15 KiB
TypeScript
import { useMemo, useState } from "react";
|
|
import { Clock, X } from "lucide-react";
|
|
import type { Issue, IssueWorkProduct } from "@paperclipai/shared";
|
|
|
|
import { Button } from "@/components/ui/button";
|
|
import {
|
|
AlertDialog,
|
|
AlertDialogTrigger,
|
|
AlertDialogContent,
|
|
AlertDialogHeader,
|
|
AlertDialogTitle,
|
|
AlertDialogDescription,
|
|
AlertDialogFooter,
|
|
AlertDialogCancel,
|
|
} from "@/components/ui/alert-dialog";
|
|
import { InlineBanner } from "@/components/InlineBanner";
|
|
import { IssuePullRequestLinks } from "@/components/IssuePullRequestLinks";
|
|
import { getIssuePullRequests, pullRequestNeedsReview } from "@/lib/issue-pull-requests";
|
|
import { cn } from "@/lib/utils";
|
|
import {
|
|
areAutomaticMonitorChecksPaused,
|
|
canCheckIssueMonitorNow,
|
|
deriveMonitorState,
|
|
formatMonitorAbsolute,
|
|
formatMonitorEta,
|
|
useMonitorCountdown,
|
|
type DerivedMonitorState,
|
|
type MonitorDisplayState,
|
|
} from "@/lib/issue-monitor";
|
|
|
|
/** Matches the `Date | string` inputs accepted by the issue-monitor helpers. */
|
|
type MonitorDate = Date | string;
|
|
|
|
/**
|
|
* States in which the waiting-monitor surfaces (top banner + composer strip)
|
|
* are shown. `cleared` and `none` hide both surfaces entirely — see
|
|
* wireframe 04 (PAP-14557).
|
|
*/
|
|
const WAITING_STATES: readonly MonitorDisplayState[] = [
|
|
"scheduled",
|
|
"retrying",
|
|
"due-now",
|
|
"overdue",
|
|
];
|
|
|
|
export function isWaitingMonitorState(state: MonitorDisplayState): boolean {
|
|
return WAITING_STATES.includes(state);
|
|
}
|
|
|
|
export function hasVisibleMonitorSurface(issue: Issue): boolean {
|
|
const derived = deriveMonitorState(issue);
|
|
return isWaitingMonitorState(derived.state) && derived.nextCheckAt !== null;
|
|
}
|
|
|
|
export interface MonitorSurfaceCopy {
|
|
/** Prominent lead for the top banner, e.g. "Waiting on monitor — resumes in 2h 12m". */
|
|
bannerTitle: string;
|
|
/** Prominent lead for the composer strip, e.g. "Resumes in 2h 12m". */
|
|
stripTitle: string;
|
|
/** Muted detail line for the banner (absolute time carries a "(your time)" hint). */
|
|
bannerMeta: string[];
|
|
/** Muted detail line for the composer strip. */
|
|
stripMeta: string[];
|
|
/** `warning` (amber) once overdue, `info` (blue) while still on schedule. */
|
|
tone: "info" | "warning";
|
|
workspaceWait?: boolean;
|
|
pullRequestReview?: boolean;
|
|
automaticChecksPaused?: boolean;
|
|
checkUnavailable?: boolean;
|
|
executionWait?: boolean;
|
|
}
|
|
|
|
function capitalize(value: string): string {
|
|
return value.length === 0 ? value : `${value.charAt(0).toUpperCase()}${value.slice(1)}`;
|
|
}
|
|
|
|
/**
|
|
* Pure copy builder shared by the banner and the composer strip so both
|
|
* surfaces render one consistent copy system (see wireframe 04). Kept free of
|
|
* hooks/`Date.now()` so it is deterministic under test.
|
|
*/
|
|
export function buildMonitorSurfaceCopy(
|
|
derived: DerivedMonitorState,
|
|
now: MonitorDate,
|
|
scheduledRetryReason?: string | null,
|
|
pendingPullRequestReviews = 0,
|
|
issueStatus?: string,
|
|
hasActiveRun = false,
|
|
): MonitorSurfaceCopy | null {
|
|
if (!isWaitingMonitorState(derived.state) || !derived.nextCheckAt) return null;
|
|
|
|
if (derived.source === "monitor" && areAutomaticMonitorChecksPaused({ status: issueStatus })) {
|
|
const canCheckNow = canCheckIssueMonitorNow({ status: issueStatus }, derived.serviceName);
|
|
const hint = canCheckNow
|
|
? "This task is blocked. You can ask the agent to check now."
|
|
: "Resume this task to continue checking.";
|
|
return {
|
|
bannerTitle: "Automatic checks paused",
|
|
stripTitle: "Automatic checks paused",
|
|
bannerMeta: [hint],
|
|
stripMeta: [hint],
|
|
tone: "info",
|
|
automaticChecksPaused: true,
|
|
checkUnavailable: !canCheckNow,
|
|
};
|
|
}
|
|
|
|
if (derived.source === "scheduled-retry" && scheduledRetryReason === "environment_provider_wait") {
|
|
return {
|
|
bannerTitle: "Waiting for the sandbox provider",
|
|
stripTitle: "Waiting for the sandbox provider",
|
|
bannerMeta: ["The sandbox provider is unavailable. Work continues automatically when it is back."],
|
|
stripMeta: ["Work continues automatically when the sandbox provider is back."],
|
|
tone: "info",
|
|
workspaceWait: true,
|
|
};
|
|
}
|
|
|
|
if (derived.source === "scheduled-retry" && scheduledRetryReason === "workspace_busy") {
|
|
return {
|
|
bannerTitle: "Waiting for workspace",
|
|
stripTitle: "Waiting for workspace",
|
|
bannerMeta: ["Another task is using this workspace. Work starts automatically when it is available."],
|
|
stripMeta: ["Work starts automatically when the workspace is available."],
|
|
tone: "info",
|
|
workspaceWait: true,
|
|
};
|
|
}
|
|
|
|
const eta = formatMonitorEta(derived.nextCheckAt, now); // "in 2h 12m" | "due now" | "overdue by 18m"
|
|
const absolute = formatMonitorAbsolute(derived.nextCheckAt, {}, now); // local time, e.g. "Today, 4:08 PM"
|
|
const awaitingPullRequestReview = derived.source === "monitor" && derived.serviceName?.toLowerCase() === "github" && pendingPullRequestReviews > 0;
|
|
if (derived.source === "monitor" && hasActiveRun) {
|
|
const hint = "The check can start after the current run finishes saving its work.";
|
|
return {
|
|
bannerTitle: "Monitor waits for current run",
|
|
stripTitle: "Monitor waits for current run",
|
|
bannerMeta: [hint, `Scheduled for ${absolute} (your time)`],
|
|
stripMeta: [hint, `Scheduled for ${absolute}`],
|
|
tone: "info",
|
|
executionWait: true,
|
|
checkUnavailable: true,
|
|
pullRequestReview: awaitingPullRequestReview,
|
|
};
|
|
}
|
|
if (awaitingPullRequestReview) {
|
|
return {
|
|
bannerTitle: "Pull request review requested",
|
|
stripTitle: "Pull request review requested",
|
|
bannerMeta: [`Next check ${eta} · ${absolute} (your time)`],
|
|
stripMeta: [`Next check ${eta} · ${absolute}`],
|
|
tone: derived.state === "overdue" ? "warning" : "info",
|
|
pullRequestReview: true,
|
|
};
|
|
}
|
|
if (derived.source === "scheduled-retry" && scheduledRetryReason === "ai_connection_pool_wait") {
|
|
return {
|
|
bannerTitle: "Pool exhausted",
|
|
stripTitle: "Pool exhausted",
|
|
bannerMeta: [`Usage recheck ${eta} · ${absolute} (your time)`, "Tasks with a selected account keep it while waiting. Work resumes when usage permits."],
|
|
stripMeta: [`Usage recheck ${eta} · ${absolute}`, "Tasks with a selected account keep it while waiting."],
|
|
tone: "info",
|
|
};
|
|
}
|
|
|
|
const isScheduledRetryOnly = derived.source === "scheduled-retry";
|
|
|
|
let bannerTitle: string;
|
|
let stripTitle: string;
|
|
let statusHint: string | null = null;
|
|
switch (derived.state) {
|
|
case "scheduled":
|
|
case "retrying":
|
|
bannerTitle = isScheduledRetryOnly ? `Agent resumes ${eta}` : `Waiting on monitor — resumes ${eta}`;
|
|
stripTitle = `Resumes ${eta}`;
|
|
break;
|
|
case "due-now":
|
|
bannerTitle = isScheduledRetryOnly ? "Agent retry due now" : "Waiting on monitor — due now";
|
|
stripTitle = "Due now";
|
|
statusHint = "Checking momentarily…";
|
|
break;
|
|
case "overdue":
|
|
default:
|
|
bannerTitle = isScheduledRetryOnly ? `Agent retry ${eta}` : `Waiting on monitor — ${eta}`;
|
|
stripTitle = capitalize(eta);
|
|
statusHint = "Fires on next tick";
|
|
break;
|
|
}
|
|
|
|
const attemptLabel = derived.attemptCount >= 1 ? `Attempt ${derived.attemptCount}` : null;
|
|
const serviceLabel = derived.serviceName ? `Watching: ${derived.serviceName}` : null;
|
|
|
|
const bannerMeta = [statusHint, `${absolute} (your time)`, attemptLabel, serviceLabel].filter(
|
|
(piece): piece is string => Boolean(piece),
|
|
);
|
|
const stripMeta = [statusHint, absolute, attemptLabel, serviceLabel].filter(
|
|
(piece): piece is string => Boolean(piece),
|
|
);
|
|
|
|
return {
|
|
bannerTitle,
|
|
stripTitle,
|
|
bannerMeta,
|
|
stripMeta,
|
|
tone: derived.state === "overdue" ? "warning" : "info",
|
|
};
|
|
}
|
|
|
|
function useMonitorSurfaceCopy(issue: Issue, pendingPullRequestReviews: number, hasActiveRun: boolean): MonitorSurfaceCopy | null {
|
|
// `nextCheckAt` is stable for a given issue; derive once to seed the ticking
|
|
// countdown cadence, then re-derive against the live clock so the surfaces
|
|
// roll scheduled → due → overdue on their own.
|
|
const nextCheckAt = useMemo(() => {
|
|
const derived = deriveMonitorState(issue);
|
|
return derived.source === "monitor" && areAutomaticMonitorChecksPaused(issue) ? null : derived.nextCheckAt;
|
|
}, [issue]);
|
|
const now = useMonitorCountdown(nextCheckAt);
|
|
return useMemo(() => buildMonitorSurfaceCopy(deriveMonitorState(issue, now), now, issue.scheduledRetry?.scheduledRetryReason, pendingPullRequestReviews, issue.status, hasActiveRun), [issue, now, pendingPullRequestReviews, hasActiveRun]);
|
|
}
|
|
|
|
function CheckNowButton({
|
|
onCheckNow,
|
|
checkingNow,
|
|
reviewRequested = false,
|
|
}: {
|
|
onCheckNow: () => void;
|
|
checkingNow: boolean;
|
|
reviewRequested?: boolean;
|
|
}) {
|
|
return (
|
|
<Button
|
|
type="button"
|
|
variant="outline"
|
|
size="sm"
|
|
className="shrink-0 shadow-none"
|
|
onClick={onCheckNow}
|
|
disabled={checkingNow}
|
|
>
|
|
{checkingNow ? "Checking…" : reviewRequested ? "Check status" : "Check now"}
|
|
</Button>
|
|
);
|
|
}
|
|
|
|
function CancelMonitorButton({ onCancel }: { onCancel: () => Promise<unknown> }) {
|
|
const [open, setOpen] = useState(false);
|
|
const [pending, setPending] = useState(false);
|
|
const [error, setError] = useState<string | null>(null);
|
|
const cancel = async () => {
|
|
setPending(true);
|
|
setError(null);
|
|
try {
|
|
await onCancel();
|
|
setOpen(false);
|
|
} catch (err) {
|
|
setError(err instanceof Error ? err.message : "Unable to cancel the monitor. Try again.");
|
|
} finally {
|
|
setPending(false);
|
|
}
|
|
};
|
|
return (
|
|
<AlertDialog open={open} onOpenChange={(next) => { if (!pending) { setOpen(next); setError(null); } }}>
|
|
<AlertDialogTrigger asChild>
|
|
<Button type="button" variant="ghost" size="icon" className="absolute right-2 top-2" aria-label="Cancel monitor" title="Cancel monitor">
|
|
<X className="h-4 w-4" aria-hidden="true" />
|
|
</Button>
|
|
</AlertDialogTrigger>
|
|
<AlertDialogContent>
|
|
<AlertDialogHeader>
|
|
<AlertDialogTitle>Cancel monitor?</AlertDialogTitle>
|
|
<AlertDialogDescription>This removes the scheduled monitor check. The agent will no longer resume from this monitor. You can send a message to continue the task.</AlertDialogDescription>
|
|
</AlertDialogHeader>
|
|
{error ? <p role="alert" className="text-sm text-destructive">{error}</p> : null}
|
|
<AlertDialogFooter>
|
|
<AlertDialogCancel disabled={pending}>Keep monitor</AlertDialogCancel>
|
|
<Button type="button" variant="destructive" disabled={pending} onClick={() => void cancel()}>{pending ? "Cancelling…" : "Cancel monitor"}</Button>
|
|
</AlertDialogFooter>
|
|
</AlertDialogContent>
|
|
</AlertDialog>
|
|
);
|
|
}
|
|
|
|
export interface IssueMonitorSurfaceProps {
|
|
issue: Issue;
|
|
hasActiveRun?: boolean;
|
|
onCheckNow?: (() => void) | null;
|
|
checkingNow?: boolean;
|
|
workProducts?: IssueWorkProduct[] | null;
|
|
checkError?: string | null;
|
|
onCancelMonitor?: (() => Promise<unknown>) | null;
|
|
}
|
|
|
|
/**
|
|
* Pinned banner rendered between the issue title and description while a
|
|
* monitor is waiting. Replaces the description-area "Monitor scheduled" card
|
|
* for the waiting state (PAP-14557 decision 1) — the two never render at once.
|
|
*/
|
|
export function IssueMonitorBanner({
|
|
issue,
|
|
hasActiveRun = false,
|
|
onCheckNow = null,
|
|
checkingNow = false,
|
|
workProducts,
|
|
checkError,
|
|
onCancelMonitor,
|
|
}: IssueMonitorSurfaceProps) {
|
|
const reviews = getIssuePullRequests(workProducts).filter(pullRequestNeedsReview);
|
|
const copy = useMonitorSurfaceCopy(issue, reviews.length, hasActiveRun);
|
|
if (!copy) return null;
|
|
|
|
// A busy workspace is a transient system wait the user cannot act on. It stays
|
|
// a quiet status (composer strip, properties row), never a pinned notice.
|
|
if (copy.workspaceWait) return null;
|
|
|
|
const canCancel = onCancelMonitor && deriveMonitorState(issue).source === "monitor";
|
|
|
|
return (
|
|
<InlineBanner
|
|
tone={copy.tone}
|
|
icon={Clock}
|
|
title={copy.bannerTitle}
|
|
className={cn("relative my-3", canCancel && "pr-12")}
|
|
actions={onCheckNow && !copy.workspaceWait && !copy.checkUnavailable ? <CheckNowButton onCheckNow={onCheckNow} checkingNow={checkingNow} reviewRequested={copy.pullRequestReview} /> : null}
|
|
>
|
|
{canCancel ? <CancelMonitorButton key={issue.id} onCancel={onCancelMonitor} /> : null}
|
|
<div className="flex flex-col gap-2">
|
|
{copy.pullRequestReview ? <IssuePullRequestLinks products={reviews} /> : null}
|
|
<span>{copy.bannerMeta.join(" · ")}</span>
|
|
{checkError ? <p role="alert">{checkError}</p> : null}
|
|
</div>
|
|
</InlineBanner>
|
|
);
|
|
}
|
|
|
|
/**
|
|
* Slim, inline (not sticky) strip anchored directly above the reply composer.
|
|
* Mirrors the banner's monitor state and reminds the reader that replying wakes
|
|
* the agent early (PAP-14557 decisions 2 + wireframe 02).
|
|
*/
|
|
export function IssueMonitorComposerStrip({
|
|
issue,
|
|
hasActiveRun = false,
|
|
onCheckNow = null,
|
|
checkingNow = false,
|
|
workProducts,
|
|
checkError,
|
|
className,
|
|
}: IssueMonitorSurfaceProps & { className?: string }) {
|
|
const reviews = getIssuePullRequests(workProducts).filter(pullRequestNeedsReview);
|
|
const copy = useMonitorSurfaceCopy(issue, reviews.length, hasActiveRun);
|
|
if (!copy) return null;
|
|
|
|
return (
|
|
<div
|
|
role="note"
|
|
data-testid="issue-monitor-composer-strip"
|
|
className={cn("rounded-lg border border-border bg-muted/30 px-3 py-2", className)}
|
|
>
|
|
<div className="flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between">
|
|
<div className="flex min-w-0 items-start gap-2">
|
|
<Clock className={cn("mt-0.5 h-4 w-4 shrink-0", issue.displayStatus === "monitoring" ? "text-(--status-task-icon-monitoring)" : "text-muted-foreground")} aria-hidden="true" />
|
|
<div className="flex min-w-0 flex-col gap-2">
|
|
<div className="text-sm font-medium text-foreground">{copy.stripTitle}</div>
|
|
{copy.pullRequestReview ? <IssuePullRequestLinks products={reviews} /> : null}
|
|
<div className="text-xs text-muted-foreground">{copy.stripMeta.join(" · ")}</div>
|
|
</div>
|
|
</div>
|
|
{onCheckNow && !copy.workspaceWait && !copy.checkUnavailable ? <CheckNowButton onCheckNow={onCheckNow} checkingNow={checkingNow} reviewRequested={copy.pullRequestReview} /> : null}
|
|
</div>
|
|
{!copy.automaticChecksPaused ? (
|
|
<p className="mt-1.5 text-xs text-muted-foreground">
|
|
{copy.pullRequestReview && copy.executionWait
|
|
? "Review on GitHub while the current run finishes saving its work."
|
|
: copy.pullRequestReview
|
|
? "Review on GitHub, then check status to have the agent verify the result."
|
|
: copy.workspaceWait || copy.executionWait
|
|
? "You can keep sending instructions while the agent waits."
|
|
: "Sending a reply wakes the agent now — before the scheduled check."}
|
|
</p>
|
|
) : null}
|
|
{checkError ? <p role="alert" className="text-sm text-destructive">{checkError}</p> : null}
|
|
</div>
|
|
);
|
|
}
|