From 082244c9de7bdef45b3778241b5ee01840d816ca Mon Sep 17 00:00:00 2001 From: Andrew Anderson Date: Thu, 29 Oct 2026 15:30:06 -0400 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20hub:=20wrap=20the=20spoke=20Vers?= =?UTF-8?q?ion=20column=20so=20the=20table=20fits?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The Assigned hives table's Version column rendered its pieces on unwrapped nowrap lines (channel pill, SHA/behind/drift, a long 'behind by N · next check … · why not now: …' badge, Upgrade now, the progress pill with the drain agents or missed-window reason inline, the interrupt action, the history chip and the auto-upgrade select), so the column measured ~1300px and pushed Repos/Maturity and later columns off a 1600px screen. Bound the td (min 14rem / max 22rem, white-space normal, overflow-wrap anywhere) and lay the cell out as two wrapping flex lines: identity (channel · SHA · behind · drift) and status + actions. Long explanations move into hover titles. Apply the same bound to the Repos cell so the 'as: ' line wraps, and tighten horizontal cell padding one step. At 1600x900 the table now fits its container (1426px, no scroll) with the Version column at 232px instead of 1307px. Signed-off-by: Andrew Anderson --- changelog.d/fixed-hub-version-column-wrap.md | 1 + src/docs/operator-reference.md | 2 +- src/pkg/hub/assets/dashboard.html | 95 +++++++---- src/pkg/hub/upgrade_affordance_ux_test.go | 2 +- src/pkg/hub/version_column_stack_test.go | 164 ++++++++++++++----- 5 files changed, 188 insertions(+), 76 deletions(-) create mode 100644 changelog.d/fixed-hub-version-column-wrap.md diff --git a/changelog.d/fixed-hub-version-column-wrap.md b/changelog.d/fixed-hub-version-column-wrap.md new file mode 100644 index 0000000000..4f0b2f2bc3 --- /dev/null +++ b/changelog.d/fixed-hub-version-column-wrap.md @@ -0,0 +1 @@ +- hub: the Assigned hives table's Version column is now width-bounded and wraps as a two-line block (channel · SHA · behind · drift / status · actions · auto-upgrade select); the "why not now", drain-agents and missed-window explanations moved to hover titles, the Repos "as:" line wraps, and cell side padding tightened, so the table fits a 1600px viewport without horizontal scroll. diff --git a/src/docs/operator-reference.md b/src/docs/operator-reference.md index 8610f1725a..6d4acfd017 100644 --- a/src/docs/operator-reference.md +++ b/src/docs/operator-reference.md @@ -1264,7 +1264,7 @@ A hub-instructed upgrade is a short state machine, and both dashboards expose it **History.** The hub persists the last `HIVE_HUB_UPGRADE_HISTORY_MAX` (default 14) attempts and held windows per hive under `/data/saas/upgrade-history/.json`, so they survive a hub restart. Each row carries `target`, `from`, `trigger` (`scheduled` / `instant` / `manual` / `observed` / `window`), `startedAt`, `endedAt`, `outcome` (`done` / `missed`) and `reason`. A daily window the gate held records exactly one `window` row per calendar day (ET), updated in place if the hold reason changes; a window that fired records the attempt instead. Deleting a hive drops its history. -**Where it shows.** On the hub, the hive card's Version cell gains a pill for the `draining`, `pulling`, `rolling`, `verifying` and `missed` states — `Draining · 2/5 agents in turn: reviewer 38m, scanner 12m · 14m left` — and a `history` badge whose tooltip lists the recent attempts (it turns red and counts the misses when any are present); a quiet `scheduled` row renders as before. On the spoke, `/api/version` carries the same `upgradeProgress` and `upgradeHistory`, and the operator dashboard's version menu shows a **Progress** row with the pill and an **Upgrade history** list; the header chip adds a `Draining 14m` / `Missed window` pill while either state holds. +**Where it shows.** On the hub, the hive card's Version cell gains a pill for the `draining`, `pulling`, `rolling`, `verifying` and `missed` states — `Draining · 14m left`, with the agents still in turn (`2/5 agents in turn: reviewer 38m, scanner 12m`) or a missed window's reason in the pill's hover title so the Version column stays narrow — and a `history` badge whose tooltip lists the recent attempts (it turns red and counts the misses when any are present); a quiet `scheduled` row renders as before. On the spoke, `/api/version` carries the same `upgradeProgress` and `upgradeHistory`, and the operator dashboard's version menu shows a **Progress** row with the pill and an **Upgrade history** list; the header chip adds a `Draining 14m` / `Missed window` pill while either state holds. **Upgrade now (interrupt turns).** While a hive is `draining` or `missed`, its owner sees an *Upgrade now (interrupt turns)* action on the hub card. It is the ordinary upgrade request — `POST /api/saas/hives/{id}/upgrade?interrupt=1`, same owner/admin check as every other hub mutation — with an interrupt flag the hub audit-logs (`audit: hosted hive upgrade requested … interrupt_turns=true`), records on the hive timeline, and hands to the spoke on the next heartbeat (`upgrade_interrupt: true` beside `upgrade_to`). The spoke then skips the drain and restarts at once; the agents listed as in-turn are cut and their owners must re-run those turns. The request is held in hub memory for 2 hours and cleared when the upgrade closes, so a stale interrupt never cuts a later upgrade's turns; a hub restart drops it (the spoke falls back to draining). While it is armed the card shows `interrupt requested` instead of the action. diff --git a/src/pkg/hub/assets/dashboard.html b/src/pkg/hub/assets/dashboard.html index 9de5657ee0..7ba7a93a6c 100644 --- a/src/pkg/hub/assets/dashboard.html +++ b/src/pkg/hub/assets/dashboard.html @@ -275,8 +275,11 @@ .ws-badge--github_projects { background:#1a3a5c; color:#58a6ff; } .ws-badge--linear { background:#2d1b69; color:#a78bfa; } .ws-badge--jira { background:#0052cc; color:#fff; } - .hive-table th { text-align: center; padding: 10px 12px; border-bottom: 2px solid var(--line); color: var(--muted); font-weight: 600; font-size: var(--fs-sm); white-space: nowrap; text-transform: uppercase; letter-spacing: 0.5px; } - .hive-table td { padding: var(--sp-5); border-bottom: 1px solid #ffffff0a; vertical-align: middle; text-align: center; } + .hive-table th { text-align: center; padding: 10px var(--sp-4); border-bottom: 2px solid var(--line); color: var(--muted); font-weight: 600; font-size: var(--fs-sm); white-space: nowrap; text-transform: uppercase; letter-spacing: 0.5px; } + /* Horizontal cell padding is one step tighter than vertical: with 14 + columns, 4px a side is ~110px of table width, the difference between + the fleet table fitting a 1600px viewport and scrolling sideways. */ + .hive-table td { padding: var(--sp-5) var(--sp-4); border-bottom: 1px solid #ffffff0a; vertical-align: middle; text-align: center; } .hive-table td:first-child { text-align: left; } /* Zebra striping: a subtle alternating shade on every OTHER hive row so the eye can track one hive's cells straight across the wide table. Keyed off a @@ -675,6 +678,18 @@ .nps-admin-response-text { font-size: var(--fs-sm); color: var(--text); white-space: pre-wrap; overflow-wrap: anywhere; margin-top: var(--sp-2); } .upgrade-ctl[aria-disabled="true"] { cursor: not-allowed !important; opacity: 0.5; pointer-events: auto; } .version-missing { font-size: var(--fs-2xs); white-space: nowrap; color: var(--muted); } + /* Version column: bounded width, wrapping content. The cell is a two-line + block (identity / status+actions); each line is a wrapping flex row so + a long status folds inside the column instead of widening it, and + SHAs/long words may break anywhere. Individual pills keep their own + nowrap so a chip never splits mid-label. */ + .hive-table td.version-cell { min-width: 14rem; max-width: 22rem; white-space: normal; overflow-wrap: anywhere; } + .version-stack { display: inline-flex; flex-direction: column; align-items: center; gap: var(--sp-1); max-width: 100%; } + .version-line { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: var(--sp-1) var(--sp-2); white-space: normal; max-width: 100%; } + .version-line .upgrade-progress-history, .version-line .upgrade-progress-interrupt { margin-left: 0; } + /* Repos column: the "as: " line and host pill wrap inside a + bounded width rather than stretching the column. */ + .hive-table td.repos-cell { max-width: 12rem; white-space: normal; overflow-wrap: anywhere; } /* Scheduled-upgrade progress pill, history badge and interrupt action on the hive card's Version cell (#14950). */ .upgrade-progress-pill { display: inline-block; padding: var(--sp-1) var(--sp-3); border-radius: var(--r-pill); font-size: var(--fs-2xs); background: var(--surface); color: var(--muted); border: 1px solid var(--border); white-space: nowrap; font-variant-numeric: tabular-nums; } @@ -8976,13 +8991,19 @@

