fix(report): recompute token totals after subagent row, fix import order
- Recompute totalInputTokens, totalOutputTokens, totalCacheCreation, totalCacheRead, and grandTotal after injecting the "Subagents (combined)" row so tokenUsage.totals stays consistent with byModel rows - Fix CostSection import order: external packages before path aliases, merge duplicate import type statements Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
bbd6441b9e
commit
6cd2845edb
2 changed files with 14 additions and 3 deletions
|
|
@ -6,8 +6,11 @@ import { DollarSign } from 'lucide-react';
|
|||
import { AssessmentBadge } from '../AssessmentBadge';
|
||||
import { ReportSection, sectionId } from '../ReportSection';
|
||||
|
||||
import type { ModelTokenStats, ReportCostAnalysis } from '@renderer/types/sessionReport';
|
||||
import type { ModelPricing } from '@renderer/types/sessionReport';
|
||||
import type {
|
||||
ModelPricing,
|
||||
ModelTokenStats,
|
||||
ReportCostAnalysis,
|
||||
} from '@renderer/types/sessionReport';
|
||||
|
||||
const fmt = (v: number) => `$${v.toFixed(4)}`;
|
||||
const fmtK = (v: number) => (v >= 1000 ? `${(v / 1000).toFixed(1)}k` : String(v));
|
||||
|
|
|
|||
|
|
@ -882,7 +882,7 @@ export function analyzeSession(detail: SessionDetail): SessionReport {
|
|||
totalCacheReadTokens += stats.cacheRead;
|
||||
}
|
||||
|
||||
const grandTotal =
|
||||
let grandTotal =
|
||||
totalInputTokens + totalOutputTokens + totalCacheCreationTokens + totalCacheReadTokens;
|
||||
|
||||
// --- Cost analysis ---
|
||||
|
|
@ -1150,6 +1150,14 @@ export function analyzeSession(detail: SessionDetail): SessionReport {
|
|||
const subagentLabel = 'Subagents (combined)';
|
||||
byModel[subagentLabel] = subagentTokenStats;
|
||||
modelStats.set(subagentLabel, subagentTokenStats);
|
||||
|
||||
// Update totals to include subagent tokens so the footer row stays consistent
|
||||
totalInputTokens += subagentTokenStats.inputTokens;
|
||||
totalOutputTokens += subagentTokenStats.outputTokens;
|
||||
totalCacheCreationTokens += subagentTokenStats.cacheCreation;
|
||||
totalCacheReadTokens += subagentTokenStats.cacheRead;
|
||||
grandTotal =
|
||||
totalInputTokens + totalOutputTokens + totalCacheCreationTokens + totalCacheReadTokens;
|
||||
}
|
||||
|
||||
// --- Assessment computations ---
|
||||
|
|
|
|||
Loading…
Reference in a new issue