From d598f4abad9e6cd4e16156da75a6eafaaeb8f8dc Mon Sep 17 00:00:00 2001 From: Andrew Anderson Date: Fri, 30 Oct 2026 12:32:33 -0400 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20dashboard:=20fix=20stray=20dot?= =?UTF-8?q?=20and=20clipped=20label=20in=20Governor=20RUNNING=20tile?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The .val host had text-overflow: ellipsis while holding the fixed agent count plus the inline-grid cost rotor (max-width: 100%, not accounting for the count). When count + rotor overflowed the 140px column Chrome painted the host's ellipsis at the rotor's left edge, under the "$", and the middle dot peeked out between "$" and the digits during the phrase crossfade ("$.1,010"). Make the host a flex row (count flex:none, rotor min-width:0) without text-overflow so only the phrase ellipsizes; shorten window labels; round today/week/month to whole dollars via a new fmtUSDWhole while the hour window keeps cents. The cost panel keeps the precise fmtUSD. Closes #15826 Signed-off-by: Andrew Anderson --- .../fixed-15826-running-tile-stray-dot.md | 1 + src/pkg/dashboard/fleet_cost_rotor.test.js | 59 ++++++++++++++----- src/pkg/dashboard/static-src/css/governor.css | 12 ++-- src/pkg/dashboard/static-src/js/agent-now.js | 13 ++-- src/pkg/dashboard/static-src/js/cost.js | 10 ++++ src/pkg/dashboard/static/index.html | 35 ++++++++--- 6 files changed, 97 insertions(+), 33 deletions(-) create mode 100644 changelog.d/fixed-15826-running-tile-stray-dot.md diff --git a/changelog.d/fixed-15826-running-tile-stray-dot.md b/changelog.d/fixed-15826-running-tile-stray-dot.md new file mode 100644 index 0000000000..1c2cc3ca1f --- /dev/null +++ b/changelog.d/fixed-15826-running-tile-stray-dot.md @@ -0,0 +1 @@ +- The Governor RUNNING tile no longer shows a stray dot between "$" and the amount ("$.1,010") or clips the cost window label: the host's text-overflow ellipsis was being painted under the "$" when the agent count plus the cost rotor overflowed the tile. The tile is now a flex row whose rotor shrinks and ellipsizes on its own, window labels are shorter ("this hr", "today", "this wk", "this mo"), and the today / week / month amounts round to whole dollars while the hour window keeps cents ([#15826](https://github.com/hivecommons/hive/issues/15826)). diff --git a/src/pkg/dashboard/fleet_cost_rotor.test.js b/src/pkg/dashboard/fleet_cost_rotor.test.js index 7f47941e6e..65e2a070c8 100644 --- a/src/pkg/dashboard/fleet_cost_rotor.test.js +++ b/src/pkg/dashboard/fleet_cost_rotor.test.js @@ -19,6 +19,9 @@ function pick(re, what) { const rotorSrc = pick(/\/\/ --- fleet cost rotor \(begin\) ---[\s\S]*?\/\/ --- fleet cost rotor \(end\) ---/, 'fleet cost rotor block'); const statSrc = pick(/function fleetRunStatHtml\(\) \{[\s\S]*?\n \}\n/, 'fleetRunStatHtml'); const stripSrc = pick(/function fleetRunStripHtml\(\) \{[\s\S]*?\n \}\n/, 'fleetRunStripHtml'); +// The real formatters, so the test sees exactly what the tile prints. +const fmtSrc = pick(/function fmtUSD\(n\) \{[\s\S]*?\n \}\n/, 'fmtUSD') + pick(/function fmtUSDWhole\(n\) \{[\s\S]*?\n \}\n/, 'fmtUSDWhole'); +const formatNumber = (value, locale, options) => new Intl.NumberFormat(locale || undefined, options || {}).format(value); // Minimal DOM stand-in: one rotor whose phrases are plain objects with a // classList, plus a document with fake timers and a visibility flag. @@ -61,13 +64,12 @@ function makeEnv({ reducedMotion = false } = {}) { } now = until; }; - const fmtUSD = n => '$' + Number(n).toFixed(2); const esc = s => String(s).replace(/&/g, '&').replace(/ { assert.strictEqual(key, 'fleetCostRotor'); return setInterval(fn, ms); }; - const api = new Function('window', 'document', 'dashboardSetInterval', 'fmtUSD', 'esc', - rotorSrc + '\n' + statSrc + '\n' + stripSrc + - '\nreturn { FLEET_COST_WINDOWS, FLEET_COST_DWELL_MS, _fleetCost, fleetCostPhrases, fleetCostRotorHtml, fleetCostTick, fleetRunStatHtml, fleetRunStripHtml, fleetCostTooltipLines };' - )(window, document, dashboardSetInterval, fmtUSD, esc); + const api = new Function('window', 'document', 'dashboardSetInterval', 'formatNumber', 'esc', + fmtSrc + '\n' + rotorSrc + '\n' + statSrc + '\n' + stripSrc + + '\nreturn { FLEET_COST_WINDOWS, FLEET_COST_DWELL_MS, _fleetCost, fleetCostPhrases, fleetCostRotorHtml, fleetCostTick, fleetRunStatHtml, fleetRunStripHtml, fleetCostTooltipLines, fmtUSD, fmtUSDWhole };' + )(window, document, dashboardSetInterval, formatNumber, esc); api._fleetCost.clock = () => now; // Seed the fake phrases from the rendered markup so the DOM matches it. const rendered = api.fleetRunStatHtml(); @@ -151,21 +153,48 @@ test('markup: fixed agent count, four phrases in one rotor, tooltip lists all fo assert.match(r, /3 · <\/span>this hour today this week this month this hr today this wk this mo p.text); - assert.deepStrictEqual(unpriced, ['$1.00 this hour', '$– today', '$– this week', '$– this month']); + assert.deepStrictEqual(unpriced, ['$1.00 this hr', '$– today', '$– this wk', '$– this mo']); }); -test('never a second line: nowrap + ellipsis on the tile, phrases share one grid area', () => { +test('whole-dollar windows: nearest dollar, comma-grouped, never a decimal point', () => { + const { fmtUSDWhole, fleetCostPhrases } = makeEnv().api; + assert.strictEqual(fmtUSDWhole(0), '$0'); + assert.strictEqual(fmtUSDWhole(0.5), '$1'); + assert.strictEqual(fmtUSDWhole(0.49), '<$1', 'a real but sub-dollar spend is not shown as $0'); + assert.strictEqual(fmtUSDWhole(9.99), '$10'); + assert.strictEqual(fmtUSDWhole(999.99), '$1,000'); + assert.strictEqual(fmtUSDWhole(1010), '$1,010'); + assert.strictEqual(fmtUSDWhole(1010.4), '$1,010'); + assert.strictEqual(fmtUSDWhole(12345.67), '$12,346'); + assert.strictEqual(fmtUSDWhole(null), '—'); + assert.strictEqual(fmtUSDWhole(NaN), '—'); + const phrases = fleetCostPhrases({ running: 2, hourUSD: 25.27, hourPriced: true, dayUSD: 1010.4, weekUSD: 5728.9, monthUSD: 11128.01, windowsPriced: true }); + assert.deepStrictEqual(phrases.map(p => p.amount), ['$25.27', '$1,010', '$5,729', '$11,128']); + for (const p of phrases.slice(1)) assert.doesNotMatch(p.amount, /\./, p.key + ' window must not carry cents'); +}); + +test('never a second line, and no host ellipsis: the host is a flex row whose rotor shrinks', () => { const css = html.match(/]*>([\s\S]*?)<\/style>/)[1]; - assert.match(css, /\.fleet-run-stat \.val, \.fleet-run-stat \.gm-val \{ white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; \}/); - assert.match(css, /\.fleet-cost-rotor \{ display: inline-grid; grid-template-areas: 'phrase';/); + // A text-overflow ellipsis on the host was painted at the rotor's left + // edge when count + rotor overflowed the tile, surfacing as a stray dot + // between "$" and the digits ("$.1,010"). Only the phrase may ellipsize. + const hostRule = css.match(/\.fleet-run-stat \.val, \.fleet-run-stat \.gm-val \{([^}]*)\}/); + assert.ok(hostRule, 'host rule present'); + assert.match(hostRule[1], /display: flex;/); + assert.match(hostRule[1], /white-space: nowrap;/); + assert.match(hostRule[1], /min-width: 0;/); + assert.doesNotMatch(hostRule[1], /text-overflow/); + assert.match(css, /\.fleet-run-count \{ flex: none;/); + assert.match(css, /\.fleet-cost-rotor \{ display: inline-grid; grid-template-areas: 'phrase'; flex: 0 1 auto; min-width: 0;/); assert.match(css, /\.fleet-cost-rotor \.fcr-phrase \{ grid-area: phrase; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;/); // Amber/text tokens only in the rotor rules — no raw colours. const rotorCss = css.match(/\.fleet-run-stat[\s\S]*?prefers-reduced-motion: reduce\) \{[\s\S]*?\}\s*\}/)[0]; diff --git a/src/pkg/dashboard/static-src/css/governor.css b/src/pkg/dashboard/static-src/css/governor.css index dfe24b4b75..28ebfc3b7c 100644 --- a/src/pkg/dashboard/static-src/css/governor.css +++ b/src/pkg/dashboard/static-src/css/governor.css @@ -19,10 +19,14 @@ /* RUNNING tile cost rotor (#15614): the four window phrases share one grid cell, so the tile is always as wide as its widest phrase and the amount + window crossfades in place while the agent count stays put. - nowrap + ellipsis is the fallback when the tile is narrower still. */ - .fleet-run-stat .val, .fleet-run-stat .gm-val { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; } - .fleet-run-count { color: var(--text); } - .fleet-cost-rotor { display: inline-grid; grid-template-areas: 'phrase'; vertical-align: bottom; max-width: 100%; overflow: hidden; color: var(--text); } + The host is a flex row — count fixed, rotor shrinks — so the host + itself never overflows: a text-overflow ellipsis on the host would be + painted at the rotor's left edge, showing up as a stray dot between + "$" and the digits ("$.1,010"). Only the phrase ellipsizes. */ + .fleet-run-stat .val, .fleet-run-stat .gm-val { display: flex; align-items: baseline; white-space: nowrap; overflow: hidden; min-width: 0; } + /* pre keeps the trailing space of "N · " that flex would otherwise trim. */ + .fleet-run-count { flex: none; white-space: pre; color: var(--text); } + .fleet-cost-rotor { display: inline-grid; grid-template-areas: 'phrase'; flex: 0 1 auto; min-width: 0; overflow: hidden; color: var(--text); } .fleet-cost-rotor .fcr-phrase { grid-area: phrase; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; opacity: 0; transform: translateY(0.5em); transition: opacity 360ms ease, transform 360ms ease; pointer-events: none; } .fleet-cost-rotor .fcr-phrase.is-cur { opacity: 1; transform: translateY(0); } .fleet-cost-rotor .fcr-phrase.is-out { opacity: 0; transform: translateY(-0.5em); } diff --git a/src/pkg/dashboard/static-src/js/agent-now.js b/src/pkg/dashboard/static-src/js/agent-now.js index d5e45183f5..33e6e97ff8 100644 --- a/src/pkg/dashboard/static-src/js/agent-now.js +++ b/src/pkg/dashboard/static-src/js/agent-now.js @@ -259,18 +259,21 @@ // phrases are rendered into the same grid cell so the tile is always as // wide as its widest phrase and never shifts or wraps. The rotation // index is module state so a status repaint keeps the current phrase. + // The hour window keeps cents (it is small and moves fast); the longer + // windows round to whole dollars (fmtUSDWhole) so the figure stays short. + // Labels are short so the phrase fits the 140px gov-grid column. const FLEET_COST_WINDOWS = [ - { key: 'hour', label: 'this hour', usd: 'hourUSD', priced: 'hourPriced' }, - { key: 'day', label: 'today', usd: 'dayUSD', priced: 'windowsPriced' }, - { key: 'week', label: 'this week', usd: 'weekUSD', priced: 'windowsPriced' }, - { key: 'month', label: 'this month', usd: 'monthUSD', priced: 'windowsPriced' }, + { key: 'hour', label: 'this hr', usd: 'hourUSD', priced: 'hourPriced', fmt: fmtUSD }, + { key: 'day', label: 'today', usd: 'dayUSD', priced: 'windowsPriced', fmt: fmtUSDWhole }, + { key: 'week', label: 'this wk', usd: 'weekUSD', priced: 'windowsPriced', fmt: fmtUSDWhole }, + { key: 'month', label: 'this mo', usd: 'monthUSD', priced: 'windowsPriced', fmt: fmtUSDWhole }, ]; const FLEET_COST_DWELL_MS = 4000; const FLEET_COST_WINDOWS_HELP = 'today / this week / this month are the cost ledger summed from 00:00 UTC today, Monday 00:00 UTC (ISO week) and the 1st 00:00 UTC, plus the rise since its last reading.'; const _fleetCost = { idx: 0, started: false, hover: false, lastAdvance: -Infinity, clock: () => Date.now() }; function fleetCostPhrases(f) { return FLEET_COST_WINDOWS.map(w => { - const amount = f && f[w.priced] ? fmtUSD(f[w.usd] || 0) : '$–'; + const amount = f && f[w.priced] ? w.fmt(f[w.usd] || 0) : '$–'; return { key: w.key, label: w.label, amount, text: `${amount} ${w.label}` }; }); } diff --git a/src/pkg/dashboard/static-src/js/cost.js b/src/pkg/dashboard/static-src/js/cost.js index e6c915bfc2..3c46fe37e5 100644 --- a/src/pkg/dashboard/static-src/js/cost.js +++ b/src/pkg/dashboard/static-src/js/cost.js @@ -27,6 +27,16 @@ const frac = n < 100 ? 2 : 0; return '$' + formatNumber(n, 'en-US', { minimumFractionDigits: frac, maximumFractionDigits: frac }); } + // fmtUSDWhole rounds to the nearest dollar, comma-grouped, never cents: + // "$1,010", "$10", "$0". Anything that would round to $0 but is non-zero + // shows "<$1" so a small, real spend is not mistaken for none. Used by + // the Governor RUNNING tile's today / week / month windows (#15614); + // the cost panel keeps the precise fmtUSD. + function fmtUSDWhole(n) { + if (n == null || isNaN(n)) return '—'; + if (n > 0 && n < 0.5) return '<$1'; + return '$' + formatNumber(Math.round(n), 'en-US', { maximumFractionDigits: 0 }); + } // Headline wording (#13484): one plainly-named figure. "lineage" and // "persisted history" were implementation terms; the card now says what diff --git a/src/pkg/dashboard/static/index.html b/src/pkg/dashboard/static/index.html index ae78cd1483..88a9d61473 100644 --- a/src/pkg/dashboard/static/index.html +++ b/src/pkg/dashboard/static/index.html @@ -2251,10 +2251,14 @@ /* RUNNING tile cost rotor (#15614): the four window phrases share one grid cell, so the tile is always as wide as its widest phrase and the amount + window crossfades in place while the agent count stays put. - nowrap + ellipsis is the fallback when the tile is narrower still. */ - .fleet-run-stat .val, .fleet-run-stat .gm-val { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; } - .fleet-run-count { color: var(--text); } - .fleet-cost-rotor { display: inline-grid; grid-template-areas: 'phrase'; vertical-align: bottom; max-width: 100%; overflow: hidden; color: var(--text); } + The host is a flex row — count fixed, rotor shrinks — so the host + itself never overflows: a text-overflow ellipsis on the host would be + painted at the rotor's left edge, showing up as a stray dot between + "$" and the digits ("$.1,010"). Only the phrase ellipsizes. */ + .fleet-run-stat .val, .fleet-run-stat .gm-val { display: flex; align-items: baseline; white-space: nowrap; overflow: hidden; min-width: 0; } + /* pre keeps the trailing space of "N · " that flex would otherwise trim. */ + .fleet-run-count { flex: none; white-space: pre; color: var(--text); } + .fleet-cost-rotor { display: inline-grid; grid-template-areas: 'phrase'; flex: 0 1 auto; min-width: 0; overflow: hidden; color: var(--text); } .fleet-cost-rotor .fcr-phrase { grid-area: phrase; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; opacity: 0; transform: translateY(0.5em); transition: opacity 360ms ease, transform 360ms ease; pointer-events: none; } .fleet-cost-rotor .fcr-phrase.is-cur { opacity: 1; transform: translateY(0); } .fleet-cost-rotor .fcr-phrase.is-out { opacity: 0; transform: translateY(-0.5em); } @@ -14221,18 +14225,21 @@

