mirror of
https://github.com/lWolvesl/antigravity-usage-monitor.git
synced 2026-11-27 01:19:25 +08:00
feat(panel): polish compaction row popover, pill selects, steps header, scrollbar, and chart tooltips
# Conflicts: # sidecars/panel/index.html
This commit is contained in:
@@ -412,11 +412,8 @@ test('ConsumptionView: Top Models color dot + % bar, clutter-free Client Sources
|
||||
assert.equal(modelRows.length, 6);
|
||||
assert.equal(sourceRows.length, 2);
|
||||
|
||||
// 1. Top Models: colored dot appears right after model name & 4-segment bar scales to 50% (not 100%)
|
||||
const argonTitleDot = modelRows[0].querySelector('.cons-title-model-dot');
|
||||
assert.ok(argonTitleDot && !argonTitleDot.hasAttribute('hidden'));
|
||||
const argonDotColor = argonTitleDot.style.getPropertyValue('--dot-color');
|
||||
assert.match(argonDotColor, /^hsl\(/);
|
||||
// 1. Top Models: no color dot next to model name & 4-segment bar scales to 50% (not 100%)
|
||||
assert.equal(modelRows[0].querySelector('.cons-title-model-dot'), null);
|
||||
|
||||
const argonSegSum = modelRows[0]
|
||||
.querySelectorAll('.progress-seg')
|
||||
@@ -429,7 +426,8 @@ test('ConsumptionView: Top Models color dot + % bar, clutter-free Client Sources
|
||||
assert.equal(appTopItems.length, 3, 'Should show top 3 non-other models in single-line footer');
|
||||
assert.equal(appTopItems[0].querySelector('.cons-source-top-name')?.textContent, '4-argon');
|
||||
assert.equal(appTopItems[0].querySelector('.cons-source-top-pct')?.textContent, '50%');
|
||||
assert.equal(appTopItems[0].querySelector('.cons-source-top-dot')?.style.getPropertyValue('--dot-color'), argonDotColor);
|
||||
const argonDotColor = appTopItems[0].querySelector('.cons-source-top-dot')?.style.getPropertyValue('--dot-color');
|
||||
assert.match(argonDotColor, /^hsl\(/);
|
||||
assert.equal(appTopItems[1].querySelector('.cons-source-top-name')?.textContent, '4-carbon');
|
||||
assert.equal(appTopItems[1].querySelector('.cons-source-top-pct')?.textContent, '31%');
|
||||
assert.equal(appTopItems[2].querySelector('.cons-source-top-name')?.textContent, '3.8-flash-n');
|
||||
|
||||
@@ -963,8 +963,8 @@ test('post-compaction context preserves static channels + checkpoint summary, ca
|
||||
const stylesCss = fs.readFileSync(new URL('../styles.css', import.meta.url), 'utf8');
|
||||
assert.match(stylesCss, /\.wm-ctx-seg\s*\{[^}]*width:\s*58px;/);
|
||||
assert.match(stylesCss, /\.wm-ctx-pct\s*\{[^}]*max-width:\s*none;[^}]*overflow:\s*visible;[^}]*text-overflow:\s*clip;/s);
|
||||
assert.match(stylesCss, /\.step-model-compact\s*\{[^}]*color:\s*var\(--accent-primary\);/);
|
||||
assert.doesNotMatch(stylesCss, /\.step-model-compact\s*\{[^}]*--metric-info/);
|
||||
assert.match(stylesCss, /\.data-table\s+tbody\s+tr\.is-compaction\s*\{[^}]*var\(--accent-primary\)/);
|
||||
assert.doesNotMatch(stylesCss, /\.data-table\s+tbody\s+tr\.is-compaction\s*\{[^}]*--metric-info/);
|
||||
assert.match(stylesCss, /\.long-pill-nav\s*\{[^}]*container-type:\s*inline-size;[^}]*minmax\(0,\s*1fr\)[^}]*overflow:\s*hidden;/s);
|
||||
assert.match(stylesCss, /\.pill-tab\s*\{[^}]*min-width:\s*0;/s);
|
||||
assert.match(stylesCss, /@container\s*\(max-width:\s*30em\)\s*\{[\s\S]*?\.pill-tab-badge\s*\{\s*display:\s*none\s*!important;/);
|
||||
|
||||
@@ -1147,7 +1147,11 @@ test('Capsule odometer digit rolling (0.15s) and color transition (0.1s) stay st
|
||||
|
||||
// 4. Compiled CSS strictly scopes 150ms roll & 100ms color transition under [data-modern-ui="true"]
|
||||
const builtStyles = fs.readFileSync(new URL('../styles.css', import.meta.url), 'utf8');
|
||||
assert.match(builtStyles, /\.steps-inline-scope-select\s+\.select-menu[\s\S]*?left:\s*0;\s*right:\s*auto;/);
|
||||
assert.match(builtStyles, /\.steps-inline-scope-select\s+\.select-menu[\s\S]*?left:\s*auto;\s*right:\s*0;/);
|
||||
assert.match(
|
||||
builtStyles,
|
||||
/\[data-modern-ui="true"\]\s+\.select-menu,[\s\S]*?animation:\s*anim-modern-tip-fade\s+120ms/
|
||||
);
|
||||
assert.match(builtStyles, /\[data-modern-ui="true"\]\s+\.select-menu\.is-above/);
|
||||
assert.match(
|
||||
builtStyles,
|
||||
|
||||
@@ -11,6 +11,7 @@ import { i18nStore } from '../src/i18n/index.js';
|
||||
import {
|
||||
buildModelAnomalyDiagnostic,
|
||||
buildStepAnomalyDiagnostic,
|
||||
buildStepCompactionDiagnostic,
|
||||
formatAnomalyTagText,
|
||||
formatMetric,
|
||||
formatSpeedMetric,
|
||||
@@ -420,6 +421,15 @@ test('formatSpeedMetric drops decimals at >= 100 tok/s and STEP_COLUMN_REGISTRY.
|
||||
STEP_COLUMN_REGISTRY.duration.updateCell(durCell.refs, { totalDurationSec: 42.3 });
|
||||
assert.equal(durCell.refs.valEl.textContent, '42.3s');
|
||||
|
||||
// Compaction steps keep normal TTFT formatting ("—" when null) instead of overriding the cell
|
||||
const compactTtftCell = STEP_COLUMN_REGISTRY.ttft.createCell();
|
||||
i18nStore.setState({ locale: 'zh-CN' });
|
||||
STEP_COLUMN_REGISTRY.ttft.updateCell(compactTtftCell.refs, { isCompactionStep: true, ttftSec: null });
|
||||
assert.equal(compactTtftCell.refs.valEl.textContent, '—');
|
||||
assert.notEqual(compactTtftCell.refs.valEl.getAttribute('class'), 'step-ttft-compaction');
|
||||
STEP_COLUMN_REGISTRY.ttft.updateCell(compactTtftCell.refs, { isCompactionStep: false, ttftSec: 5.2 });
|
||||
assert.equal(compactTtftCell.refs.valEl.textContent, '5.2s');
|
||||
|
||||
// ContextSegmentMeter renders crisp separated blocks (.ctx-segment-meter + .is-active + .has-sep)
|
||||
const meter = ContextSegmentMeter({
|
||||
context: {
|
||||
@@ -509,6 +519,47 @@ test('StepTableWidget tints entire anomaly rows with zero extra column width and
|
||||
ttftSec: 1.4,
|
||||
anomalySig: '',
|
||||
},
|
||||
{
|
||||
stepIndex: 4918,
|
||||
modelShort: '4-neon',
|
||||
modelLabel: '4-neon',
|
||||
isCompactionStep: true,
|
||||
inputTokens: 120000,
|
||||
cacheReadTokens: 400000,
|
||||
outputTokens: 4400,
|
||||
tokPerSec: 86.6,
|
||||
ttftSec: null,
|
||||
anomalySig: '',
|
||||
},
|
||||
{
|
||||
stepIndex: 4916,
|
||||
modelShort: '4-neon',
|
||||
modelLabel: '4-neon',
|
||||
isCompactionStep: true,
|
||||
inputTokens: 100000,
|
||||
cacheReadTokens: 300000,
|
||||
outputTokens: 2100,
|
||||
tokPerSec: null,
|
||||
selectedSpeedReason: 'error',
|
||||
ttftSec: null,
|
||||
anomalySig: 'timeout:1:w:1.5',
|
||||
anomaly: {
|
||||
count: 1,
|
||||
primaryKind: 'timeout',
|
||||
severity: 'warn',
|
||||
totalDelaySec: 1.5,
|
||||
kinds: { timeout: 1 },
|
||||
events: [
|
||||
{
|
||||
attempt: 1,
|
||||
kind: 'timeout',
|
||||
delaySec: 1.5,
|
||||
terminal: false,
|
||||
message: 'compaction stream idle timeout',
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
widget.refs.renderStepTable(steps, 'cid-1', colKeys, 'zh-CN', {
|
||||
@@ -520,7 +571,7 @@ test('StepTableWidget tints entire anomaly rows with zero extra column width and
|
||||
// Zero extra columns and zero inline text badges added to table cells
|
||||
assert.equal(widget.refs.stepsTheadRow.children.length, colKeys.length);
|
||||
const rows = widget.refs.stepsTbody.children;
|
||||
assert.equal(rows.length, 3);
|
||||
assert.equal(rows.length, 5);
|
||||
assert.equal(rows[0].children.length, colKeys.length);
|
||||
assert.equal(rows[0].querySelector('.step-anomaly-tag'), null, 'No inline tag widening the #step column');
|
||||
|
||||
@@ -533,16 +584,24 @@ test('StepTableWidget tints entire anomaly rows with zero extra column width and
|
||||
assert.equal(rows[1].classList.contains('is-anomaly-danger'), true);
|
||||
assert.equal(rows[1].classList.contains('is-anomaly-warn'), false);
|
||||
|
||||
// Row 2: normal step has NO anomaly row classes and keeps 1 decimal < 100 tok/s
|
||||
// Row 2: normal step has NO anomaly/compaction row classes and keeps 1 decimal < 100 tok/s
|
||||
assert.equal(rows[2].classList.contains('is-anomaly-warn'), false);
|
||||
assert.equal(rows[2].classList.contains('is-anomaly-danger'), false);
|
||||
assert.equal(rows[2].classList.contains('is-compaction'), false);
|
||||
assert.equal(rows[2].children[2].textContent, '65.7 tok/s');
|
||||
|
||||
// Row 3: pure compaction step uses host-accent row tint, keeps TTFT as "—", and shows compaction hover popover
|
||||
assert.equal(rows[3].classList.contains('is-compaction'), true);
|
||||
assert.equal(rows[3].classList.contains('is-anomaly-warn'), false);
|
||||
assert.equal(rows[3].classList.contains('is-anomaly-danger'), false);
|
||||
assert.equal(rows[3].children[3].textContent, '—');
|
||||
|
||||
// Hovering the tinted row expands the structured diagnostic popover
|
||||
const tipEl = widget.refs.anomalyTipEl;
|
||||
assert.equal(tipEl.hasAttribute('hidden'), true);
|
||||
rows[0].onmouseenter();
|
||||
assert.equal(tipEl.hasAttribute('hidden'), false);
|
||||
assert.equal(tipEl.classList.contains('is-compaction'), false);
|
||||
assert.match(tipEl.querySelector('.step-anomaly-tip-title').textContent, /#4924.*异常 1 次/);
|
||||
assert.equal(tipEl.querySelector('.step-anomaly-tip-sub').textContent, '退避 2.5s');
|
||||
assert.match(tipEl.querySelector('.step-anomaly-tip-detail').textContent, /stream idle timeout/);
|
||||
@@ -550,19 +609,44 @@ test('StepTableWidget tints entire anomaly rows with zero extra column width and
|
||||
rows[0].onmouseleave();
|
||||
assert.equal(tipEl.hasAttribute('hidden'), true);
|
||||
|
||||
// Hovering danger row sets danger style on tooltip
|
||||
// Hovering compaction row displays host-accent compaction popover matching warning popover structure
|
||||
rows[3].onmouseenter();
|
||||
assert.equal(tipEl.hasAttribute('hidden'), false);
|
||||
assert.equal(tipEl.classList.contains('is-compaction'), true);
|
||||
assert.equal(tipEl.classList.contains('is-danger'), false);
|
||||
assert.match(tipEl.querySelector('.step-anomaly-tip-title').textContent, /#4918.*自动压缩/);
|
||||
assert.equal(tipEl.querySelector('.step-anomaly-tip-sub').textContent, '4-neon');
|
||||
assert.match(tipEl.querySelector('.step-anomaly-tip-row').textContent, /输入 520\.0k → 摘要输出 4\.4k/);
|
||||
assert.equal(tipEl.querySelector('.step-anomaly-tip-detail').classList.contains('text-mono'), false);
|
||||
rows[3].onmouseleave();
|
||||
assert.equal(tipEl.hasAttribute('hidden'), true);
|
||||
|
||||
// Hovering danger row sets danger style and clears compaction style on tooltip
|
||||
rows[1].onmouseenter();
|
||||
assert.equal(tipEl.hasAttribute('hidden'), false);
|
||||
assert.equal(tipEl.classList.contains('is-danger'), true);
|
||||
assert.equal(tipEl.classList.contains('is-compaction'), false);
|
||||
assert.match(tipEl.querySelector('.step-anomaly-tip-detail').textContent, /429 RESOURCE_EXHAUSTED/);
|
||||
rows[1].onmouseleave();
|
||||
assert.equal(tipEl.hasAttribute('hidden'), true);
|
||||
|
||||
// Row 4: hybrid compaction + anomaly keeps anomaly diagnostic and appends compaction hint
|
||||
assert.equal(rows[4].classList.contains('is-compaction'), true);
|
||||
assert.equal(rows[4].classList.contains('is-anomaly-warn'), true);
|
||||
rows[4].onmouseenter();
|
||||
assert.equal(tipEl.hasAttribute('hidden'), false);
|
||||
assert.equal(tipEl.classList.contains('is-compaction'), false);
|
||||
assert.match(tipEl.querySelector('.step-anomaly-tip-title').textContent, /#4916.*异常 1 次/);
|
||||
assert.match(tipEl.querySelector('.step-anomaly-tip-hint').textContent, /自动压缩/);
|
||||
rows[4].onmouseleave();
|
||||
assert.equal(tipEl.hasAttribute('hidden'), true);
|
||||
|
||||
// Verify helper outputs cleanly
|
||||
assert.equal(formatAnomalyTagText('capacity', 1), '503');
|
||||
assert.equal(formatAnomalyTagText('capacity', 3), '503×3');
|
||||
assert.ok(buildStepAnomalyDiagnostic(steps[0]));
|
||||
assert.equal(buildStepAnomalyDiagnostic(steps[2]), null);
|
||||
assert.equal(buildStepCompactionDiagnostic(steps[3]).severity, 'compaction');
|
||||
} finally {
|
||||
widget.destroy();
|
||||
env.restore();
|
||||
@@ -810,15 +894,31 @@ test('Compiled styles.css centers odometer capsule slot text and ships both clas
|
||||
'Context percentage slot stays left-aligned next to its progress ring'
|
||||
);
|
||||
|
||||
// Universal Classic + Modern UI anomaly styling
|
||||
// Universal Classic + Modern UI compaction & anomaly styling (anomaly overrides compaction if both occur)
|
||||
const classicCompactIdx = builtCss.indexOf('tr.is-compaction {');
|
||||
const classicWarnIdx = builtCss.indexOf('tr.is-anomaly-warn {');
|
||||
assert.ok(classicCompactIdx > 0 && classicWarnIdx > classicCompactIdx, 'Classic tr.is-compaction precedes tr.is-anomaly-warn');
|
||||
assert.match(builtCss, /tr\.is-compaction\s*\{[^}]*var\(--accent-primary\)/);
|
||||
assert.match(builtCss, /\[data-modern-ui="true"\][\s\S]*?tr\.is-compaction[\s\S]*?var\(--accent-primary\)/);
|
||||
assert.match(builtCss, /\.step-anomaly-tip\.is-compaction[\s\S]*?var\(--accent-primary\)/);
|
||||
assert.doesNotMatch(builtCss, /\.step-ttft-compaction/);
|
||||
assert.match(builtCss, /tr\.is-anomaly-warn\s*\{/);
|
||||
assert.match(builtCss, /tr\.is-anomaly-danger\s*\{/);
|
||||
assert.match(builtCss, /\[data-modern-ui="true"\][\s\S]*?tr\.is-anomaly-warn/);
|
||||
assert.match(builtCss, /\.form-row\s*>\s*\.custom-select\s*>\s*\.select-trigger\s*\{[^}]*border:\s*none;[^}]*border-radius:\s*var\(--radius-pill\)/s);
|
||||
assert.match(builtCss, /\.steps-header-filters\s*\{[\s\S]*?justify-content:\s*flex-end;[\s\S]*?margin-left:\s*auto;/);
|
||||
assert.match(builtCss, /\.steps-inline-scope-select,\s*\.steps-inline-model-select\s*\{[\s\S]*?flex:\s*0\s+1\s+auto;/);
|
||||
assert.match(builtCss, /\.steps-inline-scope-select\s+\.select-trigger[\s\S]*?border-radius:\s*var\(--radius-pill\)/);
|
||||
assert.match(builtCss, /\[data-modern-ui="true"\]\s*\.form-row\s*>\s*\.custom-select\s*>\s*\.select-trigger,[\s\S]*?\.steps-inline-scope-select\s+\.select-trigger[\s\S]*?border-radius:\s*var\(--radius-pill\)[\s\S]*?var\(--modern-pill-select-bg\)/);
|
||||
assert.match(builtCss, /\.step-anomaly-tag\s*\{/);
|
||||
assert.match(builtCss, /\.step-anomaly-tip\s*\{/);
|
||||
assert.match(builtCss, /\.steps-anomaly-strip\s*\{/);
|
||||
assert.match(builtCss, /\.steps-anomaly-filterbar\s*\{/);
|
||||
assert.match(builtCss, /\.sstep-anomaly-dot/);
|
||||
assert.match(builtCss, /\.panel\s*>\s*\.table-scroll-host\s*\{[\s\S]*?margin-right:\s*calc\(-1\s*\*\s*var\(--space-5\)\s*\+\s*2px\)/);
|
||||
assert.match(builtCss, /\.panel\s*>\s*\.table-scroll-host\s*>\s*\.custom-scroll-content\s*\{[\s\S]*?padding-right:\s*calc\(var\(--space-5\)\s*-\s*2px\)/);
|
||||
assert.doesNotMatch(builtCss, /\.models-analytics-pane\s*\{[^}]*padding:\s*var\(--space-3\)\s+0\s+2px/);
|
||||
assert.match(builtCss, /\.trend-tip-sub\.is-grid\s*\{[\s\S]*?grid-template-columns:\s*repeat\(3,\s*minmax\(0,\s*1fr\)\)/);
|
||||
assert.match(builtCss, /\.trend-tip-anomaly/);
|
||||
assert.match(builtCss, /\[data-modern-ui="true"\]\s*\.step-anomaly-tip/);
|
||||
assert.match(builtCss, /\.progress-track\.ctx-segment-meter\s*\{[\s\S]*?height:\s*6px;/);
|
||||
|
||||
@@ -2064,7 +2064,7 @@ test('Compiled app.js mounts dual Shadow DOM hosts, tracks /c/<uuid> routes, pro
|
||||
'Consumption sub-label renders CNY approx instead of 步费用待定'
|
||||
);
|
||||
assert.ok(popoverEl.querySelector('.steps-panel-header'), 'Steps header flex wrapper present');
|
||||
assert.ok(popoverEl.querySelector('.steps-panel-title'), 'Steps title non-shrinking class present');
|
||||
assert.equal(popoverEl.querySelector('.steps-panel-title'), null, 'Redundant steps header title removed');
|
||||
|
||||
// Verify <=90d renders flush edge-to-edge SVG line chart, while >90d ('all' = 120 days) switches to GitHub-style daily heatmap grid
|
||||
const plotStageEl = popoverEl.querySelector('.trend-plot-stage');
|
||||
@@ -2093,8 +2093,8 @@ test('Compiled app.js mounts dual Shadow DOM hosts, tracks /c/<uuid> routes, pro
|
||||
assert.match(stylesCss, /\.app-shell\s*\{[^}]*max-width:\s*none;/, 'Sidecar .app-shell removes 560px width cap');
|
||||
assert.match(
|
||||
stylesCss,
|
||||
/\.models-analytics-pane\s*\{[^}]*padding:\s*var\(--space-3\)\s+0\s+2px;/,
|
||||
'Models analytics pane eliminates nested horizontal double-padding'
|
||||
/\.models-analytics-pane\s*\{[^}]*padding-left:\s*0;/,
|
||||
'Models analytics pane eliminates nested left double-padding while preserving right scrollbar clearance'
|
||||
);
|
||||
assert.doesNotMatch(
|
||||
stylesCss,
|
||||
@@ -4526,7 +4526,7 @@ test('v1.5 feedback E2E: sticky bridge port/token across hot-reloads, CDP->HTTP
|
||||
// 2. Verify frontend formatters, non-truncating compaction cell, custom token combo, trimmed model ID, adaptive width & CDP recovery
|
||||
const appJs = fs.readFileSync(new URL('../app.js', import.meta.url), 'utf8');
|
||||
const stylesCss = fs.readFileSync(new URL('../styles.css', import.meta.url), 'utf8');
|
||||
assert.match(stylesCss, /\.step-model-compact\s*\{[^}]*flex-shrink:\s*0;/, 'Compaction suffix never shrinks/truncates');
|
||||
assert.match(stylesCss, /\.data-table\s+tbody\s+tr\.is-compaction\s*\{[^}]*--accent-primary/, 'Compaction row uses whole-row host accent tint');
|
||||
assert.match(stylesCss, /\.wm-popover-panel\s*\{[^}]*--wm-popover-w,\s*540px/, 'Popover supports dynamic CSS width variable');
|
||||
|
||||
const savedSettings = {
|
||||
@@ -4729,20 +4729,20 @@ test('v1.5 feedback E2E: sticky bridge port/token across hot-reloads, CDP->HTTP
|
||||
// Adaptive width expands popover to fit wide 660px table (+ 34px chrome + 4px buffer = 698px)
|
||||
assert.equal(popEl.style.width, '698px', 'Popover adaptively widens on wide step table to eliminate horizontal scroll');
|
||||
|
||||
// Verify trimmed raw IDs (hiding gemini-, claude-, gpt-) AND non-truncating compaction suffix
|
||||
// Verify trimmed raw IDs (hiding gemini-, claude-, gpt-) AND whole-row compaction tint (no inline ·压缩)
|
||||
const bodyRows = stepTable.querySelector('tbody').querySelectorAll('tr');
|
||||
assert.equal(bodyRows.length, 3);
|
||||
|
||||
const row0ModelName = bodyRows[0].querySelector('.step-model-name').textContent;
|
||||
const row0Compact = bodyRows[0].querySelector('.step-model-compact');
|
||||
assert.equal(row0ModelName, '4-hydrogen', 'Strips gemini- prefix from gemini-4-hydrogen');
|
||||
assert.equal(row0Compact.hasAttribute('hidden'), false, 'Compaction badge visible as dedicated flex-shrink:0 span');
|
||||
assert.equal(row0Compact.textContent, '·压缩', 'Compaction suffix never merged into ellipsized span');
|
||||
assert.equal(bodyRows[0].querySelector('.step-model-compact'), null, 'No inline ·压缩 span inside model cell');
|
||||
assert.equal(bodyRows[0].classList.contains('is-compaction'), true, 'Compaction step receives whole-row is-compaction class');
|
||||
assert.equal(bodyRows[0].children[1].getAttribute('title'), 'gemini-4-hydrogen·压缩', 'Hover title keeps full upstream ID');
|
||||
|
||||
assert.equal(bodyRows[1].querySelector('.step-model-name').textContent, 'sonnet-4-6', 'Strips claude- prefix');
|
||||
assert.equal(bodyRows[1].querySelector('.step-model-compact').hasAttribute('hidden'), true);
|
||||
assert.equal(bodyRows[1].classList.contains('is-compaction'), false);
|
||||
assert.equal(bodyRows[2].querySelector('.step-model-name').textContent, '5.4-mini', 'Strips gpt- prefix');
|
||||
assert.equal(bodyRows[2].classList.contains('is-compaction'), false);
|
||||
|
||||
// Verify In / Out / Cache column & Custom Combo column ('context:in:cache')
|
||||
const ths = stepTable.querySelector('thead').querySelectorAll('th');
|
||||
|
||||
Reference in New Issue
Block a user