evOo-local/apps/mobile/lib/autopilot.ts
cynarAI ca57ebda85
feat(mobile): pick a time for the autopilot and see the night on home (#147)
The attach sheet's autopilot now offers "Until a time" with the native
time picker from Expo UI: Android's clock dialog, an iOS wheel in a sheet
with Start. The home list opens with the autopilots that run, wait or
ended within a day, as Today does on web, and each row opens its thread.
The attach and until menus move to the shared action sheet, so Android
pages them instead of dropping buttons past three.


Claude-Session: https://claude.ai/code/session_01UmSCnoCgXqBp2fU3vwz4o1

Co-authored-by: Claude <noreply@anthropic.com>
2026-10-05 05:35:47 +02:00

31 lines
1.1 KiB
TypeScript

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