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-running-cost-layout.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Show the Activity Monitor's running fleet cost and its rotating period on a separate, wrapping line below the running count so narrow tiles and zoom no longer truncate the amount or period.
39 changes: 30 additions & 9 deletions src/pkg/dashboard/fleet_cost_rotor.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// The RUNNING tile's cost rotor (#15614): "$X this hour" → "$Y today" →
// "$Z this week" → "$W this month", ~4s each, pausing while hovered or
// hidden, instant under prefers-reduced-motion, never a second line. The
// hidden, instant under prefers-reduced-motion, below the running count. The
// rotor block is lifted straight out of index.html so this runs against the
// shipped source.
const test = require('node:test');
Expand Down Expand Up @@ -150,7 +150,7 @@ test('prefers-reduced-motion swaps instantly with no outgoing phrase', () => {
test('markup: fixed agent count, four phrases in one rotor, tooltip lists all four', () => {
const env = makeEnv();
const r = env.rendered;
assert.match(r, /<span class="fleet-run-count">3 · <\/span><span class="fleet-cost-rotor" data-fleet-cost-rotor/);
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');
// Hour keeps cents; today / week / month are whole dollars (#15614 follow-up).
Expand Down Expand Up @@ -182,24 +182,45 @@ test('whole-dollar windows: nearest dollar, comma-grouped, never a decimal point
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', () => {
test('cost is below the count and wraps without clipping at narrow widths or zoom', () => {
const css = html.match(/<style\b[^>]*>([\s\S]*?)<\/style>/)[1];
// 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], /flex-direction: column;/);
assert.match(hostRule[1], /align-items: stretch;/);
assert.match(hostRule[1], /white-space: normal;/);
assert.match(hostRule[1], /overflow: visible;/);
assert.match(hostRule[1], /min-width: 0;/);
assert.doesNotMatch(hostRule[1], /text-overflow/);
assert.match(css, /\.fleet-run-stat \{ min-width: 0; \}/);
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;/);
assert.match(css, /\.fleet-cost-rotor \{ display: inline-grid; grid-template-areas: 'phrase'; grid-template-columns: minmax\(0, 1fr\); min-width: 0;/);
assert.match(css, /\.fleet-cost-rotor \.fcr-phrase \{ grid-area: phrase; white-space: normal; overflow-wrap: anywhere;/);
const phraseRule = css.match(/\.fleet-cost-rotor \.fcr-phrase \{([^}]*)\}/)[1];
assert.doesNotMatch(phraseRule, /text-overflow|overflow: hidden|height:|max-height:/);
// 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];
assert.doesNotMatch(rotorCss, /#[0-9a-fA-F]{3,8}\b|rgba?\(|hsla?\(/);
assert.match(rotorCss, /var\(--amber\)/);
assert.match(rotorCss, /var\(--text\)/);
assert.doesNotMatch(makeEnv().rendered, /<br/);
});

test('both running tiles preserve large costs and all periods separately from the count', () => {
const env = makeEnv();
Object.assign(env.window._lastStatus.fleetRun, {
running: 4, hourUSD: 11675.25, dayUSD: 1234567, weekUSD: 9876543, monthUSD: 123456789,
});
for (const rendered of [env.api.fleetRunStatHtml(), env.api.fleetRunStripHtml()]) {
assert.match(rendered, /<span class="fleet-run-count">4<\/span><span class="fleet-cost-rotor"/);
for (const phrase of env.api.fleetCostPhrases(env.window._lastStatus.fleetRun)) {
assert.ok(rendered.includes(`<span class="fcr-amount">${phrase.amount}</span> <span class="fcr-window">${phrase.label}</span>`));
}
assert.match(rendered, /aria-live="off"/);
assert.strictEqual((rendered.match(/aria-hidden="true"/g) || []).length, 3);
}
env.window._lastStatus.fleetRun = null;
assert.strictEqual(env.api.fleetRunStatHtml(), '');
assert.strictEqual(env.api.fleetRunStripHtml(), '');
});
20 changes: 8 additions & 12 deletions src/pkg/dashboard/static-src/css/governor.css
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,14 @@
the "N Issues" / on-hold indicators. */
.gov-stat .val.planning-alert { color: var(--yellow); }
/* 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.
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; }
grid cell to reserve the tallest wrapped phrase while the amount +
window crossfades. Cost lives below the count and may wrap at narrow
widths or zoom levels; neither the amount nor its period is clipped. */
.fleet-run-stat { min-width: 0; }
.fleet-run-stat .val, .fleet-run-stat .gm-val { display: flex; flex-direction: column; align-items: stretch; gap: var(--sp-1); white-space: normal; overflow: visible; min-width: 0; }
.fleet-run-count { flex: none; overflow-wrap: anywhere; color: var(--text); }
.fleet-cost-rotor { display: inline-grid; grid-template-areas: 'phrase'; grid-template-columns: minmax(0, 1fr); min-width: 0; color: var(--text); font-size: var(--fs-sm); line-height: 1.4; }
.fleet-cost-rotor .fcr-phrase { grid-area: phrase; white-space: normal; overflow-wrap: anywhere; 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); }
.fleet-cost-rotor .fcr-window { color: var(--amber); font-weight: 600; }
Expand Down Expand Up @@ -134,4 +131,3 @@
display: none;
}
}

8 changes: 4 additions & 4 deletions src/pkg/dashboard/static-src/js/agent-now.js
Original file line number Diff line number Diff line change
Expand Up @@ -256,8 +256,8 @@
// The RUNNING tile rotates its cost window — this hour → today → this
// week → this month — one phrase at a time (#15614). The agent count
// stays put; only the amount + window phrase crossfades. All four
// 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
// phrases share a grid cell below the count, reserving room for the
// tallest wrapped phrase without shifting on rotation. 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.
Expand Down Expand Up @@ -339,13 +339,13 @@
const f = window._lastStatus?.fleetRun;
if (!f) return '';
fleetCostRotorStart();
return `<div class="gov-stat fleet-run-stat" data-fleet-cost-host title="RUNNING — agents mid-kick right now · estimated spend accrued by the whole fleet (token × list price; $– when a running agent's model is unpriced).&#10;&#10;${esc(fleetCostTooltipLines(f))}&#10;&#10;${FLEET_COST_WINDOWS_HELP}&#10;&#10;Updates with every status poll; the per-agent breakdown is on each card's run line in Agents."><div class="label">running</div><div class="val" id="gov-fleet-run"><span class="fleet-run-count">${f.running || 0} · </span>${fleetCostRotorHtml(f)}</div></div>`;
return `<div class="gov-stat fleet-run-stat" data-fleet-cost-host title="RUNNING — agents mid-kick right now · estimated spend accrued by the whole fleet (token × list price; $– when a running agent's model is unpriced).&#10;&#10;${esc(fleetCostTooltipLines(f))}&#10;&#10;${FLEET_COST_WINDOWS_HELP}&#10;&#10;Updates with every status poll; the per-agent breakdown is on each card's run line in Agents."><div class="label">running</div><div class="val" id="gov-fleet-run"><span class="fleet-run-count">${f.running || 0}</span>${fleetCostRotorHtml(f)}</div></div>`;
}
function fleetRunStripHtml() {
const f = window._lastStatus?.fleetRun;
if (!f) return '';
fleetCostRotorStart();
return `<div class="gov-metric fleet-run-stat" data-fleet-cost-host title="Agents mid-kick right now · estimated spend accrued by the whole fleet (token × list price)&#10;&#10;${esc(fleetCostTooltipLines(f))}&#10;&#10;${FLEET_COST_WINDOWS_HELP}"><span class="gm-label">running</span><span class="gm-val" id="oc-fleet-run"><span class="fleet-run-count">${f.running || 0} · </span>${fleetCostRotorHtml(f)}</span></div>`;
return `<div class="gov-metric fleet-run-stat" data-fleet-cost-host title="Agents mid-kick right now · estimated spend accrued by the whole fleet (token × list price)&#10;&#10;${esc(fleetCostTooltipLines(f))}&#10;&#10;${FLEET_COST_WINDOWS_HELP}"><span class="gm-label">running</span><span class="gm-val" id="oc-fleet-run"><span class="fleet-run-count">${f.running || 0}</span>${fleetCostRotorHtml(f)}</span></div>`;
}

// Repaints every "Now:" line in place so "ago" keeps counting up (and
Expand Down
28 changes: 12 additions & 16 deletions src/pkg/dashboard/static/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2282,17 +2282,14 @@
the "N Issues" / on-hold indicators. */
.gov-stat .val.planning-alert { color: var(--yellow); }
/* 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.
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; }
grid cell to reserve the tallest wrapped phrase while the amount +
window crossfades. Cost lives below the count and may wrap at narrow
widths or zoom levels; neither the amount nor its period is clipped. */
.fleet-run-stat { min-width: 0; }
.fleet-run-stat .val, .fleet-run-stat .gm-val { display: flex; flex-direction: column; align-items: stretch; gap: var(--sp-1); white-space: normal; overflow: visible; min-width: 0; }
.fleet-run-count { flex: none; overflow-wrap: anywhere; color: var(--text); }
.fleet-cost-rotor { display: inline-grid; grid-template-areas: 'phrase'; grid-template-columns: minmax(0, 1fr); min-width: 0; color: var(--text); font-size: var(--fs-sm); line-height: 1.4; }
.fleet-cost-rotor .fcr-phrase { grid-area: phrase; white-space: normal; overflow-wrap: anywhere; 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); }
.fleet-cost-rotor .fcr-window { color: var(--amber); font-weight: 600; }
Expand Down Expand Up @@ -2399,7 +2396,6 @@
display: none;
}
}

