import { useState } from "react"; import { Link, useNavigate, useParams } from "react-router-dom"; import { MachineRuntimeAvailability } from "../components/MachineRuntimes"; import { formatRelative } from "../components/TaskDetailFields"; import { Button } from "../components/ui/button"; import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle } from "../components/ui/dialog"; import { useDeleteMachine, useMachine } from "../hooks/useMachines"; const statusDotColors: Record = { online: "bg-success", offline: "bg-content-tertiary", }; export function MachineDetailPage() { const { id } = useParams<{ id: string }>(); const navigate = useNavigate(); const { machine, loading } = useMachine(id); const deleteMachine = useDeleteMachine(); const [showDeleteDialog, setShowDeleteDialog] = useState(false); const [showReconnect, setShowReconnect] = useState(false); async function handleDelete() { if (!id) return; await deleteMachine.mutateAsync(id); navigate("/machines"); } if (loading) { return (
); } if (!machine) { return (

Machine not found.

); } const isOffline = machine.status === "offline"; const apiUrl = window.location.origin; const runtimes = machine.runtimes || []; const usageWindows = machine.usage_info?.windows ?? []; return (
{/* Breadcrumb */}
Machines / {machine.name}
{/* Machine header */}

{machine.name}

{machine.status}
{/* Machine summary */}
OS {machine.os || "—"}
Version {machine.version || "—"}
Last Heartbeat {machine.last_heartbeat_at ? formatRelative(machine.last_heartbeat_at) : "—"}
Created {formatRelative(machine.created_at)}
Sessions {machine.session_count}
Active {machine.active_session_count}
{/* Offline reconnect */} {isOffline && (
Machine is offline

Restart the daemon on this machine to bring it back online.

)} {/* Runtime availability */}
Runtime Availability {machine.usage_info?.updated_at ? `Usage updated ${formatRelative(machine.usage_info.updated_at)}` : ""}
{/* Agents on this machine */}
Agents ({(machine.agents || []).length})
{(machine.agents || []).length === 0 ? (

No agents registered on this machine.

) : (
{(machine.agents || []).map((agent: any) => ( 0 ? "border-accent/30 shadow-[0_0_16px_rgba(34,211,238,0.06)]" : "border-border" }`} >
{agent.name.slice(0, 2).toUpperCase()}
{agent.name}
0 ? "bg-accent animate-pulse-glow" : "bg-content-tertiary"}`} /> {agent.active_session_count || 0} active sessions
{agent.last_session_at ? formatRelative(agent.last_session_at) : "—"} ))}
)}
{/* Danger zone */}
Danger Zone

Revoke this machine's API key and remove it from the workspace.

{/* Reconnect dialog */} Reconnect {machine?.name} Run this command to reconnect:
              {`ak start --api-url ${apiUrl}`}
            
{/* Delete confirmation dialog */} Delete Machine This will revoke the API key for {machine.name}. The daemon will stop authenticating and any running agents will lose access.
); }