fix(panel): resolve P0 step inspector, V4 timing projection, harmonic speed merge, and UI cleanup bugs

This commit is contained in:
fish
2026-11-23 16:21:39 +09:00
parent c38869f8bd
commit 3a40bacc9d
17 changed files with 958 additions and 140 deletions
@@ -2921,6 +2921,9 @@ export function mountWindowOverlay() {
window.removeEventListener?.('popstate', onPopState);
navigator?.windowControlsOverlay?.removeEventListener?.('geometrychange', onWindowResize);
restorePatchedActionToolbar();
try {
multiRunningWidget.destroy();
} catch {}
try {
hoverWidgetHost.destroy();
} catch {}
@@ -577,7 +577,7 @@ export const SessionMigrationCard = defineComponent({
}
}
listScrollbar?.methods?.refresh?.();
listScrollbar?.refresh?.();
patchAttr(migrateBtn, 'disabled', isMigrating || selectedIds.size === 0 || !targetClient);
patchText(
@@ -14,9 +14,18 @@ import {
positionAnchoredPopup,
} from '../../core/domPatch.js';
import { formatCompactDateTime } from '../../core/formatters.js';
import { i18nStore, t } from '../../i18n/index.js';
import { createSvgIcon } from '../../icons/SvgIcon.js';
const WEEKDAYS = ['一', '二', '三', '四', '五', '六', '日'];
const WEEKDAY_KEYS = [
'ui.dt.wdayMon',
'ui.dt.wdayTue',
'ui.dt.wdayWed',
'ui.dt.wdayThu',
'ui.dt.wdayFri',
'ui.dt.wdaySat',
'ui.dt.wdaySun',
];
function buildCalendarDays(viewYear, viewMonth, selectedDate) {
const firstDay = new Date(viewYear, viewMonth, 1);
@@ -77,7 +86,7 @@ export const CustomDateTimePicker = defineComponent({
{
type: 'button',
className: 'icon-btn',
'aria-label': '上个月',
'aria-label': t('ui.dt.prevMonth'),
onClick: (e) => {
e.stopPropagation();
viewMonth -= 1;
@@ -96,7 +105,7 @@ export const CustomDateTimePicker = defineComponent({
{
type: 'button',
className: 'icon-btn',
'aria-label': '下个月',
'aria-label': t('ui.dt.nextMonth'),
onClick: (e) => {
e.stopPropagation();
viewMonth += 1;
@@ -112,11 +121,10 @@ export const CustomDateTimePicker = defineComponent({
const navBar = h('div', { className: 'dt-nav' }, [prevMonthBtn, monthTitle, nextMonthBtn]);
const weekdayRow = h(
'div',
{ className: 'dt-weekdays' },
WEEKDAYS.map((w) => h('span', { className: 'dt-weekday', text: w }))
const weekdaySpans = WEEKDAY_KEYS.map((key) =>
h('span', { className: 'dt-weekday', text: t(key) })
);
const weekdayRow = h('div', { className: 'dt-weekdays' }, weekdaySpans);
const daysGrid = h('div', { className: 'dt-days' });
@@ -136,8 +144,9 @@ export const CustomDateTimePicker = defineComponent({
emit('update:modelValue', nextMs);
}
const hourMinLabelEl = h('span', { className: 'text-muted', text: t('ui.dt.hourMinute') });
const timeRow = h('div', { className: 'dt-time-row' }, [
h('span', { className: 'text-muted', text: '时 / 分' }),
hourMinLabelEl,
h('div', { className: 'dt-time-controls' }, [
h('div', { className: 'dt-mini-step' }, [
h('button', {
@@ -306,6 +315,25 @@ export const CustomDateTimePicker = defineComponent({
onCleanup(() => setRepositionListeners(false));
}
function syncI18nLabels() {
patchAttr(prevMonthBtn, 'aria-label', t('ui.dt.prevMonth'));
patchAttr(nextMonthBtn, 'aria-label', t('ui.dt.nextMonth'));
patchText(hourMinLabelEl, t('ui.dt.hourMinute'));
for (let i = 0; i < WEEKDAY_KEYS.length; i += 1) {
patchText(weekdaySpans[i], t(WEEKDAY_KEYS[i]));
}
}
const unsubI18n = i18nStore.subscribe(
(st) => st.locale,
() => {
syncI18nLabels();
syncDisplay();
},
{ immediate: false }
);
onCleanup(unsubI18n);
syncDisplay();
return {
@@ -6,11 +6,12 @@
import { defineComponent } from '../../core/component.js';
import { h, patchAttr } from '../../core/domPatch.js';
import { i18nStore, t } from '../../i18n/index.js';
import { createSvgIcon } from '../../icons/SvgIcon.js';
export const CustomNumberInput = defineComponent({
name: 'CustomNumberInput',
setup({ getProps, setProps, emit }) {
setup({ getProps, setProps, emit, onCleanup }) {
function clampValue(raw) {
const { min = -Infinity, max = Infinity, precision = 0 } = getProps();
const num = Number(raw);
@@ -37,7 +38,7 @@ export const CustomNumberInput = defineComponent({
{
type: 'button',
className: 'num-step-btn',
'aria-label': '减少数值',
'aria-label': t('ui.num.decrease'),
onClick: (e) => {
e.preventDefault();
applyStep(-1, e.shiftKey ? 10 : 1);
@@ -51,7 +52,7 @@ export const CustomNumberInput = defineComponent({
{
type: 'button',
className: 'num-step-btn',
'aria-label': '增加数值',
'aria-label': t('ui.num.increase'),
onClick: (e) => {
e.preventDefault();
applyStep(1, e.shiftKey ? 10 : 1);
@@ -115,6 +116,15 @@ export const CustomNumberInput = defineComponent({
}
const rootEl = h('div', { className: 'number-input' }, [decBtn, textField, incBtn]);
const unsubI18n = i18nStore.subscribe(
(st) => st.locale,
() => {
patchAttr(decBtn, 'aria-label', t('ui.num.decrease'));
patchAttr(incBtn, 'aria-label', t('ui.num.increase'));
},
{ immediate: false }
);
onCleanup(unsubI18n);
syncFieldDisplay();
return {
@@ -7,6 +7,7 @@
import { defineComponent } from '../../core/component.js';
import { h, patchAttr, patchClasses, patchStyleVar, patchText } from '../../core/domPatch.js';
import { i18nStore, t } from '../../i18n/index.js';
export const SegmentedControl = defineComponent({
name: 'SegmentedControl',
@@ -17,10 +18,18 @@ export const SegmentedControl = defineComponent({
{
className: 'segmented',
role: 'group',
'aria-label': getProps().ariaLabel || '分段切换器',
'aria-label': getProps().ariaLabel || t('ui.seg.defaultAria'),
},
[gliderEl]
);
const unsubI18n = i18nStore.subscribe(
(st) => st.locale,
() => {
patchAttr(rootEl, 'aria-label', getProps().ariaLabel || t('ui.seg.defaultAria'));
},
{ immediate: false }
);
onCleanup(unsubI18n);
const btnMap = new Map();
let orderedBtns = [];
@@ -21,6 +21,7 @@ import {
resolveModelDisplayInfo,
speedReasonText,
} from '../../core/formatters.js';
import { getStepSelectionKey } from '../../core/stepInspector.js';
import { getEffectiveLocale, t } from '../../i18n/index.js';
import { createSvgIcon, patchSvgIcon } from '../../icons/SvgIcon.js';
import {
@@ -722,9 +723,11 @@ export const StepTableWidget = defineComponent({
}
function getStepRowIdentity(st, fallbackCascadeId) {
const agentKey = String(st?.agentCascadeId || fallbackCascadeId || 'conv');
const agentKey = String(
st?.agentCascadeId || st?.agentId || st?.cascadeId || fallbackCascadeId || 'conv'
);
const stepNum = Number(st?.stepIndex);
const rowKey = `${agentKey}-${st?.stepIndex}`;
const rowKey = getStepSelectionKey(st, fallbackCascadeId);
return { agentKey, stepNum, rowKey };
}
@@ -1100,7 +1103,7 @@ export const StepTableWidget = defineComponent({
logicalIdx: idx,
isStripeEven: (idx & 1) === 1,
hasReason: Boolean(hasReasonFlags && hasReasonFlags[idx]),
rowKey: `${st.agentCascadeId || cascadeId || 'conv'}-${st.stepIndex}`,
rowKey: getStepSelectionKey(st, cascadeId),
hasTurn,
hasUp,
hasDown,
+48 -7
View File
@@ -829,14 +829,30 @@ export function mergeModelsByDisplayName(models = [], settings = {}, options = {
const speedSampleCount = Math.max(0, Number(m.speedSummary?.sampleCount || 0));
const speedExcludedCount = Math.max(0, Number(m.speedSummary?.excludedCount || 0));
const speedWeight = speedSampleCount > 0 ? speedSampleCount : Math.max(1, outTok || calls || 1);
const hasSpeed = m.avgTokPerSec != null && Number.isFinite(Number(m.avgTokPerSec)) && Number(m.avgTokPerSec) > 0;
const hasSpeed =
m.avgTokPerSec != null && Number.isFinite(Number(m.avgTokPerSec)) && Number(m.avgTokPerSec) > 0;
const rawSpeedTokens = Number(m.speedSummary?.tokens);
const rawSpeedSeconds = Number(m.speedSummary?.seconds);
const hasExactSpeedSummary =
Number.isFinite(rawSpeedTokens) &&
Number.isFinite(rawSpeedSeconds) &&
rawSpeedSeconds > 0 &&
rawSpeedTokens >= 0;
const ttftSampleCount = Math.max(0, Number(m.ttftSampleCount || 0));
const ttftWeight = ttftSampleCount > 0 ? ttftSampleCount : Math.max(1, calls || 1);
const hasTtft = m.avgTtftSec != null && Number.isFinite(Number(m.avgTtftSec)) && Number(m.avgTtftSec) >= 0;
const hasTtft =
m.avgTtftSec != null && Number.isFinite(Number(m.avgTtftSec)) && Number(m.avgTtftSec) >= 0;
let acc = byDisplay.get(key);
if (!acc) {
const initExcludedReasons = {};
if (m.speedSummary?.excludedReasons && typeof m.speedSummary.excludedReasons === 'object') {
for (const [rk, rv] of Object.entries(m.speedSummary.excludedReasons)) {
const cnt = Math.max(0, Number(rv || 0));
if (cnt > 0) initExcludedReasons[rk] = cnt;
}
}
acc = {
baseItem: m,
mergedCount: 1,
@@ -856,10 +872,15 @@ export function mergeModelsByDisplayName(models = [], settings = {}, options = {
totalTokens: totTok,
costUsd,
unpricedCalls,
hasAnySpeedSummary: Boolean(m.speedSummary),
allSpeedExact: !hasSpeed || hasExactSpeedSummary,
speedTokens: hasExactSpeedSummary ? rawSpeedTokens : 0,
speedSeconds: hasExactSpeedSummary ? rawSpeedSeconds : 0,
speedWeightedSum: hasSpeed ? Number(m.avgTokPerSec) * speedWeight : 0,
speedWeight: hasSpeed ? speedWeight : 0,
speedSampleCount,
speedExcludedCount,
speedExcludedReasons: initExcludedReasons,
ttftWeightedSum: hasTtft ? Number(m.avgTtftSec) * ttftWeight : 0,
ttftWeight: hasTtft ? ttftWeight : 0,
ttftSampleCount,
@@ -908,12 +929,24 @@ export function mergeModelsByDisplayName(models = [], settings = {}, options = {
}
}
if (m.speedSummary) acc.hasAnySpeedSummary = true;
if (hasSpeed && !hasExactSpeedSummary) acc.allSpeedExact = false;
if (hasExactSpeedSummary) {
acc.speedTokens += rawSpeedTokens;
acc.speedSeconds += rawSpeedSeconds;
}
if (hasSpeed) {
acc.speedWeightedSum += Number(m.avgTokPerSec) * speedWeight;
acc.speedWeight += speedWeight;
}
acc.speedSampleCount += speedSampleCount;
acc.speedExcludedCount += speedExcludedCount;
if (m.speedSummary?.excludedReasons && typeof m.speedSummary.excludedReasons === 'object') {
for (const [rk, rv] of Object.entries(m.speedSummary.excludedReasons)) {
const cnt = Math.max(0, Number(rv || 0));
if (cnt > 0) acc.speedExcludedReasons[rk] = (acc.speedExcludedReasons[rk] || 0) + cnt;
}
}
if (hasTtft) {
acc.ttftWeightedSum += Number(m.avgTtftSec) * ttftWeight;
@@ -933,8 +966,13 @@ export function mergeModelsByDisplayName(models = [], settings = {}, options = {
}
const promptTok = acc.inputTokens + acc.cacheReadTokens;
const cacheHitPct = promptTok > 0 ? +((acc.cacheReadTokens / promptTok) * 100).toFixed(1) : 0;
const avgTokPerSec =
acc.speedWeight > 0 ? +(acc.speedWeightedSum / acc.speedWeight).toFixed(1) : null;
const rawAvgTps =
acc.allSpeedExact && acc.speedSeconds > 0
? acc.speedTokens / acc.speedSeconds
: acc.speedWeight > 0
? acc.speedWeightedSum / acc.speedWeight
: null;
const avgTokPerSec = rawAvgTps !== null ? +rawAvgTps.toFixed(1) : null;
const avgTtftSec =
acc.ttftWeight > 0 ? +(acc.ttftWeightedSum / acc.ttftWeight).toFixed(1) : null;
const upstreamModels = Array.from(acc.upstreamSet);
@@ -967,12 +1005,15 @@ export function mergeModelsByDisplayName(models = [], settings = {}, options = {
anomalyByKind: acc.anomalyByKind,
}
: {}),
speedSummary: acc.baseItem.speedSummary
speedSummary: acc.hasAnySpeedSummary
? {
...acc.baseItem.speedSummary,
...(acc.baseItem.speedSummary || {}),
tokens: acc.speedTokens,
seconds: +acc.speedSeconds.toFixed(6),
sampleCount: acc.speedSampleCount,
excludedCount: acc.speedExcludedCount,
avgTokPerSec,
excludedReasons: acc.speedExcludedReasons,
avgTokPerSec: rawAvgTps,
}
: undefined,
upstreamModels,
+54 -25
View File
@@ -172,7 +172,8 @@ function summarizeStepsForExport(list, displaySettings) {
let sumCost = 0;
let sumDuration = 0;
let maxContext = 0;
let tpsSum = 0;
let tpsTokSum = 0;
let tpsSecSum = 0;
let tpsCnt = 0;
let ttftSum = 0;
let ttftCnt = 0;
@@ -194,7 +195,8 @@ function summarizeStepsForExport(list, displaySettings) {
: Math.max(0, outTok - thinkTok);
const ctxTok = Math.max(0, Number(st.contextTokens || inTok + cacheTok + outTok));
const cost = Number(st.costUsd || 0);
const dur = Number(st.durationSec || 0);
const rawDur = st.totalDurationSec ?? st.durationSec;
const dur = rawDur != null && Number.isFinite(Number(rawDur)) ? Number(rawDur) : 0;
sumIn += inTok;
sumCache += cacheTok;
@@ -206,11 +208,21 @@ function summarizeStepsForExport(list, displaySettings) {
if (Number.isFinite(dur) && dur > 0) sumDuration += dur;
const validTps =
!st.isCompactionStep && Number.isFinite(Number(st.tokPerSec)) && Number(st.tokPerSec) > 0;
!st.isCompactionStep &&
outTok >= 50 &&
!st.selectedSpeedReason &&
Number.isFinite(Number(st.tokPerSec)) &&
Number(st.tokPerSec) > 0;
const stepSpeedSec = validTps
? st.totalDurationSec != null && Number(st.totalDurationSec) >= 0.5
? Number(st.totalDurationSec)
: outTok / Number(st.tokPerSec)
: 0;
const validTtft =
!st.isCompactionStep && Number.isFinite(Number(st.ttftSec)) && Number(st.ttftSec) >= 0;
if (validTps) {
tpsSum += Number(st.tokPerSec);
if (validTps && stepSpeedSec > 0) {
tpsTokSum += outTok;
tpsSecSum += stepSpeedSec;
tpsCnt += 1;
}
if (validTtft) {
@@ -235,7 +247,8 @@ function summarizeStepsForExport(list, displaySettings) {
cacheTok: 0,
outTok: 0,
cost: 0,
tpsSum: 0,
tpsTokSum: 0,
tpsSecSum: 0,
tpsCnt: 0,
ttftSum: 0,
ttftCnt: 0,
@@ -247,8 +260,9 @@ function summarizeStepsForExport(list, displaySettings) {
mAcc.cacheTok += cacheTok;
mAcc.outTok += outTok;
if (Number.isFinite(cost) && cost > 0) mAcc.cost += cost;
if (validTps) {
mAcc.tpsSum += Number(st.tokPerSec);
if (validTps && stepSpeedSec > 0) {
mAcc.tpsTokSum += outTok;
mAcc.tpsSecSum += stepSpeedSec;
mAcc.tpsCnt += 1;
}
if (validTtft) {
@@ -272,7 +286,8 @@ function summarizeStepsForExport(list, displaySettings) {
sumCost,
sumDuration,
maxContext,
tpsSum,
tpsTokSum,
tpsSecSum,
tpsCnt,
ttftSum,
ttftCnt,
@@ -455,8 +470,9 @@ export function buildStepsCsv(steps, { displaySettings = {}, includeBom = true }
st.ttftSec != null && Number.isFinite(Number(st.ttftSec))
? Number(st.ttftSec).toFixed(3)
: '',
st.durationSec != null && Number.isFinite(Number(st.durationSec))
? Number(st.durationSec).toFixed(3)
(st.totalDurationSec ?? st.durationSec) != null &&
Number.isFinite(Number(st.totalDurationSec ?? st.durationSec))
? Number(st.totalDurationSec ?? st.durationSec).toFixed(3)
: '',
inTok,
cacheTok,
@@ -523,9 +539,10 @@ export function buildStepsXlsx(
!st.isCompactionStep && st.ttftSec != null && Number.isFinite(Number(st.ttftSec))
? Number(st.ttftSec)
: null;
const rawDurVal = st.totalDurationSec ?? st.durationSec;
const durVal =
st.durationSec != null && Number.isFinite(Number(st.durationSec))
? Number(st.durationSec)
rawDurVal != null && Number.isFinite(Number(rawDurVal))
? Number(rawDurVal)
: null;
const costVal =
st.costUsd != null && Number.isFinite(Number(st.costUsd)) ? Number(st.costUsd) : null;
@@ -577,7 +594,7 @@ export function buildStepsXlsx(
? `${agg.compactionCount} compact`
: `含 ${agg.compactionCount} 次压缩`
: '',
agg.tpsCnt > 0 ? +(agg.tpsSum / agg.tpsCnt).toFixed(1) : null,
agg.tpsSecSum > 0 ? +(agg.tpsTokSum / agg.tpsSecSum).toFixed(1) : null,
agg.ttftCnt > 0 ? +(agg.ttftSum / agg.ttftCnt).toFixed(2) : null,
agg.sumDuration > 0 ? +agg.sumDuration.toFixed(2) : null,
agg.sumIn,
@@ -636,7 +653,7 @@ export function buildStepsXlsx(
m.outTok,
mTotal,
computeCacheHitRatio(m.inTok, m.cacheTok),
m.tpsCnt > 0 ? +(m.tpsSum / m.tpsCnt).toFixed(1) : null,
m.tpsSecSum > 0 ? +(m.tpsTokSum / m.tpsSecSum).toFixed(1) : null,
m.ttftCnt > 0 ? +(m.ttftSum / m.ttftCnt).toFixed(2) : null,
m.cost,
];
@@ -651,7 +668,7 @@ export function buildStepsXlsx(
agg.sumOut,
agg.sumIn + agg.sumCache + agg.sumOut,
computeCacheHitRatio(agg.sumIn, agg.sumCache),
agg.tpsCnt > 0 ? +(agg.tpsSum / agg.tpsCnt).toFixed(1) : null,
agg.tpsSecSum > 0 ? +(agg.tpsTokSum / agg.tpsSecSum).toFixed(1) : null,
agg.ttftCnt > 0 ? +(agg.ttftSum / agg.ttftCnt).toFixed(2) : null,
agg.sumCost,
],
@@ -695,7 +712,8 @@ export function buildStepsMarkdownReport(
const totalTok = agg.sumIn + agg.sumCache + agg.sumOut;
const cacheHitPct = formatPctNumber(computeCacheHitRatio(agg.sumIn, agg.sumCache) * 100);
const avgTps = agg.tpsCnt > 0 ? formatSpeedMetric(agg.tpsSum / agg.tpsCnt, ' tok/s') : '—';
const avgTps =
agg.tpsSecSum > 0 ? formatSpeedMetric(agg.tpsTokSum / agg.tpsSecSum, ' tok/s') : '—';
const avgTtft = agg.ttftCnt > 0 ? formatMetric(agg.ttftSum / agg.ttftCnt, 's') : '—';
const heading = title
? `# ${title}`
@@ -738,7 +756,8 @@ export function buildStepsMarkdownReport(
const mCache = formatPctNumber(computeCacheHitRatio(m.inTok, m.cacheTok) * 100, {
withSymbol: true,
});
const mTps = m.tpsCnt > 0 ? formatSpeedMetric(m.tpsSum / m.tpsCnt, ' tok/s') : '—';
const mTps =
m.tpsSecSum > 0 ? formatSpeedMetric(m.tpsTokSum / m.tpsSecSum, ' tok/s') : '—';
lines.push(
`| ${escapeMdCell(m.label)} | ${m.calls} | ${formatTokensPrecise(mTotal)} | ${mCache} | ${mTps} | ${formatUsd(m.cost, { precise: m.cost > 0 && m.cost < 0.1 })} |`
);
@@ -1053,8 +1072,8 @@ export function buildConsumptionXlsx(
let mOut = 0;
let mTot = 0;
let mCost = 0;
let tpsWeighted = 0;
let tpsWeight = 0;
let tpsTokSum = 0;
let tpsSecSum = 0;
const modelRows = models.map((m, idx) => {
const calls = Math.max(0, Number(m.calls || 0));
const inTok = Math.max(0, Number(m.inputTokens || 0));
@@ -1072,10 +1091,20 @@ export function buildConsumptionXlsx(
mOut += outTok;
mTot += totTok;
mCost += cost;
if (tps != null) {
const w = Math.max(1, outTok || calls);
tpsWeighted += tps * w;
tpsWeight += w;
const rawSpeedTok = Number(m.speedSummary?.tokens);
const rawSpeedSec = Number(m.speedSummary?.seconds);
if (
Number.isFinite(rawSpeedTok) &&
Number.isFinite(rawSpeedSec) &&
rawSpeedSec > 0 &&
rawSpeedTok >= 0
) {
tpsTokSum += rawSpeedTok;
tpsSecSum += rawSpeedSec;
} else if (tps != null) {
const fallbackTok = outTok > 0 ? outTok : Math.max(1, calls);
tpsTokSum += fallbackTok;
tpsSecSum += fallbackTok / tps;
}
return [
idx + 1,
@@ -1101,7 +1130,7 @@ export function buildConsumptionXlsx(
mOut,
mTot,
computeCacheHitRatio(mIn, mCache),
tpsWeight > 0 ? +(tpsWeighted / tpsWeight).toFixed(1) : null,
tpsSecSum > 0 ? +(tpsTokSum / tpsSecSum).toFixed(1) : null,
mCost,
],
});
+20 -9
View File
@@ -30,7 +30,8 @@ export const STEP_SLOW_TTFT_MIN_SEC = 30;
*/
export function getStepSelectionKey(st, fallbackCascadeId = '') {
if (!st || typeof st !== 'object') return '';
const agentKey = st.agentId || st.cascadeId || fallbackCascadeId || 'main';
const agentKey =
st.agentCascadeId || st.agentId || st.cascadeId || fallbackCascadeId || 'conv';
return `${agentKey}-${st.stepIndex}`;
}
@@ -125,6 +126,11 @@ export function filterStepsBySearchAndChip(
if (rawTerms.length > 0) {
const modelInfo = resolveModelDisplayInfo(st, displaySettings);
const anomalyKinds = st.anomaly?.kinds ? Object.keys(st.anomaly.kinds).join(' ') : '';
const anomalyEventsText = Array.isArray(st.anomaly?.events)
? st.anomaly.events
.map((ev) => `${ev?.kind || ''} ${ev?.attempt ?? ''} ${ev?.message || ''}`)
.join(' ')
: '';
const anomalyItemsText = Array.isArray(st.anomaly?.items)
? st.anomaly.items
.map((it) => `${it?.kind || ''} ${it?.httpStatus || ''} ${it?.detail || ''}`)
@@ -137,6 +143,9 @@ export function filterStepsBySearchAndChip(
modelInfo.title,
st.modelLabel || '',
st.modelShort || '',
st.modelKey || '',
st.modelUpstream || '',
st.responseModel || '',
st.rawModelId || '',
st.upstreamName || '',
st.turnPrompt || '',
@@ -146,6 +155,7 @@ export function filterStepsBySearchAndChip(
st.agentBadge || '',
st.isCompactionStep ? 'compaction 压缩' : '',
anomalyKinds,
anomalyEventsText,
anomalyItemsText,
]
.join(' ')
@@ -210,15 +220,15 @@ export function findPrevAgentContextTokens(allSteps, targetStep) {
*/
export function computeStepTimingWaterfall(st) {
if (!st || typeof st !== 'object') return null;
const rawTtft = st.ttftSec ?? st.nativeTtftSec;
const ttft =
st.ttftSec != null && Number.isFinite(Number(st.ttftSec)) && Number(st.ttftSec) >= 0
? Number(st.ttftSec)
rawTtft != null && Number.isFinite(Number(rawTtft)) && Number(rawTtft) >= 0
? Number(rawTtft)
: 0;
const rawStream = st.nativeStreamSec ?? st.streamDurationSec;
const stream =
st.streamDurationSec != null &&
Number.isFinite(Number(st.streamDurationSec)) &&
Number(st.streamDurationSec) >= 0
? Number(st.streamDurationSec)
rawStream != null && Number.isFinite(Number(rawStream)) && Number(rawStream) >= 0
? Number(rawStream)
: 0;
const thinking =
st.thinkingDurationSec != null &&
@@ -226,9 +236,10 @@ export function computeStepTimingWaterfall(st) {
Number(st.thinkingDurationSec) >= 0
? Number(st.thinkingDurationSec)
: 0;
const rawDur = st.totalDurationSec ?? st.durationSec;
const rawTotal =
st.durationSec != null && Number.isFinite(Number(st.durationSec)) && Number(st.durationSec) > 0
? Number(st.durationSec)
rawDur != null && Number.isFinite(Number(rawDur)) && Number(rawDur) > 0
? Number(rawDur)
: ttft + stream;
const totalSec = Math.max(rawTotal, ttft + stream);
if (!(totalSec > 0)) return null;
+15
View File
@@ -873,4 +873,19 @@ export const I18N_MESSAGES_EN_US = Object.freeze({
'chart.trend.hmActivePeak': 'Active {active}/{total}d · Peak {label} · {tokens}',
'chart.trend.hmActiveZero': 'Active 0/{total}d',
'chart.trend.peakPill': 'Peak {label} · {tokens}',
// Base UI Controls (CustomDateTimePicker, CustomNumberInput, SegmentedControl)
'ui.dt.wdayMon': 'Mo',
'ui.dt.wdayTue': 'Tu',
'ui.dt.wdayWed': 'We',
'ui.dt.wdayThu': 'Th',
'ui.dt.wdayFri': 'Fr',
'ui.dt.wdaySat': 'Sa',
'ui.dt.wdaySun': 'Su',
'ui.dt.prevMonth': 'Previous month',
'ui.dt.nextMonth': 'Next month',
'ui.dt.hourMinute': 'Hr / Min',
'ui.num.decrease': 'Decrease value',
'ui.num.increase': 'Increase value',
'ui.seg.defaultAria': 'Segmented switcher',
});
+15
View File
@@ -873,4 +873,19 @@ export const I18N_MESSAGES_ZH_CN = Object.freeze({
'chart.trend.hmActivePeak': '活跃 {active}/{total} 天 · 峰值 {label} · {tokens}',
'chart.trend.hmActiveZero': '活跃 0/{total} 天',
'chart.trend.peakPill': '峰值 {label} · {tokens}',
// Base UI Controls (CustomDateTimePicker, CustomNumberInput, SegmentedControl)
'ui.dt.wdayMon': '一',
'ui.dt.wdayTue': '二',
'ui.dt.wdayWed': '三',
'ui.dt.wdayThu': '四',
'ui.dt.wdayFri': '五',
'ui.dt.wdaySat': '六',
'ui.dt.wdaySun': '日',
'ui.dt.prevMonth': '上个月',
'ui.dt.nextMonth': '下个月',
'ui.dt.hourMinute': '时 / 分',
'ui.num.decrease': '减少数值',
'ui.num.increase': '增加数值',
'ui.seg.defaultAria': '分段切换器',
});
+52 -10
View File
@@ -78,7 +78,7 @@ import { SegmentedControl } from '../components/ui/SegmentedControl.js';
import { StepTableWidget } from '../components/widgets/StepTableWidget.js';
import { sortStepsByColumn } from '../registries/stepColumnRegistry.js';
function mergeSelectedAgentUnits(units) {
export function mergeSelectedAgentUnits(units) {
const combinedSteps = [];
const modelMap = new Map();
@@ -115,10 +115,15 @@ function mergeSelectedAgentUnits(units) {
anomalyDangerCount: 0,
anomalyTotalDelaySec: 0,
anomalyByKind: {},
_speedWeightedSum: 0,
_speedWeight: 0,
_hasAnySpeedSummary: false,
_speedTokens: 0,
_speedSeconds: 0,
_speedSampleCount: 0,
_speedExcludedCount: 0,
_speedExcludedReasons: {},
_ttftWeightedSum: 0,
_ttftWeight: 0,
_ttftSampleCount: 0,
};
if (acc.upstreamName) acc.upstreamSet.add(acc.upstreamName);
modelMap.set(gk, acc);
@@ -165,19 +170,43 @@ function mergeSelectedAgentUnits(units) {
}
}
if (Number.isFinite(Number(m.avgTokPerSec)) && Number(m.avgTokPerSec) > 0) {
const w = Math.max(1, outTok || calls || 1);
acc._speedWeightedSum += Number(m.avgTokPerSec) * w;
acc._speedWeight += w;
const rawSpeedTok = Number(m.speedSummary?.tokens);
const rawSpeedSec = Number(m.speedSummary?.seconds);
if (
Number.isFinite(rawSpeedTok) &&
Number.isFinite(rawSpeedSec) &&
rawSpeedSec > 0 &&
rawSpeedTok >= 0
) {
acc._hasAnySpeedSummary = true;
acc._speedTokens += rawSpeedTok;
acc._speedSeconds += rawSpeedSec;
} else if (Number.isFinite(Number(m.avgTokPerSec)) && Number(m.avgTokPerSec) > 0) {
const fallbackTok = outTok > 0 ? outTok : Math.max(1, calls || 1);
acc._speedTokens += fallbackTok;
acc._speedSeconds += fallbackTok / Number(m.avgTokPerSec);
}
if (m.speedSummary) {
acc._hasAnySpeedSummary = true;
acc._speedSampleCount += Math.max(0, Number(m.speedSummary.sampleCount || 0));
acc._speedExcludedCount += Math.max(0, Number(m.speedSummary.excludedCount || 0));
if (m.speedSummary.excludedReasons && typeof m.speedSummary.excludedReasons === 'object') {
for (const [rk, rv] of Object.entries(m.speedSummary.excludedReasons)) {
const cnt = Math.max(0, Number(rv || 0));
if (cnt > 0) acc._speedExcludedReasons[rk] = (acc._speedExcludedReasons[rk] || 0) + cnt;
}
}
}
if (
m.avgTtftSec != null &&
Number.isFinite(Number(m.avgTtftSec)) &&
Number(m.avgTtftSec) >= 0
) {
const w = Math.max(1, calls || 1);
const ttftSamples = Math.max(0, Number(m.ttftSampleCount || 0));
const w = ttftSamples > 0 ? ttftSamples : Math.max(1, calls || 1);
acc._ttftWeightedSum += Number(m.avgTtftSec) * w;
acc._ttftWeight += w;
acc._ttftSampleCount += ttftSamples;
}
}
}
@@ -192,6 +221,7 @@ function mergeSelectedAgentUnits(units) {
const mergedModels = Array.from(modelMap.values())
.map((acc) => {
const promptTok = acc.inputTokens + acc.cacheReadTokens;
const rawAvgTps = acc._speedSeconds > 0 ? acc._speedTokens / acc._speedSeconds : null;
return {
label: acc.label,
shortName: acc.shortName,
@@ -207,10 +237,22 @@ function mergeSelectedAgentUnits(units) {
totalTokens: acc.totalTokens,
costUsd: +acc.costUsd.toFixed(6),
unpricedCalls: acc.unpricedCalls,
avgTokPerSec:
acc._speedWeight > 0 ? +(acc._speedWeightedSum / acc._speedWeight).toFixed(1) : null,
avgTokPerSec: rawAvgTps !== null ? +rawAvgTps.toFixed(1) : null,
avgTtftSec:
acc._ttftWeight > 0 ? +(acc._ttftWeightedSum / acc._ttftWeight).toFixed(1) : null,
ttftSampleCount: acc._ttftSampleCount,
...(acc._hasAnySpeedSummary
? {
speedSummary: {
tokens: acc._speedTokens,
seconds: +acc._speedSeconds.toFixed(6),
sampleCount: acc._speedSampleCount,
excludedCount: acc._speedExcludedCount,
excludedReasons: acc._speedExcludedReasons,
avgTokPerSec: rawAvgTps,
},
}
: {}),
cacheHitPct: promptTok > 0 ? +((acc.cacheReadTokens / promptTok) * 100).toFixed(1) : 0,
...(acc.anomalyCount > 0
? {