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`}