"use client"; // THE COOKIE REFRESH BANNERS (plans/cookie-refresh-alerts.md): one per service // whose cookies look stale — "Rumble needs fresh cookies: open rumble.com in // firefox" — with Recheck (one request through the service's own path) and // Dismiss; once the service answers cleanly again, "OK again" with Re-run for // the jobs it stopped. The dashboard's top slot, like the first-run checklist. // X's card also says how fresh its cookie jar is, read from disk (`data.x`). import Link from "next/link"; import { useState, useTransition } from "react"; import type { ServiceCookieAlertView, ServiceCookieAlertsPayload, XJarStatusView, } from "yt-dlp-transcript-common/lib/serviceCookies"; import { dismissServiceCookiesAction, recheckServiceCookiesAction, rerunServiceStoppedJobsAction, } from "../../operations/serviceCookiesActions"; const BUTTON = "rounded-md border border-border bg-card px-2.5 py-1 text-xs hover:bg-muted disabled:opacity-50"; function AlertCard({ alert, xJar, onChange, }: { alert: ServiceCookieAlertView; xJar?: XJarStatusView; onChange: () => void; }) { const [note, setNote] = useState<{ text: string; error: boolean } | null>(null); const [pending, start] = useTransition(); const stale = alert.state === "stale"; const act = (fn: () => Promise<{ ok: boolean; message?: string; error?: string }>) => start(async () => { setNote(null); const r = await fn(); setNote(r.ok ? { text: r.message ?? "", error: false } : { text: r.error ?? "Failed.", error: true }); onChange(); }); const channel = alert.evidence.channel; return (

{alert.headline}

{alert.compact ? ( <>

{alert.fix}

{alert.detail ? <>{alert.detail} · : null} Cookies

) : ( <>

{alert.detail} {alert.family === "forum" && channel && ( <> {alert.detail ? " · " : null} channel page )} {/* A separator only after something: no leading " · ". */} {alert.detail || (alert.family === "forum" && channel) ? " · " : null} Cookies

{alert.family === "x" && xJar && (

{xJar.summary}

)} {alert.evidence.line && ( {alert.evidence.line} )} )}
{stale && alert.canRecheck && ( )} {!stale && alert.stoppedJobs.length > 0 && ( )} {stale && ( )}
{note && (

{note.text}

)}
); } export function CookieAlertsPanel({ data, onChange, }: { data: ServiceCookieAlertsPayload; onChange: () => void; }) { if (data.alerts.length === 0) return null; return (
{data.alerts.map((a) => ( ))}
); }