mirror of
https://github.com/lWolvesl/antigravity-usage-monitor.git
synced 2026-11-27 01:19:25 +08:00
fix: preserve unknown model identity and pending costs
This commit is contained in:
@@ -521,7 +521,7 @@ export const ConsumptionView = defineComponent({
|
||||
patchText(refs.pctBadge, `${share.toFixed(1)}%`);
|
||||
patchText(refs.totalTokEl, showTokensInHeader ? formatTokensPrecise(total) : '');
|
||||
patchAttr(refs.totalTokEl, 'hidden', !showTokensInHeader);
|
||||
patchText(refs.costEl, formatUsd(item.costUsd || 0));
|
||||
patchText(refs.costEl, formatUsd(item.costUsd || 0, { unpricedCalls: item.unpricedCalls }));
|
||||
|
||||
const responseTok =
|
||||
item.responseTokens != null
|
||||
@@ -573,8 +573,8 @@ export const ConsumptionView = defineComponent({
|
||||
|
||||
patchText(heroTotalTokens, formatTokensPrecise(totalTokens));
|
||||
patchText(heroTotalCalls, `${acct.calls || 0} 调用`);
|
||||
patchText(heroCostUsd, formatUsd(costUsd));
|
||||
patchText(heroCostCny, formatCnyApprox(costUsd));
|
||||
patchText(heroCostUsd, formatUsd(costUsd, { unpricedCalls: acct.unpricedCalls }));
|
||||
patchText(heroCostCny, acct.unpricedCalls > 0 ? `${acct.unpricedCalls} 步费用待定` : formatCnyApprox(costUsd));
|
||||
|
||||
patchText(cacheHitPctEl, `${Number(acct.cacheHitPct ?? 0).toFixed(1)}%`);
|
||||
patchText(cacheTokensEl, `命中 ${formatTokensPrecise(cacheTokens)}`);
|
||||
@@ -627,7 +627,7 @@ export const ConsumptionView = defineComponent({
|
||||
patchKeyedList(modelsListEl, models, {
|
||||
keyFn: (m) => m.label || m.shortName,
|
||||
sigFn: (m) =>
|
||||
`${m.label}:${m.totalTokens}:${m.costUsd}:${m.calls}:${modelsTotalTok}`,
|
||||
`${m.label}:${m.totalTokens}:${m.costUsd}:${m.unpricedCalls}:${m.calls}:${modelsTotalTok}`,
|
||||
createRow: createBreakdownItemRow,
|
||||
updateRow: (refs, m) => updateBreakdownItemRow(refs, m, modelsTotalTok, true),
|
||||
});
|
||||
@@ -637,7 +637,7 @@ export const ConsumptionView = defineComponent({
|
||||
const sourcesTotalTok = sources.reduce((s, x) => s + Number(x.totalTokens || 0), 0);
|
||||
patchKeyedList(sourcesListEl, sources, {
|
||||
keyFn: (s) => s.name,
|
||||
sigFn: (s) => `${s.name}:${s.totalTokens}:${s.costUsd}:${s.calls}:${sourcesTotalTok}`,
|
||||
sigFn: (s) => `${s.name}:${s.totalTokens}:${s.costUsd}:${s.unpricedCalls}:${s.calls}:${sourcesTotalTok}`,
|
||||
createRow: createBreakdownItemRow,
|
||||
updateRow: (refs, s) => updateBreakdownItemRow(refs, s, sourcesTotalTok, true),
|
||||
});
|
||||
@@ -667,7 +667,8 @@ export const ConsumptionView = defineComponent({
|
||||
patchText(col.tokText, '');
|
||||
} else {
|
||||
const cVal = Number(m.costUsd || 0);
|
||||
patchText(col.costText, cVal >= 10 ? `$${Math.round(cVal)}` : `$${cVal.toFixed(2)}`);
|
||||
patchText(col.costText, m.unpricedCalls > 0 ? formatUsd(cVal, { unpricedCalls: m.unpricedCalls })
|
||||
: cVal >= 10 ? `$${Math.round(cVal)}` : `$${cVal.toFixed(2)}`);
|
||||
patchText(col.tokText, formatTokensPrecise(mTot));
|
||||
|
||||
const totalHeightPct = Math.max(8, Math.min(100, (mTot / maxMonthTokens) * 100));
|
||||
|
||||
@@ -31,7 +31,7 @@ export const LiveOverviewView = defineComponent({
|
||||
setup({ onCleanup }) {
|
||||
// 1. 4-Cell Real-time Telemetry Matrix
|
||||
const tpsVal = h('strong', { className: 'cell-value accent-speed', text: '—' });
|
||||
const tpsSub = h('span', { className: 'cell-sub', text: 'argon-4' });
|
||||
const tpsSub = h('span', { className: 'cell-sub', text: '模型未知' });
|
||||
const pulseDot = createSvgIcon('dot', { size: 10 });
|
||||
|
||||
const ttftVal = h('strong', { className: 'cell-value', text: '—' });
|
||||
@@ -265,7 +265,7 @@ export const LiveOverviewView = defineComponent({
|
||||
const reason = speedReasonText(active.latestSpeedReason);
|
||||
patchText(
|
||||
tpsSub,
|
||||
reason ? `${active.activeModelShort || 'argon-4'} · ${reason}` : active.activeModelShort || 'argon-4'
|
||||
reason ? `${active.activeModelShort || '模型未知'} · ${reason}` : active.activeModelShort || '模型未知'
|
||||
);
|
||||
|
||||
patchText(ttftVal, formatMetric(active.latestTtftSec, 's'));
|
||||
@@ -274,11 +274,11 @@ export const LiveOverviewView = defineComponent({
|
||||
patchText(avgVal, formatMetric(active.avgTokPerSec, ' tok/s'));
|
||||
patchText(avgSub, `有效 ${sampleSummary(active.speedSummary)}`);
|
||||
|
||||
const stepCost = Number(active.latestStepCostUsd ?? active.recentSteps?.[0]?.costUsd ?? 0);
|
||||
const stepCost = active.latestStepCostUsd;
|
||||
patchText(costVal, formatUsd(stepCost, { precise: true }));
|
||||
patchText(
|
||||
cacheSub,
|
||||
`缓 ${active.latestCacheHitPct ?? 0}% · 累 ${formatUsd(active.sessionCostUsd || 0)}`
|
||||
`缓 ${active.latestCacheHitPct ?? 0}% · 累 ${formatUsd(active.sessionCostUsd || 0, { unpricedCalls: active.sessionUnpricedCalls })}`
|
||||
);
|
||||
|
||||
// 2. Context (Auto Compaction Baseline)
|
||||
@@ -313,16 +313,17 @@ export const LiveOverviewView = defineComponent({
|
||||
{};
|
||||
const claudePool =
|
||||
pools.find((p) => p.family === 'Claude & GPT' || p.family === 'Claude') ||
|
||||
(activePool.family && activePool.family !== 'Gemini' ? activePool : null) ||
|
||||
(['Claude & GPT', 'Claude', 'GPT'].includes(activePool.family) ? activePool : null) ||
|
||||
{};
|
||||
|
||||
const activeIsGemini = (activePool.family || 'Gemini') === 'Gemini';
|
||||
const activeIsGemini = activePool.family === 'Gemini';
|
||||
const activeIsThirdParty = ['Claude & GPT', 'Claude', 'GPT'].includes(activePool.family);
|
||||
syncPoolQuotaBlock(geminiQuotaBlock, 'Gemini', geminiPool, weekly, activeIsGemini);
|
||||
syncPoolQuotaBlock(claudeQuotaBlock, 'Claude & GPT', claudePool, weekly, !activeIsGemini);
|
||||
syncPoolQuotaBlock(claudeQuotaBlock, 'Claude & GPT', claudePool, weekly, activeIsThirdParty);
|
||||
|
||||
patchText(
|
||||
wkFootLeft,
|
||||
`本周本机: ${formatTokens(weekly.tokens || 0)} (${formatUsd(weekly.costUsd || 0)})`
|
||||
`本周本机: ${formatTokens(weekly.tokens || 0)} (${formatUsd(weekly.costUsd || 0, { unpricedCalls: weekly.unpricedCalls })})`
|
||||
);
|
||||
patchText(
|
||||
wkFootRight,
|
||||
|
||||
@@ -189,7 +189,7 @@ export const StepsDetailView = defineComponent({
|
||||
);
|
||||
patchText(refs.tdCache, `${Number(st.cacheHitPct ?? 0)}%`);
|
||||
|
||||
const costVal = Number(st.costUsd || 0);
|
||||
const costVal = st.costUsd;
|
||||
patchText(refs.tdCost, formatUsd(costVal, { precise: true }));
|
||||
patchClasses(refs.tdCost, { 'accent-speed': costVal >= 0.15 });
|
||||
},
|
||||
@@ -198,7 +198,7 @@ export const StepsDetailView = defineComponent({
|
||||
patchKeyedList(modelsTbody, models, {
|
||||
keyFn: (m) => m.label || m.shortName,
|
||||
sigFn: (m) =>
|
||||
`${m.shortName}:${m.calls}:${m.avgTokPerSec}:${m.totalTokens}:${m.costUsd}:${m.speedSummary?.sampleCount}`,
|
||||
`${m.shortName}:${m.calls}:${m.avgTokPerSec}:${m.totalTokens}:${m.costUsd}:${m.unpricedCalls}:${m.speedSummary?.sampleCount}`,
|
||||
createRow: () => {
|
||||
const tdName = h('td', { style: 'font-weight: 600;' });
|
||||
const tdCalls = h('td');
|
||||
@@ -219,7 +219,7 @@ export const StepsDetailView = defineComponent({
|
||||
patchText(refs.speedMain, formatMetric(m.avgTokPerSec, ' tok/s'));
|
||||
patchText(refs.speedSub, `有效 ${sampleSummary(m.speedSummary)}`);
|
||||
patchText(refs.tdTokens, formatTokens(m.totalTokens || 0));
|
||||
patchText(refs.tdCost, formatUsd(m.costUsd || 0, { estimated: m.isEstimatedPrice }));
|
||||
patchText(refs.tdCost, formatUsd(m.costUsd, { estimated: m.isEstimatedPrice, unpricedCalls: m.unpricedCalls }));
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user