mirror of
https://github.com/lWolvesl/antigravity-usage-monitor.git
synced 2026-11-27 01:19:25 +08:00
fix(panel): resolve P0 step inspector, V4 timing projection, harmonic speed merge, and UI cleanup bugs
This commit is contained in:
+270
-68
@@ -2124,6 +2124,21 @@ const I18N_MESSAGES_ZH_CN = Object.freeze({
|
|||||||
'chart.trend.hmActivePeak': '活跃 {active}/{total} 天 · 峰值 {label} · {tokens}',
|
'chart.trend.hmActivePeak': '活跃 {active}/{total} 天 · 峰值 {label} · {tokens}',
|
||||||
'chart.trend.hmActiveZero': '活跃 0/{total} 天',
|
'chart.trend.hmActiveZero': '活跃 0/{total} 天',
|
||||||
'chart.trend.peakPill': '峰值 {label} · {tokens}',
|
'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': '分段切换器',
|
||||||
});
|
});
|
||||||
return { I18N_MESSAGES_ZH_CN };
|
return { I18N_MESSAGES_ZH_CN };
|
||||||
})();
|
})();
|
||||||
@@ -3005,6 +3020,21 @@ const I18N_MESSAGES_EN_US = Object.freeze({
|
|||||||
'chart.trend.hmActivePeak': 'Active {active}/{total}d · Peak {label} · {tokens}',
|
'chart.trend.hmActivePeak': 'Active {active}/{total}d · Peak {label} · {tokens}',
|
||||||
'chart.trend.hmActiveZero': 'Active 0/{total}d',
|
'chart.trend.hmActiveZero': 'Active 0/{total}d',
|
||||||
'chart.trend.peakPill': 'Peak {label} · {tokens}',
|
'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',
|
||||||
});
|
});
|
||||||
return { I18N_MESSAGES_EN_US };
|
return { I18N_MESSAGES_EN_US };
|
||||||
})();
|
})();
|
||||||
@@ -4833,14 +4863,30 @@ function mergeModelsByDisplayName(models = [], settings = {}, options = {}) {
|
|||||||
const speedSampleCount = Math.max(0, Number(m.speedSummary?.sampleCount || 0));
|
const speedSampleCount = Math.max(0, Number(m.speedSummary?.sampleCount || 0));
|
||||||
const speedExcludedCount = Math.max(0, Number(m.speedSummary?.excludedCount || 0));
|
const speedExcludedCount = Math.max(0, Number(m.speedSummary?.excludedCount || 0));
|
||||||
const speedWeight = speedSampleCount > 0 ? speedSampleCount : Math.max(1, outTok || calls || 1);
|
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 ttftSampleCount = Math.max(0, Number(m.ttftSampleCount || 0));
|
||||||
const ttftWeight = ttftSampleCount > 0 ? ttftSampleCount : Math.max(1, calls || 1);
|
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);
|
let acc = byDisplay.get(key);
|
||||||
if (!acc) {
|
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 = {
|
acc = {
|
||||||
baseItem: m,
|
baseItem: m,
|
||||||
mergedCount: 1,
|
mergedCount: 1,
|
||||||
@@ -4860,10 +4906,15 @@ function mergeModelsByDisplayName(models = [], settings = {}, options = {}) {
|
|||||||
totalTokens: totTok,
|
totalTokens: totTok,
|
||||||
costUsd,
|
costUsd,
|
||||||
unpricedCalls,
|
unpricedCalls,
|
||||||
|
hasAnySpeedSummary: Boolean(m.speedSummary),
|
||||||
|
allSpeedExact: !hasSpeed || hasExactSpeedSummary,
|
||||||
|
speedTokens: hasExactSpeedSummary ? rawSpeedTokens : 0,
|
||||||
|
speedSeconds: hasExactSpeedSummary ? rawSpeedSeconds : 0,
|
||||||
speedWeightedSum: hasSpeed ? Number(m.avgTokPerSec) * speedWeight : 0,
|
speedWeightedSum: hasSpeed ? Number(m.avgTokPerSec) * speedWeight : 0,
|
||||||
speedWeight: hasSpeed ? speedWeight : 0,
|
speedWeight: hasSpeed ? speedWeight : 0,
|
||||||
speedSampleCount,
|
speedSampleCount,
|
||||||
speedExcludedCount,
|
speedExcludedCount,
|
||||||
|
speedExcludedReasons: initExcludedReasons,
|
||||||
ttftWeightedSum: hasTtft ? Number(m.avgTtftSec) * ttftWeight : 0,
|
ttftWeightedSum: hasTtft ? Number(m.avgTtftSec) * ttftWeight : 0,
|
||||||
ttftWeight: hasTtft ? ttftWeight : 0,
|
ttftWeight: hasTtft ? ttftWeight : 0,
|
||||||
ttftSampleCount,
|
ttftSampleCount,
|
||||||
@@ -4912,12 +4963,24 @@ 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) {
|
if (hasSpeed) {
|
||||||
acc.speedWeightedSum += Number(m.avgTokPerSec) * speedWeight;
|
acc.speedWeightedSum += Number(m.avgTokPerSec) * speedWeight;
|
||||||
acc.speedWeight += speedWeight;
|
acc.speedWeight += speedWeight;
|
||||||
}
|
}
|
||||||
acc.speedSampleCount += speedSampleCount;
|
acc.speedSampleCount += speedSampleCount;
|
||||||
acc.speedExcludedCount += speedExcludedCount;
|
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) {
|
if (hasTtft) {
|
||||||
acc.ttftWeightedSum += Number(m.avgTtftSec) * ttftWeight;
|
acc.ttftWeightedSum += Number(m.avgTtftSec) * ttftWeight;
|
||||||
@@ -4937,8 +5000,13 @@ function mergeModelsByDisplayName(models = [], settings = {}, options = {}) {
|
|||||||
}
|
}
|
||||||
const promptTok = acc.inputTokens + acc.cacheReadTokens;
|
const promptTok = acc.inputTokens + acc.cacheReadTokens;
|
||||||
const cacheHitPct = promptTok > 0 ? +((acc.cacheReadTokens / promptTok) * 100).toFixed(1) : 0;
|
const cacheHitPct = promptTok > 0 ? +((acc.cacheReadTokens / promptTok) * 100).toFixed(1) : 0;
|
||||||
const avgTokPerSec =
|
const rawAvgTps =
|
||||||
acc.speedWeight > 0 ? +(acc.speedWeightedSum / acc.speedWeight).toFixed(1) : null;
|
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 =
|
const avgTtftSec =
|
||||||
acc.ttftWeight > 0 ? +(acc.ttftWeightedSum / acc.ttftWeight).toFixed(1) : null;
|
acc.ttftWeight > 0 ? +(acc.ttftWeightedSum / acc.ttftWeight).toFixed(1) : null;
|
||||||
const upstreamModels = Array.from(acc.upstreamSet);
|
const upstreamModels = Array.from(acc.upstreamSet);
|
||||||
@@ -4971,12 +5039,15 @@ function mergeModelsByDisplayName(models = [], settings = {}, options = {}) {
|
|||||||
anomalyByKind: acc.anomalyByKind,
|
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,
|
sampleCount: acc.speedSampleCount,
|
||||||
excludedCount: acc.speedExcludedCount,
|
excludedCount: acc.speedExcludedCount,
|
||||||
avgTokPerSec,
|
excludedReasons: acc.speedExcludedReasons,
|
||||||
|
avgTokPerSec: rawAvgTps,
|
||||||
}
|
}
|
||||||
: undefined,
|
: undefined,
|
||||||
upstreamModels,
|
upstreamModels,
|
||||||
@@ -5363,7 +5434,8 @@ const STEP_SLOW_TTFT_MIN_SEC = 30;
|
|||||||
*/
|
*/
|
||||||
function getStepSelectionKey(st, fallbackCascadeId = '') {
|
function getStepSelectionKey(st, fallbackCascadeId = '') {
|
||||||
if (!st || typeof st !== 'object') return '';
|
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}`;
|
return `${agentKey}-${st.stepIndex}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -5458,6 +5530,11 @@ function filterStepsBySearchAndChip(
|
|||||||
if (rawTerms.length > 0) {
|
if (rawTerms.length > 0) {
|
||||||
const modelInfo = resolveModelDisplayInfo(st, displaySettings);
|
const modelInfo = resolveModelDisplayInfo(st, displaySettings);
|
||||||
const anomalyKinds = st.anomaly?.kinds ? Object.keys(st.anomaly.kinds).join(' ') : '';
|
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)
|
const anomalyItemsText = Array.isArray(st.anomaly?.items)
|
||||||
? st.anomaly.items
|
? st.anomaly.items
|
||||||
.map((it) => `${it?.kind || ''} ${it?.httpStatus || ''} ${it?.detail || ''}`)
|
.map((it) => `${it?.kind || ''} ${it?.httpStatus || ''} ${it?.detail || ''}`)
|
||||||
@@ -5470,6 +5547,9 @@ function filterStepsBySearchAndChip(
|
|||||||
modelInfo.title,
|
modelInfo.title,
|
||||||
st.modelLabel || '',
|
st.modelLabel || '',
|
||||||
st.modelShort || '',
|
st.modelShort || '',
|
||||||
|
st.modelKey || '',
|
||||||
|
st.modelUpstream || '',
|
||||||
|
st.responseModel || '',
|
||||||
st.rawModelId || '',
|
st.rawModelId || '',
|
||||||
st.upstreamName || '',
|
st.upstreamName || '',
|
||||||
st.turnPrompt || '',
|
st.turnPrompt || '',
|
||||||
@@ -5479,6 +5559,7 @@ function filterStepsBySearchAndChip(
|
|||||||
st.agentBadge || '',
|
st.agentBadge || '',
|
||||||
st.isCompactionStep ? 'compaction 压缩' : '',
|
st.isCompactionStep ? 'compaction 压缩' : '',
|
||||||
anomalyKinds,
|
anomalyKinds,
|
||||||
|
anomalyEventsText,
|
||||||
anomalyItemsText,
|
anomalyItemsText,
|
||||||
]
|
]
|
||||||
.join(' ')
|
.join(' ')
|
||||||
@@ -5543,15 +5624,15 @@ function findPrevAgentContextTokens(allSteps, targetStep) {
|
|||||||
*/
|
*/
|
||||||
function computeStepTimingWaterfall(st) {
|
function computeStepTimingWaterfall(st) {
|
||||||
if (!st || typeof st !== 'object') return null;
|
if (!st || typeof st !== 'object') return null;
|
||||||
|
const rawTtft = st.ttftSec ?? st.nativeTtftSec;
|
||||||
const ttft =
|
const ttft =
|
||||||
st.ttftSec != null && Number.isFinite(Number(st.ttftSec)) && Number(st.ttftSec) >= 0
|
rawTtft != null && Number.isFinite(Number(rawTtft)) && Number(rawTtft) >= 0
|
||||||
? Number(st.ttftSec)
|
? Number(rawTtft)
|
||||||
: 0;
|
: 0;
|
||||||
|
const rawStream = st.nativeStreamSec ?? st.streamDurationSec;
|
||||||
const stream =
|
const stream =
|
||||||
st.streamDurationSec != null &&
|
rawStream != null && Number.isFinite(Number(rawStream)) && Number(rawStream) >= 0
|
||||||
Number.isFinite(Number(st.streamDurationSec)) &&
|
? Number(rawStream)
|
||||||
Number(st.streamDurationSec) >= 0
|
|
||||||
? Number(st.streamDurationSec)
|
|
||||||
: 0;
|
: 0;
|
||||||
const thinking =
|
const thinking =
|
||||||
st.thinkingDurationSec != null &&
|
st.thinkingDurationSec != null &&
|
||||||
@@ -5559,9 +5640,10 @@ function computeStepTimingWaterfall(st) {
|
|||||||
Number(st.thinkingDurationSec) >= 0
|
Number(st.thinkingDurationSec) >= 0
|
||||||
? Number(st.thinkingDurationSec)
|
? Number(st.thinkingDurationSec)
|
||||||
: 0;
|
: 0;
|
||||||
|
const rawDur = st.totalDurationSec ?? st.durationSec;
|
||||||
const rawTotal =
|
const rawTotal =
|
||||||
st.durationSec != null && Number.isFinite(Number(st.durationSec)) && Number(st.durationSec) > 0
|
rawDur != null && Number.isFinite(Number(rawDur)) && Number(rawDur) > 0
|
||||||
? Number(st.durationSec)
|
? Number(rawDur)
|
||||||
: ttft + stream;
|
: ttft + stream;
|
||||||
const totalSec = Math.max(rawTotal, ttft + stream);
|
const totalSec = Math.max(rawTotal, ttft + stream);
|
||||||
if (!(totalSec > 0)) return null;
|
if (!(totalSec > 0)) return null;
|
||||||
@@ -6726,7 +6808,8 @@ function summarizeStepsForExport(list, displaySettings) {
|
|||||||
let sumCost = 0;
|
let sumCost = 0;
|
||||||
let sumDuration = 0;
|
let sumDuration = 0;
|
||||||
let maxContext = 0;
|
let maxContext = 0;
|
||||||
let tpsSum = 0;
|
let tpsTokSum = 0;
|
||||||
|
let tpsSecSum = 0;
|
||||||
let tpsCnt = 0;
|
let tpsCnt = 0;
|
||||||
let ttftSum = 0;
|
let ttftSum = 0;
|
||||||
let ttftCnt = 0;
|
let ttftCnt = 0;
|
||||||
@@ -6748,7 +6831,8 @@ function summarizeStepsForExport(list, displaySettings) {
|
|||||||
: Math.max(0, outTok - thinkTok);
|
: Math.max(0, outTok - thinkTok);
|
||||||
const ctxTok = Math.max(0, Number(st.contextTokens || inTok + cacheTok + outTok));
|
const ctxTok = Math.max(0, Number(st.contextTokens || inTok + cacheTok + outTok));
|
||||||
const cost = Number(st.costUsd || 0);
|
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;
|
sumIn += inTok;
|
||||||
sumCache += cacheTok;
|
sumCache += cacheTok;
|
||||||
@@ -6760,11 +6844,21 @@ function summarizeStepsForExport(list, displaySettings) {
|
|||||||
if (Number.isFinite(dur) && dur > 0) sumDuration += dur;
|
if (Number.isFinite(dur) && dur > 0) sumDuration += dur;
|
||||||
|
|
||||||
const validTps =
|
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 =
|
const validTtft =
|
||||||
!st.isCompactionStep && Number.isFinite(Number(st.ttftSec)) && Number(st.ttftSec) >= 0;
|
!st.isCompactionStep && Number.isFinite(Number(st.ttftSec)) && Number(st.ttftSec) >= 0;
|
||||||
if (validTps) {
|
if (validTps && stepSpeedSec > 0) {
|
||||||
tpsSum += Number(st.tokPerSec);
|
tpsTokSum += outTok;
|
||||||
|
tpsSecSum += stepSpeedSec;
|
||||||
tpsCnt += 1;
|
tpsCnt += 1;
|
||||||
}
|
}
|
||||||
if (validTtft) {
|
if (validTtft) {
|
||||||
@@ -6789,7 +6883,8 @@ function summarizeStepsForExport(list, displaySettings) {
|
|||||||
cacheTok: 0,
|
cacheTok: 0,
|
||||||
outTok: 0,
|
outTok: 0,
|
||||||
cost: 0,
|
cost: 0,
|
||||||
tpsSum: 0,
|
tpsTokSum: 0,
|
||||||
|
tpsSecSum: 0,
|
||||||
tpsCnt: 0,
|
tpsCnt: 0,
|
||||||
ttftSum: 0,
|
ttftSum: 0,
|
||||||
ttftCnt: 0,
|
ttftCnt: 0,
|
||||||
@@ -6801,8 +6896,9 @@ function summarizeStepsForExport(list, displaySettings) {
|
|||||||
mAcc.cacheTok += cacheTok;
|
mAcc.cacheTok += cacheTok;
|
||||||
mAcc.outTok += outTok;
|
mAcc.outTok += outTok;
|
||||||
if (Number.isFinite(cost) && cost > 0) mAcc.cost += cost;
|
if (Number.isFinite(cost) && cost > 0) mAcc.cost += cost;
|
||||||
if (validTps) {
|
if (validTps && stepSpeedSec > 0) {
|
||||||
mAcc.tpsSum += Number(st.tokPerSec);
|
mAcc.tpsTokSum += outTok;
|
||||||
|
mAcc.tpsSecSum += stepSpeedSec;
|
||||||
mAcc.tpsCnt += 1;
|
mAcc.tpsCnt += 1;
|
||||||
}
|
}
|
||||||
if (validTtft) {
|
if (validTtft) {
|
||||||
@@ -6826,7 +6922,8 @@ function summarizeStepsForExport(list, displaySettings) {
|
|||||||
sumCost,
|
sumCost,
|
||||||
sumDuration,
|
sumDuration,
|
||||||
maxContext,
|
maxContext,
|
||||||
tpsSum,
|
tpsTokSum,
|
||||||
|
tpsSecSum,
|
||||||
tpsCnt,
|
tpsCnt,
|
||||||
ttftSum,
|
ttftSum,
|
||||||
ttftCnt,
|
ttftCnt,
|
||||||
@@ -7009,8 +7106,9 @@ function buildStepsCsv(steps, { displaySettings = {}, includeBom = true } = {})
|
|||||||
st.ttftSec != null && Number.isFinite(Number(st.ttftSec))
|
st.ttftSec != null && Number.isFinite(Number(st.ttftSec))
|
||||||
? Number(st.ttftSec).toFixed(3)
|
? Number(st.ttftSec).toFixed(3)
|
||||||
: '',
|
: '',
|
||||||
st.durationSec != null && Number.isFinite(Number(st.durationSec))
|
(st.totalDurationSec ?? st.durationSec) != null &&
|
||||||
? Number(st.durationSec).toFixed(3)
|
Number.isFinite(Number(st.totalDurationSec ?? st.durationSec))
|
||||||
|
? Number(st.totalDurationSec ?? st.durationSec).toFixed(3)
|
||||||
: '',
|
: '',
|
||||||
inTok,
|
inTok,
|
||||||
cacheTok,
|
cacheTok,
|
||||||
@@ -7077,9 +7175,10 @@ function buildStepsXlsx(
|
|||||||
!st.isCompactionStep && st.ttftSec != null && Number.isFinite(Number(st.ttftSec))
|
!st.isCompactionStep && st.ttftSec != null && Number.isFinite(Number(st.ttftSec))
|
||||||
? Number(st.ttftSec)
|
? Number(st.ttftSec)
|
||||||
: null;
|
: null;
|
||||||
|
const rawDurVal = st.totalDurationSec ?? st.durationSec;
|
||||||
const durVal =
|
const durVal =
|
||||||
st.durationSec != null && Number.isFinite(Number(st.durationSec))
|
rawDurVal != null && Number.isFinite(Number(rawDurVal))
|
||||||
? Number(st.durationSec)
|
? Number(rawDurVal)
|
||||||
: null;
|
: null;
|
||||||
const costVal =
|
const costVal =
|
||||||
st.costUsd != null && Number.isFinite(Number(st.costUsd)) ? Number(st.costUsd) : null;
|
st.costUsd != null && Number.isFinite(Number(st.costUsd)) ? Number(st.costUsd) : null;
|
||||||
@@ -7131,7 +7230,7 @@ function buildStepsXlsx(
|
|||||||
? `${agg.compactionCount} compact`
|
? `${agg.compactionCount} compact`
|
||||||
: `含 ${agg.compactionCount} 次压缩`
|
: `含 ${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.ttftCnt > 0 ? +(agg.ttftSum / agg.ttftCnt).toFixed(2) : null,
|
||||||
agg.sumDuration > 0 ? +agg.sumDuration.toFixed(2) : null,
|
agg.sumDuration > 0 ? +agg.sumDuration.toFixed(2) : null,
|
||||||
agg.sumIn,
|
agg.sumIn,
|
||||||
@@ -7190,7 +7289,7 @@ function buildStepsXlsx(
|
|||||||
m.outTok,
|
m.outTok,
|
||||||
mTotal,
|
mTotal,
|
||||||
computeCacheHitRatio(m.inTok, m.cacheTok),
|
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.ttftCnt > 0 ? +(m.ttftSum / m.ttftCnt).toFixed(2) : null,
|
||||||
m.cost,
|
m.cost,
|
||||||
];
|
];
|
||||||
@@ -7205,7 +7304,7 @@ function buildStepsXlsx(
|
|||||||
agg.sumOut,
|
agg.sumOut,
|
||||||
agg.sumIn + agg.sumCache + agg.sumOut,
|
agg.sumIn + agg.sumCache + agg.sumOut,
|
||||||
computeCacheHitRatio(agg.sumIn, agg.sumCache),
|
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.ttftCnt > 0 ? +(agg.ttftSum / agg.ttftCnt).toFixed(2) : null,
|
||||||
agg.sumCost,
|
agg.sumCost,
|
||||||
],
|
],
|
||||||
@@ -7249,7 +7348,8 @@ function buildStepsMarkdownReport(
|
|||||||
|
|
||||||
const totalTok = agg.sumIn + agg.sumCache + agg.sumOut;
|
const totalTok = agg.sumIn + agg.sumCache + agg.sumOut;
|
||||||
const cacheHitPct = formatPctNumber(computeCacheHitRatio(agg.sumIn, agg.sumCache) * 100);
|
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 avgTtft = agg.ttftCnt > 0 ? formatMetric(agg.ttftSum / agg.ttftCnt, 's') : '—';
|
||||||
const heading = title
|
const heading = title
|
||||||
? `# ${title}`
|
? `# ${title}`
|
||||||
@@ -7292,7 +7392,8 @@ function buildStepsMarkdownReport(
|
|||||||
const mCache = formatPctNumber(computeCacheHitRatio(m.inTok, m.cacheTok) * 100, {
|
const mCache = formatPctNumber(computeCacheHitRatio(m.inTok, m.cacheTok) * 100, {
|
||||||
withSymbol: true,
|
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(
|
lines.push(
|
||||||
`| ${escapeMdCell(m.label)} | ${m.calls} | ${formatTokensPrecise(mTotal)} | ${mCache} | ${mTps} | ${formatUsd(m.cost, { precise: m.cost > 0 && m.cost < 0.1 })} |`
|
`| ${escapeMdCell(m.label)} | ${m.calls} | ${formatTokensPrecise(mTotal)} | ${mCache} | ${mTps} | ${formatUsd(m.cost, { precise: m.cost > 0 && m.cost < 0.1 })} |`
|
||||||
);
|
);
|
||||||
@@ -7607,8 +7708,8 @@ function buildConsumptionXlsx(
|
|||||||
let mOut = 0;
|
let mOut = 0;
|
||||||
let mTot = 0;
|
let mTot = 0;
|
||||||
let mCost = 0;
|
let mCost = 0;
|
||||||
let tpsWeighted = 0;
|
let tpsTokSum = 0;
|
||||||
let tpsWeight = 0;
|
let tpsSecSum = 0;
|
||||||
const modelRows = models.map((m, idx) => {
|
const modelRows = models.map((m, idx) => {
|
||||||
const calls = Math.max(0, Number(m.calls || 0));
|
const calls = Math.max(0, Number(m.calls || 0));
|
||||||
const inTok = Math.max(0, Number(m.inputTokens || 0));
|
const inTok = Math.max(0, Number(m.inputTokens || 0));
|
||||||
@@ -7626,10 +7727,20 @@ function buildConsumptionXlsx(
|
|||||||
mOut += outTok;
|
mOut += outTok;
|
||||||
mTot += totTok;
|
mTot += totTok;
|
||||||
mCost += cost;
|
mCost += cost;
|
||||||
if (tps != null) {
|
const rawSpeedTok = Number(m.speedSummary?.tokens);
|
||||||
const w = Math.max(1, outTok || calls);
|
const rawSpeedSec = Number(m.speedSummary?.seconds);
|
||||||
tpsWeighted += tps * w;
|
if (
|
||||||
tpsWeight += w;
|
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 [
|
return [
|
||||||
idx + 1,
|
idx + 1,
|
||||||
@@ -7655,7 +7766,7 @@ function buildConsumptionXlsx(
|
|||||||
mOut,
|
mOut,
|
||||||
mTot,
|
mTot,
|
||||||
computeCacheHitRatio(mIn, mCache),
|
computeCacheHitRatio(mIn, mCache),
|
||||||
tpsWeight > 0 ? +(tpsWeighted / tpsWeight).toFixed(1) : null,
|
tpsSecSum > 0 ? +(tpsTokSum / tpsSecSum).toFixed(1) : null,
|
||||||
mCost,
|
mCost,
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
@@ -11925,7 +12036,7 @@ const { CustomNumberInput } = (() => {
|
|||||||
|
|
||||||
const CustomNumberInput = defineComponent({
|
const CustomNumberInput = defineComponent({
|
||||||
name: 'CustomNumberInput',
|
name: 'CustomNumberInput',
|
||||||
setup({ getProps, setProps, emit }) {
|
setup({ getProps, setProps, emit, onCleanup }) {
|
||||||
function clampValue(raw) {
|
function clampValue(raw) {
|
||||||
const { min = -Infinity, max = Infinity, precision = 0 } = getProps();
|
const { min = -Infinity, max = Infinity, precision = 0 } = getProps();
|
||||||
const num = Number(raw);
|
const num = Number(raw);
|
||||||
@@ -11952,7 +12063,7 @@ const CustomNumberInput = defineComponent({
|
|||||||
{
|
{
|
||||||
type: 'button',
|
type: 'button',
|
||||||
className: 'num-step-btn',
|
className: 'num-step-btn',
|
||||||
'aria-label': '减少数值',
|
'aria-label': t('ui.num.decrease'),
|
||||||
onClick: (e) => {
|
onClick: (e) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
applyStep(-1, e.shiftKey ? 10 : 1);
|
applyStep(-1, e.shiftKey ? 10 : 1);
|
||||||
@@ -11966,7 +12077,7 @@ const CustomNumberInput = defineComponent({
|
|||||||
{
|
{
|
||||||
type: 'button',
|
type: 'button',
|
||||||
className: 'num-step-btn',
|
className: 'num-step-btn',
|
||||||
'aria-label': '增加数值',
|
'aria-label': t('ui.num.increase'),
|
||||||
onClick: (e) => {
|
onClick: (e) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
applyStep(1, e.shiftKey ? 10 : 1);
|
applyStep(1, e.shiftKey ? 10 : 1);
|
||||||
@@ -12030,6 +12141,15 @@ const CustomNumberInput = defineComponent({
|
|||||||
}
|
}
|
||||||
|
|
||||||
const rootEl = h('div', { className: 'number-input' }, [decBtn, textField, incBtn]);
|
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();
|
syncFieldDisplay();
|
||||||
|
|
||||||
return {
|
return {
|
||||||
@@ -12053,7 +12173,15 @@ const { CustomDateTimePicker } = (() => {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
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) {
|
function buildCalendarDays(viewYear, viewMonth, selectedDate) {
|
||||||
const firstDay = new Date(viewYear, viewMonth, 1);
|
const firstDay = new Date(viewYear, viewMonth, 1);
|
||||||
@@ -12114,7 +12242,7 @@ const CustomDateTimePicker = defineComponent({
|
|||||||
{
|
{
|
||||||
type: 'button',
|
type: 'button',
|
||||||
className: 'icon-btn',
|
className: 'icon-btn',
|
||||||
'aria-label': '上个月',
|
'aria-label': t('ui.dt.prevMonth'),
|
||||||
onClick: (e) => {
|
onClick: (e) => {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
viewMonth -= 1;
|
viewMonth -= 1;
|
||||||
@@ -12133,7 +12261,7 @@ const CustomDateTimePicker = defineComponent({
|
|||||||
{
|
{
|
||||||
type: 'button',
|
type: 'button',
|
||||||
className: 'icon-btn',
|
className: 'icon-btn',
|
||||||
'aria-label': '下个月',
|
'aria-label': t('ui.dt.nextMonth'),
|
||||||
onClick: (e) => {
|
onClick: (e) => {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
viewMonth += 1;
|
viewMonth += 1;
|
||||||
@@ -12149,11 +12277,10 @@ const CustomDateTimePicker = defineComponent({
|
|||||||
|
|
||||||
const navBar = h('div', { className: 'dt-nav' }, [prevMonthBtn, monthTitle, nextMonthBtn]);
|
const navBar = h('div', { className: 'dt-nav' }, [prevMonthBtn, monthTitle, nextMonthBtn]);
|
||||||
|
|
||||||
const weekdayRow = h(
|
const weekdaySpans = WEEKDAY_KEYS.map((key) =>
|
||||||
'div',
|
h('span', { className: 'dt-weekday', text: t(key) })
|
||||||
{ className: 'dt-weekdays' },
|
|
||||||
WEEKDAYS.map((w) => h('span', { className: 'dt-weekday', text: w }))
|
|
||||||
);
|
);
|
||||||
|
const weekdayRow = h('div', { className: 'dt-weekdays' }, weekdaySpans);
|
||||||
|
|
||||||
const daysGrid = h('div', { className: 'dt-days' });
|
const daysGrid = h('div', { className: 'dt-days' });
|
||||||
|
|
||||||
@@ -12173,8 +12300,9 @@ const CustomDateTimePicker = defineComponent({
|
|||||||
emit('update:modelValue', nextMs);
|
emit('update:modelValue', nextMs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const hourMinLabelEl = h('span', { className: 'text-muted', text: t('ui.dt.hourMinute') });
|
||||||
const timeRow = h('div', { className: 'dt-time-row' }, [
|
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-time-controls' }, [
|
||||||
h('div', { className: 'dt-mini-step' }, [
|
h('div', { className: 'dt-mini-step' }, [
|
||||||
h('button', {
|
h('button', {
|
||||||
@@ -12343,6 +12471,25 @@ const CustomDateTimePicker = defineComponent({
|
|||||||
onCleanup(() => setRepositionListeners(false));
|
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();
|
syncDisplay();
|
||||||
|
|
||||||
return {
|
return {
|
||||||
@@ -12554,10 +12701,18 @@ const SegmentedControl = defineComponent({
|
|||||||
{
|
{
|
||||||
className: 'segmented',
|
className: 'segmented',
|
||||||
role: 'group',
|
role: 'group',
|
||||||
'aria-label': getProps().ariaLabel || '分段切换器',
|
'aria-label': getProps().ariaLabel || t('ui.seg.defaultAria'),
|
||||||
},
|
},
|
||||||
[gliderEl]
|
[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();
|
const btnMap = new Map();
|
||||||
let orderedBtns = [];
|
let orderedBtns = [];
|
||||||
@@ -21514,9 +21669,11 @@ const StepTableWidget = defineComponent({
|
|||||||
}
|
}
|
||||||
|
|
||||||
function getStepRowIdentity(st, fallbackCascadeId) {
|
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 stepNum = Number(st?.stepIndex);
|
||||||
const rowKey = `${agentKey}-${st?.stepIndex}`;
|
const rowKey = getStepSelectionKey(st, fallbackCascadeId);
|
||||||
return { agentKey, stepNum, rowKey };
|
return { agentKey, stepNum, rowKey };
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -21892,7 +22049,7 @@ const StepTableWidget = defineComponent({
|
|||||||
logicalIdx: idx,
|
logicalIdx: idx,
|
||||||
isStripeEven: (idx & 1) === 1,
|
isStripeEven: (idx & 1) === 1,
|
||||||
hasReason: Boolean(hasReasonFlags && hasReasonFlags[idx]),
|
hasReason: Boolean(hasReasonFlags && hasReasonFlags[idx]),
|
||||||
rowKey: `${st.agentCascadeId || cascadeId || 'conv'}-${st.stepIndex}`,
|
rowKey: getStepSelectionKey(st, cascadeId),
|
||||||
hasTurn,
|
hasTurn,
|
||||||
hasUp,
|
hasUp,
|
||||||
hasDown,
|
hasDown,
|
||||||
@@ -24705,7 +24862,7 @@ const SessionMigrationCard = defineComponent({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
listScrollbar?.methods?.refresh?.();
|
listScrollbar?.refresh?.();
|
||||||
|
|
||||||
patchAttr(migrateBtn, 'disabled', isMigrating || selectedIds.size === 0 || !targetClient);
|
patchAttr(migrateBtn, 'disabled', isMigrating || selectedIds.size === 0 || !targetClient);
|
||||||
patchText(
|
patchText(
|
||||||
@@ -30870,7 +31027,7 @@ return { ConsumptionView };
|
|||||||
})();
|
})();
|
||||||
|
|
||||||
// --- src/views/StepsDetailView.js ---
|
// --- src/views/StepsDetailView.js ---
|
||||||
const { StepsDetailView } = (() => {
|
const { mergeSelectedAgentUnits, StepsDetailView } = (() => {
|
||||||
/**
|
/**
|
||||||
* @fileoverview View 3: StepsDetailView (步骤明细与总汇总分析视图).
|
* @fileoverview View 3: StepsDetailView (步骤明细与总汇总分析视图).
|
||||||
* 提供“按步查看”与“总汇总”双子视图切换:
|
* 提供“按步查看”与“总汇总”双子视图切换:
|
||||||
@@ -30916,10 +31073,15 @@ function mergeSelectedAgentUnits(units) {
|
|||||||
anomalyDangerCount: 0,
|
anomalyDangerCount: 0,
|
||||||
anomalyTotalDelaySec: 0,
|
anomalyTotalDelaySec: 0,
|
||||||
anomalyByKind: {},
|
anomalyByKind: {},
|
||||||
_speedWeightedSum: 0,
|
_hasAnySpeedSummary: false,
|
||||||
_speedWeight: 0,
|
_speedTokens: 0,
|
||||||
|
_speedSeconds: 0,
|
||||||
|
_speedSampleCount: 0,
|
||||||
|
_speedExcludedCount: 0,
|
||||||
|
_speedExcludedReasons: {},
|
||||||
_ttftWeightedSum: 0,
|
_ttftWeightedSum: 0,
|
||||||
_ttftWeight: 0,
|
_ttftWeight: 0,
|
||||||
|
_ttftSampleCount: 0,
|
||||||
};
|
};
|
||||||
if (acc.upstreamName) acc.upstreamSet.add(acc.upstreamName);
|
if (acc.upstreamName) acc.upstreamSet.add(acc.upstreamName);
|
||||||
modelMap.set(gk, acc);
|
modelMap.set(gk, acc);
|
||||||
@@ -30966,19 +31128,43 @@ function mergeSelectedAgentUnits(units) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Number.isFinite(Number(m.avgTokPerSec)) && Number(m.avgTokPerSec) > 0) {
|
const rawSpeedTok = Number(m.speedSummary?.tokens);
|
||||||
const w = Math.max(1, outTok || calls || 1);
|
const rawSpeedSec = Number(m.speedSummary?.seconds);
|
||||||
acc._speedWeightedSum += Number(m.avgTokPerSec) * w;
|
if (
|
||||||
acc._speedWeight += w;
|
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 (
|
if (
|
||||||
m.avgTtftSec != null &&
|
m.avgTtftSec != null &&
|
||||||
Number.isFinite(Number(m.avgTtftSec)) &&
|
Number.isFinite(Number(m.avgTtftSec)) &&
|
||||||
Number(m.avgTtftSec) >= 0
|
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._ttftWeightedSum += Number(m.avgTtftSec) * w;
|
||||||
acc._ttftWeight += w;
|
acc._ttftWeight += w;
|
||||||
|
acc._ttftSampleCount += ttftSamples;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -30993,6 +31179,7 @@ function mergeSelectedAgentUnits(units) {
|
|||||||
const mergedModels = Array.from(modelMap.values())
|
const mergedModels = Array.from(modelMap.values())
|
||||||
.map((acc) => {
|
.map((acc) => {
|
||||||
const promptTok = acc.inputTokens + acc.cacheReadTokens;
|
const promptTok = acc.inputTokens + acc.cacheReadTokens;
|
||||||
|
const rawAvgTps = acc._speedSeconds > 0 ? acc._speedTokens / acc._speedSeconds : null;
|
||||||
return {
|
return {
|
||||||
label: acc.label,
|
label: acc.label,
|
||||||
shortName: acc.shortName,
|
shortName: acc.shortName,
|
||||||
@@ -31008,10 +31195,22 @@ function mergeSelectedAgentUnits(units) {
|
|||||||
totalTokens: acc.totalTokens,
|
totalTokens: acc.totalTokens,
|
||||||
costUsd: +acc.costUsd.toFixed(6),
|
costUsd: +acc.costUsd.toFixed(6),
|
||||||
unpricedCalls: acc.unpricedCalls,
|
unpricedCalls: acc.unpricedCalls,
|
||||||
avgTokPerSec:
|
avgTokPerSec: rawAvgTps !== null ? +rawAvgTps.toFixed(1) : null,
|
||||||
acc._speedWeight > 0 ? +(acc._speedWeightedSum / acc._speedWeight).toFixed(1) : null,
|
|
||||||
avgTtftSec:
|
avgTtftSec:
|
||||||
acc._ttftWeight > 0 ? +(acc._ttftWeightedSum / acc._ttftWeight).toFixed(1) : null,
|
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,
|
cacheHitPct: promptTok > 0 ? +((acc.cacheReadTokens / promptTok) * 100).toFixed(1) : 0,
|
||||||
...(acc.anomalyCount > 0
|
...(acc.anomalyCount > 0
|
||||||
? {
|
? {
|
||||||
@@ -32946,7 +33145,7 @@ const StepsDetailView = defineComponent({
|
|||||||
};
|
};
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
return { StepsDetailView };
|
return { mergeSelectedAgentUnits, StepsDetailView };
|
||||||
})();
|
})();
|
||||||
|
|
||||||
// --- src/views/SettingsView.js ---
|
// --- src/views/SettingsView.js ---
|
||||||
@@ -36390,6 +36589,9 @@ function mountWindowOverlay() {
|
|||||||
window.removeEventListener?.('popstate', onPopState);
|
window.removeEventListener?.('popstate', onPopState);
|
||||||
navigator?.windowControlsOverlay?.removeEventListener?.('geometrychange', onWindowResize);
|
navigator?.windowControlsOverlay?.removeEventListener?.('geometrychange', onWindowResize);
|
||||||
restorePatchedActionToolbar();
|
restorePatchedActionToolbar();
|
||||||
|
try {
|
||||||
|
multiRunningWidget.destroy();
|
||||||
|
} catch {}
|
||||||
try {
|
try {
|
||||||
hoverWidgetHost.destroy();
|
hoverWidgetHost.destroy();
|
||||||
} catch {}
|
} catch {}
|
||||||
|
|||||||
@@ -103,7 +103,7 @@ export async function handleAccountCredentialAction(data, {
|
|||||||
if (!['list', 'save', 'capture', 'switch', 'remove', 'quota'].includes(action)) return { error: 'invalidCredential' };
|
if (!['list', 'save', 'capture', 'switch', 'remove', 'quota'].includes(action)) return { error: 'invalidCredential' };
|
||||||
const email = normalizeAccountEmail(data?.email);
|
const email = normalizeAccountEmail(data?.email);
|
||||||
if (['switch', 'remove', 'quota'].includes(action) && !email) return { error: 'invalidEmail' };
|
if (['switch', 'remove', 'quota'].includes(action) && !email) return { error: 'invalidEmail' };
|
||||||
const gemini = join(homedir(), '.gemini');
|
const gemini = String(process.env.ANTIGRAVITY_GEMINI_DIR || '').trim() || join(homedir(), '.gemini');
|
||||||
const config = {
|
const config = {
|
||||||
target: 'gemini:antigravity',
|
target: 'gemini:antigravity',
|
||||||
vault: join(process.env.LOCALAPPDATA || join(homedir(), 'AppData', 'Local'), 'AntigravityUsageMonitor', 'accounts.dpapi'),
|
vault: join(process.env.LOCALAPPDATA || join(homedir(), 'AppData', 'Local'), 'AntigravityUsageMonitor', 'accounts.dpapi'),
|
||||||
|
|||||||
@@ -92,7 +92,8 @@ function projectDisplayStep(st) {
|
|||||||
const {
|
const {
|
||||||
stepIndex, createdAtMs, isCompactionStep, modelKey, modelShort, modelLabel,
|
stepIndex, createdAtMs, isCompactionStep, modelKey, modelShort, modelLabel,
|
||||||
modelUpstream, responseModel, modelSource, tokPerSec, ttftSec, totalDurationSec,
|
modelUpstream, responseModel, modelSource, tokPerSec, ttftSec, totalDurationSec,
|
||||||
streamDurationSec, selectedSpeedReason, anomaly, anomalySig, contextTokens, inputTokens, cacheReadTokens,
|
nativeStreamSec, thinkingDurationSec, hasToolCalls, selectedSpeedReason, anomaly, anomalySig,
|
||||||
|
contextTokens, inputTokens, cacheReadTokens,
|
||||||
outputTokens, thinkingTokens, responseTokens, cacheHitPct, costUsd, inCostUsd,
|
outputTokens, thinkingTokens, responseTokens, cacheHitPct, costUsd, inCostUsd,
|
||||||
cacheCostUsd, outCostUsd, agentId, agentCascadeId, agentKind, agentOrdinal,
|
cacheCostUsd, outCostUsd, agentId, agentCascadeId, agentKind, agentOrdinal,
|
||||||
agentCustomRole, agentLabel, agentBadge, agentRole, agentIndex, isSubagent,
|
agentCustomRole, agentLabel, agentBadge, agentRole, agentIndex, isSubagent,
|
||||||
@@ -104,7 +105,7 @@ function projectDisplayStep(st) {
|
|||||||
return {
|
return {
|
||||||
stepIndex, createdAtMs, isCompactionStep, modelKey, modelShort, modelLabel,
|
stepIndex, createdAtMs, isCompactionStep, modelKey, modelShort, modelLabel,
|
||||||
modelUpstream, responseModel, modelSource, tokPerSec, ttftSec, totalDurationSec,
|
modelUpstream, responseModel, modelSource, tokPerSec, ttftSec, totalDurationSec,
|
||||||
streamDurationSec, selectedSpeedReason,
|
nativeStreamSec, thinkingDurationSec, hasToolCalls, selectedSpeedReason,
|
||||||
...(anomaly ? { anomaly, anomalySig } : {}),
|
...(anomaly ? { anomaly, anomalySig } : {}),
|
||||||
contextTokens, inputTokens, cacheReadTokens,
|
contextTokens, inputTokens, cacheReadTokens,
|
||||||
outputTokens, thinkingTokens, responseTokens, cacheHitPct, costUsd, inCostUsd,
|
outputTokens, thinkingTokens, responseTokens, cacheHitPct, costUsd, inCostUsd,
|
||||||
|
|||||||
@@ -4,11 +4,11 @@
|
|||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
<title>用量监控</title>
|
<title>用量监控</title>
|
||||||
<link rel="stylesheet" href="/styles.css?v=1795351786040">
|
<link rel="stylesheet" href="/styles.css?v=1795356783419">
|
||||||
<script src="/preload.js"></script>
|
<script src="/preload.js"></script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div id="app-root"></div>
|
<div id="app-root"></div>
|
||||||
<script src="/app.js?v=1795351786040"></script>
|
<script src="/app.js?v=1795356783419"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -2921,6 +2921,9 @@ export function mountWindowOverlay() {
|
|||||||
window.removeEventListener?.('popstate', onPopState);
|
window.removeEventListener?.('popstate', onPopState);
|
||||||
navigator?.windowControlsOverlay?.removeEventListener?.('geometrychange', onWindowResize);
|
navigator?.windowControlsOverlay?.removeEventListener?.('geometrychange', onWindowResize);
|
||||||
restorePatchedActionToolbar();
|
restorePatchedActionToolbar();
|
||||||
|
try {
|
||||||
|
multiRunningWidget.destroy();
|
||||||
|
} catch {}
|
||||||
try {
|
try {
|
||||||
hoverWidgetHost.destroy();
|
hoverWidgetHost.destroy();
|
||||||
} catch {}
|
} catch {}
|
||||||
|
|||||||
@@ -577,7 +577,7 @@ export const SessionMigrationCard = defineComponent({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
listScrollbar?.methods?.refresh?.();
|
listScrollbar?.refresh?.();
|
||||||
|
|
||||||
patchAttr(migrateBtn, 'disabled', isMigrating || selectedIds.size === 0 || !targetClient);
|
patchAttr(migrateBtn, 'disabled', isMigrating || selectedIds.size === 0 || !targetClient);
|
||||||
patchText(
|
patchText(
|
||||||
|
|||||||
@@ -14,9 +14,18 @@ import {
|
|||||||
positionAnchoredPopup,
|
positionAnchoredPopup,
|
||||||
} from '../../core/domPatch.js';
|
} from '../../core/domPatch.js';
|
||||||
import { formatCompactDateTime } from '../../core/formatters.js';
|
import { formatCompactDateTime } from '../../core/formatters.js';
|
||||||
|
import { i18nStore, t } from '../../i18n/index.js';
|
||||||
import { createSvgIcon } from '../../icons/SvgIcon.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) {
|
function buildCalendarDays(viewYear, viewMonth, selectedDate) {
|
||||||
const firstDay = new Date(viewYear, viewMonth, 1);
|
const firstDay = new Date(viewYear, viewMonth, 1);
|
||||||
@@ -77,7 +86,7 @@ export const CustomDateTimePicker = defineComponent({
|
|||||||
{
|
{
|
||||||
type: 'button',
|
type: 'button',
|
||||||
className: 'icon-btn',
|
className: 'icon-btn',
|
||||||
'aria-label': '上个月',
|
'aria-label': t('ui.dt.prevMonth'),
|
||||||
onClick: (e) => {
|
onClick: (e) => {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
viewMonth -= 1;
|
viewMonth -= 1;
|
||||||
@@ -96,7 +105,7 @@ export const CustomDateTimePicker = defineComponent({
|
|||||||
{
|
{
|
||||||
type: 'button',
|
type: 'button',
|
||||||
className: 'icon-btn',
|
className: 'icon-btn',
|
||||||
'aria-label': '下个月',
|
'aria-label': t('ui.dt.nextMonth'),
|
||||||
onClick: (e) => {
|
onClick: (e) => {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
viewMonth += 1;
|
viewMonth += 1;
|
||||||
@@ -112,11 +121,10 @@ export const CustomDateTimePicker = defineComponent({
|
|||||||
|
|
||||||
const navBar = h('div', { className: 'dt-nav' }, [prevMonthBtn, monthTitle, nextMonthBtn]);
|
const navBar = h('div', { className: 'dt-nav' }, [prevMonthBtn, monthTitle, nextMonthBtn]);
|
||||||
|
|
||||||
const weekdayRow = h(
|
const weekdaySpans = WEEKDAY_KEYS.map((key) =>
|
||||||
'div',
|
h('span', { className: 'dt-weekday', text: t(key) })
|
||||||
{ className: 'dt-weekdays' },
|
|
||||||
WEEKDAYS.map((w) => h('span', { className: 'dt-weekday', text: w }))
|
|
||||||
);
|
);
|
||||||
|
const weekdayRow = h('div', { className: 'dt-weekdays' }, weekdaySpans);
|
||||||
|
|
||||||
const daysGrid = h('div', { className: 'dt-days' });
|
const daysGrid = h('div', { className: 'dt-days' });
|
||||||
|
|
||||||
@@ -136,8 +144,9 @@ export const CustomDateTimePicker = defineComponent({
|
|||||||
emit('update:modelValue', nextMs);
|
emit('update:modelValue', nextMs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const hourMinLabelEl = h('span', { className: 'text-muted', text: t('ui.dt.hourMinute') });
|
||||||
const timeRow = h('div', { className: 'dt-time-row' }, [
|
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-time-controls' }, [
|
||||||
h('div', { className: 'dt-mini-step' }, [
|
h('div', { className: 'dt-mini-step' }, [
|
||||||
h('button', {
|
h('button', {
|
||||||
@@ -306,6 +315,25 @@ export const CustomDateTimePicker = defineComponent({
|
|||||||
onCleanup(() => setRepositionListeners(false));
|
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();
|
syncDisplay();
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|||||||
@@ -6,11 +6,12 @@
|
|||||||
|
|
||||||
import { defineComponent } from '../../core/component.js';
|
import { defineComponent } from '../../core/component.js';
|
||||||
import { h, patchAttr } from '../../core/domPatch.js';
|
import { h, patchAttr } from '../../core/domPatch.js';
|
||||||
|
import { i18nStore, t } from '../../i18n/index.js';
|
||||||
import { createSvgIcon } from '../../icons/SvgIcon.js';
|
import { createSvgIcon } from '../../icons/SvgIcon.js';
|
||||||
|
|
||||||
export const CustomNumberInput = defineComponent({
|
export const CustomNumberInput = defineComponent({
|
||||||
name: 'CustomNumberInput',
|
name: 'CustomNumberInput',
|
||||||
setup({ getProps, setProps, emit }) {
|
setup({ getProps, setProps, emit, onCleanup }) {
|
||||||
function clampValue(raw) {
|
function clampValue(raw) {
|
||||||
const { min = -Infinity, max = Infinity, precision = 0 } = getProps();
|
const { min = -Infinity, max = Infinity, precision = 0 } = getProps();
|
||||||
const num = Number(raw);
|
const num = Number(raw);
|
||||||
@@ -37,7 +38,7 @@ export const CustomNumberInput = defineComponent({
|
|||||||
{
|
{
|
||||||
type: 'button',
|
type: 'button',
|
||||||
className: 'num-step-btn',
|
className: 'num-step-btn',
|
||||||
'aria-label': '减少数值',
|
'aria-label': t('ui.num.decrease'),
|
||||||
onClick: (e) => {
|
onClick: (e) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
applyStep(-1, e.shiftKey ? 10 : 1);
|
applyStep(-1, e.shiftKey ? 10 : 1);
|
||||||
@@ -51,7 +52,7 @@ export const CustomNumberInput = defineComponent({
|
|||||||
{
|
{
|
||||||
type: 'button',
|
type: 'button',
|
||||||
className: 'num-step-btn',
|
className: 'num-step-btn',
|
||||||
'aria-label': '增加数值',
|
'aria-label': t('ui.num.increase'),
|
||||||
onClick: (e) => {
|
onClick: (e) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
applyStep(1, e.shiftKey ? 10 : 1);
|
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 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();
|
syncFieldDisplay();
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
|
|
||||||
import { defineComponent } from '../../core/component.js';
|
import { defineComponent } from '../../core/component.js';
|
||||||
import { h, patchAttr, patchClasses, patchStyleVar, patchText } from '../../core/domPatch.js';
|
import { h, patchAttr, patchClasses, patchStyleVar, patchText } from '../../core/domPatch.js';
|
||||||
|
import { i18nStore, t } from '../../i18n/index.js';
|
||||||
|
|
||||||
export const SegmentedControl = defineComponent({
|
export const SegmentedControl = defineComponent({
|
||||||
name: 'SegmentedControl',
|
name: 'SegmentedControl',
|
||||||
@@ -17,10 +18,18 @@ export const SegmentedControl = defineComponent({
|
|||||||
{
|
{
|
||||||
className: 'segmented',
|
className: 'segmented',
|
||||||
role: 'group',
|
role: 'group',
|
||||||
'aria-label': getProps().ariaLabel || '分段切换器',
|
'aria-label': getProps().ariaLabel || t('ui.seg.defaultAria'),
|
||||||
},
|
},
|
||||||
[gliderEl]
|
[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();
|
const btnMap = new Map();
|
||||||
let orderedBtns = [];
|
let orderedBtns = [];
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ import {
|
|||||||
resolveModelDisplayInfo,
|
resolveModelDisplayInfo,
|
||||||
speedReasonText,
|
speedReasonText,
|
||||||
} from '../../core/formatters.js';
|
} from '../../core/formatters.js';
|
||||||
|
import { getStepSelectionKey } from '../../core/stepInspector.js';
|
||||||
import { getEffectiveLocale, t } from '../../i18n/index.js';
|
import { getEffectiveLocale, t } from '../../i18n/index.js';
|
||||||
import { createSvgIcon, patchSvgIcon } from '../../icons/SvgIcon.js';
|
import { createSvgIcon, patchSvgIcon } from '../../icons/SvgIcon.js';
|
||||||
import {
|
import {
|
||||||
@@ -722,9 +723,11 @@ export const StepTableWidget = defineComponent({
|
|||||||
}
|
}
|
||||||
|
|
||||||
function getStepRowIdentity(st, fallbackCascadeId) {
|
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 stepNum = Number(st?.stepIndex);
|
||||||
const rowKey = `${agentKey}-${st?.stepIndex}`;
|
const rowKey = getStepSelectionKey(st, fallbackCascadeId);
|
||||||
return { agentKey, stepNum, rowKey };
|
return { agentKey, stepNum, rowKey };
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1100,7 +1103,7 @@ export const StepTableWidget = defineComponent({
|
|||||||
logicalIdx: idx,
|
logicalIdx: idx,
|
||||||
isStripeEven: (idx & 1) === 1,
|
isStripeEven: (idx & 1) === 1,
|
||||||
hasReason: Boolean(hasReasonFlags && hasReasonFlags[idx]),
|
hasReason: Boolean(hasReasonFlags && hasReasonFlags[idx]),
|
||||||
rowKey: `${st.agentCascadeId || cascadeId || 'conv'}-${st.stepIndex}`,
|
rowKey: getStepSelectionKey(st, cascadeId),
|
||||||
hasTurn,
|
hasTurn,
|
||||||
hasUp,
|
hasUp,
|
||||||
hasDown,
|
hasDown,
|
||||||
|
|||||||
@@ -829,14 +829,30 @@ export function mergeModelsByDisplayName(models = [], settings = {}, options = {
|
|||||||
const speedSampleCount = Math.max(0, Number(m.speedSummary?.sampleCount || 0));
|
const speedSampleCount = Math.max(0, Number(m.speedSummary?.sampleCount || 0));
|
||||||
const speedExcludedCount = Math.max(0, Number(m.speedSummary?.excludedCount || 0));
|
const speedExcludedCount = Math.max(0, Number(m.speedSummary?.excludedCount || 0));
|
||||||
const speedWeight = speedSampleCount > 0 ? speedSampleCount : Math.max(1, outTok || calls || 1);
|
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 ttftSampleCount = Math.max(0, Number(m.ttftSampleCount || 0));
|
||||||
const ttftWeight = ttftSampleCount > 0 ? ttftSampleCount : Math.max(1, calls || 1);
|
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);
|
let acc = byDisplay.get(key);
|
||||||
if (!acc) {
|
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 = {
|
acc = {
|
||||||
baseItem: m,
|
baseItem: m,
|
||||||
mergedCount: 1,
|
mergedCount: 1,
|
||||||
@@ -856,10 +872,15 @@ export function mergeModelsByDisplayName(models = [], settings = {}, options = {
|
|||||||
totalTokens: totTok,
|
totalTokens: totTok,
|
||||||
costUsd,
|
costUsd,
|
||||||
unpricedCalls,
|
unpricedCalls,
|
||||||
|
hasAnySpeedSummary: Boolean(m.speedSummary),
|
||||||
|
allSpeedExact: !hasSpeed || hasExactSpeedSummary,
|
||||||
|
speedTokens: hasExactSpeedSummary ? rawSpeedTokens : 0,
|
||||||
|
speedSeconds: hasExactSpeedSummary ? rawSpeedSeconds : 0,
|
||||||
speedWeightedSum: hasSpeed ? Number(m.avgTokPerSec) * speedWeight : 0,
|
speedWeightedSum: hasSpeed ? Number(m.avgTokPerSec) * speedWeight : 0,
|
||||||
speedWeight: hasSpeed ? speedWeight : 0,
|
speedWeight: hasSpeed ? speedWeight : 0,
|
||||||
speedSampleCount,
|
speedSampleCount,
|
||||||
speedExcludedCount,
|
speedExcludedCount,
|
||||||
|
speedExcludedReasons: initExcludedReasons,
|
||||||
ttftWeightedSum: hasTtft ? Number(m.avgTtftSec) * ttftWeight : 0,
|
ttftWeightedSum: hasTtft ? Number(m.avgTtftSec) * ttftWeight : 0,
|
||||||
ttftWeight: hasTtft ? ttftWeight : 0,
|
ttftWeight: hasTtft ? ttftWeight : 0,
|
||||||
ttftSampleCount,
|
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) {
|
if (hasSpeed) {
|
||||||
acc.speedWeightedSum += Number(m.avgTokPerSec) * speedWeight;
|
acc.speedWeightedSum += Number(m.avgTokPerSec) * speedWeight;
|
||||||
acc.speedWeight += speedWeight;
|
acc.speedWeight += speedWeight;
|
||||||
}
|
}
|
||||||
acc.speedSampleCount += speedSampleCount;
|
acc.speedSampleCount += speedSampleCount;
|
||||||
acc.speedExcludedCount += speedExcludedCount;
|
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) {
|
if (hasTtft) {
|
||||||
acc.ttftWeightedSum += Number(m.avgTtftSec) * ttftWeight;
|
acc.ttftWeightedSum += Number(m.avgTtftSec) * ttftWeight;
|
||||||
@@ -933,8 +966,13 @@ export function mergeModelsByDisplayName(models = [], settings = {}, options = {
|
|||||||
}
|
}
|
||||||
const promptTok = acc.inputTokens + acc.cacheReadTokens;
|
const promptTok = acc.inputTokens + acc.cacheReadTokens;
|
||||||
const cacheHitPct = promptTok > 0 ? +((acc.cacheReadTokens / promptTok) * 100).toFixed(1) : 0;
|
const cacheHitPct = promptTok > 0 ? +((acc.cacheReadTokens / promptTok) * 100).toFixed(1) : 0;
|
||||||
const avgTokPerSec =
|
const rawAvgTps =
|
||||||
acc.speedWeight > 0 ? +(acc.speedWeightedSum / acc.speedWeight).toFixed(1) : null;
|
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 =
|
const avgTtftSec =
|
||||||
acc.ttftWeight > 0 ? +(acc.ttftWeightedSum / acc.ttftWeight).toFixed(1) : null;
|
acc.ttftWeight > 0 ? +(acc.ttftWeightedSum / acc.ttftWeight).toFixed(1) : null;
|
||||||
const upstreamModels = Array.from(acc.upstreamSet);
|
const upstreamModels = Array.from(acc.upstreamSet);
|
||||||
@@ -967,12 +1005,15 @@ export function mergeModelsByDisplayName(models = [], settings = {}, options = {
|
|||||||
anomalyByKind: acc.anomalyByKind,
|
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,
|
sampleCount: acc.speedSampleCount,
|
||||||
excludedCount: acc.speedExcludedCount,
|
excludedCount: acc.speedExcludedCount,
|
||||||
avgTokPerSec,
|
excludedReasons: acc.speedExcludedReasons,
|
||||||
|
avgTokPerSec: rawAvgTps,
|
||||||
}
|
}
|
||||||
: undefined,
|
: undefined,
|
||||||
upstreamModels,
|
upstreamModels,
|
||||||
|
|||||||
@@ -172,7 +172,8 @@ function summarizeStepsForExport(list, displaySettings) {
|
|||||||
let sumCost = 0;
|
let sumCost = 0;
|
||||||
let sumDuration = 0;
|
let sumDuration = 0;
|
||||||
let maxContext = 0;
|
let maxContext = 0;
|
||||||
let tpsSum = 0;
|
let tpsTokSum = 0;
|
||||||
|
let tpsSecSum = 0;
|
||||||
let tpsCnt = 0;
|
let tpsCnt = 0;
|
||||||
let ttftSum = 0;
|
let ttftSum = 0;
|
||||||
let ttftCnt = 0;
|
let ttftCnt = 0;
|
||||||
@@ -194,7 +195,8 @@ function summarizeStepsForExport(list, displaySettings) {
|
|||||||
: Math.max(0, outTok - thinkTok);
|
: Math.max(0, outTok - thinkTok);
|
||||||
const ctxTok = Math.max(0, Number(st.contextTokens || inTok + cacheTok + outTok));
|
const ctxTok = Math.max(0, Number(st.contextTokens || inTok + cacheTok + outTok));
|
||||||
const cost = Number(st.costUsd || 0);
|
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;
|
sumIn += inTok;
|
||||||
sumCache += cacheTok;
|
sumCache += cacheTok;
|
||||||
@@ -206,11 +208,21 @@ function summarizeStepsForExport(list, displaySettings) {
|
|||||||
if (Number.isFinite(dur) && dur > 0) sumDuration += dur;
|
if (Number.isFinite(dur) && dur > 0) sumDuration += dur;
|
||||||
|
|
||||||
const validTps =
|
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 =
|
const validTtft =
|
||||||
!st.isCompactionStep && Number.isFinite(Number(st.ttftSec)) && Number(st.ttftSec) >= 0;
|
!st.isCompactionStep && Number.isFinite(Number(st.ttftSec)) && Number(st.ttftSec) >= 0;
|
||||||
if (validTps) {
|
if (validTps && stepSpeedSec > 0) {
|
||||||
tpsSum += Number(st.tokPerSec);
|
tpsTokSum += outTok;
|
||||||
|
tpsSecSum += stepSpeedSec;
|
||||||
tpsCnt += 1;
|
tpsCnt += 1;
|
||||||
}
|
}
|
||||||
if (validTtft) {
|
if (validTtft) {
|
||||||
@@ -235,7 +247,8 @@ function summarizeStepsForExport(list, displaySettings) {
|
|||||||
cacheTok: 0,
|
cacheTok: 0,
|
||||||
outTok: 0,
|
outTok: 0,
|
||||||
cost: 0,
|
cost: 0,
|
||||||
tpsSum: 0,
|
tpsTokSum: 0,
|
||||||
|
tpsSecSum: 0,
|
||||||
tpsCnt: 0,
|
tpsCnt: 0,
|
||||||
ttftSum: 0,
|
ttftSum: 0,
|
||||||
ttftCnt: 0,
|
ttftCnt: 0,
|
||||||
@@ -247,8 +260,9 @@ function summarizeStepsForExport(list, displaySettings) {
|
|||||||
mAcc.cacheTok += cacheTok;
|
mAcc.cacheTok += cacheTok;
|
||||||
mAcc.outTok += outTok;
|
mAcc.outTok += outTok;
|
||||||
if (Number.isFinite(cost) && cost > 0) mAcc.cost += cost;
|
if (Number.isFinite(cost) && cost > 0) mAcc.cost += cost;
|
||||||
if (validTps) {
|
if (validTps && stepSpeedSec > 0) {
|
||||||
mAcc.tpsSum += Number(st.tokPerSec);
|
mAcc.tpsTokSum += outTok;
|
||||||
|
mAcc.tpsSecSum += stepSpeedSec;
|
||||||
mAcc.tpsCnt += 1;
|
mAcc.tpsCnt += 1;
|
||||||
}
|
}
|
||||||
if (validTtft) {
|
if (validTtft) {
|
||||||
@@ -272,7 +286,8 @@ function summarizeStepsForExport(list, displaySettings) {
|
|||||||
sumCost,
|
sumCost,
|
||||||
sumDuration,
|
sumDuration,
|
||||||
maxContext,
|
maxContext,
|
||||||
tpsSum,
|
tpsTokSum,
|
||||||
|
tpsSecSum,
|
||||||
tpsCnt,
|
tpsCnt,
|
||||||
ttftSum,
|
ttftSum,
|
||||||
ttftCnt,
|
ttftCnt,
|
||||||
@@ -455,8 +470,9 @@ export function buildStepsCsv(steps, { displaySettings = {}, includeBom = true }
|
|||||||
st.ttftSec != null && Number.isFinite(Number(st.ttftSec))
|
st.ttftSec != null && Number.isFinite(Number(st.ttftSec))
|
||||||
? Number(st.ttftSec).toFixed(3)
|
? Number(st.ttftSec).toFixed(3)
|
||||||
: '',
|
: '',
|
||||||
st.durationSec != null && Number.isFinite(Number(st.durationSec))
|
(st.totalDurationSec ?? st.durationSec) != null &&
|
||||||
? Number(st.durationSec).toFixed(3)
|
Number.isFinite(Number(st.totalDurationSec ?? st.durationSec))
|
||||||
|
? Number(st.totalDurationSec ?? st.durationSec).toFixed(3)
|
||||||
: '',
|
: '',
|
||||||
inTok,
|
inTok,
|
||||||
cacheTok,
|
cacheTok,
|
||||||
@@ -523,9 +539,10 @@ export function buildStepsXlsx(
|
|||||||
!st.isCompactionStep && st.ttftSec != null && Number.isFinite(Number(st.ttftSec))
|
!st.isCompactionStep && st.ttftSec != null && Number.isFinite(Number(st.ttftSec))
|
||||||
? Number(st.ttftSec)
|
? Number(st.ttftSec)
|
||||||
: null;
|
: null;
|
||||||
|
const rawDurVal = st.totalDurationSec ?? st.durationSec;
|
||||||
const durVal =
|
const durVal =
|
||||||
st.durationSec != null && Number.isFinite(Number(st.durationSec))
|
rawDurVal != null && Number.isFinite(Number(rawDurVal))
|
||||||
? Number(st.durationSec)
|
? Number(rawDurVal)
|
||||||
: null;
|
: null;
|
||||||
const costVal =
|
const costVal =
|
||||||
st.costUsd != null && Number.isFinite(Number(st.costUsd)) ? Number(st.costUsd) : null;
|
st.costUsd != null && Number.isFinite(Number(st.costUsd)) ? Number(st.costUsd) : null;
|
||||||
@@ -577,7 +594,7 @@ export function buildStepsXlsx(
|
|||||||
? `${agg.compactionCount} compact`
|
? `${agg.compactionCount} compact`
|
||||||
: `含 ${agg.compactionCount} 次压缩`
|
: `含 ${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.ttftCnt > 0 ? +(agg.ttftSum / agg.ttftCnt).toFixed(2) : null,
|
||||||
agg.sumDuration > 0 ? +agg.sumDuration.toFixed(2) : null,
|
agg.sumDuration > 0 ? +agg.sumDuration.toFixed(2) : null,
|
||||||
agg.sumIn,
|
agg.sumIn,
|
||||||
@@ -636,7 +653,7 @@ export function buildStepsXlsx(
|
|||||||
m.outTok,
|
m.outTok,
|
||||||
mTotal,
|
mTotal,
|
||||||
computeCacheHitRatio(m.inTok, m.cacheTok),
|
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.ttftCnt > 0 ? +(m.ttftSum / m.ttftCnt).toFixed(2) : null,
|
||||||
m.cost,
|
m.cost,
|
||||||
];
|
];
|
||||||
@@ -651,7 +668,7 @@ export function buildStepsXlsx(
|
|||||||
agg.sumOut,
|
agg.sumOut,
|
||||||
agg.sumIn + agg.sumCache + agg.sumOut,
|
agg.sumIn + agg.sumCache + agg.sumOut,
|
||||||
computeCacheHitRatio(agg.sumIn, agg.sumCache),
|
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.ttftCnt > 0 ? +(agg.ttftSum / agg.ttftCnt).toFixed(2) : null,
|
||||||
agg.sumCost,
|
agg.sumCost,
|
||||||
],
|
],
|
||||||
@@ -695,7 +712,8 @@ export function buildStepsMarkdownReport(
|
|||||||
|
|
||||||
const totalTok = agg.sumIn + agg.sumCache + agg.sumOut;
|
const totalTok = agg.sumIn + agg.sumCache + agg.sumOut;
|
||||||
const cacheHitPct = formatPctNumber(computeCacheHitRatio(agg.sumIn, agg.sumCache) * 100);
|
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 avgTtft = agg.ttftCnt > 0 ? formatMetric(agg.ttftSum / agg.ttftCnt, 's') : '—';
|
||||||
const heading = title
|
const heading = title
|
||||||
? `# ${title}`
|
? `# ${title}`
|
||||||
@@ -738,7 +756,8 @@ export function buildStepsMarkdownReport(
|
|||||||
const mCache = formatPctNumber(computeCacheHitRatio(m.inTok, m.cacheTok) * 100, {
|
const mCache = formatPctNumber(computeCacheHitRatio(m.inTok, m.cacheTok) * 100, {
|
||||||
withSymbol: true,
|
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(
|
lines.push(
|
||||||
`| ${escapeMdCell(m.label)} | ${m.calls} | ${formatTokensPrecise(mTotal)} | ${mCache} | ${mTps} | ${formatUsd(m.cost, { precise: m.cost > 0 && m.cost < 0.1 })} |`
|
`| ${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 mOut = 0;
|
||||||
let mTot = 0;
|
let mTot = 0;
|
||||||
let mCost = 0;
|
let mCost = 0;
|
||||||
let tpsWeighted = 0;
|
let tpsTokSum = 0;
|
||||||
let tpsWeight = 0;
|
let tpsSecSum = 0;
|
||||||
const modelRows = models.map((m, idx) => {
|
const modelRows = models.map((m, idx) => {
|
||||||
const calls = Math.max(0, Number(m.calls || 0));
|
const calls = Math.max(0, Number(m.calls || 0));
|
||||||
const inTok = Math.max(0, Number(m.inputTokens || 0));
|
const inTok = Math.max(0, Number(m.inputTokens || 0));
|
||||||
@@ -1072,10 +1091,20 @@ export function buildConsumptionXlsx(
|
|||||||
mOut += outTok;
|
mOut += outTok;
|
||||||
mTot += totTok;
|
mTot += totTok;
|
||||||
mCost += cost;
|
mCost += cost;
|
||||||
if (tps != null) {
|
const rawSpeedTok = Number(m.speedSummary?.tokens);
|
||||||
const w = Math.max(1, outTok || calls);
|
const rawSpeedSec = Number(m.speedSummary?.seconds);
|
||||||
tpsWeighted += tps * w;
|
if (
|
||||||
tpsWeight += w;
|
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 [
|
return [
|
||||||
idx + 1,
|
idx + 1,
|
||||||
@@ -1101,7 +1130,7 @@ export function buildConsumptionXlsx(
|
|||||||
mOut,
|
mOut,
|
||||||
mTot,
|
mTot,
|
||||||
computeCacheHitRatio(mIn, mCache),
|
computeCacheHitRatio(mIn, mCache),
|
||||||
tpsWeight > 0 ? +(tpsWeighted / tpsWeight).toFixed(1) : null,
|
tpsSecSum > 0 ? +(tpsTokSum / tpsSecSum).toFixed(1) : null,
|
||||||
mCost,
|
mCost,
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -30,7 +30,8 @@ export const STEP_SLOW_TTFT_MIN_SEC = 30;
|
|||||||
*/
|
*/
|
||||||
export function getStepSelectionKey(st, fallbackCascadeId = '') {
|
export function getStepSelectionKey(st, fallbackCascadeId = '') {
|
||||||
if (!st || typeof st !== 'object') return '';
|
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}`;
|
return `${agentKey}-${st.stepIndex}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -125,6 +126,11 @@ export function filterStepsBySearchAndChip(
|
|||||||
if (rawTerms.length > 0) {
|
if (rawTerms.length > 0) {
|
||||||
const modelInfo = resolveModelDisplayInfo(st, displaySettings);
|
const modelInfo = resolveModelDisplayInfo(st, displaySettings);
|
||||||
const anomalyKinds = st.anomaly?.kinds ? Object.keys(st.anomaly.kinds).join(' ') : '';
|
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)
|
const anomalyItemsText = Array.isArray(st.anomaly?.items)
|
||||||
? st.anomaly.items
|
? st.anomaly.items
|
||||||
.map((it) => `${it?.kind || ''} ${it?.httpStatus || ''} ${it?.detail || ''}`)
|
.map((it) => `${it?.kind || ''} ${it?.httpStatus || ''} ${it?.detail || ''}`)
|
||||||
@@ -137,6 +143,9 @@ export function filterStepsBySearchAndChip(
|
|||||||
modelInfo.title,
|
modelInfo.title,
|
||||||
st.modelLabel || '',
|
st.modelLabel || '',
|
||||||
st.modelShort || '',
|
st.modelShort || '',
|
||||||
|
st.modelKey || '',
|
||||||
|
st.modelUpstream || '',
|
||||||
|
st.responseModel || '',
|
||||||
st.rawModelId || '',
|
st.rawModelId || '',
|
||||||
st.upstreamName || '',
|
st.upstreamName || '',
|
||||||
st.turnPrompt || '',
|
st.turnPrompt || '',
|
||||||
@@ -146,6 +155,7 @@ export function filterStepsBySearchAndChip(
|
|||||||
st.agentBadge || '',
|
st.agentBadge || '',
|
||||||
st.isCompactionStep ? 'compaction 压缩' : '',
|
st.isCompactionStep ? 'compaction 压缩' : '',
|
||||||
anomalyKinds,
|
anomalyKinds,
|
||||||
|
anomalyEventsText,
|
||||||
anomalyItemsText,
|
anomalyItemsText,
|
||||||
]
|
]
|
||||||
.join(' ')
|
.join(' ')
|
||||||
@@ -210,15 +220,15 @@ export function findPrevAgentContextTokens(allSteps, targetStep) {
|
|||||||
*/
|
*/
|
||||||
export function computeStepTimingWaterfall(st) {
|
export function computeStepTimingWaterfall(st) {
|
||||||
if (!st || typeof st !== 'object') return null;
|
if (!st || typeof st !== 'object') return null;
|
||||||
|
const rawTtft = st.ttftSec ?? st.nativeTtftSec;
|
||||||
const ttft =
|
const ttft =
|
||||||
st.ttftSec != null && Number.isFinite(Number(st.ttftSec)) && Number(st.ttftSec) >= 0
|
rawTtft != null && Number.isFinite(Number(rawTtft)) && Number(rawTtft) >= 0
|
||||||
? Number(st.ttftSec)
|
? Number(rawTtft)
|
||||||
: 0;
|
: 0;
|
||||||
|
const rawStream = st.nativeStreamSec ?? st.streamDurationSec;
|
||||||
const stream =
|
const stream =
|
||||||
st.streamDurationSec != null &&
|
rawStream != null && Number.isFinite(Number(rawStream)) && Number(rawStream) >= 0
|
||||||
Number.isFinite(Number(st.streamDurationSec)) &&
|
? Number(rawStream)
|
||||||
Number(st.streamDurationSec) >= 0
|
|
||||||
? Number(st.streamDurationSec)
|
|
||||||
: 0;
|
: 0;
|
||||||
const thinking =
|
const thinking =
|
||||||
st.thinkingDurationSec != null &&
|
st.thinkingDurationSec != null &&
|
||||||
@@ -226,9 +236,10 @@ export function computeStepTimingWaterfall(st) {
|
|||||||
Number(st.thinkingDurationSec) >= 0
|
Number(st.thinkingDurationSec) >= 0
|
||||||
? Number(st.thinkingDurationSec)
|
? Number(st.thinkingDurationSec)
|
||||||
: 0;
|
: 0;
|
||||||
|
const rawDur = st.totalDurationSec ?? st.durationSec;
|
||||||
const rawTotal =
|
const rawTotal =
|
||||||
st.durationSec != null && Number.isFinite(Number(st.durationSec)) && Number(st.durationSec) > 0
|
rawDur != null && Number.isFinite(Number(rawDur)) && Number(rawDur) > 0
|
||||||
? Number(st.durationSec)
|
? Number(rawDur)
|
||||||
: ttft + stream;
|
: ttft + stream;
|
||||||
const totalSec = Math.max(rawTotal, ttft + stream);
|
const totalSec = Math.max(rawTotal, ttft + stream);
|
||||||
if (!(totalSec > 0)) return null;
|
if (!(totalSec > 0)) return null;
|
||||||
|
|||||||
@@ -873,4 +873,19 @@ export const I18N_MESSAGES_EN_US = Object.freeze({
|
|||||||
'chart.trend.hmActivePeak': 'Active {active}/{total}d · Peak {label} · {tokens}',
|
'chart.trend.hmActivePeak': 'Active {active}/{total}d · Peak {label} · {tokens}',
|
||||||
'chart.trend.hmActiveZero': 'Active 0/{total}d',
|
'chart.trend.hmActiveZero': 'Active 0/{total}d',
|
||||||
'chart.trend.peakPill': 'Peak {label} · {tokens}',
|
'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',
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -873,4 +873,19 @@ export const I18N_MESSAGES_ZH_CN = Object.freeze({
|
|||||||
'chart.trend.hmActivePeak': '活跃 {active}/{total} 天 · 峰值 {label} · {tokens}',
|
'chart.trend.hmActivePeak': '活跃 {active}/{total} 天 · 峰值 {label} · {tokens}',
|
||||||
'chart.trend.hmActiveZero': '活跃 0/{total} 天',
|
'chart.trend.hmActiveZero': '活跃 0/{total} 天',
|
||||||
'chart.trend.peakPill': '峰值 {label} · {tokens}',
|
'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': '分段切换器',
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -78,7 +78,7 @@ import { SegmentedControl } from '../components/ui/SegmentedControl.js';
|
|||||||
import { StepTableWidget } from '../components/widgets/StepTableWidget.js';
|
import { StepTableWidget } from '../components/widgets/StepTableWidget.js';
|
||||||
import { sortStepsByColumn } from '../registries/stepColumnRegistry.js';
|
import { sortStepsByColumn } from '../registries/stepColumnRegistry.js';
|
||||||
|
|
||||||
function mergeSelectedAgentUnits(units) {
|
export function mergeSelectedAgentUnits(units) {
|
||||||
const combinedSteps = [];
|
const combinedSteps = [];
|
||||||
const modelMap = new Map();
|
const modelMap = new Map();
|
||||||
|
|
||||||
@@ -115,10 +115,15 @@ function mergeSelectedAgentUnits(units) {
|
|||||||
anomalyDangerCount: 0,
|
anomalyDangerCount: 0,
|
||||||
anomalyTotalDelaySec: 0,
|
anomalyTotalDelaySec: 0,
|
||||||
anomalyByKind: {},
|
anomalyByKind: {},
|
||||||
_speedWeightedSum: 0,
|
_hasAnySpeedSummary: false,
|
||||||
_speedWeight: 0,
|
_speedTokens: 0,
|
||||||
|
_speedSeconds: 0,
|
||||||
|
_speedSampleCount: 0,
|
||||||
|
_speedExcludedCount: 0,
|
||||||
|
_speedExcludedReasons: {},
|
||||||
_ttftWeightedSum: 0,
|
_ttftWeightedSum: 0,
|
||||||
_ttftWeight: 0,
|
_ttftWeight: 0,
|
||||||
|
_ttftSampleCount: 0,
|
||||||
};
|
};
|
||||||
if (acc.upstreamName) acc.upstreamSet.add(acc.upstreamName);
|
if (acc.upstreamName) acc.upstreamSet.add(acc.upstreamName);
|
||||||
modelMap.set(gk, acc);
|
modelMap.set(gk, acc);
|
||||||
@@ -165,19 +170,43 @@ function mergeSelectedAgentUnits(units) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Number.isFinite(Number(m.avgTokPerSec)) && Number(m.avgTokPerSec) > 0) {
|
const rawSpeedTok = Number(m.speedSummary?.tokens);
|
||||||
const w = Math.max(1, outTok || calls || 1);
|
const rawSpeedSec = Number(m.speedSummary?.seconds);
|
||||||
acc._speedWeightedSum += Number(m.avgTokPerSec) * w;
|
if (
|
||||||
acc._speedWeight += w;
|
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 (
|
if (
|
||||||
m.avgTtftSec != null &&
|
m.avgTtftSec != null &&
|
||||||
Number.isFinite(Number(m.avgTtftSec)) &&
|
Number.isFinite(Number(m.avgTtftSec)) &&
|
||||||
Number(m.avgTtftSec) >= 0
|
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._ttftWeightedSum += Number(m.avgTtftSec) * w;
|
||||||
acc._ttftWeight += w;
|
acc._ttftWeight += w;
|
||||||
|
acc._ttftSampleCount += ttftSamples;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -192,6 +221,7 @@ function mergeSelectedAgentUnits(units) {
|
|||||||
const mergedModels = Array.from(modelMap.values())
|
const mergedModels = Array.from(modelMap.values())
|
||||||
.map((acc) => {
|
.map((acc) => {
|
||||||
const promptTok = acc.inputTokens + acc.cacheReadTokens;
|
const promptTok = acc.inputTokens + acc.cacheReadTokens;
|
||||||
|
const rawAvgTps = acc._speedSeconds > 0 ? acc._speedTokens / acc._speedSeconds : null;
|
||||||
return {
|
return {
|
||||||
label: acc.label,
|
label: acc.label,
|
||||||
shortName: acc.shortName,
|
shortName: acc.shortName,
|
||||||
@@ -207,10 +237,22 @@ function mergeSelectedAgentUnits(units) {
|
|||||||
totalTokens: acc.totalTokens,
|
totalTokens: acc.totalTokens,
|
||||||
costUsd: +acc.costUsd.toFixed(6),
|
costUsd: +acc.costUsd.toFixed(6),
|
||||||
unpricedCalls: acc.unpricedCalls,
|
unpricedCalls: acc.unpricedCalls,
|
||||||
avgTokPerSec:
|
avgTokPerSec: rawAvgTps !== null ? +rawAvgTps.toFixed(1) : null,
|
||||||
acc._speedWeight > 0 ? +(acc._speedWeightedSum / acc._speedWeight).toFixed(1) : null,
|
|
||||||
avgTtftSec:
|
avgTtftSec:
|
||||||
acc._ttftWeight > 0 ? +(acc._ttftWeightedSum / acc._ttftWeight).toFixed(1) : null,
|
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,
|
cacheHitPct: promptTok > 0 ? +((acc.cacheReadTokens / promptTok) * 100).toFixed(1) : 0,
|
||||||
...(acc.anomalyCount > 0
|
...(acc.anomalyCount > 0
|
||||||
? {
|
? {
|
||||||
|
|||||||
@@ -2107,3 +2107,412 @@ test('Feature 14: compact vertical ActionMenu replaces export bars, backend expo
|
|||||||
assert.equal(failedRes.mode, 'failed');
|
assert.equal(failedRes.mode, 'failed');
|
||||||
assert.equal(uiStore.getState().toast?.tone, 'warn');
|
assert.equal(uiStore.getState().toast?.tone, 'warn');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('P0 regression: V4 display-projected steps open inspector, preserve waterfall/diagnostics/XLSX duration, match anomaly events, compute harmonic speed, and clean up UI observers/i18n', async (t) => {
|
||||||
|
const { extractModelSteps, summarizeSpeed } = await import('../trajectory-metrics.mjs');
|
||||||
|
const { handleAccountCredentialAction } = await import('../backend/account-switch.mjs');
|
||||||
|
const {
|
||||||
|
getStepSelectionKey,
|
||||||
|
computeStepTimingWaterfall,
|
||||||
|
filterStepsBySearchAndChip,
|
||||||
|
} = await import('../src/core/stepInspector.js');
|
||||||
|
const {
|
||||||
|
buildStepTimingDiagnostic,
|
||||||
|
mergeModelsByDisplayName,
|
||||||
|
} = await import('../src/core/formatters.js');
|
||||||
|
const {
|
||||||
|
buildStepsXlsx,
|
||||||
|
buildStepsCsv,
|
||||||
|
buildStepsMarkdownReport,
|
||||||
|
buildConsumptionXlsx,
|
||||||
|
} = await import('../src/core/reportExporter.js');
|
||||||
|
const { StepsDetailView, mergeSelectedAgentUnits } = await import('../src/views/StepsDetailView.js');
|
||||||
|
const { CustomDateTimePicker } = await import('../src/components/ui/CustomDateTimePicker.js');
|
||||||
|
const { CustomNumberInput } = await import('../src/components/ui/CustomNumberInput.js');
|
||||||
|
const { SegmentedControl } = await import('../src/components/ui/SegmentedControl.js');
|
||||||
|
const { mountWindowOverlay } = await import('../src/components/layout/WindowOverlayShell.js');
|
||||||
|
const { WINDOW_OVERLAY_KEY } = await import('../shared/window-bridge-protocol.mjs');
|
||||||
|
const { uiStore } = await import('../src/store/uiStore.js');
|
||||||
|
const { telemetryStore } = await import('../src/store/telemetryStore.js');
|
||||||
|
const { i18nStore, setI18nLanguage } = await import('../src/i18n/index.js');
|
||||||
|
|
||||||
|
function parseZipEntries(bytes) {
|
||||||
|
const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
||||||
|
const entries = new Map();
|
||||||
|
let pos = 0;
|
||||||
|
while (pos + 30 <= bytes.length && view.getUint32(pos, true) === 0x04034b50) {
|
||||||
|
const compSize = view.getUint32(pos + 18, true);
|
||||||
|
const nameLen = view.getUint16(pos + 26, true);
|
||||||
|
const extraLen = view.getUint16(pos + 28, true);
|
||||||
|
const nameStart = pos + 30;
|
||||||
|
const dataStart = nameStart + nameLen + extraLen;
|
||||||
|
const name = Buffer.from(bytes.subarray(nameStart, nameStart + nameLen)).toString('utf8');
|
||||||
|
const text = Buffer.from(bytes.subarray(dataStart, dataStart + compSize)).toString('utf8');
|
||||||
|
entries.set(name, text);
|
||||||
|
pos = dataStart + compSize;
|
||||||
|
}
|
||||||
|
return entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Extract genuine V4 step with nativeTtftSec, nativeStreamSec, thinkingDurationSec, toolCalls, and retryInfos
|
||||||
|
const rawSteps = [
|
||||||
|
{
|
||||||
|
type: 'CORTEX_STEP_TYPE_USER_INPUT',
|
||||||
|
metadata: { createdAt: '2026-11-22T10:00:00Z' },
|
||||||
|
userInput: { items: [{ text: 'Inspect V4 projected telemetry step' }] },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: 'CORTEX_STEP_TYPE_PLANNER_RESPONSE',
|
||||||
|
status: 'CORTEX_STEP_STATUS_DONE',
|
||||||
|
metadata: {
|
||||||
|
createdAt: '2026-11-22T10:00:01Z',
|
||||||
|
completedAt: '2026-11-22T10:00:11.050Z',
|
||||||
|
generatorModel: 'MODEL_PLACEHOLDER_M37',
|
||||||
|
modelUsage: {
|
||||||
|
model: 'MODEL_PLACEHOLDER_M37',
|
||||||
|
inputTokens: '4000',
|
||||||
|
outputTokens: '200',
|
||||||
|
thinkingTokens: '120',
|
||||||
|
cacheReadInputTokens: '16000',
|
||||||
|
},
|
||||||
|
retryInfos: [
|
||||||
|
{
|
||||||
|
attempt: 1,
|
||||||
|
error: 'HTTP 429 Resource Exhausted UniqueQuotaToken777',
|
||||||
|
retryDelay: '2.5s',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
plannerResponse: {
|
||||||
|
response: 'Completed',
|
||||||
|
thinkingDuration: '8.64s',
|
||||||
|
toolCalls: [{ id: 'tc-1', name: 'read_file' }],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
];
|
||||||
|
const generatorMetadata = [
|
||||||
|
{
|
||||||
|
stepIndices: [1],
|
||||||
|
chatModel: {
|
||||||
|
usage: {
|
||||||
|
model: 'MODEL_PLACEHOLDER_M37',
|
||||||
|
inputTokens: '4000',
|
||||||
|
outputTokens: '200',
|
||||||
|
thinkingOutputTokens: '120',
|
||||||
|
cacheReadTokens: '16000',
|
||||||
|
},
|
||||||
|
timeToFirstToken: '8.32s',
|
||||||
|
streamingDuration: '1.73s',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
];
|
||||||
|
const [extracted] = extractModelSteps(rawSteps, generatorMetadata);
|
||||||
|
const cascadeUuid = '28a876b9-8b93-4dbd-8c0b-3b6101fc481d';
|
||||||
|
const projectedLikeStep = {
|
||||||
|
stepIndex: extracted.stepIndex,
|
||||||
|
createdAtMs: extracted.createdAtMs,
|
||||||
|
isCompactionStep: extracted.isCompactionStep,
|
||||||
|
modelKey: extracted.modelKey,
|
||||||
|
modelShort: '3.1-pro-h',
|
||||||
|
modelLabel: 'Gemini 3.1 Pro (High)',
|
||||||
|
modelUpstream: 'gemini-3.1-pro-high-upstream-id',
|
||||||
|
responseModel: '',
|
||||||
|
modelSource: extracted.modelSource,
|
||||||
|
tokPerSec: +(extracted.outputTokens / extracted.totalDurationSec).toFixed(1),
|
||||||
|
ttftSec: extracted.nativeTtftSec,
|
||||||
|
totalDurationSec: extracted.totalDurationSec,
|
||||||
|
nativeStreamSec: extracted.nativeStreamSec,
|
||||||
|
thinkingDurationSec: extracted.thinkingDurationSec,
|
||||||
|
hasToolCalls: extracted.hasToolCalls,
|
||||||
|
selectedSpeedReason: extracted.speedReason,
|
||||||
|
anomaly: extracted.anomaly,
|
||||||
|
anomalySig: extracted.anomalySig,
|
||||||
|
contextTokens: 20200,
|
||||||
|
inputTokens: extracted.inputTokens,
|
||||||
|
cacheReadTokens: extracted.cacheReadTokens,
|
||||||
|
outputTokens: extracted.outputTokens,
|
||||||
|
thinkingTokens: extracted.thinkingTokens,
|
||||||
|
responseTokens: extracted.responseTokens,
|
||||||
|
cacheHitPct: 80,
|
||||||
|
costUsd: 0.042,
|
||||||
|
agentId: 'main',
|
||||||
|
agentCascadeId: cascadeUuid,
|
||||||
|
agentLabel: 'Main',
|
||||||
|
agentBadge: 'MAIN',
|
||||||
|
agentIndex: 0,
|
||||||
|
isSubagent: false,
|
||||||
|
turnIndex: extracted.turnIndex,
|
||||||
|
isTurnStart: extracted.isTurnStart,
|
||||||
|
isLatestTurn: true,
|
||||||
|
turnPrompt: extracted.turnPrompt,
|
||||||
|
};
|
||||||
|
|
||||||
|
// B-04: Anomaly event message, modelKey, and modelUpstream search
|
||||||
|
assert.equal(
|
||||||
|
filterStepsBySearchAndChip([projectedLikeStep], { query: 'UniqueQuotaToken777' }).length,
|
||||||
|
1
|
||||||
|
);
|
||||||
|
assert.equal(
|
||||||
|
filterStepsBySearchAndChip([projectedLikeStep], { query: 'MODEL_PLACEHOLDER_M37' }).length,
|
||||||
|
1
|
||||||
|
);
|
||||||
|
assert.equal(
|
||||||
|
filterStepsBySearchAndChip([projectedLikeStep], {
|
||||||
|
query: 'gemini-3.1-pro-high-upstream-id',
|
||||||
|
}).length,
|
||||||
|
1
|
||||||
|
);
|
||||||
|
|
||||||
|
// B-02 & B-03: Waterfall, XLSX H2 duration cell, CSV duration, and timing diagnostic parity
|
||||||
|
const wf = computeStepTimingWaterfall(projectedLikeStep);
|
||||||
|
assert.equal(wf.totalSec, 10.05);
|
||||||
|
assert.equal(wf.ttftSec, 8.32);
|
||||||
|
assert.equal(wf.streamSec, 1.73);
|
||||||
|
assert.equal(wf.thinkingSec, 8.64);
|
||||||
|
|
||||||
|
const xlsxXml = parseZipEntries(buildStepsXlsx([projectedLikeStep], { locale: 'en-US' })).get(
|
||||||
|
'xl/worksheets/sheet1.xml'
|
||||||
|
);
|
||||||
|
assert.match(xlsxXml, /<c r="H2"[^>]*><v>10\.05<\/v><\/c>/);
|
||||||
|
assert.match(buildStepsCsv([projectedLikeStep], { includeBom: false }), /,10\.050,/);
|
||||||
|
|
||||||
|
setI18nLanguage('zh-CN');
|
||||||
|
const diag = buildStepTimingDiagnostic(projectedLikeStep);
|
||||||
|
assert.equal(diag.rows.length, 3);
|
||||||
|
assert.match(diag.rows[1].text, /流式返回/);
|
||||||
|
assert.match(diag.rows[2].text, /原生思考计时/);
|
||||||
|
assert.match(diag.hint, /重叠/);
|
||||||
|
|
||||||
|
// B-05: Speed aggregation matches official summarizeSpeed (18.2 tok/s, not 55.0 tok/s) and skips <50 tok short samples
|
||||||
|
const stepSlow = {
|
||||||
|
measurementVersion: 4,
|
||||||
|
isComplete: true,
|
||||||
|
isCompactionStep: false,
|
||||||
|
speedSampleEligible: true,
|
||||||
|
speedReason: null,
|
||||||
|
selectedSpeedReason: null,
|
||||||
|
stepIndex: 1,
|
||||||
|
modelShort: '4-neon',
|
||||||
|
modelLabel: 'Gemini 4 Neon',
|
||||||
|
outputTokens: 100,
|
||||||
|
totalDurationSec: 10,
|
||||||
|
totalTokPerSec: 10,
|
||||||
|
tokPerSec: 10,
|
||||||
|
};
|
||||||
|
const stepFast = {
|
||||||
|
...stepSlow,
|
||||||
|
stepIndex: 2,
|
||||||
|
totalDurationSec: 1,
|
||||||
|
totalTokPerSec: 100,
|
||||||
|
tokPerSec: 100,
|
||||||
|
};
|
||||||
|
const stepShort = {
|
||||||
|
...stepSlow,
|
||||||
|
stepIndex: 3,
|
||||||
|
speedSampleEligible: false,
|
||||||
|
speedReason: 'short_sample',
|
||||||
|
selectedSpeedReason: 'short_sample',
|
||||||
|
outputTokens: 10,
|
||||||
|
totalDurationSec: 0.5,
|
||||||
|
totalTokPerSec: 20,
|
||||||
|
tokPerSec: 20,
|
||||||
|
};
|
||||||
|
const mSlow = {
|
||||||
|
label: 'Gemini 4 Neon',
|
||||||
|
shortName: '4-neon',
|
||||||
|
rawModel: 'MODEL_A',
|
||||||
|
calls: 1,
|
||||||
|
outputTokens: 100,
|
||||||
|
totalTokens: 100,
|
||||||
|
avgTokPerSec: 10,
|
||||||
|
speedSummary: summarizeSpeed([stepSlow]),
|
||||||
|
};
|
||||||
|
const mFast = {
|
||||||
|
label: 'Gemini 4 Neon',
|
||||||
|
shortName: '4-neon',
|
||||||
|
rawModel: 'MODEL_A',
|
||||||
|
calls: 1,
|
||||||
|
outputTokens: 100,
|
||||||
|
totalTokens: 100,
|
||||||
|
avgTokPerSec: 100,
|
||||||
|
speedSummary: summarizeSpeed([stepFast]),
|
||||||
|
};
|
||||||
|
const mergedDisplay = mergeModelsByDisplayName(
|
||||||
|
[mSlow, { ...mFast, rawModel: 'MODEL_B' }],
|
||||||
|
{ modelDisplayMode: 'short' }
|
||||||
|
);
|
||||||
|
assert.equal(mergedDisplay[0].avgTokPerSec, 18.2);
|
||||||
|
assert.equal(mergedDisplay[0].speedSummary.tokens, 200);
|
||||||
|
assert.equal(mergedDisplay[0].speedSummary.seconds, 11);
|
||||||
|
|
||||||
|
const mergedUnits = mergeSelectedAgentUnits([
|
||||||
|
{ recentSteps: [stepSlow], modelBreakdown: [mSlow] },
|
||||||
|
{ recentSteps: [stepFast], modelBreakdown: [mFast] },
|
||||||
|
]);
|
||||||
|
assert.equal(mergedUnits.models[0].avgTokPerSec, 18.2);
|
||||||
|
|
||||||
|
const consXlsxXml = parseZipEntries(
|
||||||
|
buildConsumptionXlsx(
|
||||||
|
{ selectedRange: { key: '7d', label: '7d' }, account: { calls: 2, outputTokens: 200 } },
|
||||||
|
[
|
||||||
|
{ ...mSlow, label: 'Slow', shortName: 'slow' },
|
||||||
|
{ ...mFast, label: 'Fast', shortName: 'fast' },
|
||||||
|
],
|
||||||
|
{ locale: 'en-US' }
|
||||||
|
)
|
||||||
|
).get('xl/worksheets/sheet2.xml');
|
||||||
|
assert.match(consXlsxXml, /<c r="I4"[^>]*><v>18\.2<\/v><\/c>/);
|
||||||
|
assert.match(
|
||||||
|
buildStepsMarkdownReport([stepSlow, stepFast, stepShort], { locale: 'en-US' }),
|
||||||
|
/\*\*Avg Speed\*\*: 18\.2 tok\/s/
|
||||||
|
);
|
||||||
|
|
||||||
|
// B-01 & B-07 DOM checks: click real projected step opens drawer + i18n controls + WindowOverlayShell ResizeObserver cleanup
|
||||||
|
const prevDoc = globalThis.document;
|
||||||
|
const prevWin = globalThis.window;
|
||||||
|
const prevRo = globalThis.ResizeObserver;
|
||||||
|
const prevMo = globalThis.MutationObserver;
|
||||||
|
const prevUi = uiStore.getState();
|
||||||
|
const prevTel = telemetryStore.getState();
|
||||||
|
const prevLocale = i18nStore.getState().language;
|
||||||
|
|
||||||
|
const { document } = createMockDom();
|
||||||
|
globalThis.document = document;
|
||||||
|
let activeResizeObservers = 0;
|
||||||
|
globalThis.ResizeObserver = class {
|
||||||
|
constructor() {
|
||||||
|
this.connected = false;
|
||||||
|
}
|
||||||
|
observe() {
|
||||||
|
if (!this.connected) {
|
||||||
|
this.connected = true;
|
||||||
|
activeResizeObservers += 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
unobserve() {}
|
||||||
|
disconnect() {
|
||||||
|
if (this.connected) {
|
||||||
|
this.connected = false;
|
||||||
|
activeResizeObservers -= 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
globalThis.MutationObserver = class {
|
||||||
|
observe() {}
|
||||||
|
disconnect() {}
|
||||||
|
};
|
||||||
|
globalThis.window = {
|
||||||
|
innerWidth: 1280,
|
||||||
|
innerHeight: 800,
|
||||||
|
addEventListener() {},
|
||||||
|
removeEventListener() {},
|
||||||
|
requestAnimationFrame: (fn) => setTimeout(fn, 0),
|
||||||
|
cancelAnimationFrame: (id) => clearTimeout(id),
|
||||||
|
};
|
||||||
|
|
||||||
|
let stepsView = null;
|
||||||
|
let overlay = null;
|
||||||
|
t.after(() => {
|
||||||
|
stepsView?.destroy?.();
|
||||||
|
overlay?.dispose?.();
|
||||||
|
uiStore.setState(prevUi, { sync: true });
|
||||||
|
telemetryStore.setState(prevTel, { sync: true });
|
||||||
|
setI18nLanguage(prevLocale);
|
||||||
|
globalThis.document = prevDoc;
|
||||||
|
globalThis.window = prevWin;
|
||||||
|
globalThis.ResizeObserver = prevRo;
|
||||||
|
globalThis.MutationObserver = prevMo;
|
||||||
|
});
|
||||||
|
|
||||||
|
uiStore.setState({ activeView: 'steps', stepsSubTab: 'steps', monitorVisible: true }, { sync: true });
|
||||||
|
telemetryStore.setState(
|
||||||
|
{
|
||||||
|
telemetry: {
|
||||||
|
settings: { stepTableColumns: ['step', 'model', 'tps', 'duration', 'cost'] },
|
||||||
|
activeConversation: {
|
||||||
|
cascadeId: cascadeUuid,
|
||||||
|
stepCount: 1,
|
||||||
|
recentSteps: [projectedLikeStep],
|
||||||
|
modelBreakdown: [],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{ sync: true }
|
||||||
|
);
|
||||||
|
stepsView = StepsDetailView();
|
||||||
|
document.body.appendChild(stepsView.el);
|
||||||
|
assert.equal(
|
||||||
|
getStepSelectionKey(projectedLikeStep, cascadeUuid),
|
||||||
|
`${cascadeUuid}-${projectedLikeStep.stepIndex}`
|
||||||
|
);
|
||||||
|
const tr = stepsView.el.querySelectorAll('tbody tr')[0];
|
||||||
|
tr.onclick({});
|
||||||
|
assert.equal(stepsView.refs.stepInspectorDrawerEl.hasAttribute('hidden'), false);
|
||||||
|
stepsView.destroy();
|
||||||
|
stepsView = null;
|
||||||
|
|
||||||
|
// B-07 i18n reactive switching
|
||||||
|
setI18nLanguage('en-US');
|
||||||
|
const dt = CustomDateTimePicker({ modelValue: Date.UTC(2026, 10, 22, 12, 30) });
|
||||||
|
const num = CustomNumberInput({ modelValue: 5 });
|
||||||
|
const seg = SegmentedControl({ options: [{ label: 'A', value: 'a' }], modelValue: 'a' });
|
||||||
|
assert.equal(dt.el.querySelector('.dt-weekdays').textContent, 'MoTuWeThFrSaSu');
|
||||||
|
assert.equal(dt.el.querySelector('.dt-time-row .text-muted').textContent, 'Hr / Min');
|
||||||
|
assert.equal(num.el.querySelectorAll('.num-step-btn')[0].getAttribute('aria-label'), 'Decrease value');
|
||||||
|
assert.equal(seg.el.getAttribute('aria-label'), 'Segmented switcher');
|
||||||
|
setI18nLanguage('zh-CN');
|
||||||
|
await Promise.resolve();
|
||||||
|
assert.equal(dt.el.querySelector('.dt-weekdays').textContent, '一二三四五六日');
|
||||||
|
assert.equal(dt.el.querySelector('.dt-time-row .text-muted').textContent, '时 / 分');
|
||||||
|
dt.destroy();
|
||||||
|
num.destroy();
|
||||||
|
seg.destroy();
|
||||||
|
|
||||||
|
// B-07 WindowOverlayShell dispose cleans up multiRunningWidget subScroll ResizeObserver
|
||||||
|
const roBaseline = activeResizeObservers;
|
||||||
|
globalThis.window[WINDOW_OVERLAY_KEY] = { isMultiPinnedOpen: () => true, dispose() {} };
|
||||||
|
overlay = mountWindowOverlay();
|
||||||
|
telemetryStore.setState(
|
||||||
|
{
|
||||||
|
telemetry: {
|
||||||
|
settings: {},
|
||||||
|
runningConversations: [
|
||||||
|
{
|
||||||
|
cascadeId: 'run-ro-1',
|
||||||
|
title: 'Swarm Run',
|
||||||
|
isMainRunning: true,
|
||||||
|
subagentCount: 1,
|
||||||
|
runningSubagentCount: 1,
|
||||||
|
subagents: [{ cascadeId: 'sub-ro-1', isRunning: true, stepCount: 2 }],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
activeConversation: { cascadeId: 'run-ro-1', recentSteps: [], modelBreakdown: [] },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{ sync: true }
|
||||||
|
);
|
||||||
|
overlay.dispose();
|
||||||
|
overlay = null;
|
||||||
|
assert.equal(activeResizeObservers, roBaseline);
|
||||||
|
|
||||||
|
// B-07 account-switch honors ANTIGRAVITY_GEMINI_DIR
|
||||||
|
const prevGemEnv = process.env.ANTIGRAVITY_GEMINI_DIR;
|
||||||
|
process.env.ANTIGRAVITY_GEMINI_DIR = 'D:\\CustomGeminiVerify';
|
||||||
|
try {
|
||||||
|
let seenFallbacks = [];
|
||||||
|
await handleAccountCredentialAction(
|
||||||
|
{ action: 'list' },
|
||||||
|
{
|
||||||
|
platform: 'win32',
|
||||||
|
store: async (cfg) => {
|
||||||
|
seenFallbacks = cfg.fallbacks || [];
|
||||||
|
return { accounts: [], selectedEmail: '' };
|
||||||
|
},
|
||||||
|
}
|
||||||
|
);
|
||||||
|
assert.equal(seenFallbacks.every((p) => p.startsWith('D:\\CustomGeminiVerify')), true);
|
||||||
|
} finally {
|
||||||
|
if (prevGemEnv === undefined) delete process.env.ANTIGRAVITY_GEMINI_DIR;
|
||||||
|
else process.env.ANTIGRAVITY_GEMINI_DIR = prevGemEnv;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user