Skip to content

[web] Compact the page header's info block from four lines to two - #1475

Merged
manugarg merged 2 commits into
mainfrom
web-header-compact
Sep 7, 2026
Merged

manugarg merged 2 commits into
mainfrom
web-header-compact

Conversation

@manugarg

@manugarg manugarg commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

The block under the header rule carried Started, Version, Built at and Other
Links -- four lines of mostly cold metadata pushing the actual page content
down. Only two of those facts get read at a glance.

Before:

[cloudprober wordmark]
────────────────────────────────────────────────────────────
Started: 2026-09-07 11:36:48.498 -0700 PDT -- up 2562047h47m16.854s
Version: v0.14.5-23-gcecedded
Built at: 2026-09-07 11:36:46 -0700 PDT
Other Links (all): /status, /config (parsed | raw), /logs, /metrics, /alerts

After:

[cloudprober wordmark]
v0.14.5-23-gcecedded          ← title="Built at 2026-09-07 11:36:46 -0700 PDT"
────────────────────────────────────────────────────────────
Uptime: 5s                    ← title="Started 2026-09-07 11:36:48.498 -0700 PDT"
Links (all): /status, /config (parsed | raw), /logs, /metrics, /alerts

What changed

Version moves under the wordmark as a small grey tag, where it reads as part
of the identity rather than as a fourth status line. The build timestamp is
metadata about the version, not a peer of it, so it becomes that tag's
tooltip.

Uptime stays in the body, above the links -- it is the one live value in the
group, and burying it in a tooltip or shrinking it into the header corner made
it easy to miss. Its absolute start time moves into a tooltip.

Uptime is now readable. Go's Duration.String() stops at hours, so a
long-running instance reported 2562047h47m16.854s. humanizeDuration() shows
the two most significant units instead: 45s, 12m 30s, 4h 12m, 3d 4h.
Days are the largest unit on purpose -- a "year" is 365 or 365.25 days depending
on who is reading, while 423d is unambiguous and still scans.

The unset-ldflags case is handled. version and buildTimestamp are only
set through -ldflags, so a plain go build binary (and tools/build.sh) has
neither, and the old template rendered an empty version plus a Built at of
0001-01-01 00:00:00 +0000 UTC. The tag and its tooltip are now dropped
entirely in that case.

"Other Links" loses the "Other". It distinguished the links from the three
info lines above them; with those gone there is nothing left for them to be
other than. "Links" also matches both the /links URL and that page's own
"All Links" heading.

Along the way, headerTmplData gets real string and bool fields instead of
interface{}, and loses RightDiv, unused since it was added.

Notes

  • The header is shared by /status, /alerts, /logs, /config-* and the artifacts
    browser, so all of them pick this up.
  • Tooltips use the plain title attribute rather than the existing
    .tooltip/.tooltiptext pair, which has no position: relative on the
    anchor and only lands correctly in the short status-table cells it was
    written for. Tradeoff: title does not surface on touch devices, which
    seemed acceptable for build metadata.

Testing

go test ./web/... ./internal/surfacers/probestatus/... ./probes/browser/artifacts/...
passes; goldens in header_test.go and templates_test.go updated. Added
TestHumanizeDuration (unit boundaries, zero, negative/clock-skew, and the
saturated value the goldens depend on) and an unset-version/timestamp case to
TestHeaderData. Also verified against a locally built binary with real
-ldflags values, on /status and /alerts.

The block under the header rule carried Started, Version, Built at and
Other Links, four lines of mostly cold metadata pushing the actual page
content down. Only two of those facts get read at a glance.

Version moves under the wordmark as a small grey tag, where it reads as
part of the identity rather than as a fourth status line, and the build
timestamp -- metadata about the version, not a peer of it -- becomes its
tooltip. Uptime stays in the body, above the links, since it is the one
live value in the group.

The absolute start time moves into the uptime's tooltip, and the uptime
itself gets humanizeDuration(): Go's Duration.String() stops at hours,
so a long-running instance reported "2562047h47m16.854s". It now shows
the two most significant units, "3d 4h" or "12m 30s". Days are the
largest unit on purpose -- a "year" is 365 or 365.25 days depending on
who is reading, while "423d" is unambiguous and still scans.

Both facts are only set through -ldflags, so a plain "go build" binary
has neither, and the old template rendered an empty version and a "Built
at" of 0001-01-01. Drop the tag and the tooltip entirely in that case.

Finally, "Other Links" loses the "Other". It distinguished the links
from the three info lines above them; with those gone there is nothing
left for them to be other than, and "Links" matches both the /links URL
and that page's own "All Links" heading.

Also give headerTmplData real string and bool fields instead of
interface{}, and drop its RightDiv field, unused since it was added.
Three fixes from review, none user-visible on a Makefile build.

versionTitle was computed from the build timestamp alone, but the
template only renders it inside {{if .Version}}, so a build that set
buildTimestamp without version produced a title nothing could reach.
Guard on both, and add a test case pinning the behaviour: the tooltip
hangs off the version tag, so without a tag there is nowhere to put it.

The version tag carries a tooltip too but, unlike the uptime, got no
cursor affordance, leaving "Built at" undiscoverable on desktop. Key the
rule off [title] instead of the class, so it covers both and stays
silent when the timestamp was never set.

Finally, TestHumanizeDuration named its subtests after the expected
string, which is not unique -- "0s" appeared three times and "3d" twice,
so a failure reported 0s#02 and you had to count table rows to find the
input. Name them after the duration instead.
@manugarg
manugarg merged commit aec1db1 into main Sep 7, 2026
13 checks passed
@manugarg
manugarg deleted the web-header-compact branch September 7, 2026 22:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant