import { useMemo } from "react"; import type { MachineState } from "@opengeni/sdk"; import type { SessionCapabilitiesState } from "./use-session-capabilities"; import { sandboxAcceptsLiveIo } from "../lib/sandbox-liveness"; import { connectionStatusForState } from "../types/machines"; import { useOpenGeniText, type OpenGeniText } from "../messages/runtime"; /** The one truthful machine indicator. Managed cold compute is sleeping; a * Connected Machine that is genuinely unreachable remains offline. */ export type MachineChipState = "live" | "waking" | "offline"; export type MachineChip = { state: MachineChipState; /** A ready-to-render label ("Live" / "Waking…" / "Sleeping · saved 3m ago"). */ label: string; /** The capture time backing an offline/stale label (ISO), or null. M4 may * reformat this; `label` already embeds a relative form. */ asOf: string | null; }; export type DeriveMachineChipInput = { /** `capabilities.liveness` — "warm" | "draining" | "cold" (or null pre-negotiation). */ liveness?: string | null | undefined; /** `useSessionCapabilities().state` — drives the "waking" (negotiating) read. */ capabilitiesState?: SessionCapabilitiesState | null | undefined; /** The ACTIVE machine's connection state (from `useMachines`), when known. A * self-hosted machine that is `offline` cannot be remotely woken. */ activeMachineState?: MachineState | null | undefined; /** Whether the active sandbox is a user-owned self-hosted machine (no remote wake). */ activeIsSelfhosted?: boolean | undefined; /** An interaction (wake-on-edit, terminal focus) is actively warming the box. */ wantsWarm?: boolean | undefined; /** The latest capture's `capturedAt` (ISO) — the "as of