);
}
function CheckGroupIcon({ kind }: { kind: CheckBucket }) {
if (kind === "passed") return ;
if (kind === "in_progress")
return ;
return ;
}
/** `kind` is the persisted CheckBucket; only the catalog key is copy. */
const BUCKET_LABEL_KEYS: Record = {
passed: "github:checkBucketPassed",
in_progress: "github:checkBucketInProgress",
failed: "github:checkBucketFailed",
};
function CheckGroupHeader({ kind, count }: { kind: CheckBucket; count: number }) {
const { t } = useTranslation();
const label = t(BUCKET_LABEL_KEYS[kind]);
return (
{label}
{count}
);
}
function PRWorkflowRow({
group,
onAddAsContext,
}: {
group: WorkflowGroup;
onAddAsContext: ((message: string) => void) | null;
}) {
const { t } = useTranslation();
// For an in-progress workflow, "0/1 ran" reads as "nothing finished"
// and confuses people: did it start? It's clearer to just report how
// many jobs are running. (Failed workflows go to a different bucket,
// so an in_progress group never has failed jobs.)
const badge =
group.bucket === "in_progress"
? `${group.inProgress} running`
: `${group.passed}/${group.total} passed`;
return (
);
}
/**
* Stacked progress bar mirroring TodoIndicator's bar but split into three
* segments — green (passed), yellow (in_progress), red (failed) — each
* sized proportionally to its count. The leading "pass rate" label gives
* the same at-a-glance number TodoIndicator shows ("6/10 (60%)").
*
* Skipped/cancelled-but-not-failed jobs aren't counted toward the total
* (they never enter any bucket), so the bar always reflects the actionable
* picture: how close are we to "all green".
*/
function PRChecksProgressBar({ counts }: { counts: CountsView }) {
const { t } = useTranslation();
const total = counts.passed + counts.inProgress + counts.failed;
if (total === 0) return null;
const pct = (n: number) => (n / total) * 100;
const passedPct = pct(counts.passed);
const inProgressPct = pct(counts.inProgress);
const failedPct = pct(counts.failed);
const completePct = Math.round(passedPct);
return (
);
}
function PRReviewRow({ pr }: { pr: TaskPR }) {
const required = pr.required_reviews ?? null;
const approved = pr.review_count;
const requested = pr.pending_review_count;
let label: string;
let icon: ReactNode;
if (pr.review_state === "approved") {
icon = ;
label = "Approved";
} else if (pr.review_state === "changes_requested") {
icon = ;
label = "Changes requested";
} else {
// Default branch covers "no reviews yet", "review pending", and any
// unknown state. Always rendered (no early-return) so a fresh PR
// still surfaces its review status.
icon = ;
label = "Awaiting review";
}
// Counts live on the right edge, mirroring the check-group rows.
// Use "K / M" when a required-minimum is known, otherwise just the
// approved count. The "(K requested)" suffix slides in when reviewers
// have been pinged but haven't submitted a review.
let countText: string;
if (required != null) countText = `${approved} / ${required}`;
else countText = `${approved}`;
if (requested > 0) countText += ` · ${requested} requested`;
return (
{icon}
{label}
{countText}
);
}
function PRCommentsRow({ pr }: { pr: TaskPR }) {
const { t } = useTranslation();
if (!pr.unresolved_review_threads || pr.unresolved_review_threads <= 0) return null;
return (
);
}
function elapsedLabel(
elapsed: number | null,
t: (k: string, v?: Record) => string,
): string {
if (elapsed == null) return "";
if (elapsed === 0) return t("github:updatedJustNow");
return t("github:updatedAgo", { elapsed: formatElapsedShort(elapsed) });
}
function PRPopoverFooter({
lastUpdatedAt,
isRefreshing,
}: {
lastUpdatedAt: number | null;
isRefreshing: boolean;
}) {
const { t } = useTranslation();
// Capture a "now" snapshot only inside the setInterval callback (an event
// handler — no impurity in render, no setState during commit). When no
// tick has fired yet, fall back to lastUpdatedAt so the rendered elapsed
// is 0 ("just now").
const [now, setNow] = useState(null);
useEffect(() => {
if (lastUpdatedAt == null) return;
const id = setInterval(() => setNow(Date.now()), 10_000);
return () => clearInterval(id);
}, [lastUpdatedAt]);
const elapsed =
lastUpdatedAt == null
? null
: Math.max(0, Math.floor(((now ?? lastUpdatedAt) - lastUpdatedAt) / 1000));
// The first open of a PR has no cache entry yet — that's the slowest fetch of
// all, so the footer has to exist for the spinner even with nothing to date.
if (lastUpdatedAt == null && !isRefreshing) return null;
return (