mirror of
https://github.com/farion1231/cc-switch.git
synced 2026-07-28 00:35:32 +08:00
feat(db): rebuild Codex usage on upgrade and via maintenance action
Schema v16 wipes codex_session detail rows, _codex_session rollups and Codex rollout cursors inside the migration savepoint (cursor deletion uses pure shape matching so CODEX_HOME drift cannot orphan cursors); the next session sync re-imports history from source JSONL under the corrected importer. Fresh installs traverse the same branch as a no-op. Add a manual "Rebuild Codex usage" maintenance action (single-flight, hard-fail backup before reset, unconditional refresh notification even when reimport is empty or fails after reset) with a destructive confirm dialog, result toast and four-locale strings. Historical proxy-side duplicate rows are intentionally left untouched; history whose source JSONL was already deleted cannot be reconstructed.
This commit is contained in:
@@ -180,6 +180,10 @@ export const usageApi = {
|
||||
return invoke("sync_session_usage");
|
||||
},
|
||||
|
||||
rebuildCodexUsage: async (): Promise<SessionSyncResult> => {
|
||||
return invoke("rebuild_codex_usage");
|
||||
},
|
||||
|
||||
getDataSourceBreakdown: async (): Promise<DataSourceSummary[]> => {
|
||||
return invoke("get_usage_data_sources");
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user