Repository navigation
[web] Compact the page header's info block from four lines to two - #1475
Merged
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
After:
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 along-running instance reported
2562047h47m16.854s.humanizeDuration()showsthe 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
423dis unambiguous and still scans.The unset-ldflags case is handled.
versionandbuildTimestampare onlyset through
-ldflags, so a plaingo buildbinary (andtools/build.sh) hasneither, and the old template rendered an empty version plus a
Built atof0001-01-01 00:00:00 +0000 UTC. The tag and its tooltip are now droppedentirely 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
/linksURL and that page's own"All Links" heading.
Along the way,
headerTmplDatagets realstringandboolfields instead ofinterface{}, and losesRightDiv, unused since it was added.Notes
browser, so all of them pick this up.
titleattribute rather than the existing.tooltip/.tooltiptextpair, which has noposition: relativeon theanchor and only lands correctly in the short status-table cells it was
written for. Tradeoff:
titledoes not surface on touch devices, whichseemed acceptable for build metadata.
Testing
go test ./web/... ./internal/surfacers/probestatus/... ./probes/browser/artifacts/...passes; goldens in
header_test.goandtemplates_test.goupdated. AddedTestHumanizeDuration(unit boundaries, zero, negative/clock-skew, and thesaturated value the goldens depend on) and an unset-version/timestamp case to
TestHeaderData. Also verified against a locally built binary with real-ldflagsvalues, on /status and /alerts.