Where to get help

// phrases are rendered into the same grid cell so the tile is always as // wide as its widest phrase and never shifts or wraps. The rotation // index is module state so a status repaint keeps the current phrase. + // The hour window keeps cents (it is small and moves fast); the longer + // windows round to whole dollars (fmtUSDWhole) so the figure stays short. + // Labels are short so the phrase fits the 140px gov-grid column. const FLEET_COST_WINDOWS = [ - { key: 'hour', label: 'this hour', usd: 'hourUSD', priced: 'hourPriced' }, - { key: 'day', label: 'today', usd: 'dayUSD', priced: 'windowsPriced' }, - { key: 'week', label: 'this week', usd: 'weekUSD', priced: 'windowsPriced' }, - { key: 'month', label: 'this month', usd: 'monthUSD', priced: 'windowsPriced' }, + { key: 'hour', label: 'this hr', usd: 'hourUSD', priced: 'hourPriced', fmt: fmtUSD }, + { key: 'day', label: 'today', usd: 'dayUSD', priced: 'windowsPriced', fmt: fmtUSDWhole }, + { key: 'week', label: 'this wk', usd: 'weekUSD', priced: 'windowsPriced', fmt: fmtUSDWhole }, + { key: 'month', label: 'this mo', usd: 'monthUSD', priced: 'windowsPriced', fmt: fmtUSDWhole }, ]; const FLEET_COST_DWELL_MS = 4000; const FLEET_COST_WINDOWS_HELP = 'today / this week / this month are the cost ledger summed from 00:00 UTC today, Monday 00:00 UTC (ISO week) and the 1st 00:00 UTC, plus the rise since its last reading.'; const _fleetCost = { idx: 0, started: false, hover: false, lastAdvance: -Infinity, clock: () => Date.now() }; function fleetCostPhrases(f) { return FLEET_COST_WINDOWS.map(w => { - const amount = f && f[w.priced] ? fmtUSD(f[w.usd] || 0) : '$–'; + const amount = f && f[w.priced] ? w.fmt(f[w.usd] || 0) : '$–'; return { key: w.key, label: w.label, amount, text: `${amount} ${w.label}` }; }); } @@ -31907,6 +31914,16 @@

All labels

const frac = n < 100 ? 2 : 0; return '$' + formatNumber(n, 'en-US', { minimumFractionDigits: frac, maximumFractionDigits: frac }); } + // fmtUSDWhole rounds to the nearest dollar, comma-grouped, never cents: + // "$1,010", "$10", "$0". Anything that would round to $0 but is non-zero + // shows "<$1" so a small, real spend is not mistaken for none. Used by + // the Governor RUNNING tile's today / week / month windows (#15614); + // the cost panel keeps the precise fmtUSD. + function fmtUSDWhole(n) { + if (n == null || isNaN(n)) return '—'; + if (n > 0 && n < 0.5) return '<$1'; + return '$' + formatNumber(Math.round(n), 'en-US', { maximumFractionDigits: 0 }); + } // Headline wording (#13484): one plainly-named figure. "lineage" and // "persisted history" were implementation terms; the card now says what