import type { Issue, IssueBlockerStalledWakeContext } from "@paperclipai/shared"; import { useQueries } from "@tanstack/react-query"; import { AlertTriangle, RotateCcw } from "lucide-react"; import { Link } from "@/lib/router"; import { Button } from "@/components/ui/button"; import { issuesApi } from "../api/issues"; import { queryKeys } from "../lib/queryKeys"; import { createIssueDetailPath } from "../lib/issueDetailBreadcrumb"; import { useTaskRetry } from "../hooks/useTaskRetry"; import { describeError } from "../api/errors"; /** * Children and blockers of this task that stopped on a recovery action that * needs the board (for example, retries exhausted). The task's agent is woken * once per stall (`issue_blocker_stalled`); this lets the board see and act on * each one from here, with the child's own Retry, without opening it. */ export function StalledDependencyNotice({ stalled }: { stalled: IssueBlockerStalledWakeContext[] | null | undefined }) { // Most tasks have none: render nothing and read nothing. if (!stalled || stalled.length === 0) return null; return ; } function StalledDependencyList({ entries }: { entries: IssueBlockerStalledWakeContext[] }) { // The child's own task state decides whether Retry is offered, as on its page. const children = useQueries({ queries: entries.map(entry => { const ref = entry.stalledIssueIdentifier ?? entry.stalledIssueId; return { queryKey: queryKeys.issues.detail(ref), queryFn: () => issuesApi.get(ref) }; }), }); // The waiter's saved list refreshes only with the waiter. Once a child's own // refreshed state has moved on (its Retry started it, or it was unblocked), // drop it here rather than show a cleared stall. const rows = entries.map((entry, index) => ({ entry, child: children[index] })) .filter(({ entry, child }) => !child?.data || child.data.status === entry.stalledIssueStatus); if (rows.length === 0) return null; return (
{rows.length === 1 ? "A dependency needs the board" : `${rows.length} dependencies need the board`}
); } function StalledDependencyRow({ entry, child, readError, isFetching, refetch }: { entry: IssueBlockerStalledWakeContext; child: Issue | undefined; readError: Error | null; isFetching: boolean; refetch: () => void; }) { const ref = entry.stalledIssueIdentifier ?? entry.stalledIssueId; const retry = useTaskRetry(child); const canRetry = child?.interruption?.canRetry === true; // Same states as the task's own Retry (ExecutionBlockerNotice): a refused // request explains why, and a lost response can be retried. const failed = Boolean(retry.error) && !retry.optimistic && !retry.takingLonger; return (
  • {entry.relation === "child" ? "Child" : "Blocker"} {entry.stalledIssueIdentifier ?? "Task"} {entry.stalledIssueTitle} {entry.recoveryAction.nextAction ? ( {entry.recoveryAction.nextAction} ) : null} {readError && !child ? ( Could not load this task's state: {describeError(readError).body} ) : null} {failed ? ( {describeError(retry.error).body} ) : null} {retry.takingLonger ? ( Taking longer than usual… ) : null} {canRetry || failed || retry.takingLonger ? ( ) : null}
  • ); }