interrupt requested'; - /* The progress pill shares the upgrade line so the cell keeps its - one-element-per-line shape (TestVersionCellPutsEachElementOnItsOwnLine). */ + /* The progress pill and its interrupt action share the status line + with the queued badge and Upgrade now. */ if (upgradeProgressLine) upgradeIcon = upgradeIcon ? upgradeIcon + ' ' + upgradeProgressLine : upgradeProgressLine; - versionCell = '
' + - '
' + branch + '
' + - '
' + shaLine + '
' + - (upgradeIcon ? '
' + upgradeIcon + '
' : '') + - (autoUpgradeCheck ? '
' + autoUpgradeCheck + '
' : '') + + /* TWO wrapping lines inside a width-bounded block (see .version-stack): + 1. identity — the channel/branch pill, the running SHA with its + current/behind glyph, the behind chip and the drift count; + 2. status + actions — one short state badge, Upgrade now, the + progress pill, Upgrade now (interrupt turns), the history chip + and the auto-upgrade select. + Each line is a wrapping flex row, so a crowded status line folds + onto a third visual row INSIDE the column instead of pushing the + column wider. Long explanations ("why not now", the missed-window + reason, the agents holding a drain) live in the badges' hover + titles, never inline. Line 2 is omitted for a viewer with neither + an action nor a select, so a read-only row stays one line tall. */ + var statusLine = (upgradeIcon || '') + (autoUpgradeCheck ? ' ' + autoUpgradeCheck : ''); + versionCell = '
' + + '
' + branch + ' ' + shaLine + '
' + + (statusLine ? '
' + statusLine + '
' : '') + '
'; /* No version reported, but drift can still exist (e.g. heartbeat-stale on a spoke too old to report a SHA) — surface the dot beside the dash so @@ -9273,7 +9294,7 @@

