feat: add session log usage tracking without proxy

Parse Claude Code JSONL session files (~/.claude/projects/) and Codex
SQLite database (~/.codex/state_5.sqlite) to track API usage without
requiring proxy interception. This enables usage statistics for users
who don't use the proxy feature.

Key changes:
- Add session_usage.rs: incremental JSONL parser with message.id dedup
- Add session_usage_codex.rs: import thread-level token data from Codex
- Add data_source column to proxy_request_logs (proxy/session_log/codex_db)
- Add session_log_sync table for tracking parse offsets
- Background sync every 60s + manual sync via DataSourceBar UI
- Schema migration v7→v8
- i18n support for zh/en/ja
This commit is contained in:
Jason
2026-04-06 10:54:09 +08:00
parent 2d581bce91
commit 154342ca00
16 changed files with 1238 additions and 5 deletions
+3
View File
@@ -6,6 +6,7 @@ import { UsageTrendChart } from "./UsageTrendChart";
import { RequestLogTable } from "./RequestLogTable";
import { ProviderStatsTable } from "./ProviderStatsTable";
import { ModelStatsTable } from "./ModelStatsTable";
import { DataSourceBar } from "./DataSourceBar";
import type { TimeRange } from "@/types/usage";
import { motion } from "framer-motion";
import {
@@ -100,6 +101,8 @@ export function UsageDashboard() {
</Tabs>
</div>
<DataSourceBar refreshIntervalMs={refreshIntervalMs} />
<UsageSummaryCards days={days} refreshIntervalMs={refreshIntervalMs} />
<UsageTrendChart days={days} refreshIntervalMs={refreshIntervalMs} />