Asking for a cluster and building it were two clicks on two pages,
with the record sitting at "requested" in between. Nobody wants the
record; they want the cluster. Creating it now starts the build and
opens the log. A portal with no provisioner still just records the
request - that is all it can do - and lands on the list instead, and
a build that fails to start does the same rather than showing an
error page about a cluster that is nonetheless there.
The log used to be a text endpoint you reloaded, which is the same
information by a worse route: the interesting moment is usually the
one you reloaded past. /clusters/watch follows it as it is written
and stops on its own when the cluster stops moving.
It polls rather than streams. A build is one writer appending to one
file, and asking for the bytes after the ones you already have is the
whole of what server-sent events would give here, without a
long-lived connection to keep alive through Caddy and the proxy.
?from=N is what makes that cheap: a Terraform log reaches a few
hundred kilobytes, and re-sending all of it every two seconds to
append one line is most of a megabyte a minute for nothing. An offset
past the end means a rebuild truncated the file, so the reader starts
again rather than waiting for bytes that will never come.
X-Cluster-State is read from the record, not guessed from the log's
last line: a build that was killed writes no last line at all. The
script backs off to five seconds while nothing is happening, and
keeps the view pinned to the bottom only while the reader is already
there - scrolling up to read something is deliberate, and yanking the
view back down two seconds later undoes it.
The script is a file rather than an inline block because the control
plane's Content-Security-Policy is script-src 'self', and loosening
that for a log viewer would be the wrong trade.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>