"use client"; import { useTranslation } from "react-i18next"; import { IconAlertTriangle } from "@tabler/icons-react"; import { useAppStore } from "@/components/state-provider"; import { formatRelative } from "@/lib/i18n/formats"; type LaunchWarningProps = { sessionId: string; }; function reasonKey(reason: string): string { switch (reason) { case "config": return "task:launchWarningReasonConfig"; case "timeout": return "task:launchWarningReasonTimeout"; case "host_key": return "task:launchWarningReasonHostKey"; case "auth": return "task:launchWarningReasonAuth"; case "network": return "task:launchWarningReasonNetwork"; default: return "task:launchWarningReasonUnknown"; } } /** * Renders the session.launch.warning event verbatim at the point the user * initiated the launch — never re-derives reachability from the settings * store slice, and never blocks or confirms the launch it describes. */ export function LaunchWarning({ sessionId }: LaunchWarningProps) { const { t } = useTranslation(); const entry = useAppStore((state) => state.launchWarning.bySessionId[sessionId]); if (!entry) return null; return (
{t("task:launchWarningTitle")}
{entry.host ? ({t("task:launchWarningHost", { host: entry.host })}
) : null}{entry.lastSuccessAt ? t("task:launchWarningLastSuccess", { age: formatRelative(entry.lastSuccessAt) }) : t("task:launchWarningNeverSucceeded")}
{t(reasonKey(entry.reason))}