feat: replace Codex estimated usage with precise JSONL session log parsing

Replace the 70/30 input/output token estimation from state_5.sqlite
with precise parsing of Codex CLI JSONL session logs (~/.codex/sessions/).

- Parse event_msg (token_count), turn_context, and session_meta events
- Compute exact input/output/cached token deltas from cumulative totals
- Reuse session_log_sync table for incremental file scanning
- Pre-filter lines with string contains() before JSON deserialization
- Add codex_session data source to DataSourceBar with i18n (zh/en/ja)
This commit is contained in:
Jason
2026-04-06 18:31:38 +08:00
parent 46051317da
commit 2ea6a307fc
5 changed files with 608 additions and 177 deletions
+1
View File
@@ -15,6 +15,7 @@ const DATA_SOURCE_ICONS: Record<string, React.ReactNode> = {
proxy: <Database className="h-3.5 w-3.5" />,
session_log: <FileText className="h-3.5 w-3.5" />,
codex_db: <Database className="h-3.5 w-3.5" />,
codex_session: <FileText className="h-3.5 w-3.5" />,
};
export function DataSourceBar({ refreshIntervalMs }: DataSourceBarProps) {
+2 -1
View File
@@ -1023,7 +1023,8 @@
"dataSource": {
"proxy": "Proxy",
"session_log": "Session Log",
"codex_db": "Codex DB"
"codex_db": "Codex DB",
"codex_session": "Codex Session"
},
"sessionSync": {
"trigger": "Sync session logs",
+2 -1
View File
@@ -1023,7 +1023,8 @@
"dataSource": {
"proxy": "プロキシ",
"session_log": "セッションログ",
"codex_db": "Codex DB"
"codex_db": "Codex DB",
"codex_session": "Codex セッション"
},
"sessionSync": {
"trigger": "セッションログを同期",
+2 -1
View File
@@ -1023,7 +1023,8 @@
"dataSource": {
"proxy": "代理",
"session_log": "会话日志",
"codex_db": "Codex 数据库"
"codex_db": "Codex 数据库",
"codex_session": "Codex 会话日志"
},
"sessionSync": {
"trigger": "同步会话日志",