/* ── ACMM level-up recommendation (advisory) + lifecycle timeline ── */
.reco-badge {
display: inline-block; font-size: var(--fs-2xs); font-weight: 700; letter-spacing: 0.06em;
Expand Down Expand Up @@ -14371,8 +14367,8 @@ <h3 class="faq-group-title">Where to get help</h3>
// The RUNNING tile rotates its cost window — this hour → today → this
// week → this month — one phrase at a time (#15614). The agent count
// stays put; only the amount + window phrase crossfades. All four
// 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
// phrases share a grid cell below the count, reserving room for the
// tallest wrapped phrase without shifting on rotation. 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.
Expand Down Expand Up @@ -14454,13 +14450,13 @@ <h3 class="faq-group-title">Where to get help</h3>
const f = window._lastStatus?.fleetRun;
if (!f) return '';
fleetCostRotorStart();
return `<div class="gov-stat fleet-run-stat" data-fleet-cost-host title="RUNNING — agents mid-kick right now · estimated spend accrued by the whole fleet (token × list price; $– when a running agent's model is unpriced).&#10;&#10;${esc(fleetCostTooltipLines(f))}&#10;&#10;${FLEET_COST_WINDOWS_HELP}&#10;&#10;Updates with every status poll; the per-agent breakdown is on each card's run line in Agents."><div class="label">running</div><div class="val" id="gov-fleet-run"><span class="fleet-run-count">${f.running || 0} · </span>${fleetCostRotorHtml(f)}</div></div>`;
return `<div class="gov-stat fleet-run-stat" data-fleet-cost-host title="RUNNING — agents mid-kick right now · estimated spend accrued by the whole fleet (token × list price; $– when a running agent's model is unpriced).&#10;&#10;${esc(fleetCostTooltipLines(f))}&#10;&#10;${FLEET_COST_WINDOWS_HELP}&#10;&#10;Updates with every status poll; the per-agent breakdown is on each card's run line in Agents."><div class="label">running</div><div class="val" id="gov-fleet-run"><span class="fleet-run-count">${f.running || 0}</span>${fleetCostRotorHtml(f)}</div></div>`;
}
function fleetRunStripHtml() {
const f = window._lastStatus?.fleetRun;
if (!f) return '';
fleetCostRotorStart();
return `<div class="gov-metric fleet-run-stat" data-fleet-cost-host title="Agents mid-kick right now · estimated spend accrued by the whole fleet (token × list price)&#10;&#10;${esc(fleetCostTooltipLines(f))}&#10;&#10;${FLEET_COST_WINDOWS_HELP}"><span class="gm-label">running</span><span class="gm-val" id="oc-fleet-run"><span class="fleet-run-count">${f.running || 0} · </span>${fleetCostRotorHtml(f)}</span></div>`;
return `<div class="gov-metric fleet-run-stat" data-fleet-cost-host title="Agents mid-kick right now · estimated spend accrued by the whole fleet (token × list price)&#10;&#10;${esc(fleetCostTooltipLines(f))}&#10;&#10;${FLEET_COST_WINDOWS_HELP}"><span class="gm-label">running</span><span class="gm-val" id="oc-fleet-run"><span class="fleet-run-count">${f.running || 0}</span>${fleetCostRotorHtml(f)}</span></div>`;
}

// Repaints every "Now:" line in place so "ago" keeps counting up (and
Expand Down
Loading