claude_session_viewer/lib/models/token_usage.dart
Mathias Beaulieu-Duncan 364877d376 Initial commit: Claude Code session viewer (Flutter macOS)
A desktop app that parses Claude Code .jsonl session logs and provides
a rich UI for exploring conversations, tool usage, subagents, and token
consumption. Features include project browser with auto-discovery of
~/.claude/projects, conversation timeline with inline subagent expansion,
agents overview, toolbelt chart, and token usage dashboard.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 16:17:23 -04:00

36 lines
1.1 KiB
Dart

class TokenUsage {
final int inputTokens;
final int outputTokens;
final int cacheCreationInputTokens;
final int cacheReadInputTokens;
const TokenUsage({
this.inputTokens = 0,
this.outputTokens = 0,
this.cacheCreationInputTokens = 0,
this.cacheReadInputTokens = 0,
});
int get totalTokens =>
inputTokens + outputTokens + cacheCreationInputTokens + cacheReadInputTokens;
TokenUsage operator +(TokenUsage other) => TokenUsage(
inputTokens: inputTokens + other.inputTokens,
outputTokens: outputTokens + other.outputTokens,
cacheCreationInputTokens:
cacheCreationInputTokens + other.cacheCreationInputTokens,
cacheReadInputTokens:
cacheReadInputTokens + other.cacheReadInputTokens,
);
factory TokenUsage.fromJson(Map<String, dynamic> json) {
return TokenUsage(
inputTokens: json['input_tokens'] as int? ?? 0,
outputTokens: json['output_tokens'] as int? ?? 0,
cacheCreationInputTokens:
json['cache_creation_input_tokens'] as int? ?? 0,
cacheReadInputTokens: json['cache_read_input_tokens'] as int? ?? 0,
);
}
}