' + versionCell + '' + + '' + versionCell + '' + /* Repo count over the GitHub-instance pill: the host qualifies WHICH GitHub these repos live on, so the two belong together. Stacked rather than inline to keep the numeric column narrow. */ @@ -9284,11 +9305,11 @@

[bot]", else empty); a hive with no usable GitHub App renders "—", never a stale personal ai_author it can't act as. Prefixed "as:" so the line reads as the authoring identity, not another repo. */ - '' + + '' + '
' + '
' + repoCount + '
' + '
' + githubHostPill(hiveForgeHost(h)) + '
' + - '
as: ' + esc(h.aiAuthorEffective || '—') + '
' + + '
as: ' + esc(h.aiAuthorEffective || '—') + '
' + '
' + '' + /* MATURITY: the ACMM level badge and the Journey status stacked into @@ -9966,15 +9987,21 @@

' + esc(label + extra) + ''; var action = ''; if (canAct && (st.state === 'draining' || st.state === 'missed')) { diff --git a/src/pkg/hub/upgrade_affordance_ux_test.go b/src/pkg/hub/upgrade_affordance_ux_test.go index 1b6c2b7804..c444e01458 100644 --- a/src/pkg/hub/upgrade_affordance_ux_test.go +++ b/src/pkg/hub/upgrade_affordance_ux_test.go @@ -25,7 +25,7 @@ import ( func TestQueuedStateSplitsBadgeFromUpgradeNowAction(t *testing.T) { body := funcBody(t, "var buildRow = function(") for _, want := range []string{ - "var queuedLabel = behindLabel + ' · ' + nextCheck + ' · why not now: ' + whyNotNow;", + "var queuedLabel = behindLabel + ' · ' + nextCheck;", "var whyNotNow = h.upgradeWhyNotNow || (queuedDaily ? 'daily schedule' : 'waiting for idle/health gates');", // The badge is affordance-free: styled by the shared state-badge // constant, with no role/onclick of its own. diff --git a/src/pkg/hub/version_column_stack_test.go b/src/pkg/hub/version_column_stack_test.go index f7035fd4a9..ee217c2fbe 100644 --- a/src/pkg/hub/version_column_stack_test.go +++ b/src/pkg/hub/version_column_stack_test.go @@ -5,19 +5,22 @@ import ( "testing" ) -// The Version column in the My Hives table stacks its contents ONE ELEMENT PER -// LINE. That constraint is the whole point of the layout and it is invisible to -// the compiler: putting two controls back on one line would silently restore -// the wide column these tests exist to prevent, because a column is as wide as -// its widest line. +// The Version column in the My Hives table is a WIDTH-BOUNDED, WRAPPING +// two-line block: line 1 is the identity (channel pill, running SHA, behind +// chip, drift count), line 2 the status badge plus every action and the +// auto-upgrade select. Each line is a wrapping flex row inside a td whose +// width is capped by CSS, so a long status folds onto a second visual row +// instead of widening the column. Before this layout the column rendered its +// pieces on unwrapped nowrap lines and measured ~1300px, pushing the Repos, +// Maturity and later columns off a 1600px screen. // -// The behavioural proof — that all four lines render and every control still -// fires — is driven in jsdom against the real dashboardHTML. These tests guard -// the structure that proof depends on, so a later edit cannot quietly undo it. +// The compiler cannot see any of this: a later edit that drops the class, the +// bound or the wrap would silently restore the wide column. These tests guard +// the structure. -// versionCellExpr isolates the expression that assembles the stacked Version -// cell, so the assertions below cannot be satisfied by an unrelated part of the -// 13k-line dashboard string. +// versionCellExpr isolates the expression that assembles the Version cell, so +// the assertions below cannot be satisfied by an unrelated part of the +// dashboard string. func versionCellExpr(t *testing.T) string { t.Helper() const start = "var shaLine = " @@ -33,48 +36,129 @@ func versionCellExpr(t *testing.T) string { return dashboardHTML[i : i+j] } -// Four separate lines, each wrapping exactly one thing. The upgrade affordance -// and the auto-upgrade select must NOT share a line: that pairing is what made -// #2200's three-line stack fail to narrow the column at all. -func TestVersionCellPutsEachElementOnItsOwnLine(t *testing.T) { +// The cell is two classed, wrapping lines: identity and status. The pieces +// must land on the right line and no line may be an inline nowrap flex row +// (STACKED_LINE_STYLE), which is what made the column as wide as its longest +// status string. +func TestVersionCellIsTwoWrappingLines(t *testing.T) { expr := versionCellExpr(t) - - // Each of the four must appear inside its own STACKED_LINE_STYLE wrapper. for _, frag := range []string{ - `'
' + branch + '
'`, - `'
' + shaLine + '
'`, - `'
' + upgradeIcon + '
'`, - `'
' + autoUpgradeCheck + '
'`, + `'
'`, + `'
' + branch + ' ' + shaLine + '
'`, + `'
' + statusLine + '
'`, + `var statusLine = (upgradeIcon || '') + (autoUpgradeCheck ? ' ' + autoUpgradeCheck : '');`, } { if !strings.Contains(expr, frag) { - t.Errorf("the Version cell does not wrap each element in its own line; missing:\n %s", frag) + t.Errorf("the Version cell is not the two-line wrapping block; missing:\n %s", frag) } } + if strings.Contains(expr, "STACKED_LINE_STYLE") { + t.Error("the Version cell still uses STACKED_LINE_STYLE (white-space:nowrap); " + + "a nowrap line makes the column as wide as its longest status string") + } +} - // The regression guard proper: the two controls must never be concatenated - // into a single line variable again. - for _, bad := range []string{ - "upgradeIcon + autoUpgradeCheck", - "autoUpgradeCheck + upgradeIcon", - } { - if strings.Contains(expr, bad) { - t.Errorf("the upgrade affordance and the auto-upgrade select share a line (%q); "+ - "the column is then as wide as the PAIR and the stacking buys nothing", bad) +// The status line is conditional: a read-only viewer has neither an action +// nor a mode select and must get a one-line cell, not a blank second row. +func TestVersionCellOmitsEmptyStatusLine(t *testing.T) { + expr := versionCellExpr(t) + if !strings.Contains(expr, "(statusLine ?") { + t.Error("the Version cell emits the status line unconditionally; a non-owner would get a blank line") + } +} + +// The td carries the class the width bound hangs on, and the CSS actually +// bounds and wraps it. Without the max-width the flex-wrap never triggers; +// without white-space:normal the inherited nowrap wins. +func TestVersionColumnIsWidthBoundedAndWraps(t *testing.T) { + html := dashboardHTML + if !strings.Contains(html, `'' + versionCell + ''`) { + t.Error("the Version lost the version-cell class the width bound is keyed on") + } + css := cssRule(t, ".hive-table td.version-cell") + for _, want := range []string{"min-width:", "max-width:", "white-space: normal", "overflow-wrap: anywhere"} { + if !strings.Contains(css, want) { + t.Errorf(".hive-table td.version-cell is missing %q; the column can grow unbounded again", want) + } + } + line := cssRule(t, ".version-line") + for _, want := range []string{"flex-wrap: wrap", "white-space: normal"} { + if !strings.Contains(line, want) { + t.Errorf(".version-line is missing %q; a crowded status line widens the column instead of folding", want) } } } -// Lines 3 and 4 are conditional. A read-only viewer has neither an upgrade -// action nor a mode select, and must get a two-line cell — not a four-line cell -// containing two empty rows, which would pad every non-owner row for nothing. -func TestVersionCellOmitsEmptyLines(t *testing.T) { - expr := versionCellExpr(t) - for _, guard := range []string{"(upgradeIcon ?", "(autoUpgradeCheck ?"} { - if !strings.Contains(expr, guard) { - t.Errorf("the Version cell emits a line unconditionally (missing guard %q); "+ - "a non-owner would get a blank line", guard) +// The Repos cell had the same one-line problem ("as: " never +// wrapped). It is bounded and wraps the same way. +func TestReposColumnIsWidthBoundedAndWraps(t *testing.T) { + css := cssRule(t, ".hive-table td.repos-cell") + for _, want := range []string{"max-width:", "white-space: normal", "overflow-wrap: anywhere"} { + if !strings.Contains(css, want) { + t.Errorf(".hive-table td.repos-cell is missing %q", want) } } + body := funcBody(t, "var buildRow = function(") + if !strings.Contains(body, `' lost the repos-cell class the width bound is keyed on") + } + if !strings.Contains(body, `'