{{define "awaiting_agent"}} {{$page := .Page}} {{/* Polled status fragment for the Add-host pending page. Wrapper carries the HTMX poll trigger only while State == "awaiting" — state == "connected" or "expired" both stop polling. The wrapper is what HTMX swaps via hx-swap=outerHTML, so the trigger getting removed is what stops the loop. */}}
{{if eq $page.State "connected"}}
Agent connected
{{$page.HostName}} — enrolled, online{{if $page.LastSeenAt}}, last heartbeat {{relTime $page.LastSeenAt}}{{end}}
{{else if eq $page.State "expired"}}
Token expired

The 1-hour window has elapsed without the agent connecting. Mint a fresh token and run the new install command.

{{else}}
Awaiting agent connection
— polling every 2s; this page redirects to the host detail when enrolment lands.
token expires {{relTime $page.ExpiresAt}}
awaiting POST /api/agents/enroll …
{{end}}
{{end}}