Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/fixed-15826-running-tile-stray-dot.md
Original file line number Diff line number Diff line change
@@ -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)).
59 changes: 44 additions & 15 deletions src/pkg/dashboard/fleet_cost_rotor.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -61,13 +64,12 @@ function makeEnv({ reducedMotion = false } = {}) {
}
now = until;
};
const fmtUSD = n => '$' + Number(n).toFixed(2);
const esc = s => String(s).replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/"/g, '&quot;');
const dashboardSetInterval = (key, fn, ms) => { 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();
Expand Down Expand Up @@ -151,21 +153,48 @@ test('markup: fixed agent count, four phrases in one rotor, tooltip lists all fo
assert.match(r, /<span class="fleet-run-count">3 Β· <\/span><span class="fleet-cost-rotor" data-fleet-cost-rotor/);
assert.strictEqual((r.match(/class="fcr-phrase/g) || []).length, 4);
assert.strictEqual((r.match(/data-fleet-cost-rotor/g) || []).length, 1, 'all phrases share one rotor cell');
assert.match(r, /\$53\.91<\/span> <span class="fcr-window">this hour</);
assert.match(r, /\$120\.50<\/span> <span class="fcr-window">today</);
assert.match(r, /\$410\.00<\/span> <span class="fcr-window">this week</);
assert.match(r, /\$1234\.56<\/span> <span class="fcr-window">this month</);
assert.strictEqual(env.api.fleetCostTooltipLines(env.window._lastStatus.fleetRun), '$53.91 this hour Β· $120.50 today Β· $410.00 this week Β· $1234.56 this month');
assert.match(r, /title="RUNNING[^"]*\$53\.91 this hour Β· \$120\.50 today Β· \$410\.00 this week Β· \$1234\.56 this month/);
// Hour keeps cents; today / week / month are whole dollars (#15614 follow-up).
assert.match(r, /\$53\.91<\/span> <span class="fcr-window">this hr</);
assert.match(r, /\$121<\/span> <span class="fcr-window">today</);
assert.match(r, /\$410<\/span> <span class="fcr-window">this wk</);
assert.match(r, /\$1,235<\/span> <span class="fcr-window">this mo</);
assert.strictEqual(env.api.fleetCostTooltipLines(env.window._lastStatus.fleetRun), '$53.91 this hr Β· $121 today Β· $410 this wk Β· $1,235 this mo');
assert.match(r, /title="RUNNING[^"]*\$53\.91 this hr Β· \$121 today Β· \$410 this wk Β· \$1,235 this mo/);
// Unpriced windows read "$–" rather than a guess.
const unpriced = env.api.fleetCostPhrases({ hourUSD: 1, hourPriced: true, windowsPriced: false }).map(p => 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(/<style\b[^>]*>([\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];
Expand Down
12 changes: 8 additions & 4 deletions src/pkg/dashboard/static-src/css/governor.css
Original file line number Diff line number Diff line change
Expand Up @@ -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); }
Expand Down
13 changes: 8 additions & 5 deletions src/pkg/dashboard/static-src/js/agent-now.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}` };
});
}
Expand Down
10 changes: 10 additions & 0 deletions src/pkg/dashboard/static-src/js/cost.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
35 changes: 26 additions & 9 deletions src/pkg/dashboard/static/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -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); }
Expand Down Expand Up @@ -14221,18 +14225,21 @@ <h3 class="faq-group-title">Where to get help</h3>
// 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}` };
});
}
Expand Down Expand Up @@ -31907,6 +31914,16 @@ <h2 class="config-title" id="activity-monitor-labels-title">All labels</h2>
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
Expand Down
Loading