mirror of
https://github.com/lWolvesl/antigravity-usage-monitor.git
synced 2026-11-26 17:09:28 +08:00
feat(panel): add step anomaly diagnostics, >=100 tok/s integer speed formatting, and capsule alignment fix
This commit is contained in:
@@ -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,
|
||||
},
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user