Codex History Reconcile
Overview
Detect when Codex history exists locally but is hidden by provider filtering, then safely remap top-level VS Code threads to the provider visible under the current login mode.
Workflow
- Run
node scripts/codex-history-reconcile.js check. - Confirm the environment is healthy and inspect:
- current auth mode
- current visible provider
- visible thread count from
codex app-server - top-level
source='vscode'thread counts by provider from.codex/state_5.sqlite
- If the visible thread count is unexpectedly low and the target provider is clear, run a dry run:
node scripts/codex-history-reconcile.js reconcile --dry-run
- If the dry run matches expectations, run the real migration:
node scripts/codex-history-reconcile.js reconcile
- Reload or restart VS Code so the history panel refreshes from the updated thread data.
- Re-run
checkto verify the visible thread count now matches the expected top-level history count.
Safety Rules
- Back up
state_5.sqliteand affected session files before writing. - Modify only top-level
source='vscode'threads by default. - Leave sub-agent threads alone unless the user explicitly asks to retag them.
- Do not edit thread content or turn payloads; only update provider metadata.
- If target provider auto-detection is ambiguous, stop and require
--target-provider.
Environment Checks
Use the built-in check command before any write:
node scripts/codex-history-reconcile.js check
The script validates:
- Node.js version and
node:sqliteavailability .codex/state_5.sqliteand.codex/sessionsexistence- VS Code
state.vscdbexistence - Codex CLI or extension-bundled
codexexecutable discovery - current login status from
codex login status - current visible thread list from
codex app-server
Auto-Detection Rules
The reconcile script chooses the target provider in this order:
- Use the single provider returned by the current visible
thread/listresponse. - If login status says API key auth, use
custom. - If login status suggests ChatGPT or OpenAI auth, use
openai. - If login status suggests Copilot auth, prefer
fluxcode. - If still ambiguous, require
--target-provider.
Commands
Inspect only:
node scripts/codex-history-reconcile.js check
Preview the change set:
node scripts/codex-history-reconcile.js reconcile --dry-run
Force a specific provider:
node scripts/codex-history-reconcile.js reconcile --target-provider custom
Include archived top-level threads:
node scripts/codex-history-reconcile.js reconcile --include-archived
Resources
scripts/
scripts/codex-history-reconcile.js: Check environment, inspect visible history, back up local state, and retag top-level thread providers.