import type { AutopilotRecent } from "@rakazo/contracts"; import { t } from "./i18n"; /** "HH:MM" for autopilotUntil's time choice. */ export function autopilotTimeOfDay(date: Date): string { const pad = (value: number) => String(value).padStart(2, "0"); return `${pad(date.getHours())}:${pad(date.getMinutes())}`; } /** * One autopilot in the home list, like Today on web: how it ended or where it stands, and its step * count, or Paused when it waits on the user. */ export function autopilotSummary(autopilot: AutopilotRecent): { detail: string; trail: string } { const detail = autopilot.status === "finished" ? autopilot.result : autopilot.status === "paused" ? autopilot.pauseReason : autopilot.lastCheckpoint ? t("last: {latest}", { latest: autopilot.lastCheckpoint }) : null; const trail = autopilot.status === "paused" ? t("Paused") : autopilot.stepCount === 1 ? t("1 step") : t("{count} steps", { count: autopilot.stepCount }); return { detail: detail ?? "", trail }; }