feat(panel): polish compaction row popover, pill selects, steps header, scrollbar, and chart tooltips

# Conflicts:
#	sidecars/panel/index.html
This commit is contained in:
fish
2026-11-20 16:35:18 +09:00
parent e1c3134e72
commit 481f383763
23 changed files with 1062 additions and 321 deletions
+203 -68
View File
@@ -1368,6 +1368,10 @@ const I18N_MESSAGES_ZH_CN = Object.freeze({
'steps.anomalyKind.canceled': '用户取消',
'steps.anomalyStepTitle': '#{step} · 异常 {count} 次',
'steps.anomalyDelayPart': '退避 {sec}s',
'steps.compactionStepTitle': '#{step} · 自动压缩',
'steps.compactionSummaryRow': '输入 {input} → 摘要输出 {output}',
'steps.compactionDetailHint': '系统自动触发的上下文压缩步骤,用于折叠历史对话以释放窗口空间',
'steps.compactionAnomalyHint': '该步骤同时为系统自动压缩步骤',
'steps.anomalyTerminalTag': '中止',
'steps.anomalyModelTitle': '{model} · 异常 {count} 次',
'steps.anomalyModelSub': '涉及 {steps} 步',
@@ -2073,6 +2077,10 @@ const I18N_MESSAGES_EN_US = Object.freeze({
'steps.anomalyKind.canceled': 'Canceled by User',
'steps.anomalyStepTitle': '#{step} · {count} Retries / Errors',
'steps.anomalyDelayPart': 'Backoff {sec}s',
'steps.compactionStepTitle': '#{step} · Auto-Compaction',
'steps.compactionSummaryRow': 'Input {input} → Summary {output}',
'steps.compactionDetailHint': 'Automatic context compaction step triggered to summarize history and free window space',
'steps.compactionAnomalyHint': 'This step is also an auto-compaction step',
'steps.anomalyTerminalTag': 'Stopped',
'steps.anomalyModelTitle': '{model} · {count} Retries / Errors',
'steps.anomalyModelSub': '{steps} steps affected',
@@ -3268,7 +3276,22 @@ function positionAnchoredPopup(
popupEl.style.maxHeight = '';
const availWidth = Math.max(120, Math.floor(bound.width - margin * 2));
popupEl.style.maxWidth = `${availWidth}px`;
let cssMaxW = NaN;
if (typeof window !== 'undefined' && typeof window.getComputedStyle === 'function') {
try {
const rawMaxW = window.getComputedStyle(popupEl)?.maxWidth;
if (rawMaxW && rawMaxW !== 'none') {
cssMaxW = Number.parseFloat(rawMaxW);
}
} catch {
// 忽略 Mock DOM 样式查询异常
}
}
const effectiveMaxW =
Number.isFinite(cssMaxW) && cssMaxW > 0
? Math.max(120, Math.min(availWidth, Math.floor(cssMaxW)))
: availWidth;
popupEl.style.maxWidth = `${effectiveMaxW}px`;
const rawRect = popupEl.getBoundingClientRect?.();
// 优先读取 offsetWidth,避免入场动画 scale(0.975) 导致测宽偏小
@@ -3276,10 +3299,13 @@ function positionAnchoredPopup(
Number(popupEl.offsetWidth || 0),
Math.ceil(Number(rawRect?.width || 0))
);
if (naturalW > availWidth) {
if (naturalW > effectiveMaxW) {
popupEl.style.minWidth = '0px';
}
const popupW = Math.min(availWidth, naturalW > 0 ? naturalW : Math.max(triggerRect.width, 210));
const popupW = Math.min(
effectiveMaxW,
naturalW > 0 ? naturalW : Math.max(triggerRect.width, 210)
);
const safeLeft = bound.left + margin;
const safeRight = bound.right - margin;
@@ -3422,7 +3448,7 @@ return { defineComponent };
})();
// --- src/core/formatters.js ---
const { formatMetric, formatSpeedMetric, formatCachePct, getSpeedToneClass, getCacheToneClass, getStepCostToneClass, getTtftToneClass, formatTokens, formatTokensPrecise, formatCnyApprox, formatDateSpanBadge, formatUsd, speedReasonText, formatAnomalyKindLabel, formatAnomalyTagText, resolveModelAnomalySummary, formatStepAnomalyInlineSummary, buildStepAnomalyDiagnostic, buildModelAnomalyDiagnostic, sampleSummary, formatCountdown, formatCompactDateTime, formatElapsedSec, stripVendorModelPrefix, normalizeOrchestratorIdDisplayMode, resolveModelDisplayInfo, mergeModelsByDisplayName, getAgentBadgeClass, formatAgentBadgeText, formatAgentLabel, formatConversationMeta, formatLiveActivityLabel, formatLiveActivityDetail, getCanonicalModelColorSeed, resolveDeterministicModelColor, buildDeterministicModelColorMap } = (() => {
const { formatMetric, formatSpeedMetric, formatCachePct, getSpeedToneClass, getCacheToneClass, getStepCostToneClass, getTtftToneClass, formatTokens, formatTokensPrecise, formatCnyApprox, formatDateSpanBadge, formatUsd, speedReasonText, formatAnomalyKindLabel, formatAnomalyTagText, resolveModelAnomalySummary, formatStepAnomalyInlineSummary, buildStepAnomalyDiagnostic, buildStepCompactionDiagnostic, buildModelAnomalyDiagnostic, sampleSummary, formatCountdown, formatCompactDateTime, formatElapsedSec, stripVendorModelPrefix, normalizeOrchestratorIdDisplayMode, resolveModelDisplayInfo, mergeModelsByDisplayName, getAgentBadgeClass, formatAgentBadgeText, formatAgentLabel, formatConversationMeta, formatLiveActivityLabel, formatLiveActivityDetail, getCanonicalModelColorSeed, resolveDeterministicModelColor, buildDeterministicModelColorMap } = (() => {
/**
* @fileoverview Pure formatting utilities for speed metrics, token counts,
* USD estimates, countdown timers, and custom datetime displays.
@@ -3635,6 +3661,42 @@ function buildStepAnomalyDiagnostic(st) {
};
}
function buildStepCompactionDiagnostic(st, displaySettings = {}) {
if (!st || typeof st !== 'object') return null;
const disp = resolveModelDisplayInfo(st, displaySettings, { fallback: '' });
const promptTok =
Math.max(0, Number(st.inputTokens || 0)) + Math.max(0, Number(st.cacheReadTokens || 0));
const outTok = Math.max(0, Number(st.outputTokens || 0));
const title = t('steps.compactionStepTitle', { step: Number(st.stepIndex ?? 0) });
const rows =
promptTok > 0 || outTok > 0
? [
{
text: t('steps.compactionSummaryRow', {
input: formatTokens(promptTok),
output: formatTokens(outTok),
}),
detail: t('steps.compactionDetailHint'),
mono: false,
danger: false,
},
]
: [
{
text: t('steps.compactionDetailHint'),
detail: '',
danger: false,
},
];
return {
title,
sub: disp.baseText || '',
rows,
hint: '',
severity: 'compaction',
};
}
function buildModelAnomalyDiagnostic(m) {
const sum = resolveModelAnomalySummary(m);
if (!sum) return null;
@@ -4444,7 +4506,7 @@ function buildDeterministicModelColorMap(models = []) {
return colorMap;
}
return { formatMetric, formatSpeedMetric, formatCachePct, getSpeedToneClass, getCacheToneClass, getStepCostToneClass, getTtftToneClass, formatTokens, formatTokensPrecise, formatCnyApprox, formatDateSpanBadge, formatUsd, speedReasonText, formatAnomalyKindLabel, formatAnomalyTagText, resolveModelAnomalySummary, formatStepAnomalyInlineSummary, buildStepAnomalyDiagnostic, buildModelAnomalyDiagnostic, sampleSummary, formatCountdown, formatCompactDateTime, formatElapsedSec, stripVendorModelPrefix, normalizeOrchestratorIdDisplayMode, resolveModelDisplayInfo, mergeModelsByDisplayName, getAgentBadgeClass, formatAgentBadgeText, formatAgentLabel, formatConversationMeta, formatLiveActivityLabel, formatLiveActivityDetail, getCanonicalModelColorSeed, resolveDeterministicModelColor, buildDeterministicModelColorMap };
return { formatMetric, formatSpeedMetric, formatCachePct, getSpeedToneClass, getCacheToneClass, getStepCostToneClass, getTtftToneClass, formatTokens, formatTokensPrecise, formatCnyApprox, formatDateSpanBadge, formatUsd, speedReasonText, formatAnomalyKindLabel, formatAnomalyTagText, resolveModelAnomalySummary, formatStepAnomalyInlineSummary, buildStepAnomalyDiagnostic, buildStepCompactionDiagnostic, buildModelAnomalyDiagnostic, sampleSummary, formatCountdown, formatCompactDateTime, formatElapsedSec, stripVendorModelPrefix, normalizeOrchestratorIdDisplayMode, resolveModelDisplayInfo, mergeModelsByDisplayName, getAgentBadgeClass, formatAgentBadgeText, formatAgentLabel, formatConversationMeta, formatLiveActivityLabel, formatLiveActivityDetail, getCanonicalModelColorSeed, resolveDeterministicModelColor, buildDeterministicModelColorMap };
})();
// --- src/core/httpClient.js ---
@@ -7057,6 +7119,7 @@ const CustomSelect = defineComponent({
setup({ getProps, setProps, emit, onCleanup }) {
let isOpen = false;
let focusedIndex = -1;
let lastOpenMenuLayoutSig = '';
const initialIcon = getProps().icon;
const leadIcon = createSvgIcon(initialIcon || 'bolt', { size: 13 });
@@ -7135,6 +7198,15 @@ const CustomSelect = defineComponent({
}
}
function buildMenuLayoutSig(options = [], labelText = '') {
let sig = `${labelText}|${options.length}`;
for (let i = 0; i < options.length; i++) {
const o = options[i];
sig += `|${o?.value ?? ''}:${o?.label ?? ''}:${o?.meta ?? ''}`;
}
return sig;
}
function toggleOpen(nextOpen) {
isOpen = Boolean(nextOpen);
if (isOpen) {
@@ -7145,6 +7217,9 @@ const CustomSelect = defineComponent({
opts.findIndex((o) => selSet.has(o.value))
);
renderMenuOptions();
lastOpenMenuLayoutSig = buildMenuLayoutSig(opts, triggerLabel.textContent || '');
} else {
lastOpenMenuLayoutSig = '';
}
patchClasses(rootEl, { 'is-open': isOpen });
patchAttr(triggerBtn, 'aria-expanded', isOpen ? 'true' : 'false');
@@ -7344,9 +7419,13 @@ const CustomSelect = defineComponent({
patchAttr(triggerBtn, 'title', titleText);
if (isOpen) {
renderMenuOptions();
const nextLayoutSig = buildMenuLayoutSig(options, labelText);
if (nextLayoutSig !== lastOpenMenuLayoutSig) {
lastOpenMenuLayoutSig = nextLayoutSig;
positionMenu();
}
}
}
const handleDocClick = (e) => {
if (isOpen && !isEventInside(e, rootEl)) {
@@ -8708,7 +8787,17 @@ function createTrendAreaChart() {
const tipCallsEl = h('span', { className: 'trend-tip-calls text-mono' });
const tipTokensEl = h('strong', { className: 'trend-tip-tokens text-mono' });
const tipCostEl = h('span', { className: 'trend-tip-cost text-mono' });
const tipSubEl = h('div', { className: 'trend-tip-sub text-mono', hidden: true });
const tipInLabelEl = h('span', { className: 'trend-tip-stat-label', text: t('cons.legInput') });
const tipInValEl = h('span', { className: 'trend-tip-stat-val text-mono' });
const tipCacheLabelEl = h('span', { className: 'trend-tip-stat-label', text: t('cons.legCache') });
const tipCacheValEl = h('span', { className: 'trend-tip-stat-val text-mono' });
const tipOutLabelEl = h('span', { className: 'trend-tip-stat-label', text: t('cons.legOutput') });
const tipOutValEl = h('span', { className: 'trend-tip-stat-val text-mono' });
const tipSubEl = h('div', { className: 'trend-tip-sub is-grid', hidden: true }, [
h('div', { className: 'trend-tip-stat' }, [tipInLabelEl, tipInValEl]),
h('div', { className: 'trend-tip-stat' }, [tipCacheLabelEl, tipCacheValEl]),
h('div', { className: 'trend-tip-stat' }, [tipOutLabelEl, tipOutValEl]),
]);
const tipModelsEl = h('div', { className: 'cons-pop-models', hidden: true });
const tooltipEl = h(
@@ -8839,14 +8928,12 @@ function createTrendAreaChart() {
slot.outputTokens !== undefined);
patchAttr(tipSubEl, 'hidden', !hasSubBreakdown);
if (hasSubBreakdown) {
patchText(
tipSubEl,
t('chart.step.ioSplit', {
inTok: formatTokensPrecise(safeSlotTokens(slot.inputTokens)),
cacheTok: formatTokensPrecise(safeSlotTokens(slot.cacheReadTokens)),
outTok: formatTokensPrecise(safeSlotTokens(slot.outputTokens)),
})
);
patchText(tipInLabelEl, t('cons.legInput'));
patchText(tipCacheLabelEl, t('cons.legCache'));
patchText(tipOutLabelEl, t('cons.legOutput'));
patchText(tipInValEl, formatTokensPrecise(safeSlotTokens(slot.inputTokens)));
patchText(tipCacheValEl, formatTokensPrecise(safeSlotTokens(slot.cacheReadTokens)));
patchText(tipOutValEl, formatTokensPrecise(safeSlotTokens(slot.outputTokens)));
}
const modelSegs = Array.isArray(slot.modelSegments) ? slot.modelSegments : [];
@@ -10251,11 +10338,23 @@ function createSessionLineChart() {
const tipHeadRight = h('span', { className: 'trend-tip-calls text-mono' });
const tipMainLeft = h('strong', { className: 'trend-tip-tokens text-mono' });
const tipMainRight = h('span', { className: 'trend-tip-cost text-mono' });
const tipInLabelEl = h('span', { className: 'trend-tip-stat-label', text: t('cons.legInput') });
const tipInValEl = h('span', { className: 'trend-tip-stat-val text-mono' });
const tipCacheLabelEl = h('span', { className: 'trend-tip-stat-label', text: t('cons.legCache') });
const tipCacheValEl = h('span', { className: 'trend-tip-stat-val text-mono' });
const tipOutLabelEl = h('span', { className: 'trend-tip-stat-label', text: t('cons.legOutput') });
const tipOutValEl = h('span', { className: 'trend-tip-stat-val text-mono' });
const tipIoGrid = h('div', { className: 'trend-tip-sub is-grid', hidden: true }, [
h('div', { className: 'trend-tip-stat' }, [tipInLabelEl, tipInValEl]),
h('div', { className: 'trend-tip-stat' }, [tipCacheLabelEl, tipCacheValEl]),
h('div', { className: 'trend-tip-stat' }, [tipOutLabelEl, tipOutValEl]),
]);
const tipSub = h('div', { className: 'trend-tip-sub text-mono', hidden: true });
const tipAnomaly = h('div', { className: 'trend-tip-anomaly text-mono', hidden: true });
const tooltipEl = h('div', { className: 'trend-tooltip', hidden: true }, [
h('div', { className: 'trend-tip-head' }, [tipHeadLeft, tipHeadRight]),
h('div', { className: 'trend-tip-main' }, [tipMainLeft, tipMainRight]),
tipIoGrid,
tipSub,
tipAnomaly,
]);
@@ -10332,8 +10431,18 @@ function createSessionLineChart() {
pt.valid ? formatChartMetricValue(currentMetric, pt.value) : t('chart.step.excluded')
);
patchText(tipMainRight, pt.secondaryRight || '');
patchAttr(tipSub, 'hidden', !pt.subDetail);
if (pt.subDetail) {
const hasIoParts = Boolean(pt.ioParts);
patchAttr(tipIoGrid, 'hidden', !hasIoParts);
if (hasIoParts) {
patchText(tipInLabelEl, t('cons.legInput'));
patchText(tipCacheLabelEl, t('cons.legCache'));
patchText(tipOutLabelEl, t('cons.legOutput'));
patchText(tipInValEl, pt.ioParts.inTok);
patchText(tipCacheValEl, pt.ioParts.cacheTok);
patchText(tipOutValEl, pt.ioParts.outTok);
}
patchAttr(tipSub, 'hidden', hasIoParts || !pt.subDetail);
if (!hasIoParts && pt.subDetail) {
patchText(tipSub, pt.subDetail);
}
patchAttr(tipAnomaly, 'hidden', !pt.anomalySummary);
@@ -10576,15 +10685,17 @@ function createSessionLineChart() {
let value = 0;
let secondaryRight = '';
let subDetail = '';
let ioParts = null;
if (metric === 'totalTokens') {
value = isMultiCompare ? modelCumTok : runningTokens;
secondaryRight = t('chart.step.stepAdd', { tokens: formatTokens(stepTotalTok) });
subDetail = t('chart.step.ioSplit', {
ioParts = {
inTok: formatTokens(inTok),
cacheTok: formatTokens(cacheTok),
outTok: formatTokens(outTok),
});
};
subDetail = t('chart.step.ioSplit', ioParts);
} else if (metric === 'context') {
value = ctxTok;
if (hasPrevCtx) {
@@ -10667,6 +10778,7 @@ function createSessionLineChart() {
value,
secondaryRight,
subDetail,
ioParts,
anomalySummary,
anomalySeverity: st.anomaly?.severity || '',
};
@@ -14666,7 +14778,7 @@ return { OVERVIEW_WIDGET_KEYS, OVERVIEW_WIDGET_REGISTRY, getOverviewModuleOption
})();
// --- src/registries/stepColumnRegistry.js ---
const { STEP_COLUMN_KEYS, DEFAULT_STEP_COLUMN_KEYS, formatCustomTokenComboHeader, STEP_COLUMN_REGISTRY, getStepColumnOptions } = (() => {
const { STEP_COLUMN_KEYS, DEFAULT_STEP_COLUMN_KEYS, formatCustomTokenComboHeader, isCompactionStepItem, STEP_COLUMN_REGISTRY, getStepColumnOptions } = (() => {
/**
* @fileoverview Decoupled Step Table Column Registry (`stepColumnRegistry.js`).
* Defines all 12 customizable columns for `StepsDetailView` ("按步查看"),
@@ -14761,6 +14873,13 @@ function formatStepClockTime(createdAtMs) {
return { text: hhmmss, title: full };
}
function isCompactionStepItem(st) {
if (!st || typeof st !== 'object') return false;
if (st.isCompactionStep) return true;
const raw = `${st.activeModelShort ?? st.modelShort ?? ''} ${st.activeModelLabel ?? st.modelLabel ?? ''} ${st.activeModelUpstream ?? st.modelUpstream ?? ''}`;
return /·(?:压缩|compact)(?=\s|$)|\[自动压缩\]/iu.test(raw);
}
const STEP_COLUMN_REGISTRY = Object.freeze({
step: {
key: 'step',
@@ -14800,21 +14919,17 @@ const STEP_COLUMN_REGISTRY = Object.freeze({
optLabel: () => t('stepCol.model.opt'),
sigPart: (st, ctx) => {
const disp = resolveModelDisplayInfo(st, ctx.displaySettings, { fallback: '—' });
return `${disp.baseText}:${disp.compactionSuffix}:${disp.title}`;
return `${disp.baseText}:${disp.title}`;
},
createCell: () => {
const nameEl = h('span', { className: 'step-model-name' });
const compactEl = h('span', { className: 'step-model-compact', hidden: true });
const wrapEl = h('span', { className: 'step-model-cell' }, [nameEl, compactEl]);
const wrapEl = h('span', { className: 'step-model-cell' }, [nameEl]);
const td = h('td', {}, [wrapEl]);
return { td, refs: { td, wrapEl, nameEl, compactEl } };
return { td, refs: { td, wrapEl, nameEl } };
},
updateCell: (refs, st, ctx) => {
const modelDisplay = resolveModelDisplayInfo(st, ctx.displaySettings, { fallback: '—' });
patchText(refs.nameEl, modelDisplay.baseText);
const suffix = modelDisplay.compactionSuffix || '';
patchText(refs.compactEl, suffix);
patchAttr(refs.compactEl, 'hidden', !suffix);
patchAttr(refs.td, 'title', modelDisplay.title);
},
},
@@ -15083,7 +15198,7 @@ function getStepColumnOptions(
label: STEP_COLUMN_REGISTRY[key].optLabel(ctx),
}));
}
return { STEP_COLUMN_KEYS, DEFAULT_STEP_COLUMN_KEYS, formatCustomTokenComboHeader, STEP_COLUMN_REGISTRY, getStepColumnOptions };
return { STEP_COLUMN_KEYS, DEFAULT_STEP_COLUMN_KEYS, formatCustomTokenComboHeader, isCompactionStepItem, STEP_COLUMN_REGISTRY, getStepColumnOptions };
})();
// --- src/components/widgets/CapsuleBarWidget.js ---
@@ -15959,7 +16074,7 @@ function buildColumnSizerSpec(tableSteps, colKeys, wantedSet, cellCtx) {
let bestModelObj = firstStep;
for (const cand of modelCandidates.values()) {
const disp = resolveModelDisplayInfo(cand, cellCtx?.displaySettings, { fallback: '—' });
const len = (disp.baseText?.length || 0) + (disp.compactionSuffix?.length || 0);
const len = disp.baseText?.length || 0;
if (len > bestModelLen) {
bestModelLen = len;
bestModelObj = cand;
@@ -16139,7 +16254,10 @@ const StepTableWidget = defineComponent({
return;
}
hideTurnTip();
patchClasses(anomalyTipEl, { 'is-danger': diag.severity === 'danger' });
patchClasses(anomalyTipEl, {
'is-danger': diag.severity === 'danger',
'is-compaction': diag.severity === 'compaction',
});
patchText(anomalyTipTitleEl, diag.title);
patchAttr(anomalyTipSubEl, 'hidden', !diag.sub);
if (diag.sub) patchText(anomalyTipSubEl, diag.sub);
@@ -16157,7 +16275,10 @@ const StepTableWidget = defineComponent({
if (row.detail) {
itemChildren.push(
h('div', {
className: 'step-anomaly-tip-detail text-mono',
className:
row.mono === false
? 'step-anomaly-tip-detail'
: 'step-anomaly-tip-detail text-mono',
text: row.detail,
})
);
@@ -16309,16 +16430,35 @@ const StepTableWidget = defineComponent({
if (event?.target === badge) hideTurnTip();
}
function buildStepRowDiagnostic(st, displaySettings, hasStepAnomaly, isCompactionRow) {
if (hasStepAnomaly) {
const diag = buildStepAnomalyDiagnostic(st);
if (diag && isCompactionRow) {
return {
...diag,
hint: diag.hint
? `${diag.hint} · ${t('steps.compactionAnomalyHint')}`
: t('steps.compactionAnomalyHint'),
};
}
return diag;
}
if (isCompactionRow) {
return buildStepCompactionDiagnostic(st, displaySettings);
}
return null;
}
function moveAlongTurnRail(event) {
const { badge, prompt, anomalyStep } = hoverRows.get(this);
const { badge, prompt, rowDiagGetter } = hoverRows.get(this);
const rect = this.getBoundingClientRect?.();
const relX = rect ? (event?.clientX ?? 0) - rect.left : 0;
if (event?.target !== badge && relX <= 18) {
showTurnTip(this, prompt);
} else {
hideTurnTip();
if (anomalyStep) {
showAnomalyTip(this, buildStepAnomalyDiagnostic(anomalyStep));
if (rowDiagGetter) {
showAnomalyTip(this, rowDiagGetter());
}
}
}
@@ -16326,8 +16466,8 @@ const StepTableWidget = defineComponent({
function leaveStepCell(event) {
const entry = hoverRows.get(this);
hideTurnTip();
if (entry?.anomalyStep && entry.tr && event?.relatedTarget && entry.tr.contains?.(event.relatedTarget)) {
showAnomalyTip(this, buildStepAnomalyDiagnostic(entry.anomalyStep));
if (entry?.rowDiagGetter && entry.tr && event?.relatedTarget && entry.tr.contains?.(event.relatedTarget)) {
showAnomalyTip(this, entry.rowDiagGetter());
}
}
@@ -16621,7 +16761,8 @@ const StepTableWidget = defineComponent({
: '';
const stripeSig = isVirtualized ? (item.isStripeEven ? 'E' : 'O') : 'N';
const anomalySig = st.anomalySig || '';
return `${locale}:${colOrderSig}:${stripeSig}:${badgeSig}:${anomalySig}:${railActive}:${item.hasTurn}:${item.hasUp}:${item.hasDown}:${item.isStart}:${item.isLatest}:${item.prompt}:${parts}`;
const compactSig = isCompactionStepItem(st) ? 'C' : '';
return `${locale}:${colOrderSig}:${stripeSig}:${badgeSig}:${anomalySig}:${compactSig}:${railActive}:${item.hasTurn}:${item.hasUp}:${item.hasDown}:${item.isStart}:${item.isLatest}:${item.prompt}:${parts}`;
},
createRow: (item) => {
if (item.isSizer) {
@@ -16866,14 +17007,20 @@ const StepTableWidget = defineComponent({
const hasStepAnomaly = Boolean(st?.anomaly && Number(st.anomaly.count) > 0);
const isAnomalyDanger = Boolean(hasStepAnomaly && st.anomaly.severity === 'danger');
const isAnomalyWarn = Boolean(hasStepAnomaly && !isAnomalyDanger);
const isCompactionRow = isCompactionStepItem(st);
const hasRowTip = hasStepAnomaly || isCompactionRow;
const rowDiagGetter = hasRowTip
? () => buildStepRowDiagnostic(st, cellCtx.displaySettings, hasStepAnomaly, isCompactionRow)
: null;
patchClasses(tr, {
'is-compaction': isCompactionRow,
'is-anomaly-warn': isAnomalyWarn,
'is-anomaly-danger': isAnomalyDanger,
});
if (hasStepAnomaly) {
if (hasRowTip) {
const anchorEl = firstTd || tr;
tr.onmouseenter = () => {
showAnomalyTip(anchorEl, buildStepAnomalyDiagnostic(st));
showAnomalyTip(anchorEl, rowDiagGetter());
};
tr.onmouseleave = hideAnomalyTip;
} else {
@@ -16898,10 +17045,10 @@ const StepTableWidget = defineComponent({
hoverRows.set(hoverTd, {
badge: refs.agentBadgeEl,
prompt,
anomalyStep: hasStepAnomaly ? st : null,
rowDiagGetter,
tr,
});
const useWholeCellTurnTip = firstColKey === 'step' && !hasStepAnomaly;
const useWholeCellTurnTip = firstColKey === 'step' && !hasRowTip;
hoverTd.onmouseenter = useWholeCellTurnTip ? enterStepCell : null;
hoverTd.onmousemove = useWholeCellTurnTip ? moveInStepCell : moveAlongTurnRail;
hoverTd.onmouseleave = leaveStepCell;
@@ -16929,6 +17076,7 @@ const StepTableWidget = defineComponent({
patchClasses(tr, {
'is-stripe-even': false,
'is-step-entering': false,
'is-compaction': false,
'is-anomaly-warn': false,
'is-anomaly-danger': false,
});
@@ -22080,12 +22228,11 @@ const ConsumptionView = defineComponent({
}
/**
* 创建热门模型单行 DOM 结构(模型名称后附专属颜色圆点 + 按总占比缩放的 4 段比例条 + 底部分项脚标)。
* 创建热门模型单行 DOM 结构(模型名称 + 按总占比缩放的 4 段比例条 + 底部分项脚标)。
*/
function createBreakdownItemRow() {
const nameTextEl = h('span', { className: 'cons-row-title-text' });
const modelDotEl = h('span', { className: 'dot-swatch cons-model-dot cons-title-model-dot' });
const nameEl = h('strong', { className: 'cons-row-title' }, [nameTextEl, modelDotEl]);
const nameEl = h('strong', { className: 'cons-row-title' }, [nameTextEl]);
const pctBadge = h('span', { className: 'cons-share-pill text-mono', text: '0%' });
const totalTokEl = h('span', { className: 'cons-row-tok text-mono' });
const costEl = h('strong', { className: 'cons-row-cost text-mono' });
@@ -22146,7 +22293,6 @@ const ConsumptionView = defineComponent({
refs: {
nameEl,
nameTextEl,
modelDotEl,
pctBadge,
totalTokEl,
costEl,
@@ -22166,9 +22312,9 @@ const ConsumptionView = defineComponent({
}
/**
* 增量更新热门模型单行的指标文本、名称后的专属颜色圆点与按总占比缩放的 4 段比例条宽度。
* 增量更新热门模型单行的指标文本与按总占比缩放的 4 段比例条宽度。
*/
function updateBreakdownItemRow(refs, item, grandTotalTokens, modelColor = '') {
function updateBreakdownItemRow(refs, item, grandTotalTokens) {
patchText(refs.inLbl, t('cons.footInput'));
patchText(refs.cacheLbl, t('cons.footCache'));
patchText(refs.outLbl, t('cons.footOutput'));
@@ -22177,10 +22323,6 @@ const ConsumptionView = defineComponent({
const displayLabel = item.label || item.name || item.shortName || '—';
patchText(refs.nameTextEl, displayLabel);
patchAttr(refs.nameEl, 'title', item.title || displayLabel);
patchAttr(refs.modelDotEl, 'hidden', !modelColor);
if (modelColor) {
patchStyleVar(refs.modelDotEl, '--dot-color', modelColor);
}
const total = Number(item.totalTokens || 0);
const share = grandTotalTokens > 0 ? +((total / grandTotalTokens) * 100).toFixed(1) : 0;
const scaleRatio =
@@ -22663,23 +22805,17 @@ const ConsumptionView = defineComponent({
});
trendChart.update(enrichedTrendSeries);
// 3. 同步热门模型列表(名称后带专属颜色圆点 + 4 段条按总占比缩放长度)
// 3. 同步热门模型列表(4 段条按总占比缩放长度)
patchKeyedList(modelsListEl, models, {
keyFn: (m) => m.displayText || m.label || m.shortName,
sigFn: (m) => {
const seed = getCanonicalModelColorSeed(m);
const color = modelColorMap.get(seed) || resolveDeterministicModelColor(seed);
return `${localeSig}:${m.displayText}:${m.displayTitle}:${color}:${m.totalTokens}:${m.inputTokens}:${m.cacheReadTokens}:${m.responseTokens}:${m.thinkingTokens}:${m.costUsd}:${m.unpricedCalls}:${m.calls}:${modelsTotalTok}`;
},
sigFn: (m) =>
`${localeSig}:${m.displayText}:${m.displayTitle}:${m.totalTokens}:${m.inputTokens}:${m.cacheReadTokens}:${m.responseTokens}:${m.thinkingTokens}:${m.costUsd}:${m.unpricedCalls}:${m.calls}:${modelsTotalTok}`,
createRow: createBreakdownItemRow,
updateRow: (refs, m) => {
const seed = getCanonicalModelColorSeed(m);
const color = modelColorMap.get(seed) || resolveDeterministicModelColor(seed);
updateBreakdownItemRow(
refs,
{ ...m, label: m.displayText, title: m.displayTitle },
modelsTotalTok,
color
modelsTotalTok
);
},
});
@@ -23331,7 +23467,11 @@ const StepsDetailView = defineComponent({
});
modelsScroll.el.setAttribute('hidden', '');
const panelTitleTextEl = h('span', { text: t('steps.title') });
const headerFiltersEl = h('div', { className: 'steps-header-filters', hidden: true }, [
inlineScopeSelect.el,
stepsModelSelect.el,
]);
const panelEl = h(
'section',
{
@@ -23340,14 +23480,9 @@ const StepsDetailView = defineComponent({
},
[
h('div', { className: 'panel-header steps-panel-header' }, [
h('span', { className: 'panel-title steps-panel-title' }, [
createSvgIcon('table', { size: 13 }),
panelTitleTextEl,
]),
h('div', { className: 'steps-header-controls' }, [
inlineScopeSelect.el,
stepsModelSelect.el,
subTabSwitch.el,
headerFiltersEl,
]),
]),
anomalyFilterBarEl,
@@ -23420,7 +23555,6 @@ const StepsDetailView = defineComponent({
}
function refreshStaticLocaleLabels() {
patchText(panelTitleTextEl, t('steps.title'));
patchText(lineTitleEl, t('steps.lineTitle'));
patchText(fitTitleEl, t('steps.fitTitle'));
patchText(modelsSectionTitleEl, t('steps.modelsTitle'));
@@ -23640,6 +23774,7 @@ const StepsDetailView = defineComponent({
);
const showStepsModelFilter = uiSt.stepsSubTab === 'steps' && hasMultipleModels;
patchAttr(stepsModelSelect.el, 'hidden', !showStepsModelFilter);
patchAttr(headerFiltersEl, 'hidden', !hasSubagents && !showStepsModelFilter);
if (hasMultipleModels) {
stepsModelSelect.setProps({
modelValue: selectedTableModels,
+2 -2
View File
@@ -4,11 +4,11 @@
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>用量监控</title>
<link rel="stylesheet" href="/styles.css?v=1795159546122">
<link rel="stylesheet" href="/styles.css?v=1795159964533">
<script src="/preload.js"></script>
</head>
<body>
<div id="app-root"></div>
<script src="/app.js?v=1795159546122"></script>
<script src="/app.js?v=1795159964533"></script>
</body>
</html>
@@ -782,11 +782,23 @@ export function createSessionLineChart() {
const tipHeadRight = h('span', { className: 'trend-tip-calls text-mono' });
const tipMainLeft = h('strong', { className: 'trend-tip-tokens text-mono' });
const tipMainRight = h('span', { className: 'trend-tip-cost text-mono' });
const tipInLabelEl = h('span', { className: 'trend-tip-stat-label', text: t('cons.legInput') });
const tipInValEl = h('span', { className: 'trend-tip-stat-val text-mono' });
const tipCacheLabelEl = h('span', { className: 'trend-tip-stat-label', text: t('cons.legCache') });
const tipCacheValEl = h('span', { className: 'trend-tip-stat-val text-mono' });
const tipOutLabelEl = h('span', { className: 'trend-tip-stat-label', text: t('cons.legOutput') });
const tipOutValEl = h('span', { className: 'trend-tip-stat-val text-mono' });
const tipIoGrid = h('div', { className: 'trend-tip-sub is-grid', hidden: true }, [
h('div', { className: 'trend-tip-stat' }, [tipInLabelEl, tipInValEl]),
h('div', { className: 'trend-tip-stat' }, [tipCacheLabelEl, tipCacheValEl]),
h('div', { className: 'trend-tip-stat' }, [tipOutLabelEl, tipOutValEl]),
]);
const tipSub = h('div', { className: 'trend-tip-sub text-mono', hidden: true });
const tipAnomaly = h('div', { className: 'trend-tip-anomaly text-mono', hidden: true });
const tooltipEl = h('div', { className: 'trend-tooltip', hidden: true }, [
h('div', { className: 'trend-tip-head' }, [tipHeadLeft, tipHeadRight]),
h('div', { className: 'trend-tip-main' }, [tipMainLeft, tipMainRight]),
tipIoGrid,
tipSub,
tipAnomaly,
]);
@@ -863,8 +875,18 @@ export function createSessionLineChart() {
pt.valid ? formatChartMetricValue(currentMetric, pt.value) : t('chart.step.excluded')
);
patchText(tipMainRight, pt.secondaryRight || '');
patchAttr(tipSub, 'hidden', !pt.subDetail);
if (pt.subDetail) {
const hasIoParts = Boolean(pt.ioParts);
patchAttr(tipIoGrid, 'hidden', !hasIoParts);
if (hasIoParts) {
patchText(tipInLabelEl, t('cons.legInput'));
patchText(tipCacheLabelEl, t('cons.legCache'));
patchText(tipOutLabelEl, t('cons.legOutput'));
patchText(tipInValEl, pt.ioParts.inTok);
patchText(tipCacheValEl, pt.ioParts.cacheTok);
patchText(tipOutValEl, pt.ioParts.outTok);
}
patchAttr(tipSub, 'hidden', hasIoParts || !pt.subDetail);
if (!hasIoParts && pt.subDetail) {
patchText(tipSub, pt.subDetail);
}
patchAttr(tipAnomaly, 'hidden', !pt.anomalySummary);
@@ -1107,15 +1129,17 @@ export function createSessionLineChart() {
let value = 0;
let secondaryRight = '';
let subDetail = '';
let ioParts = null;
if (metric === 'totalTokens') {
value = isMultiCompare ? modelCumTok : runningTokens;
secondaryRight = t('chart.step.stepAdd', { tokens: formatTokens(stepTotalTok) });
subDetail = t('chart.step.ioSplit', {
ioParts = {
inTok: formatTokens(inTok),
cacheTok: formatTokens(cacheTok),
outTok: formatTokens(outTok),
});
};
subDetail = t('chart.step.ioSplit', ioParts);
} else if (metric === 'context') {
value = ctxTok;
if (hasPrevCtx) {
@@ -1198,6 +1222,7 @@ export function createSessionLineChart() {
value,
secondaryRight,
subDetail,
ioParts,
anomalySummary,
anomalySeverity: st.anomaly?.severity || '',
};
@@ -324,7 +324,17 @@ export function createTrendAreaChart() {
const tipCallsEl = h('span', { className: 'trend-tip-calls text-mono' });
const tipTokensEl = h('strong', { className: 'trend-tip-tokens text-mono' });
const tipCostEl = h('span', { className: 'trend-tip-cost text-mono' });
const tipSubEl = h('div', { className: 'trend-tip-sub text-mono', hidden: true });
const tipInLabelEl = h('span', { className: 'trend-tip-stat-label', text: t('cons.legInput') });
const tipInValEl = h('span', { className: 'trend-tip-stat-val text-mono' });
const tipCacheLabelEl = h('span', { className: 'trend-tip-stat-label', text: t('cons.legCache') });
const tipCacheValEl = h('span', { className: 'trend-tip-stat-val text-mono' });
const tipOutLabelEl = h('span', { className: 'trend-tip-stat-label', text: t('cons.legOutput') });
const tipOutValEl = h('span', { className: 'trend-tip-stat-val text-mono' });
const tipSubEl = h('div', { className: 'trend-tip-sub is-grid', hidden: true }, [
h('div', { className: 'trend-tip-stat' }, [tipInLabelEl, tipInValEl]),
h('div', { className: 'trend-tip-stat' }, [tipCacheLabelEl, tipCacheValEl]),
h('div', { className: 'trend-tip-stat' }, [tipOutLabelEl, tipOutValEl]),
]);
const tipModelsEl = h('div', { className: 'cons-pop-models', hidden: true });
const tooltipEl = h(
@@ -455,14 +465,12 @@ export function createTrendAreaChart() {
slot.outputTokens !== undefined);
patchAttr(tipSubEl, 'hidden', !hasSubBreakdown);
if (hasSubBreakdown) {
patchText(
tipSubEl,
t('chart.step.ioSplit', {
inTok: formatTokensPrecise(safeSlotTokens(slot.inputTokens)),
cacheTok: formatTokensPrecise(safeSlotTokens(slot.cacheReadTokens)),
outTok: formatTokensPrecise(safeSlotTokens(slot.outputTokens)),
})
);
patchText(tipInLabelEl, t('cons.legInput'));
patchText(tipCacheLabelEl, t('cons.legCache'));
patchText(tipOutLabelEl, t('cons.legOutput'));
patchText(tipInValEl, formatTokensPrecise(safeSlotTokens(slot.inputTokens)));
patchText(tipCacheValEl, formatTokensPrecise(safeSlotTokens(slot.cacheReadTokens)));
patchText(tipOutValEl, formatTokensPrecise(safeSlotTokens(slot.outputTokens)));
}
const modelSegs = Array.isArray(slot.modelSegments) ? slot.modelSegments : [];
@@ -56,6 +56,7 @@ export const CustomSelect = defineComponent({
setup({ getProps, setProps, emit, onCleanup }) {
let isOpen = false;
let focusedIndex = -1;
let lastOpenMenuLayoutSig = '';
const initialIcon = getProps().icon;
const leadIcon = createSvgIcon(initialIcon || 'bolt', { size: 13 });
@@ -134,6 +135,15 @@ export const CustomSelect = defineComponent({
}
}
function buildMenuLayoutSig(options = [], labelText = '') {
let sig = `${labelText}|${options.length}`;
for (let i = 0; i < options.length; i++) {
const o = options[i];
sig += `|${o?.value ?? ''}:${o?.label ?? ''}:${o?.meta ?? ''}`;
}
return sig;
}
function toggleOpen(nextOpen) {
isOpen = Boolean(nextOpen);
if (isOpen) {
@@ -144,6 +154,9 @@ export const CustomSelect = defineComponent({
opts.findIndex((o) => selSet.has(o.value))
);
renderMenuOptions();
lastOpenMenuLayoutSig = buildMenuLayoutSig(opts, triggerLabel.textContent || '');
} else {
lastOpenMenuLayoutSig = '';
}
patchClasses(rootEl, { 'is-open': isOpen });
patchAttr(triggerBtn, 'aria-expanded', isOpen ? 'true' : 'false');
@@ -343,9 +356,13 @@ export const CustomSelect = defineComponent({
patchAttr(triggerBtn, 'title', titleText);
if (isOpen) {
renderMenuOptions();
const nextLayoutSig = buildMenuLayoutSig(options, labelText);
if (nextLayoutSig !== lastOpenMenuLayoutSig) {
lastOpenMenuLayoutSig = nextLayoutSig;
positionMenu();
}
}
}
const handleDocClick = (e) => {
if (isOpen && !isEventInside(e, rootEl)) {
@@ -15,6 +15,7 @@ import {
} from '../../core/domPatch.js';
import {
buildStepAnomalyDiagnostic,
buildStepCompactionDiagnostic,
resolveModelDisplayInfo,
speedReasonText,
} from '../../core/formatters.js';
@@ -22,6 +23,7 @@ import { getEffectiveLocale, t } from '../../i18n/index.js';
import {
DEFAULT_STEP_COLUMN_KEYS,
STEP_COLUMN_REGISTRY,
isCompactionStepItem,
} from '../../registries/stepColumnRegistry.js';
import {
formatAgentBadgeText,
@@ -329,7 +331,7 @@ function buildColumnSizerSpec(tableSteps, colKeys, wantedSet, cellCtx) {
let bestModelObj = firstStep;
for (const cand of modelCandidates.values()) {
const disp = resolveModelDisplayInfo(cand, cellCtx?.displaySettings, { fallback: '—' });
const len = (disp.baseText?.length || 0) + (disp.compactionSuffix?.length || 0);
const len = disp.baseText?.length || 0;
if (len > bestModelLen) {
bestModelLen = len;
bestModelObj = cand;
@@ -509,7 +511,10 @@ export const StepTableWidget = defineComponent({
return;
}
hideTurnTip();
patchClasses(anomalyTipEl, { 'is-danger': diag.severity === 'danger' });
patchClasses(anomalyTipEl, {
'is-danger': diag.severity === 'danger',
'is-compaction': diag.severity === 'compaction',
});
patchText(anomalyTipTitleEl, diag.title);
patchAttr(anomalyTipSubEl, 'hidden', !diag.sub);
if (diag.sub) patchText(anomalyTipSubEl, diag.sub);
@@ -527,7 +532,10 @@ export const StepTableWidget = defineComponent({
if (row.detail) {
itemChildren.push(
h('div', {
className: 'step-anomaly-tip-detail text-mono',
className:
row.mono === false
? 'step-anomaly-tip-detail'
: 'step-anomaly-tip-detail text-mono',
text: row.detail,
})
);
@@ -679,16 +687,35 @@ export const StepTableWidget = defineComponent({
if (event?.target === badge) hideTurnTip();
}
function buildStepRowDiagnostic(st, displaySettings, hasStepAnomaly, isCompactionRow) {
if (hasStepAnomaly) {
const diag = buildStepAnomalyDiagnostic(st);
if (diag && isCompactionRow) {
return {
...diag,
hint: diag.hint
? `${diag.hint} · ${t('steps.compactionAnomalyHint')}`
: t('steps.compactionAnomalyHint'),
};
}
return diag;
}
if (isCompactionRow) {
return buildStepCompactionDiagnostic(st, displaySettings);
}
return null;
}
function moveAlongTurnRail(event) {
const { badge, prompt, anomalyStep } = hoverRows.get(this);
const { badge, prompt, rowDiagGetter } = hoverRows.get(this);
const rect = this.getBoundingClientRect?.();
const relX = rect ? (event?.clientX ?? 0) - rect.left : 0;
if (event?.target !== badge && relX <= 18) {
showTurnTip(this, prompt);
} else {
hideTurnTip();
if (anomalyStep) {
showAnomalyTip(this, buildStepAnomalyDiagnostic(anomalyStep));
if (rowDiagGetter) {
showAnomalyTip(this, rowDiagGetter());
}
}
}
@@ -696,8 +723,8 @@ export const StepTableWidget = defineComponent({
function leaveStepCell(event) {
const entry = hoverRows.get(this);
hideTurnTip();
if (entry?.anomalyStep && entry.tr && event?.relatedTarget && entry.tr.contains?.(event.relatedTarget)) {
showAnomalyTip(this, buildStepAnomalyDiagnostic(entry.anomalyStep));
if (entry?.rowDiagGetter && entry.tr && event?.relatedTarget && entry.tr.contains?.(event.relatedTarget)) {
showAnomalyTip(this, entry.rowDiagGetter());
}
}
@@ -991,7 +1018,8 @@ export const StepTableWidget = defineComponent({
: '';
const stripeSig = isVirtualized ? (item.isStripeEven ? 'E' : 'O') : 'N';
const anomalySig = st.anomalySig || '';
return `${locale}:${colOrderSig}:${stripeSig}:${badgeSig}:${anomalySig}:${railActive}:${item.hasTurn}:${item.hasUp}:${item.hasDown}:${item.isStart}:${item.isLatest}:${item.prompt}:${parts}`;
const compactSig = isCompactionStepItem(st) ? 'C' : '';
return `${locale}:${colOrderSig}:${stripeSig}:${badgeSig}:${anomalySig}:${compactSig}:${railActive}:${item.hasTurn}:${item.hasUp}:${item.hasDown}:${item.isStart}:${item.isLatest}:${item.prompt}:${parts}`;
},
createRow: (item) => {
if (item.isSizer) {
@@ -1236,14 +1264,20 @@ export const StepTableWidget = defineComponent({
const hasStepAnomaly = Boolean(st?.anomaly && Number(st.anomaly.count) > 0);
const isAnomalyDanger = Boolean(hasStepAnomaly && st.anomaly.severity === 'danger');
const isAnomalyWarn = Boolean(hasStepAnomaly && !isAnomalyDanger);
const isCompactionRow = isCompactionStepItem(st);
const hasRowTip = hasStepAnomaly || isCompactionRow;
const rowDiagGetter = hasRowTip
? () => buildStepRowDiagnostic(st, cellCtx.displaySettings, hasStepAnomaly, isCompactionRow)
: null;
patchClasses(tr, {
'is-compaction': isCompactionRow,
'is-anomaly-warn': isAnomalyWarn,
'is-anomaly-danger': isAnomalyDanger,
});
if (hasStepAnomaly) {
if (hasRowTip) {
const anchorEl = firstTd || tr;
tr.onmouseenter = () => {
showAnomalyTip(anchorEl, buildStepAnomalyDiagnostic(st));
showAnomalyTip(anchorEl, rowDiagGetter());
};
tr.onmouseleave = hideAnomalyTip;
} else {
@@ -1268,10 +1302,10 @@ export const StepTableWidget = defineComponent({
hoverRows.set(hoverTd, {
badge: refs.agentBadgeEl,
prompt,
anomalyStep: hasStepAnomaly ? st : null,
rowDiagGetter,
tr,
});
const useWholeCellTurnTip = firstColKey === 'step' && !hasStepAnomaly;
const useWholeCellTurnTip = firstColKey === 'step' && !hasRowTip;
hoverTd.onmouseenter = useWholeCellTurnTip ? enterStepCell : null;
hoverTd.onmousemove = useWholeCellTurnTip ? moveInStepCell : moveAlongTurnRail;
hoverTd.onmouseleave = leaveStepCell;
@@ -1299,6 +1333,7 @@ export const StepTableWidget = defineComponent({
patchClasses(tr, {
'is-stripe-even': false,
'is-step-entering': false,
'is-compaction': false,
'is-anomaly-warn': false,
'is-anomaly-danger': false,
});
+21 -3
View File
@@ -322,7 +322,22 @@ export function positionAnchoredPopup(
popupEl.style.maxHeight = '';
const availWidth = Math.max(120, Math.floor(bound.width - margin * 2));
popupEl.style.maxWidth = `${availWidth}px`;
let cssMaxW = NaN;
if (typeof window !== 'undefined' && typeof window.getComputedStyle === 'function') {
try {
const rawMaxW = window.getComputedStyle(popupEl)?.maxWidth;
if (rawMaxW && rawMaxW !== 'none') {
cssMaxW = Number.parseFloat(rawMaxW);
}
} catch {
// 忽略 Mock DOM 样式查询异常
}
}
const effectiveMaxW =
Number.isFinite(cssMaxW) && cssMaxW > 0
? Math.max(120, Math.min(availWidth, Math.floor(cssMaxW)))
: availWidth;
popupEl.style.maxWidth = `${effectiveMaxW}px`;
const rawRect = popupEl.getBoundingClientRect?.();
// 优先读取 offsetWidth,避免入场动画 scale(0.975) 导致测宽偏小
@@ -330,10 +345,13 @@ export function positionAnchoredPopup(
Number(popupEl.offsetWidth || 0),
Math.ceil(Number(rawRect?.width || 0))
);
if (naturalW > availWidth) {
if (naturalW > effectiveMaxW) {
popupEl.style.minWidth = '0px';
}
const popupW = Math.min(availWidth, naturalW > 0 ? naturalW : Math.max(triggerRect.width, 210));
const popupW = Math.min(
effectiveMaxW,
naturalW > 0 ? naturalW : Math.max(triggerRect.width, 210)
);
const safeLeft = bound.left + margin;
const safeRight = bound.right - margin;
+36
View File
@@ -222,6 +222,42 @@ export function buildStepAnomalyDiagnostic(st) {
};
}
export function buildStepCompactionDiagnostic(st, displaySettings = {}) {
if (!st || typeof st !== 'object') return null;
const disp = resolveModelDisplayInfo(st, displaySettings, { fallback: '' });
const promptTok =
Math.max(0, Number(st.inputTokens || 0)) + Math.max(0, Number(st.cacheReadTokens || 0));
const outTok = Math.max(0, Number(st.outputTokens || 0));
const title = t('steps.compactionStepTitle', { step: Number(st.stepIndex ?? 0) });
const rows =
promptTok > 0 || outTok > 0
? [
{
text: t('steps.compactionSummaryRow', {
input: formatTokens(promptTok),
output: formatTokens(outTok),
}),
detail: t('steps.compactionDetailHint'),
mono: false,
danger: false,
},
]
: [
{
text: t('steps.compactionDetailHint'),
detail: '',
danger: false,
},
];
return {
title,
sub: disp.baseText || '',
rows,
hint: '',
severity: 'compaction',
};
}
export function buildModelAnomalyDiagnostic(m) {
const sum = resolveModelAnomalySummary(m);
if (!sum) return null;
+4
View File
@@ -325,6 +325,10 @@ export const I18N_MESSAGES_EN_US = Object.freeze({
'steps.anomalyKind.canceled': 'Canceled by User',
'steps.anomalyStepTitle': '#{step} · {count} Retries / Errors',
'steps.anomalyDelayPart': 'Backoff {sec}s',
'steps.compactionStepTitle': '#{step} · Auto-Compaction',
'steps.compactionSummaryRow': 'Input {input} → Summary {output}',
'steps.compactionDetailHint': 'Automatic context compaction step triggered to summarize history and free window space',
'steps.compactionAnomalyHint': 'This step is also an auto-compaction step',
'steps.anomalyTerminalTag': 'Stopped',
'steps.anomalyModelTitle': '{model} · {count} Retries / Errors',
'steps.anomalyModelSub': '{steps} steps affected',
+4
View File
@@ -325,6 +325,10 @@ export const I18N_MESSAGES_ZH_CN = Object.freeze({
'steps.anomalyKind.canceled': '用户取消',
'steps.anomalyStepTitle': '#{step} · 异常 {count} 次',
'steps.anomalyDelayPart': '退避 {sec}s',
'steps.compactionStepTitle': '#{step} · 自动压缩',
'steps.compactionSummaryRow': '输入 {input} → 摘要输出 {output}',
'steps.compactionDetailHint': '系统自动触发的上下文压缩步骤,用于折叠历史对话以释放窗口空间',
'steps.compactionAnomalyHint': '该步骤同时为系统自动压缩步骤',
'steps.anomalyTerminalTag': '中止',
'steps.anomalyModelTitle': '{model} · 异常 {count} 次',
'steps.anomalyModelSub': '涉及 {steps} 步',
@@ -114,6 +114,13 @@ function formatStepClockTime(createdAtMs) {
return { text: hhmmss, title: full };
}
export function isCompactionStepItem(st) {
if (!st || typeof st !== 'object') return false;
if (st.isCompactionStep) return true;
const raw = `${st.activeModelShort ?? st.modelShort ?? ''} ${st.activeModelLabel ?? st.modelLabel ?? ''} ${st.activeModelUpstream ?? st.modelUpstream ?? ''}`;
return /·(?:压缩|compact)(?=\s|$)|\[自动压缩\]/iu.test(raw);
}
export const STEP_COLUMN_REGISTRY = Object.freeze({
step: {
key: 'step',
@@ -153,21 +160,17 @@ export const STEP_COLUMN_REGISTRY = Object.freeze({
optLabel: () => t('stepCol.model.opt'),
sigPart: (st, ctx) => {
const disp = resolveModelDisplayInfo(st, ctx.displaySettings, { fallback: '—' });
return `${disp.baseText}:${disp.compactionSuffix}:${disp.title}`;
return `${disp.baseText}:${disp.title}`;
},
createCell: () => {
const nameEl = h('span', { className: 'step-model-name' });
const compactEl = h('span', { className: 'step-model-compact', hidden: true });
const wrapEl = h('span', { className: 'step-model-cell' }, [nameEl, compactEl]);
const wrapEl = h('span', { className: 'step-model-cell' }, [nameEl]);
const td = h('td', {}, [wrapEl]);
return { td, refs: { td, wrapEl, nameEl, compactEl } };
return { td, refs: { td, wrapEl, nameEl } };
},
updateCell: (refs, st, ctx) => {
const modelDisplay = resolveModelDisplayInfo(st, ctx.displaySettings, { fallback: '—' });
patchText(refs.nameEl, modelDisplay.baseText);
const suffix = modelDisplay.compactionSuffix || '';
patchText(refs.compactEl, suffix);
patchAttr(refs.compactEl, 'hidden', !suffix);
patchAttr(refs.td, 'title', modelDisplay.title);
},
},
+32 -3
View File
@@ -31,8 +31,8 @@
.steps-inline-scope-select .select-menu,
.steps-inline-model-select .select-menu {
left: 0;
right: auto;
left: auto;
right: 0;
min-width: 220px;
max-width: min(320px, calc(100vw - 24px));
}
@@ -306,7 +306,15 @@
font-size: var(--fs-base);
cursor: pointer;
text-align: left;
transition: background-color var(--dur-instant) var(--ease-fast);
transition:
background-color var(--dur-instant) var(--ease-fast),
border-color var(--dur-instant) var(--ease-fast),
box-shadow var(--dur-instant) var(--ease-fast);
}
.select-trigger .svg-icon {
flex-shrink: 0;
color: var(--text-muted);
}
.select-trigger:hover,
@@ -314,6 +322,27 @@
background: var(--surface-hover);
}
.form-row > .custom-select > .select-trigger {
min-height: calc(28px * var(--ui-font-scale, 1));
padding: 3px 12px;
background: color-mix(in srgb, var(--text-primary) 7.5%, var(--surface-panel));
border: none;
border-radius: var(--radius-pill);
}
.form-row > .custom-select > .select-trigger:hover {
background: color-mix(in srgb, var(--text-primary) 11.5%, var(--surface-panel));
}
.form-row > .custom-select.is-open > .select-trigger {
background: color-mix(in srgb, var(--text-primary) 14%, var(--surface-panel));
}
.form-row > .custom-select > .select-trigger:disabled {
opacity: 0.52;
cursor: not-allowed;
}
.select-label {
flex: 1;
min-width: 0;
+46 -7
View File
@@ -21,6 +21,9 @@
--modern-surface-card: color-mix(in srgb, var(--surface-panel) 95.2%, #ffffff 4.8%);
--modern-surface-subtle: color-mix(in srgb, var(--text-primary) 5.2%, transparent);
--modern-surface-hover: color-mix(in srgb, var(--accent-primary) 11%, color-mix(in srgb, var(--text-primary) 4%, transparent));
--modern-pill-select-bg: color-mix(in srgb, var(--text-primary) 8.5%, var(--modern-surface-card));
--modern-pill-select-hover: color-mix(in srgb, var(--text-primary) 12.5%, var(--modern-surface-card));
--modern-pill-select-open: color-mix(in srgb, var(--text-primary) 15%, var(--modern-surface-card));
--modern-card-shadow: none;
--modern-nav-track-bg: var(--modern-surface-card);
--modern-inline-track-bg: color-mix(in srgb, var(--text-primary) 4.2%, transparent);
@@ -42,6 +45,9 @@
--modern-surface-card: #ffffff;
--modern-surface-subtle: hsl(216 42% 97.2%);
--modern-surface-hover: hsl(216 56% 94.4%);
--modern-pill-select-bg: hsl(220 14% 94%);
--modern-pill-select-hover: hsl(220 14% 90.5%);
--modern-pill-select-open: hsl(220 14% 88.5%);
--modern-card-shadow: 0 1px 3px rgb(15 23 42 / 0.045), 0 4px 14px rgb(15 23 42 / 0.028);
--modern-nav-track-bg: hsl(216 28% 94.2%);
--modern-inline-track-bg: hsl(216 32% 96.2%);
@@ -463,11 +469,16 @@ html[data-standalone="true"][data-modern-ui="true"] .app-shell {
border: none;
}
[data-modern-ui="true"] .trend-tip-sub,
[data-modern-ui="true"] .trend-tip-anomaly,
[data-modern-ui="true"] .trend-tip-sub {
background: var(--modern-surface-subtle);
}
[data-modern-ui="true"] .trend-tip-cost {
background: var(--modern-surface-subtle);
}
[data-modern-ui="true"] .cons-pop-models {
border-top: none;
padding-top: 3px;
border-top-color: var(--modern-surface-hover);
}
[data-modern-ui="true"] .cons-source-bar-hit:hover .cons-source-model-bar,
@@ -525,6 +536,17 @@ html[data-standalone="true"][data-modern-ui="true"] .app-shell {
background: var(--modern-surface-hover);
}
[data-modern-ui="true"] .data-table tbody tr.is-compaction,
[data-modern-ui="true"] .data-table:not(.is-virtualized) tbody tr.is-compaction:nth-child(even),
[data-modern-ui="true"] .data-table.is-virtualized tbody tr.is-stripe-even.is-compaction {
background: color-mix(in srgb, var(--accent-primary) 12%, transparent);
}
[data-modern-ui="true"] .data-table tbody tr.is-compaction:hover,
[data-modern-ui="true"] .data-table.is-virtualized tbody tr.is-stripe-even.is-compaction:hover {
background: color-mix(in srgb, var(--accent-primary) 19%, transparent);
}
[data-modern-ui="true"] .data-table tbody tr.is-anomaly-warn,
[data-modern-ui="true"] .data-table:not(.is-virtualized) tbody tr.is-anomaly-warn:nth-child(even),
[data-modern-ui="true"] .data-table.is-virtualized tbody tr.is-stripe-even.is-anomaly-warn {
@@ -547,11 +569,28 @@ html[data-standalone="true"][data-modern-ui="true"] .app-shell {
background: color-mix(in srgb, var(--metric-danger) 21%, transparent);
}
[data-modern-ui="true"] .form-row > .custom-select > .select-trigger,
[data-modern-ui="true"] .steps-inline-scope-select .select-trigger,
[data-modern-ui="true"] .steps-inline-model-select .select-trigger,
[data-modern-ui="true"] .sstep-fit-model-select .select-trigger {
border: none;
background: var(--modern-surface-subtle);
box-shadow: none;
border-radius: var(--radius-pill);
background: var(--modern-pill-select-bg);
}
[data-modern-ui="true"] .form-row > .custom-select > .select-trigger:hover,
[data-modern-ui="true"] .steps-inline-scope-select .select-trigger:hover,
[data-modern-ui="true"] .steps-inline-model-select .select-trigger:hover,
[data-modern-ui="true"] .sstep-fit-model-select .select-trigger:hover {
background: var(--modern-pill-select-hover);
}
[data-modern-ui="true"] .form-row > .custom-select.is-open > .select-trigger,
[data-modern-ui="true"] .steps-inline-scope-select.is-open .select-trigger,
[data-modern-ui="true"] .steps-inline-model-select.is-open .select-trigger,
[data-modern-ui="true"] .sstep-fit-model-select.is-open .select-trigger {
background: var(--modern-pill-select-open);
}
[data-modern-ui="true"] .sstep-card,
@@ -667,12 +706,12 @@ html[data-standalone="true"][data-modern-ui="true"] .app-shell {
border: none;
background: var(--modern-surface-card);
box-shadow: var(--shadow-popover);
animation: anim-modern-pop-in 150ms var(--ease-modern);
animation: anim-modern-tip-fade 120ms var(--ease-modern);
}
[data-modern-ui="true"] .select-menu.is-above,
[data-modern-ui="true"] .dt-popover.is-above {
animation-name: anim-modern-pop-in-up;
transform-origin: bottom right;
}
[data-modern-ui="true"] .trend-tooltip,
+91 -34
View File
@@ -211,12 +211,6 @@
white-space: nowrap;
}
.cons-title-model-dot {
width: 7px;
height: 7px;
flex-shrink: 0;
}
.cons-row-metrics {
display: inline-flex;
align-items: center;
@@ -349,9 +343,9 @@
left: var(--tip-x, 50%);
transform: translateX(var(--tip-shift, -50%));
width: max-content;
min-width: 196px;
max-width: min(320px, calc(100% - 8px));
padding: 6px 10px;
min-width: 224px;
max-width: min(316px, calc(100% - 8px));
padding: 9px 11px;
background: var(--surface-panel);
border: 1px solid var(--border-strong);
border-radius: var(--radius-sm);
@@ -360,27 +354,29 @@
z-index: 25;
display: flex;
flex-direction: column;
gap: 2px;
gap: 6px;
}
.trend-tip-head {
display: flex;
align-items: center;
justify-content: space-between;
gap: 10px;
font-size: var(--fs-sm);
gap: 12px;
font-size: var(--fs-xs);
line-height: 1.25;
color: var(--text-secondary);
}
.trend-tip-time {
font-weight: 600;
color: var(--text-primary);
font-weight: 500;
color: var(--text-secondary);
white-space: nowrap;
flex-shrink: 0;
}
.trend-tip-calls {
font-size: var(--fs-xs);
font-weight: 500;
color: var(--text-muted);
white-space: nowrap;
max-width: 190px;
@@ -390,36 +386,85 @@
.trend-tip-main {
display: flex;
align-items: baseline;
align-items: center;
justify-content: space-between;
gap: 12px;
gap: 10px;
margin-top: -2px;
}
.trend-tip-tokens {
font-size: var(--fs-base);
font-size: var(--fs-lg);
font-weight: 700;
line-height: 1.18;
letter-spacing: -0.02em;
color: var(--accent-primary);
white-space: nowrap;
flex-shrink: 0;
}
.trend-tip-cost {
font-size: var(--fs-md);
font-size: var(--fs-sm);
font-weight: 600;
line-height: 1.2;
padding: 2px 7px;
border-radius: var(--radius-xs);
color: var(--text-primary);
background: color-mix(in srgb, var(--text-primary) 6%, transparent);
white-space: nowrap;
flex-shrink: 0;
}
.trend-tip-cost:empty {
display: none;
}
.trend-tip-sub {
padding: 5px 8px;
border: none;
border-radius: var(--radius-xs);
background: color-mix(in srgb, var(--text-primary) 4.2%, transparent);
font-size: var(--fs-xs);
line-height: 1.3;
color: var(--text-secondary);
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
border-top: 1px solid var(--border-hairline);
padding-top: 2px;
margin-top: 1px;
}
.trend-tip-sub[hidden] {
display: none !important;
}
.trend-tip-sub.is-grid {
display: grid;
grid-template-columns: repeat(3, minmax(0, 1fr));
gap: 8px;
padding: 6px 8px;
white-space: normal;
overflow: visible;
}
.trend-tip-stat {
display: flex;
flex-direction: column;
gap: 1px;
min-width: 0;
}
.trend-tip-stat-label {
font-size: var(--fs-2xs);
font-weight: 500;
line-height: 1.2;
color: var(--text-muted);
white-space: nowrap;
}
.trend-tip-stat-val {
font-size: var(--fs-sm);
font-weight: 600;
line-height: 1.25;
color: var(--text-primary);
white-space: nowrap;
}
.trend-tooltip.is-line-low {
@@ -807,9 +852,9 @@
left: var(--pop-x, 8px);
top: var(--pop-y, 8px);
width: max-content;
min-width: 196px;
max-width: min(310px, calc(100% - 16px));
padding: 6px 10px;
min-width: 224px;
max-width: min(316px, calc(100% - 16px));
padding: 9px 11px;
background: var(--surface-panel);
border: 1px solid var(--border-strong);
border-radius: var(--radius-sm);
@@ -818,24 +863,34 @@
z-index: 30;
display: flex;
flex-direction: column;
gap: 3px;
gap: 6px;
}
.cons-pop-models {
display: flex;
flex-direction: column;
gap: 3px;
border-top: 1px solid var(--border-hairline);
padding-top: 4px;
margin-top: 2px;
gap: 4px;
border-top: 1px solid color-mix(in srgb, var(--border-hairline) 75%, transparent);
padding-top: 6px;
margin-top: 1px;
}
.cons-pop-models[hidden] {
display: none !important;
}
.trend-tip-sub:not([hidden]) + .cons-pop-models {
border-top: none;
padding-top: 1px;
margin-top: 0;
}
.cons-pop-model-row {
display: flex;
align-items: center;
justify-content: space-between;
gap: 12px;
font-size: var(--fs-sm);
gap: 10px;
font-size: var(--fs-xs);
line-height: 1.3;
}
@@ -849,6 +904,7 @@
.cons-pop-model-name {
max-width: 156px;
font-weight: 500;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
@@ -871,10 +927,11 @@
}
.cons-pop-model-pct {
min-width: 40px;
min-width: 38px;
text-align: right;
font-weight: 600;
color: var(--text-primary);
font-size: var(--fs-xs);
font-weight: 500;
color: var(--text-secondary);
}
/* --- 6. 12 个月垂直堆叠柱状图 (12-Month Stacked Bar Chart) --- */
+96 -37
View File
@@ -19,6 +19,14 @@
background: var(--surface-panel);
}
.panel > .table-scroll-host {
margin-right: calc(-1 * var(--space-5) + 2px);
}
.panel > .table-scroll-host > .custom-scroll-content {
padding-right: calc(var(--space-5) - 2px);
}
.table-viewport {
flex: 1;
min-height: 0;
@@ -127,57 +135,69 @@
flex: 0 1 auto;
}
.step-model-compact {
flex-shrink: 0;
white-space: nowrap;
color: var(--accent-primary);
font-weight: 500;
}
.step-model-compact[hidden] {
display: none !important;
}
.steps-panel-header {
flex-wrap: wrap;
row-gap: 6px;
}
.steps-panel-title {
flex: 0 0 auto;
}
.steps-header-controls {
display: flex;
align-items: center;
justify-content: flex-end;
gap: 6px;
flex: 1 1 280px;
justify-content: space-between;
flex-wrap: wrap;
gap: 6px 8px;
flex: 1 1 100%;
min-width: 0;
}
.steps-header-controls .segmented {
flex-shrink: 0;
flex: 0 0 auto;
}
.steps-header-filters {
display: flex;
align-items: center;
justify-content: flex-end;
gap: 6px;
margin-left: auto;
flex: 1 1 156px;
min-width: 0;
max-width: 100%;
}
.steps-header-filters[hidden] {
display: none !important;
}
.steps-inline-scope-select,
.steps-inline-model-select {
flex: 0 1 165px;
min-width: 72px;
max-width: 175px;
flex: 0 1 auto;
min-width: 0;
max-width: 148px;
}
.steps-inline-scope-select .select-trigger,
.steps-inline-model-select .select-trigger {
min-height: calc(22px * var(--ui-font-scale, 1));
min-height: calc(25px * var(--ui-font-scale, 1));
height: auto;
padding: 2px 6px;
gap: 4px;
padding: 2px 10px;
gap: 6px;
min-width: 0;
overflow: hidden;
font-size: var(--fs-md);
border: 1px solid var(--border-hairline);
background: var(--surface-subtle);
border: none;
border-radius: var(--radius-pill);
background: color-mix(in srgb, var(--text-primary) 7.5%, var(--surface-panel));
}
.steps-inline-scope-select .select-trigger:hover,
.steps-inline-model-select .select-trigger:hover {
background: color-mix(in srgb, var(--text-primary) 11.5%, var(--surface-panel));
}
.steps-inline-scope-select.is-open .select-trigger,
.steps-inline-model-select.is-open .select-trigger {
background: color-mix(in srgb, var(--text-primary) 14%, var(--surface-panel));
}
/* --- 2.5 极简对话轮次导轨与起点圆点 (Minimalist Turn Rail & Prompt Preview) --- */
@@ -295,7 +315,24 @@
animation: anim-popover-in var(--dur-instant) var(--ease-fast);
}
/* --- 2.6 单步异常整行语义着色、模型汇总微标、筛选条与悬停诊断卡 --- */
/* --- 2.6 单步压缩 / 异常整行语义着色、模型汇总微标、筛选条与悬停诊断卡 --- */
.data-table tbody tr.is-compaction {
background: color-mix(in srgb, var(--accent-primary) 11%, transparent);
}
.data-table tbody tr.is-compaction:hover {
background: color-mix(in srgb, var(--accent-primary) 18%, transparent);
}
.data-table tbody tr.is-compaction td:first-child {
box-shadow: inset 2px 0 0 var(--accent-primary);
}
.data-table tbody tr.is-compaction td:first-child > span:not(.agent-badge):not(.turn-rail) {
color: var(--accent-primary);
font-weight: 600;
}
.data-table tbody tr.is-anomaly-warn {
background: color-mix(in srgb, var(--metric-warn) 11%, transparent);
}
@@ -399,6 +436,10 @@
border-color: color-mix(in srgb, var(--metric-danger) 46%, var(--border-strong));
}
.step-anomaly-tip.is-compaction {
border-color: color-mix(in srgb, var(--accent-primary) 46%, var(--border-strong));
}
.step-anomaly-tip[hidden],
.step-anomaly-tip-sub[hidden],
.step-anomaly-tip-list[hidden],
@@ -423,6 +464,10 @@
color: var(--metric-danger);
}
.step-anomaly-tip.is-compaction .step-anomaly-tip-title {
color: var(--accent-primary);
}
.step-anomaly-tip-sub {
font-size: var(--fs-xs);
color: var(--text-secondary);
@@ -542,7 +587,9 @@
display: flex;
flex-direction: column;
gap: var(--space-3);
padding: var(--space-3) 0 2px;
padding-top: var(--space-3);
padding-bottom: 2px;
padding-left: 0;
}
.sstep-card {
@@ -599,15 +646,24 @@
}
.sstep-fit-model-select .select-trigger {
min-height: calc(22px * var(--ui-font-scale, 1));
min-height: calc(24px * var(--ui-font-scale, 1));
height: auto;
padding: 2px 6px;
gap: 4px;
padding: 2px 10px;
gap: 6px;
min-width: 0;
overflow: hidden;
font-size: var(--fs-sm);
border: 1px solid var(--border-hairline);
background: var(--surface-subtle);
border: none;
border-radius: var(--radius-pill);
background: color-mix(in srgb, var(--text-primary) 7.5%, var(--surface-panel));
}
.sstep-fit-model-select .select-trigger:hover {
background: color-mix(in srgb, var(--text-primary) 11.5%, var(--surface-panel));
}
.sstep-fit-model-select.is-open .select-trigger {
background: color-mix(in srgb, var(--text-primary) 14%, var(--surface-panel));
}
.sstep-chart-wrap {
@@ -783,9 +839,11 @@
}
.trend-tip-anomaly {
margin-top: 3px;
padding-top: 3px;
border-top: 1px solid var(--border-hairline);
margin-top: 0;
padding: 4px 8px;
border: none;
border-radius: var(--radius-xs);
background: color-mix(in srgb, var(--metric-warn) 11%, transparent);
font-size: var(--fs-xs);
font-weight: 600;
color: var(--metric-warn);
@@ -794,6 +852,7 @@
.trend-tip-anomaly.is-danger {
color: var(--metric-danger);
background: color-mix(in srgb, var(--metric-danger) 12%, transparent);
}
.trend-tip-anomaly[hidden] {
+8 -20
View File
@@ -586,12 +586,11 @@ export const ConsumptionView = defineComponent({
}
/**
* 创建热门模型单行 DOM 结构(模型名称后附专属颜色圆点 + 按总占比缩放的 4 段比例条 + 底部分项脚标)。
* 创建热门模型单行 DOM 结构(模型名称 + 按总占比缩放的 4 段比例条 + 底部分项脚标)。
*/
function createBreakdownItemRow() {
const nameTextEl = h('span', { className: 'cons-row-title-text' });
const modelDotEl = h('span', { className: 'dot-swatch cons-model-dot cons-title-model-dot' });
const nameEl = h('strong', { className: 'cons-row-title' }, [nameTextEl, modelDotEl]);
const nameEl = h('strong', { className: 'cons-row-title' }, [nameTextEl]);
const pctBadge = h('span', { className: 'cons-share-pill text-mono', text: '0%' });
const totalTokEl = h('span', { className: 'cons-row-tok text-mono' });
const costEl = h('strong', { className: 'cons-row-cost text-mono' });
@@ -652,7 +651,6 @@ export const ConsumptionView = defineComponent({
refs: {
nameEl,
nameTextEl,
modelDotEl,
pctBadge,
totalTokEl,
costEl,
@@ -672,9 +670,9 @@ export const ConsumptionView = defineComponent({
}
/**
* 增量更新热门模型单行的指标文本、名称后的专属颜色圆点与按总占比缩放的 4 段比例条宽度。
* 增量更新热门模型单行的指标文本与按总占比缩放的 4 段比例条宽度。
*/
function updateBreakdownItemRow(refs, item, grandTotalTokens, modelColor = '') {
function updateBreakdownItemRow(refs, item, grandTotalTokens) {
patchText(refs.inLbl, t('cons.footInput'));
patchText(refs.cacheLbl, t('cons.footCache'));
patchText(refs.outLbl, t('cons.footOutput'));
@@ -683,10 +681,6 @@ export const ConsumptionView = defineComponent({
const displayLabel = item.label || item.name || item.shortName || '—';
patchText(refs.nameTextEl, displayLabel);
patchAttr(refs.nameEl, 'title', item.title || displayLabel);
patchAttr(refs.modelDotEl, 'hidden', !modelColor);
if (modelColor) {
patchStyleVar(refs.modelDotEl, '--dot-color', modelColor);
}
const total = Number(item.totalTokens || 0);
const share = grandTotalTokens > 0 ? +((total / grandTotalTokens) * 100).toFixed(1) : 0;
const scaleRatio =
@@ -1169,23 +1163,17 @@ export const ConsumptionView = defineComponent({
});
trendChart.update(enrichedTrendSeries);
// 3. 同步热门模型列表(名称后带专属颜色圆点 + 4 段条按总占比缩放长度)
// 3. 同步热门模型列表(4 段条按总占比缩放长度)
patchKeyedList(modelsListEl, models, {
keyFn: (m) => m.displayText || m.label || m.shortName,
sigFn: (m) => {
const seed = getCanonicalModelColorSeed(m);
const color = modelColorMap.get(seed) || resolveDeterministicModelColor(seed);
return `${localeSig}:${m.displayText}:${m.displayTitle}:${color}:${m.totalTokens}:${m.inputTokens}:${m.cacheReadTokens}:${m.responseTokens}:${m.thinkingTokens}:${m.costUsd}:${m.unpricedCalls}:${m.calls}:${modelsTotalTok}`;
},
sigFn: (m) =>
`${localeSig}:${m.displayText}:${m.displayTitle}:${m.totalTokens}:${m.inputTokens}:${m.cacheReadTokens}:${m.responseTokens}:${m.thinkingTokens}:${m.costUsd}:${m.unpricedCalls}:${m.calls}:${modelsTotalTok}`,
createRow: createBreakdownItemRow,
updateRow: (refs, m) => {
const seed = getCanonicalModelColorSeed(m);
const color = modelColorMap.get(seed) || resolveDeterministicModelColor(seed);
updateBreakdownItemRow(
refs,
{ ...m, label: m.displayText, title: m.displayTitle },
modelsTotalTok,
color
modelsTotalTok
);
},
});
+7 -9
View File
@@ -27,7 +27,6 @@ import {
resolveModelAnomalySummary,
resolveModelDisplayInfo,
} from '../core/formatters.js';
import { createSvgIcon } from '../icons/SvgIcon.js';
import { getEffectiveLocale, i18nStore, t } from '../i18n/index.js';
import {
formatAgentLabel,
@@ -477,7 +476,11 @@ export const StepsDetailView = defineComponent({
});
modelsScroll.el.setAttribute('hidden', '');
const panelTitleTextEl = h('span', { text: t('steps.title') });
const headerFiltersEl = h('div', { className: 'steps-header-filters', hidden: true }, [
inlineScopeSelect.el,
stepsModelSelect.el,
]);
const panelEl = h(
'section',
{
@@ -486,14 +489,9 @@ export const StepsDetailView = defineComponent({
},
[
h('div', { className: 'panel-header steps-panel-header' }, [
h('span', { className: 'panel-title steps-panel-title' }, [
createSvgIcon('table', { size: 13 }),
panelTitleTextEl,
]),
h('div', { className: 'steps-header-controls' }, [
inlineScopeSelect.el,
stepsModelSelect.el,
subTabSwitch.el,
headerFiltersEl,
]),
]),
anomalyFilterBarEl,
@@ -566,7 +564,6 @@ export const StepsDetailView = defineComponent({
}
function refreshStaticLocaleLabels() {
patchText(panelTitleTextEl, t('steps.title'));
patchText(lineTitleEl, t('steps.lineTitle'));
patchText(fitTitleEl, t('steps.fitTitle'));
patchText(modelsSectionTitleEl, t('steps.modelsTitle'));
@@ -786,6 +783,7 @@ export const StepsDetailView = defineComponent({
);
const showStepsModelFilter = uiSt.stepsSubTab === 'steps' && hasMultipleModels;
patchAttr(stepsModelSelect.el, 'hidden', !showStepsModelFilter);
patchAttr(headerFiltersEl, 'hidden', !hasSubagents && !showStepsModelFilter);
if (hasMultipleModels) {
stepsModelSelect.setProps({
modelValue: selectedTableModels,
+265 -81
View File
@@ -421,8 +421,8 @@ html[data-standalone="true"] .app-shell {
.steps-inline-scope-select .select-menu,
.steps-inline-model-select .select-menu {
left: 0;
right: auto;
left: auto;
right: 0;
min-width: 220px;
max-width: min(320px, calc(100vw - 24px));
}
@@ -696,7 +696,15 @@ html[data-standalone="true"] .app-shell {
font-size: var(--fs-base);
cursor: pointer;
text-align: left;
transition: background-color var(--dur-instant) var(--ease-fast);
transition:
background-color var(--dur-instant) var(--ease-fast),
border-color var(--dur-instant) var(--ease-fast),
box-shadow var(--dur-instant) var(--ease-fast);
}
.select-trigger .svg-icon {
flex-shrink: 0;
color: var(--text-muted);
}
.select-trigger:hover,
@@ -704,6 +712,27 @@ html[data-standalone="true"] .app-shell {
background: var(--surface-hover);
}
.form-row > .custom-select > .select-trigger {
min-height: calc(28px * var(--ui-font-scale, 1));
padding: 3px 12px;
background: color-mix(in srgb, var(--text-primary) 7.5%, var(--surface-panel));
border: none;
border-radius: var(--radius-pill);
}
.form-row > .custom-select > .select-trigger:hover {
background: color-mix(in srgb, var(--text-primary) 11.5%, var(--surface-panel));
}
.form-row > .custom-select.is-open > .select-trigger {
background: color-mix(in srgb, var(--text-primary) 14%, var(--surface-panel));
}
.form-row > .custom-select > .select-trigger:disabled {
opacity: 0.52;
cursor: not-allowed;
}
.select-label {
flex: 1;
min-width: 0;
@@ -2299,12 +2328,6 @@ html[data-standalone="true"] .app-shell {
white-space: nowrap;
}
.cons-title-model-dot {
width: 7px;
height: 7px;
flex-shrink: 0;
}
.cons-row-metrics {
display: inline-flex;
align-items: center;
@@ -2437,9 +2460,9 @@ html[data-standalone="true"] .app-shell {
left: var(--tip-x, 50%);
transform: translateX(var(--tip-shift, -50%));
width: max-content;
min-width: 196px;
max-width: min(320px, calc(100% - 8px));
padding: 6px 10px;
min-width: 224px;
max-width: min(316px, calc(100% - 8px));
padding: 9px 11px;
background: var(--surface-panel);
border: 1px solid var(--border-strong);
border-radius: var(--radius-sm);
@@ -2448,27 +2471,29 @@ html[data-standalone="true"] .app-shell {
z-index: 25;
display: flex;
flex-direction: column;
gap: 2px;
gap: 6px;
}
.trend-tip-head {
display: flex;
align-items: center;
justify-content: space-between;
gap: 10px;
font-size: var(--fs-sm);
gap: 12px;
font-size: var(--fs-xs);
line-height: 1.25;
color: var(--text-secondary);
}
.trend-tip-time {
font-weight: 600;
color: var(--text-primary);
font-weight: 500;
color: var(--text-secondary);
white-space: nowrap;
flex-shrink: 0;
}
.trend-tip-calls {
font-size: var(--fs-xs);
font-weight: 500;
color: var(--text-muted);
white-space: nowrap;
max-width: 190px;
@@ -2478,36 +2503,85 @@ html[data-standalone="true"] .app-shell {
.trend-tip-main {
display: flex;
align-items: baseline;
align-items: center;
justify-content: space-between;
gap: 12px;
gap: 10px;
margin-top: -2px;
}
.trend-tip-tokens {
font-size: var(--fs-base);
font-size: var(--fs-lg);
font-weight: 700;
line-height: 1.18;
letter-spacing: -0.02em;
color: var(--accent-primary);
white-space: nowrap;
flex-shrink: 0;
}
.trend-tip-cost {
font-size: var(--fs-md);
font-size: var(--fs-sm);
font-weight: 600;
line-height: 1.2;
padding: 2px 7px;
border-radius: var(--radius-xs);
color: var(--text-primary);
background: color-mix(in srgb, var(--text-primary) 6%, transparent);
white-space: nowrap;
flex-shrink: 0;
}
.trend-tip-cost:empty {
display: none;
}
.trend-tip-sub {
padding: 5px 8px;
border: none;
border-radius: var(--radius-xs);
background: color-mix(in srgb, var(--text-primary) 4.2%, transparent);
font-size: var(--fs-xs);
line-height: 1.3;
color: var(--text-secondary);
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
border-top: 1px solid var(--border-hairline);
padding-top: 2px;
margin-top: 1px;
}
.trend-tip-sub[hidden] {
display: none !important;
}
.trend-tip-sub.is-grid {
display: grid;
grid-template-columns: repeat(3, minmax(0, 1fr));
gap: 8px;
padding: 6px 8px;
white-space: normal;
overflow: visible;
}
.trend-tip-stat {
display: flex;
flex-direction: column;
gap: 1px;
min-width: 0;
}
.trend-tip-stat-label {
font-size: var(--fs-2xs);
font-weight: 500;
line-height: 1.2;
color: var(--text-muted);
white-space: nowrap;
}
.trend-tip-stat-val {
font-size: var(--fs-sm);
font-weight: 600;
line-height: 1.25;
color: var(--text-primary);
white-space: nowrap;
}
.trend-tooltip.is-line-low {
@@ -2895,9 +2969,9 @@ html[data-standalone="true"] .app-shell {
left: var(--pop-x, 8px);
top: var(--pop-y, 8px);
width: max-content;
min-width: 196px;
max-width: min(310px, calc(100% - 16px));
padding: 6px 10px;
min-width: 224px;
max-width: min(316px, calc(100% - 16px));
padding: 9px 11px;
background: var(--surface-panel);
border: 1px solid var(--border-strong);
border-radius: var(--radius-sm);
@@ -2906,24 +2980,34 @@ html[data-standalone="true"] .app-shell {
z-index: 30;
display: flex;
flex-direction: column;
gap: 3px;
gap: 6px;
}
.cons-pop-models {
display: flex;
flex-direction: column;
gap: 3px;
border-top: 1px solid var(--border-hairline);
padding-top: 4px;
margin-top: 2px;
gap: 4px;
border-top: 1px solid color-mix(in srgb, var(--border-hairline) 75%, transparent);
padding-top: 6px;
margin-top: 1px;
}
.cons-pop-models[hidden] {
display: none !important;
}
.trend-tip-sub:not([hidden]) + .cons-pop-models {
border-top: none;
padding-top: 1px;
margin-top: 0;
}
.cons-pop-model-row {
display: flex;
align-items: center;
justify-content: space-between;
gap: 12px;
font-size: var(--fs-sm);
gap: 10px;
font-size: var(--fs-xs);
line-height: 1.3;
}
@@ -2937,6 +3021,7 @@ html[data-standalone="true"] .app-shell {
.cons-pop-model-name {
max-width: 156px;
font-weight: 500;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
@@ -2959,10 +3044,11 @@ html[data-standalone="true"] .app-shell {
}
.cons-pop-model-pct {
min-width: 40px;
min-width: 38px;
text-align: right;
font-weight: 600;
color: var(--text-primary);
font-size: var(--fs-xs);
font-weight: 500;
color: var(--text-secondary);
}
/* --- 6. 12 个月垂直堆叠柱状图 (12-Month Stacked Bar Chart) --- */
@@ -3079,6 +3165,14 @@ html[data-standalone="true"] .app-shell {
background: var(--surface-panel);
}
.panel > .table-scroll-host {
margin-right: calc(-1 * var(--space-5) + 2px);
}
.panel > .table-scroll-host > .custom-scroll-content {
padding-right: calc(var(--space-5) - 2px);
}
.table-viewport {
flex: 1;
min-height: 0;
@@ -3187,57 +3281,69 @@ html[data-standalone="true"] .app-shell {
flex: 0 1 auto;
}
.step-model-compact {
flex-shrink: 0;
white-space: nowrap;
color: var(--accent-primary);
font-weight: 500;
}
.step-model-compact[hidden] {
display: none !important;
}
.steps-panel-header {
flex-wrap: wrap;
row-gap: 6px;
}
.steps-panel-title {
flex: 0 0 auto;
}
.steps-header-controls {
display: flex;
align-items: center;
justify-content: flex-end;
gap: 6px;
flex: 1 1 280px;
justify-content: space-between;
flex-wrap: wrap;
gap: 6px 8px;
flex: 1 1 100%;
min-width: 0;
}
.steps-header-controls .segmented {
flex-shrink: 0;
flex: 0 0 auto;
}
.steps-header-filters {
display: flex;
align-items: center;
justify-content: flex-end;
gap: 6px;
margin-left: auto;
flex: 1 1 156px;
min-width: 0;
max-width: 100%;
}
.steps-header-filters[hidden] {
display: none !important;
}
.steps-inline-scope-select,
.steps-inline-model-select {
flex: 0 1 165px;
min-width: 72px;
max-width: 175px;
flex: 0 1 auto;
min-width: 0;
max-width: 148px;
}
.steps-inline-scope-select .select-trigger,
.steps-inline-model-select .select-trigger {
min-height: calc(22px * var(--ui-font-scale, 1));
min-height: calc(25px * var(--ui-font-scale, 1));
height: auto;
padding: 2px 6px;
gap: 4px;
padding: 2px 10px;
gap: 6px;
min-width: 0;
overflow: hidden;
font-size: var(--fs-md);
border: 1px solid var(--border-hairline);
background: var(--surface-subtle);
border: none;
border-radius: var(--radius-pill);
background: color-mix(in srgb, var(--text-primary) 7.5%, var(--surface-panel));
}
.steps-inline-scope-select .select-trigger:hover,
.steps-inline-model-select .select-trigger:hover {
background: color-mix(in srgb, var(--text-primary) 11.5%, var(--surface-panel));
}
.steps-inline-scope-select.is-open .select-trigger,
.steps-inline-model-select.is-open .select-trigger {
background: color-mix(in srgb, var(--text-primary) 14%, var(--surface-panel));
}
/* --- 2.5 极简对话轮次导轨与起点圆点 (Minimalist Turn Rail & Prompt Preview) --- */
@@ -3355,7 +3461,24 @@ html[data-standalone="true"] .app-shell {
animation: anim-popover-in var(--dur-instant) var(--ease-fast);
}
/* --- 2.6 单步异常整行语义着色、模型汇总微标、筛选条与悬停诊断卡 --- */
/* --- 2.6 单步压缩 / 异常整行语义着色、模型汇总微标、筛选条与悬停诊断卡 --- */
.data-table tbody tr.is-compaction {
background: color-mix(in srgb, var(--accent-primary) 11%, transparent);
}
.data-table tbody tr.is-compaction:hover {
background: color-mix(in srgb, var(--accent-primary) 18%, transparent);
}
.data-table tbody tr.is-compaction td:first-child {
box-shadow: inset 2px 0 0 var(--accent-primary);
}
.data-table tbody tr.is-compaction td:first-child > span:not(.agent-badge):not(.turn-rail) {
color: var(--accent-primary);
font-weight: 600;
}
.data-table tbody tr.is-anomaly-warn {
background: color-mix(in srgb, var(--metric-warn) 11%, transparent);
}
@@ -3459,6 +3582,10 @@ html[data-standalone="true"] .app-shell {
border-color: color-mix(in srgb, var(--metric-danger) 46%, var(--border-strong));
}
.step-anomaly-tip.is-compaction {
border-color: color-mix(in srgb, var(--accent-primary) 46%, var(--border-strong));
}
.step-anomaly-tip[hidden],
.step-anomaly-tip-sub[hidden],
.step-anomaly-tip-list[hidden],
@@ -3483,6 +3610,10 @@ html[data-standalone="true"] .app-shell {
color: var(--metric-danger);
}
.step-anomaly-tip.is-compaction .step-anomaly-tip-title {
color: var(--accent-primary);
}
.step-anomaly-tip-sub {
font-size: var(--fs-xs);
color: var(--text-secondary);
@@ -3602,7 +3733,9 @@ html[data-standalone="true"] .app-shell {
display: flex;
flex-direction: column;
gap: var(--space-3);
padding: var(--space-3) 0 2px;
padding-top: var(--space-3);
padding-bottom: 2px;
padding-left: 0;
}
.sstep-card {
@@ -3659,15 +3792,24 @@ html[data-standalone="true"] .app-shell {
}
.sstep-fit-model-select .select-trigger {
min-height: calc(22px * var(--ui-font-scale, 1));
min-height: calc(24px * var(--ui-font-scale, 1));
height: auto;
padding: 2px 6px;
gap: 4px;
padding: 2px 10px;
gap: 6px;
min-width: 0;
overflow: hidden;
font-size: var(--fs-sm);
border: 1px solid var(--border-hairline);
background: var(--surface-subtle);
border: none;
border-radius: var(--radius-pill);
background: color-mix(in srgb, var(--text-primary) 7.5%, var(--surface-panel));
}
.sstep-fit-model-select .select-trigger:hover {
background: color-mix(in srgb, var(--text-primary) 11.5%, var(--surface-panel));
}
.sstep-fit-model-select.is-open .select-trigger {
background: color-mix(in srgb, var(--text-primary) 14%, var(--surface-panel));
}
.sstep-chart-wrap {
@@ -3843,9 +3985,11 @@ html[data-standalone="true"] .app-shell {
}
.trend-tip-anomaly {
margin-top: 3px;
padding-top: 3px;
border-top: 1px solid var(--border-hairline);
margin-top: 0;
padding: 4px 8px;
border: none;
border-radius: var(--radius-xs);
background: color-mix(in srgb, var(--metric-warn) 11%, transparent);
font-size: var(--fs-xs);
font-weight: 600;
color: var(--metric-warn);
@@ -3854,6 +3998,7 @@ html[data-standalone="true"] .app-shell {
.trend-tip-anomaly.is-danger {
color: var(--metric-danger);
background: color-mix(in srgb, var(--metric-danger) 12%, transparent);
}
.trend-tip-anomaly[hidden] {
@@ -5938,6 +6083,9 @@ html[data-standalone="true"] .app-shell {
--modern-surface-card: color-mix(in srgb, var(--surface-panel) 95.2%, #ffffff 4.8%);
--modern-surface-subtle: color-mix(in srgb, var(--text-primary) 5.2%, transparent);
--modern-surface-hover: color-mix(in srgb, var(--accent-primary) 11%, color-mix(in srgb, var(--text-primary) 4%, transparent));
--modern-pill-select-bg: color-mix(in srgb, var(--text-primary) 8.5%, var(--modern-surface-card));
--modern-pill-select-hover: color-mix(in srgb, var(--text-primary) 12.5%, var(--modern-surface-card));
--modern-pill-select-open: color-mix(in srgb, var(--text-primary) 15%, var(--modern-surface-card));
--modern-card-shadow: none;
--modern-nav-track-bg: var(--modern-surface-card);
--modern-inline-track-bg: color-mix(in srgb, var(--text-primary) 4.2%, transparent);
@@ -5959,6 +6107,9 @@ html[data-standalone="true"] .app-shell {
--modern-surface-card: #ffffff;
--modern-surface-subtle: hsl(216 42% 97.2%);
--modern-surface-hover: hsl(216 56% 94.4%);
--modern-pill-select-bg: hsl(220 14% 94%);
--modern-pill-select-hover: hsl(220 14% 90.5%);
--modern-pill-select-open: hsl(220 14% 88.5%);
--modern-card-shadow: 0 1px 3px rgb(15 23 42 / 0.045), 0 4px 14px rgb(15 23 42 / 0.028);
--modern-nav-track-bg: hsl(216 28% 94.2%);
--modern-inline-track-bg: hsl(216 32% 96.2%);
@@ -6380,11 +6531,16 @@ html[data-standalone="true"][data-modern-ui="true"] .app-shell {
border: none;
}
[data-modern-ui="true"] .trend-tip-sub,
[data-modern-ui="true"] .trend-tip-anomaly,
[data-modern-ui="true"] .trend-tip-sub {
background: var(--modern-surface-subtle);
}
[data-modern-ui="true"] .trend-tip-cost {
background: var(--modern-surface-subtle);
}
[data-modern-ui="true"] .cons-pop-models {
border-top: none;
padding-top: 3px;
border-top-color: var(--modern-surface-hover);
}
[data-modern-ui="true"] .cons-source-bar-hit:hover .cons-source-model-bar,
@@ -6442,6 +6598,17 @@ html[data-standalone="true"][data-modern-ui="true"] .app-shell {
background: var(--modern-surface-hover);
}
[data-modern-ui="true"] .data-table tbody tr.is-compaction,
[data-modern-ui="true"] .data-table:not(.is-virtualized) tbody tr.is-compaction:nth-child(even),
[data-modern-ui="true"] .data-table.is-virtualized tbody tr.is-stripe-even.is-compaction {
background: color-mix(in srgb, var(--accent-primary) 12%, transparent);
}
[data-modern-ui="true"] .data-table tbody tr.is-compaction:hover,
[data-modern-ui="true"] .data-table.is-virtualized tbody tr.is-stripe-even.is-compaction:hover {
background: color-mix(in srgb, var(--accent-primary) 19%, transparent);
}
[data-modern-ui="true"] .data-table tbody tr.is-anomaly-warn,
[data-modern-ui="true"] .data-table:not(.is-virtualized) tbody tr.is-anomaly-warn:nth-child(even),
[data-modern-ui="true"] .data-table.is-virtualized tbody tr.is-stripe-even.is-anomaly-warn {
@@ -6464,11 +6631,28 @@ html[data-standalone="true"][data-modern-ui="true"] .app-shell {
background: color-mix(in srgb, var(--metric-danger) 21%, transparent);
}
[data-modern-ui="true"] .form-row > .custom-select > .select-trigger,
[data-modern-ui="true"] .steps-inline-scope-select .select-trigger,
[data-modern-ui="true"] .steps-inline-model-select .select-trigger,
[data-modern-ui="true"] .sstep-fit-model-select .select-trigger {
border: none;
background: var(--modern-surface-subtle);
box-shadow: none;
border-radius: var(--radius-pill);
background: var(--modern-pill-select-bg);
}
[data-modern-ui="true"] .form-row > .custom-select > .select-trigger:hover,
[data-modern-ui="true"] .steps-inline-scope-select .select-trigger:hover,
[data-modern-ui="true"] .steps-inline-model-select .select-trigger:hover,
[data-modern-ui="true"] .sstep-fit-model-select .select-trigger:hover {
background: var(--modern-pill-select-hover);
}
[data-modern-ui="true"] .form-row > .custom-select.is-open > .select-trigger,
[data-modern-ui="true"] .steps-inline-scope-select.is-open .select-trigger,
[data-modern-ui="true"] .steps-inline-model-select.is-open .select-trigger,
[data-modern-ui="true"] .sstep-fit-model-select.is-open .select-trigger {
background: var(--modern-pill-select-open);
}
[data-modern-ui="true"] .sstep-card,
@@ -6584,12 +6768,12 @@ html[data-standalone="true"][data-modern-ui="true"] .app-shell {
border: none;
background: var(--modern-surface-card);
box-shadow: var(--shadow-popover);
animation: anim-modern-pop-in 150ms var(--ease-modern);
animation: anim-modern-tip-fade 120ms var(--ease-modern);
}
[data-modern-ui="true"] .select-menu.is-above,
[data-modern-ui="true"] .dt-popover.is-above {
animation-name: anim-modern-pop-in-up;
transform-origin: bottom right;
}
[data-modern-ui="true"] .trend-tooltip,
@@ -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;/);
+5 -1
View File
@@ -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,
+104 -4
View File
@@ -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;/);
+9 -9
View File
@@ -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');