feat(panel): add step anomaly diagnostics, >=100 tok/s integer speed formatting, and capsule alignment fix

This commit is contained in:
fish
2026-11-19 22:28:39 +09:00
parent dfba5ead7b
commit 4a4e483209
20 changed files with 3546 additions and 143 deletions
@@ -11,6 +11,8 @@
import { h, patchAttr, patchClasses, patchStyleVar, patchText } from '../../core/domPatch.js';
import {
formatAgentBadgeText,
formatSpeedMetric,
formatStepAnomalyInlineSummary,
formatTokens,
formatTokensPrecise,
formatUsd,
@@ -641,7 +643,7 @@ function formatChartMetricValue(metric, val) {
case 'context':
return `${formatTokensPrecise(val)} tok`;
case 'tps':
return `${val.toFixed(1)} tok/s`;
return formatSpeedMetric(val, ' tok/s');
case 'ttft':
return `${val.toFixed(1)}s`;
case 'cache':
@@ -660,7 +662,7 @@ function formatChartMetricCompact(metric, val) {
case 'context':
return formatTokens(val);
case 'tps':
return `${val.toFixed(1)} tok/s`;
return formatSpeedMetric(val, ' tok/s');
case 'ttft':
return `${val.toFixed(1)}s`;
case 'cache':
@@ -750,6 +752,10 @@ export function createSessionLineChart() {
const dotsGroup = document.createElementNS(SVG_NS, 'g');
svg.appendChild(dotsGroup);
const anomalyDotsGroup = document.createElementNS(SVG_NS, 'g');
anomalyDotsGroup.setAttribute('class', 'sstep-anomaly-dots');
svg.appendChild(anomalyDotsGroup);
const hoverLine = document.createElementNS(SVG_NS, 'line');
hoverLine.setAttribute('class', 'trend-hover-line');
hoverLine.setAttribute('y1', '10');
@@ -776,10 +782,12 @@ export function createSessionLineChart() {
const tipMainLeft = h('strong', { className: 'trend-tip-tokens text-mono' });
const tipMainRight = h('span', { className: 'trend-tip-cost text-mono' });
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]),
tipSub,
tipAnomaly,
]);
const xAxisEl = h('div', { className: 'trend-x-axis' });
@@ -837,7 +845,12 @@ export function createSessionLineChart() {
patchAttr(hoverDot, 'hidden', false);
patchAttr(hoverDot, 'cx', pt.x.toFixed(1));
patchAttr(hoverDot, 'cy', pt.y.toFixed(1));
patchStyleVar(hoverDot, '--hover-dot-color', pt.hoverColor || 'var(--ctx-cached)');
const hoverAccent = pt.anomalySummary
? pt.anomalySeverity === 'danger'
? 'var(--metric-danger)'
: 'var(--metric-warn)'
: pt.hoverColor || 'var(--ctx-cached)';
patchStyleVar(hoverDot, '--hover-dot-color', hoverAccent);
patchAttr(peakPill, 'hidden', true);
patchAttr(tooltipEl, 'hidden', false);
@@ -853,6 +866,11 @@ export function createSessionLineChart() {
if (pt.subDetail) {
patchText(tipSub, pt.subDetail);
}
patchAttr(tipAnomaly, 'hidden', !pt.anomalySummary);
if (pt.anomalySummary) {
patchText(tipAnomaly, pt.anomalySummary);
patchClasses(tipAnomaly, { 'is-danger': pt.anomalySeverity === 'danger' });
}
const rawPct = (pt.x / viewW) * 100;
const clampedPct = Math.max(1, Math.min(99, rawPct));
@@ -998,6 +1016,7 @@ export function createSessionLineChart() {
while (multiAreaGroup.firstChild) multiAreaGroup.removeChild(multiAreaGroup.firstChild);
while (multiLineGroup.firstChild) multiLineGroup.removeChild(multiLineGroup.firstChild);
while (dotsGroup.firstChild) dotsGroup.removeChild(dotsGroup.firstChild);
while (anomalyDotsGroup.firstChild) anomalyDotsGroup.removeChild(anomalyDotsGroup.firstChild);
while (xAxisEl.firstChild) xAxisEl.removeChild(xAxisEl.firstChild);
patchAttr(modelLegendEl, 'hidden', true);
patchAttr(peakPill, 'hidden', true);
@@ -1126,7 +1145,7 @@ export function createSessionLineChart() {
} else if (metric === 'ttft') {
valid = !st.isCompactionStep && Number.isFinite(st.ttftSec) && st.ttftSec >= 0;
value = valid ? Number(st.ttftSec) : 0;
secondaryRight = Number.isFinite(st.tokPerSec) ? `${st.tokPerSec.toFixed(1)} tok/s` : '';
secondaryRight = Number.isFinite(st.tokPerSec) ? formatSpeedMetric(st.tokPerSec, ' tok/s') : '';
subDetail = valid
? t('chart.step.ctxAndCache', {
ctxTok: formatTokens(ctxTok),
@@ -1165,6 +1184,7 @@ export function createSessionLineChart() {
}
const dotColor = modelColorMap.get(gk) || accentColor;
const anomalySummary = formatStepAnomalyInlineSummary(st.anomaly);
return {
idx,
st,
@@ -1177,6 +1197,8 @@ export function createSessionLineChart() {
value,
secondaryRight,
subDetail,
anomalySummary,
anomalySeverity: st.anomaly?.severity || '',
};
});
@@ -1212,7 +1234,10 @@ export function createSessionLineChart() {
const sig =
`${locale}|${viewW}|${metric}|${showAgentPrefix}|${isMultiCompare ? 'multi' : 'single'}:${targetKeys.join(',')}|${colorSig}|` +
points
.map((p) => `${p.stepTag}:${p.modelText}:${p.valid ? p.value.toFixed(4) : 'x'}`)
.map(
(p) =>
`${p.stepTag}:${p.modelText}:${p.valid ? p.value.toFixed(4) : 'x'}:${p.st?.anomalySig || ''}`
)
.join('|');
if (sig !== lastSig) {
@@ -1220,6 +1245,7 @@ export function createSessionLineChart() {
while (multiAreaGroup.firstChild) multiAreaGroup.removeChild(multiAreaGroup.firstChild);
while (multiLineGroup.firstChild) multiLineGroup.removeChild(multiLineGroup.firstChild);
while (dotsGroup.firstChild) dotsGroup.removeChild(dotsGroup.firstChild);
while (anomalyDotsGroup.firstChild) anomalyDotsGroup.removeChild(anomalyDotsGroup.firstChild);
if (isMultiCompare) {
patchAttr(linePath, 'd', '');
@@ -1315,6 +1341,19 @@ export function createSessionLineChart() {
}
}
for (const pt of points) {
if (!pt.valid || !pt.anomalySummary) continue;
const aDot = document.createElementNS(SVG_NS, 'circle');
aDot.setAttribute('cx', pt.x.toFixed(1));
aDot.setAttribute('cy', pt.y.toFixed(1));
aDot.setAttribute('r', '2.9');
aDot.setAttribute(
'class',
`sstep-anomaly-dot${pt.anomalySeverity === 'danger' ? ' is-danger' : ''}`
);
anomalyDotsGroup.appendChild(aDot);
}
const tickIndices = computeStepTickIndices(points.length);
while (xAxisEl.firstChild) xAxisEl.removeChild(xAxisEl.firstChild);
tickElsByIdx = new Map();
@@ -1542,10 +1581,12 @@ export function createModelFitChart() {
const tipMainLeft = h('strong', { className: 'trend-tip-tokens text-mono' });
const tipMainRight = h('span', { className: 'trend-tip-cost text-mono' });
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]),
tipSub,
tipAnomaly,
]);
const fitMethodLabelEl = h('span', { text: t('chart.fit.loess') });
@@ -1636,6 +1677,10 @@ export function createModelFitChart() {
patchAttr(hoverRawDot, 'hidden', false);
patchAttr(hoverRawDot, 'cx', sp.x.toFixed(1));
patchAttr(hoverRawDot, 'cy', sp.rawY.toFixed(1));
patchClasses(hoverRawDot, {
'is-anomaly': Boolean(sp.anomalySummary),
'is-danger': Boolean(sp.anomalySummary && sp.anomalySeverity === 'danger'),
});
const wasHidden = tooltipEl.hasAttribute('hidden');
patchAttr(tooltipEl, 'hidden', false);
@@ -1668,6 +1713,11 @@ export function createModelFitChart() {
})
);
}
patchAttr(tipAnomaly, 'hidden', !sp.anomalySummary);
if (sp.anomalySummary) {
patchText(tipAnomaly, sp.anomalySummary);
patchClasses(tipAnomaly, { 'is-danger': sp.anomalySeverity === 'danger' });
}
const rawPct = (sp.x / viewW) * 100;
const clampedPct = Math.max(1, Math.min(99, rawPct));
@@ -1952,6 +2002,8 @@ export function createModelFitChart() {
rawVal,
stepTag: formatStepAxisTag(st, showAgentPrefix),
modelText: disp.baseText || disp.text,
anomalySummary: formatStepAnomalyInlineSummary(st.anomaly),
anomalySeverity: st.anomaly?.severity || '',
});
}
}
@@ -2105,7 +2157,12 @@ export function createModelFitChart() {
.map(
(s) =>
`${s.key}:${s.colorVar}:` +
s.samples.map((p) => `${p.xVal}:${p.rawVal.toFixed(3)}:${p.fitVal.toFixed(3)}`).join(',')
s.samples
.map(
(p) =>
`${p.xVal}:${p.rawVal.toFixed(3)}:${p.fitVal.toFixed(3)}:${p.st?.anomalySig || ''}`
)
.join(',')
)
.join('||');
@@ -2134,10 +2191,15 @@ export function createModelFitChart() {
typeof document.createDocumentFragment === 'function'
? document.createDocumentFragment()
: scatterGroup;
const anomalyOverlayDots = [];
for (const s of seriesList) {
const binCounts = dedupOverdraw ? new Map() : null;
for (const sp of s.samples) {
if (sp.anomalySummary) {
anomalyOverlayDots.push(sp);
continue;
}
if (binCounts) {
const binKey = (Math.round(sp.x * 2) << 11) ^ Math.round(sp.rawY * 2);
const prevCnt = binCounts.get(binKey) || 0;
@@ -2200,6 +2262,17 @@ export function createModelFitChart() {
multiCurveGroup.appendChild(curveEl);
}
}
for (const sp of anomalyOverlayDots) {
const aDot = document.createElementNS(SVG_NS, 'circle');
aDot.setAttribute('cx', sp.x.toFixed(1));
aDot.setAttribute('cy', sp.rawY.toFixed(1));
aDot.setAttribute('r', '2.9');
aDot.setAttribute(
'class',
`sstep-scatter-dot is-anomaly${sp.anomalySeverity === 'danger' ? ' is-danger' : ''}`
);
scatterTarget.appendChild(aDot);
}
if (scatterTarget !== scatterGroup) {
scatterGroup.appendChild(scatterTarget);
}
@@ -2316,7 +2389,11 @@ export function createModelFitChart() {
const sig =
`single|${locale}|${viewW}|${targetKeys[0]}|${metric}|${showAgentPrefix}|${yScale.min.toFixed(4)}|${yScale.max.toFixed(4)}|` +
samples.map((s) => `${s.xVal}:${s.rawVal.toFixed(4)}:${s.fitVal.toFixed(4)}`).join('|');
samples
.map(
(s) => `${s.xVal}:${s.rawVal.toFixed(4)}:${s.fitVal.toFixed(4)}:${s.st?.anomalySig || ''}`
)
.join('|');
if (sig !== lastSig) {
lastSig = sig;
@@ -2340,7 +2417,12 @@ export function createModelFitChart() {
typeof document.createDocumentFragment === 'function'
? document.createDocumentFragment()
: scatterGroup;
const singleAnomalyDots = [];
for (const s of samples) {
if (s.anomalySummary) {
singleAnomalyDots.push(s);
continue;
}
if (binCounts) {
const binKey = (Math.round(s.x * 2) << 11) ^ Math.round(s.rawY * 2);
const prevCnt = binCounts.get(binKey) || 0;
@@ -2354,6 +2436,17 @@ export function createModelFitChart() {
dot.setAttribute('class', 'sstep-scatter-dot');
scatterTarget.appendChild(dot);
}
for (const s of singleAnomalyDots) {
const aDot = document.createElementNS(SVG_NS, 'circle');
aDot.setAttribute('cx', s.x.toFixed(1));
aDot.setAttribute('cy', s.rawY.toFixed(1));
aDot.setAttribute('r', '2.9');
aDot.setAttribute(
'class',
`sstep-scatter-dot is-anomaly${s.anomalySeverity === 'danger' ? ' is-danger' : ''}`
);
scatterTarget.appendChild(aDot);
}
if (scatterTarget !== scatterGroup) {
scatterGroup.appendChild(scatterTarget);
}
@@ -13,7 +13,11 @@ import {
patchKeyedList,
patchText,
} from '../../core/domPatch.js';
import { resolveModelDisplayInfo, speedReasonText } from '../../core/formatters.js';
import {
buildStepAnomalyDiagnostic,
resolveModelDisplayInfo,
speedReasonText,
} from '../../core/formatters.js';
import { getEffectiveLocale, t } from '../../i18n/index.js';
import {
DEFAULT_STEP_COLUMN_KEYS,
@@ -198,9 +202,14 @@ function buildColumnSizerSpec(tableSteps, colKeys, wantedSet, cellCtx) {
if (needTps) {
const tpsVal = Number(st.tokPerSec);
if (Number.isFinite(tpsVal) && tpsVal > maxTpsVal) {
maxTpsVal = tpsVal;
maxTpsObj = st;
if (Number.isFinite(tpsVal) && tpsVal >= 0) {
const tpsScore =
(tpsVal >= 100 ? String(Math.round(tpsVal)).length : tpsVal.toFixed(1).length) * 1e6 +
tpsVal;
if (tpsScore > maxTpsVal) {
maxTpsVal = tpsScore;
maxTpsObj = st;
}
}
if (st.selectedSpeedReason) {
reasonCandidates.add(st.selectedSpeedReason);
@@ -415,8 +424,31 @@ export const StepTableWidget = defineComponent({
});
const hideTurnTip = () => patchAttr(turnTipEl, 'hidden', true);
const anomalyTipTitleEl = h('div', { className: 'step-anomaly-tip-title' });
const anomalyTipSubEl = h('div', { className: 'step-anomaly-tip-sub text-mono', hidden: true });
const anomalyTipHeadEl = h('div', { className: 'step-anomaly-tip-head' }, [
anomalyTipTitleEl,
anomalyTipSubEl,
]);
const anomalyTipListEl = h('div', { className: 'step-anomaly-tip-list' });
const anomalyTipHintEl = h('div', { className: 'step-anomaly-tip-hint', hidden: true });
const anomalyTipEl = h(
'div',
{
className: 'step-anomaly-tip',
role: 'tooltip',
hidden: true,
},
[anomalyTipHeadEl, anomalyTipListEl, anomalyTipHintEl]
);
const hideAnomalyTip = () => patchAttr(anomalyTipEl, 'hidden', true);
const standaloneHostEl = standalone
? h('div', { className: 'step-table-preview-host' }, [stepsTablePane, turnTipEl])
? h('div', { className: 'step-table-preview-host' }, [
stepsTablePane,
turnTipEl,
anomalyTipEl,
])
: null;
let boundsContainerGetter =
@@ -430,40 +462,85 @@ export const StepTableWidget = defineComponent({
}
}
function positionFloatingTip(tipEl, anchorEl) {
const boundsEl = boundsContainerGetter?.();
if (
!boundsEl ||
typeof boundsEl.getBoundingClientRect !== 'function' ||
typeof anchorEl?.getBoundingClientRect !== 'function'
) {
return;
}
const panelRect = boundsEl.getBoundingClientRect();
const anchorRect = anchorEl.getBoundingClientRect();
if (!(panelRect.width > 0 && panelRect.height > 0)) return;
const tipH = tipEl.offsetHeight || 56;
const tipW = tipEl.offsetWidth || 220;
const placeAbove =
panelRect.bottom - anchorRect.bottom < tipH + 10 &&
anchorRect.top - panelRect.top > tipH + 6;
const topPx = placeAbove
? Math.max(4, Math.round(anchorRect.top - panelRect.top - tipH - 5))
: Math.round(anchorRect.bottom - panelRect.top + 5);
const maxLeft = Math.max(6, Math.round(panelRect.width - tipW - 8));
const leftPx = Math.min(
maxLeft,
Math.max(6, Math.round(anchorRect.left - panelRect.left))
);
tipEl.style.top = `${topPx}px`;
tipEl.style.left = `${leftPx}px`;
}
function showTurnTip(anchorCell, promptText) {
const text = String(promptText || '').trim();
const boundsEl = boundsContainerGetter?.();
if (!anchorCell || !text) {
hideTurnTip();
return;
}
hideAnomalyTip();
patchText(turnTipEl, text);
patchAttr(turnTipEl, 'hidden', false);
if (
boundsEl &&
typeof boundsEl.getBoundingClientRect === 'function' &&
typeof anchorCell.getBoundingClientRect === 'function'
) {
const panelRect = boundsEl.getBoundingClientRect();
const cellRect = anchorCell.getBoundingClientRect();
if (panelRect.width > 0 && panelRect.height > 0) {
const tipH = turnTipEl.offsetHeight || 36;
const tipW = turnTipEl.offsetWidth || 180;
const placeAbove =
panelRect.bottom - cellRect.bottom < tipH + 10 &&
cellRect.top - panelRect.top > tipH + 6;
const topPx = placeAbove
? Math.max(4, Math.round(cellRect.top - panelRect.top - tipH - 4))
: Math.round(cellRect.bottom - panelRect.top + 4);
const maxLeft = Math.max(6, Math.round(panelRect.width - tipW - 8));
const leftPx = Math.min(
maxLeft,
Math.max(6, Math.round(cellRect.left - panelRect.left + 4))
);
turnTipEl.style.top = `${topPx}px`;
turnTipEl.style.left = `${leftPx}px`;
}
positionFloatingTip(turnTipEl, anchorCell);
}
function showAnomalyTip(anchorEl, diag) {
if (!anchorEl || !diag || !diag.title) {
hideAnomalyTip();
return;
}
hideTurnTip();
patchClasses(anomalyTipEl, { 'is-danger': diag.severity === 'danger' });
patchText(anomalyTipTitleEl, diag.title);
patchAttr(anomalyTipSubEl, 'hidden', !diag.sub);
if (diag.sub) patchText(anomalyTipSubEl, diag.sub);
while (anomalyTipListEl.firstChild) {
anomalyTipListEl.removeChild(anomalyTipListEl.firstChild);
}
const rows = Array.isArray(diag.rows) ? diag.rows : [];
for (const row of rows) {
const lineEl = h('div', {
className: `step-anomaly-tip-row${row.danger ? ' is-danger' : ''}`,
text: row.text,
});
const itemChildren = [lineEl];
if (row.detail) {
itemChildren.push(
h('div', {
className: 'step-anomaly-tip-detail text-mono',
text: row.detail,
})
);
}
anomalyTipListEl.appendChild(h('div', { className: 'step-anomaly-tip-item' }, itemChildren));
}
patchAttr(anomalyTipListEl, 'hidden', rows.length === 0);
patchAttr(anomalyTipHintEl, 'hidden', !diag.hint);
if (diag.hint) patchText(anomalyTipHintEl, diag.hint);
patchAttr(anomalyTipEl, 'hidden', false);
positionFloatingTip(anomalyTipEl, anchorEl);
}
const hoverRows = new WeakMap();
@@ -598,15 +675,30 @@ export const StepTableWidget = defineComponent({
}
function moveInStepCell(event) {
if (event?.target === hoverRows.get(this).badge) hideTurnTip();
const { badge } = hoverRows.get(this);
if (event?.target === badge) hideTurnTip();
}
function moveAlongTurnRail(event) {
const { badge, prompt } = hoverRows.get(this);
const { badge, prompt, anomalyStep } = 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 (event?.target !== badge && relX <= 18) {
showTurnTip(this, prompt);
} else {
hideTurnTip();
if (anomalyStep) {
showAnomalyTip(this, buildStepAnomalyDiagnostic(anomalyStep));
}
}
}
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));
}
}
function clearCellHover(cell) {
@@ -898,7 +990,8 @@ export const StepTableWidget = defineComponent({
? `${cellCtx.scopeSigKey}:${st.agentId || 'main'}:${st.agentBadge || ''}:${st.agentLabel || ''}`
: '';
const stripeSig = isVirtualized ? (item.isStripeEven ? 'E' : 'O') : 'N';
return `${locale}:${colOrderSig}:${stripeSig}:${badgeSig}:${railActive}:${item.hasTurn}:${item.hasUp}:${item.hasDown}:${item.isStart}:${item.isLatest}:${item.prompt}:${parts}`;
const anomalySig = st.anomalySig || '';
return `${locale}:${colOrderSig}:${stripeSig}:${badgeSig}:${anomalySig}:${railActive}:${item.hasTurn}:${item.hasUp}:${item.hasDown}:${item.isStart}:${item.isLatest}:${item.prompt}:${parts}`;
},
createRow: (item) => {
if (item.isSizer) {
@@ -1140,6 +1233,24 @@ export const StepTableWidget = defineComponent({
refs.agentBadgeEl.onclick = null;
}
const hasStepAnomaly = Boolean(st?.anomaly && Number(st.anomaly.count) > 0);
const isAnomalyDanger = Boolean(hasStepAnomaly && st.anomaly.severity === 'danger');
const isAnomalyWarn = Boolean(hasStepAnomaly && !isAnomalyDanger);
patchClasses(tr, {
'is-anomaly-warn': isAnomalyWarn,
'is-anomaly-danger': isAnomalyDanger,
});
if (hasStepAnomaly) {
const anchorEl = firstTd || tr;
tr.onmouseenter = () => {
showAnomalyTip(anchorEl, buildStepAnomalyDiagnostic(st));
};
tr.onmouseleave = hideAnomalyTip;
} else {
tr.onmouseenter = null;
tr.onmouseleave = null;
}
patchAttr(refs.railEl, 'hidden', !showRowRail);
if (showRowRail) {
const marker = isStart ? ' is-origin' : !hasUp && hasDown ? ' is-cap' : '';
@@ -1154,10 +1265,16 @@ export const StepTableWidget = defineComponent({
if (refs.hoverTd !== hoverTd) clearCellHover(refs.hoverTd);
refs.hoverTd = hoverTd;
if (hoverTd) {
hoverRows.set(hoverTd, { badge: refs.agentBadgeEl, prompt });
hoverTd.onmouseenter = firstColKey === 'step' ? enterStepCell : null;
hoverTd.onmousemove = firstColKey === 'step' ? moveInStepCell : moveAlongTurnRail;
hoverTd.onmouseleave = hideTurnTip;
hoverRows.set(hoverTd, {
badge: refs.agentBadgeEl,
prompt,
anomalyStep: hasStepAnomaly ? st : null,
tr,
});
const useWholeCellTurnTip = firstColKey === 'step' && !hasStepAnomaly;
hoverTd.onmouseenter = useWholeCellTurnTip ? enterStepCell : null;
hoverTd.onmousemove = useWholeCellTurnTip ? moveInStepCell : moveAlongTurnRail;
hoverTd.onmouseleave = leaveStepCell;
}
if (enteringRowKeys?.has(item.rowKey)) {
@@ -1179,7 +1296,14 @@ export const StepTableWidget = defineComponent({
}
clearRowEnterState(tr);
if (!refs?.isSpacer && !refs?.isSizer && tr) {
patchClasses(tr, { 'is-stripe-even': false, 'is-step-entering': false });
patchClasses(tr, {
'is-stripe-even': false,
'is-step-entering': false,
'is-anomaly-warn': false,
'is-anomaly-danger': false,
});
tr.onmouseenter = null;
tr.onmouseleave = null;
if (refs.agentBadgeEl) {
refs.agentBadgeEl.onclick = null;
}
@@ -1209,6 +1333,7 @@ export const StepTableWidget = defineComponent({
function onPaneScroll() {
hideTurnTip();
hideAnomalyTip();
if (!activeDataset?.isVirtualized) return;
if (typeof requestAnimationFrame === 'function') {
if (scrollRafId) return;
@@ -1221,8 +1346,13 @@ export const StepTableWidget = defineComponent({
}
}
function onTbodyLeave() {
hideTurnTip();
hideAnomalyTip();
}
stepsTablePane.addEventListener('scroll', onPaneScroll, { passive: true });
stepsTbody.addEventListener('mouseleave', hideTurnTip);
stepsTbody.addEventListener('mouseleave', onTbodyLeave);
let paneResizeObs = null;
if (typeof ResizeObserver === 'function') {
@@ -1424,7 +1554,7 @@ export const StepTableWidget = defineComponent({
onCleanup(() => {
stepsTablePane.removeEventListener('scroll', onPaneScroll);
stepsTbody.removeEventListener('mouseleave', hideTurnTip);
stepsTbody.removeEventListener('mouseleave', onTbodyLeave);
if (scrollRafId && typeof cancelAnimationFrame === 'function') {
cancelAnimationFrame(scrollRafId);
scrollRafId = 0;
@@ -1449,10 +1579,13 @@ export const StepTableWidget = defineComponent({
stepsTheadRow,
stepsTbody,
turnTipEl,
anomalyTipEl,
syncTableHeaderColumns,
renderStepTable,
refreshViewport,
hideTurnTip,
showAnomalyTip,
hideAnomalyTip,
setBoundsElGetter,
},
};
+163
View File
@@ -25,6 +25,12 @@ export function formatMetric(value, unit = '') {
return Number.isFinite(value) ? `${value.toFixed(1)}${unit}` : '—';
}
export function formatSpeedMetric(value, unit = ' tok/s') {
if (!Number.isFinite(value)) return '—';
const numStr = value >= 100 ? String(Math.round(value)) : value.toFixed(1);
return `${numStr}${unit}`;
}
export function formatCachePct(value) {
if (value == null || !Number.isFinite(Number(value))) return '—';
const num = Math.max(0, Math.min(100, +Number(value).toFixed(1)));
@@ -98,6 +104,8 @@ const SPEED_REASON_LABELS = {
__proto__: null,
incomplete_or_invalid_timing: 'fmt.speedIncomplete',
canceled: 'fmt.speedCanceled',
error: 'fmt.speedError',
interrupted: 'fmt.speedInterrupted',
compaction_timing_unavailable: 'fmt.speedCompactionTimingUnavailable',
invalid_output_tokens: 'fmt.speedInvalidOutput',
inconsistent_timing: 'fmt.speedInconsistent',
@@ -110,6 +118,135 @@ export function speedReasonText(reason) {
return label ? t(label) : '';
}
const ANOMALY_KIND_ORDER = Object.freeze([
'rate_limit',
'timeout',
'capacity',
'disconnect',
'upstream',
'model_output',
'safety',
'auth_or_model',
'error',
]);
export function formatAnomalyKindLabel(kind) {
const k = String(kind || 'error');
const key = `steps.anomalyKind.${k}`;
const text = t(key);
return text === key ? t('steps.anomalyKind.error') : text;
}
export function formatAnomalyTagText(primaryKind, count = 1) {
const n = Math.max(1, Math.floor(Number(count) || 1));
const k = String(primaryKind || 'error');
if (k === 'capacity' && n === 1) return t('steps.anomalyTag.capacitySingle');
if (k === 'upstream' && n === 1) return t('steps.anomalyTag.upstreamSingle');
const key = `steps.anomalyTag.${k}`;
const formatted = t(key, { n });
return formatted === key ? t('steps.anomalyTag.error', { n }) : formatted;
}
export function resolveModelAnomalySummary(m) {
const count = Math.max(0, Number(m?.anomalyCount || 0));
const steps = Math.max(0, Number(m?.anomalySteps || 0));
if (count <= 0 && steps <= 0) return null;
const byKind = m?.anomalyByKind && typeof m.anomalyByKind === 'object' ? m.anomalyByKind : {};
const entries = Object.entries(byKind)
.map(([k, v]) => [k, Math.max(0, Number(v || 0))])
.filter(([, v]) => v > 0)
.sort((a, b) => {
if (b[1] !== a[1]) return b[1] - a[1];
const pa = ANOMALY_KIND_ORDER.indexOf(a[0]);
const pb = ANOMALY_KIND_ORDER.indexOf(b[0]);
return (pa < 0 ? 99 : pa) - (pb < 0 ? 99 : pb);
});
const totalCount = count || entries.reduce((sum, [, v]) => sum + v, 0) || steps;
const primaryKind = entries.length === 1 ? entries[0][0] : entries.length > 1 ? 'mixed' : 'error';
const severity =
Number(m?.anomalyDangerCount || 0) > 0 ||
entries.some(([k]) => k === 'rate_limit' || k === 'auth_or_model')
? 'danger'
: 'warn';
return {
count: totalCount,
steps: steps || totalCount,
totalDelaySec: Math.max(0, Number(m?.anomalyTotalDelaySec || 0)),
primaryKind,
severity,
entries,
tagText: formatAnomalyTagText(primaryKind, totalCount),
};
}
export function formatStepAnomalyInlineSummary(anomaly) {
if (!anomaly || !(Number(anomaly.count) > 0)) return '';
const tag = formatAnomalyTagText(anomaly.primaryKind, anomaly.count);
const label = formatAnomalyKindLabel(anomaly.primaryKind);
const delaySec = Number(anomaly.totalDelaySec || 0);
const delayPart = delaySec > 0 ? ` · ${t('steps.anomalyDelayPart', { sec: delaySec })}` : '';
return `${tag} · ${label}${delayPart}`;
}
export function buildStepAnomalyDiagnostic(st) {
const a = st?.anomaly;
if (!a || !(Number(a.count) > 0)) return null;
const title = t('steps.anomalyStepTitle', {
step: Number(st.stepIndex ?? 0),
count: Number(a.count),
});
const delaySec = Number(a.totalDelaySec || 0);
const sub = delaySec > 0 ? t('steps.anomalyDelayPart', { sec: delaySec }) : '';
const events = Array.isArray(a.events) ? a.events : [];
const rows = events.map((ev, idx) => {
const label = formatAnomalyKindLabel(ev.kind);
const parts = [`#${ev.attempt || idx + 1} ${label}`];
if (Number(ev.delaySec) > 0) {
parts.push(t('steps.anomalyDelayPart', { sec: ev.delaySec }));
}
if (ev.terminal) {
parts.push(t('steps.anomalyTerminalTag'));
}
return {
text: parts.join(' · '),
detail: ev.message || '',
danger: Boolean(ev.terminal || ev.kind === 'rate_limit' || ev.kind === 'auth_or_model'),
};
});
return {
title,
sub,
rows,
hint: '',
severity: a.severity === 'danger' ? 'danger' : 'warn',
};
}
export function buildModelAnomalyDiagnostic(m) {
const sum = resolveModelAnomalySummary(m);
if (!sum) return null;
const title = t('steps.anomalyModelTitle', {
model: m?.displayText || m?.shortName || m?.label || '—',
count: sum.count,
});
const subParts = [t('steps.anomalyModelSub', { steps: sum.steps })];
if (sum.totalDelaySec > 0) {
subParts.push(t('steps.anomalyDelayPart', { sec: sum.totalDelaySec }));
}
const rows = sum.entries.map(([k, v]) => ({
text: t('steps.anomalyModelKindRow', { kind: formatAnomalyKindLabel(k), count: v }),
detail: '',
danger: k === 'rate_limit' || k === 'auth_or_model',
}));
return {
title,
sub: subParts.join(' · '),
rows,
hint: t('steps.anomalyModelClickHint'),
severity: sum.severity,
};
}
export function sampleSummary(summary) {
const valid = summary?.sampleCount || 0;
const excluded = summary?.excludedCount || 0;
@@ -389,6 +526,12 @@ export function mergeModelsByDisplayName(models = [], settings = {}, options = {
ttftWeightedSum: hasTtft ? Number(m.avgTtftSec) * ttftWeight : 0,
ttftWeight: hasTtft ? ttftWeight : 0,
ttftSampleCount,
anomalySteps: Math.max(0, Number(m.anomalySteps || 0)),
anomalyCount: Math.max(0, Number(m.anomalyCount || 0)),
anomalyDangerCount: Math.max(0, Number(m.anomalyDangerCount || 0)),
anomalyTotalDelaySec: Math.max(0, Number(m.anomalyTotalDelaySec || 0)),
anomalyByKind:
m.anomalyByKind && typeof m.anomalyByKind === 'object' ? { ...m.anomalyByKind } : {},
};
if (m.upstreamName) acc.upstreamSet.add(m.upstreamName);
byDisplay.set(key, acc);
@@ -417,6 +560,17 @@ export function mergeModelsByDisplayName(models = [], settings = {}, options = {
acc.costUsd += costUsd;
acc.unpricedCalls += unpricedCalls;
acc.anomalySteps += Math.max(0, Number(m.anomalySteps || 0));
acc.anomalyCount += Math.max(0, Number(m.anomalyCount || 0));
acc.anomalyDangerCount += Math.max(0, Number(m.anomalyDangerCount || 0));
acc.anomalyTotalDelaySec += Math.max(0, Number(m.anomalyTotalDelaySec || 0));
if (m.anomalyByKind && typeof m.anomalyByKind === 'object') {
for (const [ak, av] of Object.entries(m.anomalyByKind)) {
const cnt = Math.max(0, Number(av || 0));
if (cnt > 0) acc.anomalyByKind[ak] = (acc.anomalyByKind[ak] || 0) + cnt;
}
}
if (hasSpeed) {
acc.speedWeightedSum += Number(m.avgTokPerSec) * speedWeight;
acc.speedWeight += speedWeight;
@@ -467,6 +621,15 @@ export function mergeModelsByDisplayName(models = [], settings = {}, options = {
avgTokPerSec,
avgTtftSec,
ttftSampleCount: acc.ttftSampleCount,
...(acc.anomalyCount > 0
? {
anomalySteps: acc.anomalySteps,
anomalyCount: acc.anomalyCount,
anomalyDangerCount: acc.anomalyDangerCount,
anomalyTotalDelaySec: +acc.anomalyTotalDelaySec.toFixed(1),
anomalyByKind: acc.anomalyByKind,
}
: {}),
speedSummary: acc.baseItem.speedSummary
? {
...acc.baseItem.speedSummary,
+34
View File
@@ -37,6 +37,8 @@ export const I18N_MESSAGES_EN_US = Object.freeze({
'fmt.pending': 'N/A',
'fmt.speedIncomplete': 'Incomplete timing',
'fmt.speedCanceled': 'Canceled',
'fmt.speedError': 'Call error',
'fmt.speedInterrupted': 'Interrupted',
'fmt.speedCompactionTimingUnavailable': 'Untimed compaction',
'fmt.speedInvalidOutput': 'No valid output',
'fmt.speedInconsistent': 'Invalid timing',
@@ -299,6 +301,38 @@ export const I18N_MESSAGES_EN_US = Object.freeze({
'steps.fitInactiveCardTitle': 'Click to inspect {text} in Trend Fit (Ctrl/Shift-click to compare)',
'steps.turnMediaOnly': '[Media Attachment]',
'steps.turnMediaSuffix': '[Media]',
'steps.anomalyTag.timeout': 'TO{n}',
'steps.anomalyTag.rate_limit': '429×{n}',
'steps.anomalyTag.capacity': '503×{n}',
'steps.anomalyTag.capacitySingle': '503',
'steps.anomalyTag.disconnect': 'Drop{n}',
'steps.anomalyTag.upstream': '500×{n}',
'steps.anomalyTag.upstreamSingle': '500',
'steps.anomalyTag.model_output': 'Fix{n}',
'steps.anomalyTag.safety': 'Safe{n}',
'steps.anomalyTag.auth_or_model': 'Err{n}',
'steps.anomalyTag.error': 'Err{n}',
'steps.anomalyTag.mixed': 'Warn{n}',
'steps.anomalyKind.timeout': 'Stream Idle / Connect Timeout',
'steps.anomalyKind.rate_limit': '429 Rate Limit / Quota Reached',
'steps.anomalyKind.capacity': '503 No Capacity Available',
'steps.anomalyKind.disconnect': 'Connection Reset / Stream Interrupted',
'steps.anomalyKind.upstream': 'Upstream 5xx Internal Error',
'steps.anomalyKind.model_output': 'Invalid Model Output / Tool Call',
'steps.anomalyKind.safety': 'Content Safety Filter',
'steps.anomalyKind.auth_or_model': 'Request / Model Rejected',
'steps.anomalyKind.error': 'Call Error',
'steps.anomalyKind.canceled': 'Canceled by User',
'steps.anomalyStepTitle': '#{step} · {count} Retries / Errors',
'steps.anomalyDelayPart': 'Backoff {sec}s',
'steps.anomalyTerminalTag': 'Stopped',
'steps.anomalyModelTitle': '{model} · {count} Retries / Errors',
'steps.anomalyModelSub': '{steps} steps affected',
'steps.anomalyModelKindRow': '{kind}: {count}',
'steps.anomalyModelClickHint': 'Click to filter anomalous steps',
'steps.anomalySummaryMeta': '{count} retries/errors ({steps} steps)',
'steps.anomalyFilterLabel': 'Anomalies Only ({count})',
'steps.anomalyFilterAll': 'Show All Steps',
// Step Table Columns (Headers & Option Labels)
'stepCol.step.th': 'Step',
+34
View File
@@ -37,6 +37,8 @@ export const I18N_MESSAGES_ZH_CN = Object.freeze({
'fmt.pending': '待定',
'fmt.speedIncomplete': '计时不完整',
'fmt.speedCanceled': '已取消',
'fmt.speedError': '调用报错',
'fmt.speedInterrupted': '连接中断',
'fmt.speedCompactionTimingUnavailable': '压缩无计时',
'fmt.speedInvalidOutput': '无有效输出',
'fmt.speedInconsistent': '耗时数据异常',
@@ -299,6 +301,38 @@ export const I18N_MESSAGES_ZH_CN = Object.freeze({
'steps.fitInactiveCardTitle': '点击在上方拟合图查看 {text}(按住 Ctrl/Shift 点击可多选同图对比)',
'steps.turnMediaOnly': '[图片/附件提问]',
'steps.turnMediaSuffix': '[附图]',
'steps.anomalyTag.timeout': '超时{n}',
'steps.anomalyTag.rate_limit': '限流{n}',
'steps.anomalyTag.capacity': '503×{n}',
'steps.anomalyTag.capacitySingle': '503',
'steps.anomalyTag.disconnect': '断连{n}',
'steps.anomalyTag.upstream': '500×{n}',
'steps.anomalyTag.upstreamSingle': '500',
'steps.anomalyTag.model_output': '纠偏{n}',
'steps.anomalyTag.safety': '过滤{n}',
'steps.anomalyTag.auth_or_model': '受限{n}',
'steps.anomalyTag.error': '报错{n}',
'steps.anomalyTag.mixed': '异常{n}',
'steps.anomalyKind.timeout': '流空闲 / 连接超时',
'steps.anomalyKind.rate_limit': '429 限流 / 配额耗尽',
'steps.anomalyKind.capacity': '503 上游算力不足',
'steps.anomalyKind.disconnect': '连接中断 / 断流',
'steps.anomalyKind.upstream': '上游 5xx 内部错误',
'steps.anomalyKind.model_output': '模型输出 / 工具参数无效',
'steps.anomalyKind.safety': '内容安全过滤',
'steps.anomalyKind.auth_or_model': '请求受限 / 模型不可用',
'steps.anomalyKind.error': '调用异常',
'steps.anomalyKind.canceled': '用户取消',
'steps.anomalyStepTitle': '#{step} · 异常 {count} 次',
'steps.anomalyDelayPart': '退避 {sec}s',
'steps.anomalyTerminalTag': '中止',
'steps.anomalyModelTitle': '{model} · 异常 {count} 次',
'steps.anomalyModelSub': '涉及 {steps} 步',
'steps.anomalyModelKindRow': '{kind}:{count} 次',
'steps.anomalyModelClickHint': '点击前往「按步查看」筛选异常步',
'steps.anomalySummaryMeta': '异常 {count} 次({steps} 步)',
'steps.anomalyFilterLabel': '仅看异常 ({count})',
'steps.anomalyFilterAll': '返回全部步骤',
// Step Table Columns (Headers & Option Labels)
'stepCol.step.th': '步序',
@@ -9,6 +9,7 @@ import { h, patchAttr, patchText } from '../core/domPatch.js';
import {
formatCachePct,
formatMetric,
formatSpeedMetric,
formatTokens,
formatUsd,
getCacheToneClass,
@@ -191,7 +192,7 @@ export const STEP_COLUMN_REGISTRY = Object.freeze({
return { td, refs: { wrapEl, speedMain, speedReason: null } };
},
updateCell: (refs, st, ctx) => {
patchText(refs.speedMain, formatMetric(st.tokPerSec, ' tok/s'));
patchText(refs.speedMain, formatSpeedMetric(st.tokPerSec, ' tok/s'));
const hasValidSpeed =
st.tokPerSec != null && Number.isFinite(Number(st.tokPerSec)) && Number(st.tokPerSec) > 0;
const toneCls =
+8 -1
View File
@@ -603,6 +603,7 @@ export function isEquivalentTelemetry(prev, next) {
bs?.contextTokens !== as?.contextTokens ||
bs?.cacheHitPct !== as?.cacheHitPct ||
bs?.selectedSpeedReason !== as?.selectedSpeedReason ||
bs?.anomalySig !== as?.anomalySig ||
bs?.turnIndex !== as?.turnIndex ||
bs?.rootTurnIndex !== as?.rootTurnIndex ||
bs?.isTurnStart !== as?.isTurnStart ||
@@ -659,6 +660,7 @@ export function isEquivalentTelemetry(prev, next) {
before.contextTokens !== after.contextTokens ||
before.cacheHitPct !== after.cacheHitPct ||
before.selectedSpeedReason !== after.selectedSpeedReason ||
before.anomalySig !== after.anomalySig ||
before.turnIndex !== after.turnIndex ||
before.rootTurnIndex !== after.rootTurnIndex ||
before.isTurnStart !== after.isTurnStart ||
@@ -711,7 +713,9 @@ export function isEquivalentTelemetry(prev, next) {
a[k]?.costUsd !== b[k]?.costUsd ||
a[k]?.unpricedCalls !== b[k]?.unpricedCalls ||
a[k]?.totalTokens !== b[k]?.totalTokens ||
a[k]?.calls !== b[k]?.calls
a[k]?.calls !== b[k]?.calls ||
Number(a[k]?.anomalyCount || 0) !== Number(b[k]?.anomalyCount || 0) ||
Number(a[k]?.anomalySteps || 0) !== Number(b[k]?.anomalySteps || 0)
) {
return false;
}
@@ -750,6 +754,9 @@ export function isEquivalentTelemetry(prev, next) {
}
// 7. 比对按模型汇总明细与数据来源汇总明细
if (!areModelSlicesEqual(pAct?.modelBreakdown, nAct?.modelBreakdown)) {
return false;
}
if (!areModelSlicesEqual(prev.modelBreakdown, next.modelBreakdown)) {
return false;
}
+56 -2
View File
@@ -343,7 +343,8 @@ html[data-standalone="true"][data-modern-ui="true"] .app-shell {
}
[data-modern-ui="true"] .agent-badge,
[data-modern-ui="true"] .agent-badge.is-clickable:hover {
[data-modern-ui="true"] .agent-badge.is-clickable:hover,
[data-modern-ui="true"] .step-anomaly-tag {
border: none;
}
@@ -456,6 +457,7 @@ html[data-standalone="true"][data-modern-ui="true"] .app-shell {
}
[data-modern-ui="true"] .trend-tip-sub,
[data-modern-ui="true"] .trend-tip-anomaly,
[data-modern-ui="true"] .cons-pop-models {
border-top: none;
padding-top: 3px;
@@ -516,6 +518,28 @@ html[data-standalone="true"][data-modern-ui="true"] .app-shell {
background: var(--modern-surface-hover);
}
[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 {
background: color-mix(in srgb, var(--metric-warn) 12%, transparent);
}
[data-modern-ui="true"] .data-table tbody tr.is-anomaly-warn:hover,
[data-modern-ui="true"] .data-table.is-virtualized tbody tr.is-stripe-even.is-anomaly-warn:hover {
background: color-mix(in srgb, var(--metric-warn) 19%, transparent);
}
[data-modern-ui="true"] .data-table tbody tr.is-anomaly-danger,
[data-modern-ui="true"] .data-table:not(.is-virtualized) tbody tr.is-anomaly-danger:nth-child(even),
[data-modern-ui="true"] .data-table.is-virtualized tbody tr.is-stripe-even.is-anomaly-danger {
background: color-mix(in srgb, var(--metric-danger) 14%, transparent);
}
[data-modern-ui="true"] .data-table tbody tr.is-anomaly-danger:hover,
[data-modern-ui="true"] .data-table.is-virtualized tbody tr.is-stripe-even.is-anomaly-danger:hover {
background: color-mix(in srgb, var(--metric-danger) 21%, transparent);
}
[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 {
@@ -550,6 +574,22 @@ html[data-standalone="true"][data-modern-ui="true"] .app-shell {
background: var(--accent-primary-soft);
}
[data-modern-ui="true"] .steps-anomaly-filterbar,
[data-modern-ui="true"] .steps-anomaly-strip {
border: none;
border-radius: var(--radius-xs);
background: var(--metric-warn-soft);
}
[data-modern-ui="true"] .steps-anomaly-filterbar {
margin: 4px 2px 2px;
}
[data-modern-ui="true"] .sstep-anomaly-dot,
[data-modern-ui="true"] .sstep-scatter-dot.is-anomaly {
fill: var(--modern-surface-card);
}
/* --- 6. 设置表单、折叠面板、槽位排序与输入控件去边框 --- */
[data-modern-ui="true"] .collapsible-body,
[data-modern-ui="true"] .settings-action-block + .settings-action-block,
@@ -630,13 +670,19 @@ html[data-standalone="true"][data-modern-ui="true"] .app-shell {
[data-modern-ui="true"] .trend-tooltip,
[data-modern-ui="true"] .cons-breakdown-popover,
[data-modern-ui="true"] .turn-prompt-tip {
[data-modern-ui="true"] .turn-prompt-tip,
[data-modern-ui="true"] .step-anomaly-tip {
border: none;
background: var(--modern-surface-card);
box-shadow: var(--shadow-popover);
animation: anim-modern-tip-fade 150ms var(--ease-modern);
}
[data-modern-ui="true"] .step-anomaly-tip-list,
[data-modern-ui="true"] .step-anomaly-tip-hint {
border-top-color: var(--modern-surface-hover);
}
[data-modern-ui="true"] .trend-tooltip:not(.is-hm-top):not(.is-hm-bottom) {
top: 2px;
bottom: auto;
@@ -740,10 +786,18 @@ html[data-standalone="true"][data-modern-ui="true"] .app-shell {
[data-modern-ui="true"] .wm-multi-label[data-od-active="1"] {
display: inline-flex;
align-items: center;
justify-content: center;
height: 18px;
line-height: 18px;
}
:host([data-modern-ui="true"]) .wm-slot-text.wm-ctx-pct[data-od-active="1"],
:host([data-modern-ui="true"]) .wm-multi-label[data-od-active="1"],
[data-modern-ui="true"] .wm-slot-text.wm-ctx-pct[data-od-active="1"],
[data-modern-ui="true"] .wm-multi-label[data-od-active="1"] {
justify-content: flex-start;
}
:host([data-modern-ui="true"]) .wm-od-digit,
[data-modern-ui="true"] .wm-od-digit {
display: inline-block;
+283
View File
@@ -295,6 +295,248 @@
animation: anim-popover-in var(--dur-instant) var(--ease-fast);
}
/* --- 2.6 单步异常整行语义着色、模型汇总微标、筛选条与悬停诊断卡 --- */
.data-table tbody tr.is-anomaly-warn {
background: color-mix(in srgb, var(--metric-warn) 11%, transparent);
}
.data-table tbody tr.is-anomaly-warn:hover {
background: color-mix(in srgb, var(--metric-warn) 18%, transparent);
}
.data-table tbody tr.is-anomaly-warn td:first-child {
box-shadow: inset 2px 0 0 var(--metric-warn);
}
.data-table tbody tr.is-anomaly-warn td:first-child > span:not(.agent-badge):not(.turn-rail) {
color: var(--metric-warn);
font-weight: 600;
}
.data-table tbody tr.is-anomaly-danger {
background: color-mix(in srgb, var(--metric-danger) 13%, transparent);
}
.data-table tbody tr.is-anomaly-danger:hover {
background: color-mix(in srgb, var(--metric-danger) 20%, transparent);
}
.data-table tbody tr.is-anomaly-danger td:first-child {
box-shadow: inset 2px 0 0 var(--metric-danger);
}
.data-table tbody tr.is-anomaly-danger td:first-child > span:not(.agent-badge):not(.turn-rail) {
color: var(--metric-danger);
font-weight: 600;
}
.step-anomaly-tag {
display: inline-flex;
align-items: center;
vertical-align: middle;
margin-left: 4px;
padding: 0 3.5px;
font-size: var(--fs-2xs);
font-weight: 600;
line-height: 1.35;
border-radius: 3px;
color: var(--metric-warn);
background: var(--metric-warn-soft);
border: 1px solid color-mix(in srgb, var(--metric-warn) 34%, transparent);
cursor: help;
white-space: nowrap;
flex-shrink: 0;
}
.step-anomaly-tag.is-danger {
color: var(--metric-danger);
background: var(--metric-danger-soft);
border-color: color-mix(in srgb, var(--metric-danger) 36%, transparent);
}
.step-anomaly-tag[hidden] {
display: none !important;
}
.smodel-anomaly-tag {
margin-left: 0;
cursor: pointer;
font-family: inherit;
transition:
background-color var(--dur-instant) var(--ease-fast),
border-color var(--dur-instant) var(--ease-fast);
}
.smodel-anomaly-tag:hover {
background: color-mix(in srgb, var(--metric-warn) 22%, transparent);
}
.smodel-anomaly-tag.is-danger:hover {
background: color-mix(in srgb, var(--metric-danger) 22%, transparent);
}
.step-anomaly-tip {
position: absolute;
z-index: 46;
max-width: min(300px, calc(100% - 16px));
min-width: 176px;
padding: 7px 9px;
display: flex;
flex-direction: column;
gap: 5px;
font-size: var(--fs-sm);
line-height: 1.38;
color: var(--text-primary);
background: var(--surface-panel);
border: 1px solid color-mix(in srgb, var(--metric-warn) 42%, var(--border-strong));
border-radius: var(--radius-xs);
box-shadow: var(--shadow-popover);
pointer-events: none;
animation: anim-popover-in var(--dur-instant) var(--ease-fast);
}
.step-anomaly-tip.is-danger {
border-color: color-mix(in srgb, var(--metric-danger) 46%, var(--border-strong));
}
.step-anomaly-tip[hidden],
.step-anomaly-tip-sub[hidden],
.step-anomaly-tip-list[hidden],
.step-anomaly-tip-hint[hidden] {
display: none !important;
}
.step-anomaly-tip-head {
display: flex;
align-items: baseline;
justify-content: space-between;
gap: 8px;
}
.step-anomaly-tip-title {
font-weight: 600;
color: var(--metric-warn);
white-space: nowrap;
}
.step-anomaly-tip.is-danger .step-anomaly-tip-title {
color: var(--metric-danger);
}
.step-anomaly-tip-sub {
font-size: var(--fs-xs);
color: var(--text-secondary);
white-space: nowrap;
}
.step-anomaly-tip-list {
display: flex;
flex-direction: column;
gap: 4px;
padding-top: 4px;
border-top: 1px solid var(--border-hairline);
}
.step-anomaly-tip-item {
display: flex;
flex-direction: column;
gap: 1px;
}
.step-anomaly-tip-row {
font-size: var(--fs-xs);
font-weight: 500;
color: var(--text-primary);
}
.step-anomaly-tip-row.is-danger {
color: var(--metric-danger);
}
.step-anomaly-tip-detail {
font-size: var(--fs-2xs);
line-height: 1.35;
color: var(--text-muted);
word-break: break-word;
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: 2;
overflow: hidden;
}
.step-anomaly-tip-hint {
font-size: var(--fs-2xs);
color: var(--text-muted);
padding-top: 3px;
border-top: 1px solid var(--border-hairline);
}
.steps-anomaly-filterbar {
display: flex;
align-items: center;
justify-content: space-between;
gap: 8px;
padding: 4px 8px;
border-top: 1px solid var(--border-hairline);
background: color-mix(in srgb, var(--metric-warn) 8%, var(--surface-panel));
font-size: var(--fs-xs);
}
.steps-anomaly-filterbar[hidden] {
display: none !important;
}
.steps-anomaly-filter-label {
font-weight: 600;
color: var(--metric-warn);
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.steps-anomaly-filter-clear {
flex-shrink: 0;
padding: 1px 7px;
font-size: var(--fs-xs);
}
.steps-anomaly-strip {
display: flex;
align-items: center;
flex-wrap: wrap;
gap: 4px 6px;
padding: 4px 8px;
border: 1px solid color-mix(in srgb, var(--metric-warn) 26%, var(--border-hairline));
border-radius: var(--radius-xs);
background: color-mix(in srgb, var(--metric-warn) 7%, var(--surface-panel));
}
.steps-anomaly-strip[hidden] {
display: none !important;
}
.steps-anomaly-strip-meta {
border: none;
background: transparent;
padding: 0;
font-size: var(--fs-xs);
font-weight: 600;
color: var(--metric-warn);
cursor: pointer;
white-space: nowrap;
}
.steps-anomaly-strip-meta:hover {
text-decoration: underline;
}
.steps-anomaly-strip-tags {
display: inline-flex;
align-items: center;
flex-wrap: wrap;
gap: 4px;
}
/* --- 3. 按模型汇总分析视图:双趋势图与极简模型总览 (Models Analytics Pane) --- */
.models-analytics-pane {
display: flex;
@@ -517,6 +759,47 @@
pointer-events: none;
}
.sstep-hover-raw-dot.is-anomaly {
stroke: var(--metric-warn);
stroke-width: 1.85;
}
.sstep-hover-raw-dot.is-danger {
stroke: var(--metric-danger);
}
.sstep-anomaly-dot,
.sstep-scatter-dot.is-anomaly {
fill: var(--surface-panel);
fill-opacity: 1;
stroke: var(--metric-warn);
stroke-width: 1.6;
pointer-events: none;
}
.sstep-anomaly-dot.is-danger,
.sstep-scatter-dot.is-anomaly.is-danger {
stroke: var(--metric-danger);
}
.trend-tip-anomaly {
margin-top: 3px;
padding-top: 3px;
border-top: 1px solid var(--border-hairline);
font-size: var(--fs-xs);
font-weight: 600;
color: var(--metric-warn);
white-space: nowrap;
}
.trend-tip-anomaly.is-danger {
color: var(--metric-danger);
}
.trend-tip-anomaly[hidden] {
display: none !important;
}
.sstep-empty-hint {
position: absolute;
inset: 0;
+259 -5
View File
@@ -14,12 +14,17 @@ import {
patchText,
} from '../core/domPatch.js';
import {
buildModelAnomalyDiagnostic,
formatAnomalyKindLabel,
formatAnomalyTagText,
formatMetric,
formatSpeedMetric,
formatTokens,
formatUsd,
mergeModelsByDisplayName,
normalizeModelDisplayMode,
normalizeOrchestratorIdDisplayMode,
resolveModelAnomalySummary,
resolveModelDisplayInfo,
} from '../core/formatters.js';
import { createSvgIcon } from '../icons/SvgIcon.js';
@@ -77,6 +82,11 @@ function mergeSelectedAgentUnits(units) {
totalTokens: 0,
costUsd: 0,
unpricedCalls: 0,
anomalySteps: 0,
anomalyCount: 0,
anomalyDangerCount: 0,
anomalyTotalDelaySec: 0,
anomalyByKind: {},
_speedWeightedSum: 0,
_speedWeight: 0,
_ttftWeightedSum: 0,
@@ -116,6 +126,16 @@ function mergeSelectedAgentUnits(units) {
acc.totalTokens += totTok;
acc.costUsd += costUsd;
acc.unpricedCalls += unpricedCalls;
acc.anomalySteps += Math.max(0, Number(m.anomalySteps || 0));
acc.anomalyCount += Math.max(0, Number(m.anomalyCount || 0));
acc.anomalyDangerCount += Math.max(0, Number(m.anomalyDangerCount || 0));
acc.anomalyTotalDelaySec += Math.max(0, Number(m.anomalyTotalDelaySec || 0));
if (m.anomalyByKind && typeof m.anomalyByKind === 'object') {
for (const [kind, cnt] of Object.entries(m.anomalyByKind)) {
const n = Math.max(0, Number(cnt || 0));
if (n > 0) acc.anomalyByKind[kind] = (acc.anomalyByKind[kind] || 0) + n;
}
}
if (Number.isFinite(Number(m.avgTokPerSec)) && Number(m.avgTokPerSec) > 0) {
const w = Math.max(1, outTok || calls || 1);
@@ -164,6 +184,15 @@ function mergeSelectedAgentUnits(units) {
avgTtftSec:
acc._ttftWeight > 0 ? +(acc._ttftWeightedSum / acc._ttftWeight).toFixed(1) : null,
cacheHitPct: promptTok > 0 ? +((acc.cacheReadTokens / promptTok) * 100).toFixed(1) : 0,
...(acc.anomalyCount > 0
? {
anomalySteps: acc.anomalySteps,
anomalyCount: acc.anomalyCount,
anomalyDangerCount: acc.anomalyDangerCount,
anomalyTotalDelaySec: +acc.anomalyTotalDelaySec.toFixed(1),
anomalyByKind: acc.anomalyByKind,
}
: {}),
};
})
.sort((a, b) => b.totalTokens - a.totalTokens || b.calls - a.calls);
@@ -197,6 +226,8 @@ export const StepsDetailView = defineComponent({
let lastSyncedUiScope = uiStore.getState().selectedAgentScope || 'all';
let selectedTableModels = ['__all__'];
let selectedLineModels = ['__all__'];
let onlyAnomalies = false;
let anomalyKindFilter = '';
function applyAgentScopesSelection(nextScopes) {
selectedAgentScopes = nextScopes;
@@ -271,7 +302,10 @@ export const StepsDetailView = defineComponent({
stepsTheadRow,
stepsTbody,
turnTipEl,
anomalyTipEl,
hideTurnTip,
showAnomalyTip,
hideAnomalyTip,
syncTableHeaderColumns,
renderStepTable,
refreshViewport: refreshStepTableViewport,
@@ -281,6 +315,23 @@ export const StepsDetailView = defineComponent({
className: 'table-scroll-host',
});
const anomalyFilterLabelEl = h('span', { className: 'steps-anomaly-filter-label text-mono' });
const anomalyFilterClearBtn = h('button', {
type: 'button',
className: 'btn-ghost-sm steps-anomaly-filter-clear',
text: t('steps.anomalyFilterAll'),
onclick: () => {
onlyAnomalies = false;
anomalyKindFilter = '';
if (latestSlice) renderStepsData(latestSlice);
},
});
const anomalyFilterBarEl = h(
'div',
{ className: 'steps-anomaly-filterbar', hidden: true },
[anomalyFilterLabelEl, anomalyFilterClearBtn]
);
// --- 子视图 2:总汇总分析面板 ---
let selectedLineMetric = 'totalTokens';
let selectedFitMetric = 'tps';
@@ -383,6 +434,24 @@ export const StepsDetailView = defineComponent({
className: 'cons-badge text-mono',
text: t('cons.callsCount', { calls: 0 }),
});
const modelsAnomalyMetaEl = h('button', {
type: 'button',
className: 'steps-anomaly-strip-meta text-mono',
onclick: () => {
hideAnomalyTip();
selectedTableModels = ['__all__'];
onlyAnomalies = true;
anomalyKindFilter = '';
uiStore.setState({ stepsSubTab: 'steps' });
},
});
const modelsAnomalyTagsEl = h('div', { className: 'steps-anomaly-strip-tags' });
const modelsAnomalyStripEl = h(
'div',
{ className: 'steps-anomaly-strip', hidden: true },
[modelsAnomalyMetaEl, modelsAnomalyTagsEl]
);
let lastAnomalyStripSig = '';
const modelsEmptyEl = h('div', {
className: 'smodel-empty text-muted',
text: t('steps.modelsEmpty'),
@@ -390,6 +459,7 @@ export const StepsDetailView = defineComponent({
const modelsListEl = h('div', { className: 'smodel-list' });
const modelsSummarySection = h('div', { className: 'smodel-section' }, [
h('div', { className: 'smodel-section-head' }, [modelsSectionTitleEl, modelsSummaryMeta]),
modelsAnomalyStripEl,
modelsEmptyEl,
modelsListEl,
]);
@@ -399,6 +469,8 @@ export const StepsDetailView = defineComponent({
modelFitCard,
modelsSummarySection,
]);
const onModelsPaneScroll = () => hideAnomalyTip();
modelsAnalyticsPane.addEventListener('scroll', onModelsPaneScroll, { passive: true });
const modelsScroll = CustomScrollbar({
contentEl: modelsAnalyticsPane,
className: 'table-scroll-host',
@@ -424,9 +496,11 @@ export const StepsDetailView = defineComponent({
subTabSwitch.el,
]),
]),
anomalyFilterBarEl,
stepsScroll.el,
modelsScroll.el,
turnTipEl,
anomalyTipEl,
]
);
stepTableWidget.refs.setBoundsElGetter(() => panelEl);
@@ -497,6 +571,8 @@ export const StepsDetailView = defineComponent({
patchText(fitTitleEl, t('steps.fitTitle'));
patchText(modelsSectionTitleEl, t('steps.modelsTitle'));
patchText(modelsEmptyEl, t('steps.modelsEmpty'));
patchText(anomalyFilterClearBtn, t('steps.anomalyFilterAll'));
lastAnomalyStripSig = '';
lineMetricSwitch.setProps({
modelValue: selectedLineMetric,
options: getLineMetricSwitchOptions(),
@@ -530,6 +606,8 @@ export const StepsDetailView = defineComponent({
lastSyncedUiScope = uiSt.selectedAgentScope || 'all';
selectedTableModels = ['__all__'];
selectedLineModels = ['__all__'];
onlyAnomalies = false;
anomalyKindFilter = '';
}
fitLockedCascadeId = currentCid;
fitUserPicked = false;
@@ -723,9 +801,29 @@ export const StepsDetailView = defineComponent({
const tableModelFilterSet = selectedTableModels.includes('__all__')
? null
: new Set(selectedTableModels);
const tableSteps = tableModelFilterSet
const modelFilteredSteps = tableModelFilterSet
? steps.filter((st) => tableModelFilterSet.has(getStepModelGroupKey(st)))
: steps;
const tableSteps = onlyAnomalies
? modelFilteredSteps.filter((st) => {
const a = st?.anomaly;
if (!a || !(Number(a.count) > 0)) return false;
if (anomalyKindFilter) {
return Number(a.kinds?.[anomalyKindFilter] || 0) > 0;
}
return true;
})
: modelFilteredSteps;
const showAnomalyFilterBar = !showModels && onlyAnomalies;
patchAttr(anomalyFilterBarEl, 'hidden', !showAnomalyFilterBar);
if (showAnomalyFilterBar) {
const baseLabel = t('steps.anomalyFilterLabel', { count: tableSteps.length });
const kindSuffix = anomalyKindFilter
? ` · ${formatAnomalyKindLabel(anomalyKindFilter)}`
: '';
patchText(anomalyFilterLabelEl, `${baseLabel}${kindSuffix}`);
}
const stepsTabLabel =
tableSteps.length !== steps.length
@@ -863,10 +961,79 @@ export const StepsDetailView = defineComponent({
// 4. 极简模型总览列表增量对账
const displayModels = mergeModelsByDisplayName(models, displaySettings, { fallback: '—' });
const needStepAnomalyFallback = displayModels.every((m) => !(Number(m?.anomalyCount) > 0));
let stepAnomalyByGroup = null;
if (needStepAnomalyFallback) {
for (const st of chronoSteps) {
const a = st?.anomaly;
if (!a || !(Number(a.count) > 0)) continue;
if (!stepAnomalyByGroup) stepAnomalyByGroup = new Map();
const gk = getStepModelGroupKey(st);
let acc = stepAnomalyByGroup.get(gk);
if (!acc) {
acc = {
anomalySteps: 0,
anomalyCount: 0,
anomalyDangerCount: 0,
anomalyTotalDelaySec: 0,
anomalyByKind: {},
};
stepAnomalyByGroup.set(gk, acc);
}
acc.anomalySteps += 1;
acc.anomalyCount += Number(a.count) || 0;
if (a.severity === 'danger') acc.anomalyDangerCount += 1;
acc.anomalyTotalDelaySec += Number(a.totalDelaySec) || 0;
if (a.kinds && typeof a.kinds === 'object') {
for (const [k, cnt] of Object.entries(a.kinds)) {
const n = Math.max(0, Number(cnt || 0));
if (n > 0) acc.anomalyByKind[k] = (acc.anomalyByKind[k] || 0) + n;
}
}
}
}
const resolveEffectiveAnomalyModel = (m) => {
if (Number(m?.anomalyCount) > 0 || !stepAnomalyByGroup) return m;
const gk = getStepModelGroupKey(m);
const groupKeys =
Array.isArray(m.sourceLabels) && m.sourceLabels.length > 0
? Array.from(new Set(m.sourceLabels.map((lbl) => getStepModelGroupKey({ label: lbl }))))
: [gk];
let anomalySteps = 0;
let anomalyCount = 0;
let anomalyDangerCount = 0;
let anomalyTotalDelaySec = 0;
const anomalyByKind = {};
for (const key of groupKeys) {
const hit = stepAnomalyByGroup.get(key);
if (!hit) continue;
anomalySteps += hit.anomalySteps;
anomalyCount += hit.anomalyCount;
anomalyDangerCount += hit.anomalyDangerCount;
anomalyTotalDelaySec += hit.anomalyTotalDelaySec;
for (const [k, cnt] of Object.entries(hit.anomalyByKind)) {
anomalyByKind[k] = (anomalyByKind[k] || 0) + cnt;
}
}
if (anomalyCount <= 0) return m;
return {
...m,
anomalySteps,
anomalyCount,
anomalyDangerCount,
anomalyTotalDelaySec: +anomalyTotalDelaySec.toFixed(1),
anomalyByKind,
};
};
let sumCalls = 0;
let sumTokens = 0;
let sumCost = 0;
let sumUnpriced = 0;
let sumAnomalyCount = 0;
let sumAnomalySteps = 0;
const sumAnomalyByKind = {};
const effectiveAnomalyModels = new Map();
for (const m of displayModels) {
sumCalls += Math.max(0, Number(m.calls || 0));
sumTokens += Math.max(0, Number(m.totalTokens || 0));
@@ -874,6 +1041,54 @@ export const StepsDetailView = defineComponent({
if (Number.isFinite(Number(m.costUsd))) {
sumCost += Math.max(0, Number(m.costUsd));
}
const effM = resolveEffectiveAnomalyModel(m);
effectiveAnomalyModels.set(m, effM);
const anomSum = resolveModelAnomalySummary(effM);
if (anomSum) {
sumAnomalyCount += anomSum.count;
sumAnomalySteps += anomSum.steps;
for (const [k, v] of anomSum.entries) {
sumAnomalyByKind[k] = (sumAnomalyByKind[k] || 0) + v;
}
}
}
if (sumAnomalyCount > 0) {
patchAttr(modelsAnomalyStripEl, 'hidden', false);
const sortedKinds = Object.entries(sumAnomalyByKind)
.filter(([, v]) => v > 0)
.sort((a, b) => b[1] - a[1]);
const stripSig = `${locale}:${sumAnomalyCount}:${sumAnomalySteps}:${sortedKinds.map(([k, v]) => `${k}=${v}`).join(',')}`;
if (stripSig !== lastAnomalyStripSig) {
lastAnomalyStripSig = stripSig;
patchText(
modelsAnomalyMetaEl,
t('steps.anomalySummaryMeta', { count: sumAnomalyCount, steps: sumAnomalySteps })
);
while (modelsAnomalyTagsEl.firstChild) {
modelsAnomalyTagsEl.removeChild(modelsAnomalyTagsEl.firstChild);
}
for (const [kind, cnt] of sortedKinds) {
const isDanger = kind === 'rate_limit' || kind === 'auth_or_model';
const btn = h('button', {
type: 'button',
className: `step-anomaly-tag smodel-anomaly-tag text-mono${isDanger ? ' is-danger' : ''}`,
text: formatAnomalyTagText(kind, cnt),
title: `${formatAnomalyKindLabel(kind)} · ${t('steps.anomalyModelClickHint')}`,
onclick: () => {
hideAnomalyTip();
selectedTableModels = ['__all__'];
onlyAnomalies = true;
anomalyKindFilter = kind;
uiStore.setState({ stepsSubTab: 'steps' });
},
});
modelsAnomalyTagsEl.appendChild(btn);
}
}
} else {
lastAnomalyStripSig = '';
patchAttr(modelsAnomalyStripEl, 'hidden', true);
}
if (displayModels.length === 0) {
@@ -917,11 +1132,20 @@ export const StepsDetailView = defineComponent({
: [gk];
const isActiveFit =
hasMultipleModels && cardGroupKeys.some((k) => fitActiveKeySet.has(k));
return `${locale}:${m.displayText}:${m.displayTitle}:${m.calls}:${sumCalls}:${displayModels.length}:${m.avgTokPerSec}:${avgTtft}:${m.cacheHitPct}:${m.inputTokens}:${m.cacheReadTokens}:${m.thinkingTokens}:${m.responseTokens}:${m.totalTokens}:${m.costUsd}:${m.unpricedCalls}:${isActiveFit}:${hasMultipleModels}`;
const effM = effectiveAnomalyModels.get(m) || m;
const anomSum = resolveModelAnomalySummary(effM);
const anomSig = anomSum
? `${anomSum.count}:${anomSum.steps}:${anomSum.primaryKind}:${anomSum.severity}:${anomSum.totalDelaySec}`
: '';
return `${locale}:${m.displayText}:${m.displayTitle}:${m.calls}:${sumCalls}:${displayModels.length}:${m.avgTokPerSec}:${avgTtft}:${m.cacheHitPct}:${m.inputTokens}:${m.cacheReadTokens}:${m.thinkingTokens}:${m.responseTokens}:${m.totalTokens}:${m.costUsd}:${m.unpricedCalls}:${isActiveFit}:${hasMultipleModels}:${anomSig}`;
},
createRow: () => {
const nameEl = h('strong', { className: 'smodel-name' });
const callsPillEl = h('span', { className: 'smodel-calls-pill text-mono' });
const anomalyTagEl = h('span', {
className: 'step-anomaly-tag smodel-anomaly-tag text-mono',
hidden: true,
});
const tokEl = h('span', { className: 'smodel-tok text-mono' });
const costEl = h('strong', { className: 'smodel-cost text-mono' });
const segBar = createFourSegmentBar();
@@ -932,7 +1156,7 @@ export const StepsDetailView = defineComponent({
const cardEl = h('div', { className: 'smodel-card' }, [
h('div', { className: 'smodel-head' }, [
h('div', { className: 'smodel-ident' }, [nameEl, callsPillEl]),
h('div', { className: 'smodel-ident' }, [nameEl, callsPillEl, anomalyTagEl]),
h('div', { className: 'smodel-totals' }, [tokEl, costEl]),
]),
segBar.el,
@@ -941,7 +1165,7 @@ export const StepsDetailView = defineComponent({
return {
el: cardEl,
refs: { nameEl, callsPillEl, tokEl, costEl, segBar, perfEl, splitEl },
refs: { nameEl, callsPillEl, anomalyTagEl, tokEl, costEl, segBar, perfEl, splitEl },
};
},
updateRow: (refs, m, _idx, cardEl) => {
@@ -966,6 +1190,29 @@ export const StepsDetailView = defineComponent({
: t('steps.modelCallsOnly', { calls })
);
const effM = effectiveAnomalyModels.get(m) || m;
const anomSum = resolveModelAnomalySummary(effM);
patchAttr(refs.anomalyTagEl, 'hidden', !anomSum);
if (anomSum) {
patchText(refs.anomalyTagEl, anomSum.tagText);
patchClasses(refs.anomalyTagEl, { 'is-danger': anomSum.severity === 'danger' });
refs.anomalyTagEl.onmouseenter = () =>
showAnomalyTip(refs.anomalyTagEl, buildModelAnomalyDiagnostic(effM));
refs.anomalyTagEl.onmouseleave = hideAnomalyTip;
refs.anomalyTagEl.onclick = (e) => {
e?.stopPropagation?.();
hideAnomalyTip();
selectedTableModels = hasMultipleModels ? [...cardGroupKeys] : ['__all__'];
onlyAnomalies = true;
anomalyKindFilter = '';
uiStore.setState({ stepsSubTab: 'steps' });
};
} else {
refs.anomalyTagEl.onmouseenter = null;
refs.anomalyTagEl.onmouseleave = null;
refs.anomalyTagEl.onclick = null;
}
const inTok = Math.max(0, Number(m.inputTokens || 0));
const cacheTok = Math.max(0, Number(m.cacheReadTokens || 0));
const outTok = Math.max(0, Number(m.outputTokens || 0));
@@ -1009,7 +1256,7 @@ export const StepsDetailView = defineComponent({
patchText(
refs.perfEl,
t('steps.modelPerfFoot', {
tps: formatMetric(m.avgTokPerSec, ' tok/s'),
tps: formatSpeedMetric(m.avgTokPerSec, ' tok/s'),
ttft: formatMetric(resolvedAvgTtft, 's'),
cache: resolvedCachePct,
})
@@ -1070,7 +1317,9 @@ export const StepsDetailView = defineComponent({
(st) => st.stepsSubTab,
(tab) => {
hideTurnTip();
hideAnomalyTip();
subTabSwitch.setValue(tab);
patchAttr(anomalyFilterBarEl, 'hidden', tab !== 'steps' || !onlyAnomalies);
patchAttr(stepsScroll.el, 'hidden', tab !== 'steps');
patchAttr(modelsScroll.el, 'hidden', tab !== 'models');
if (getVisibleMonitorView() === 'steps' && latestSlice) {
@@ -1142,6 +1391,7 @@ export const StepsDetailView = defineComponent({
prevActiveView = uiSlice.activeView;
if (uiSlice.activeView !== 'steps') {
hideTurnTip();
hideAnomalyTip();
fitPinnedWhileVisible = false;
if (scopeChanged) isDirty = true;
return;
@@ -1166,6 +1416,7 @@ export const StepsDetailView = defineComponent({
);
onCleanup(() => {
modelsAnalyticsPane.removeEventListener('scroll', onModelsPaneScroll);
unsubUi();
unsubTelemetry();
unsubView();
@@ -1191,6 +1442,9 @@ export const StepsDetailView = defineComponent({
stepsTheadRow,
stepsTbody,
turnTipEl,
anomalyTipEl,
anomalyFilterBarEl,
modelsAnomalyStripEl,
modelsListEl,
inlineScopeSelect,
stepsModelSelect,