Skip to content

feat(history): add provider-agnostic local session browser (#612) - #613

Merged
ndycode merged 2 commits into
mainfrom
fix/612-history-command
Jun 16, 2026
Merged

feat(history): add provider-agnostic local session browser (#612)#613
ndycode merged 2 commits into
mainfrom
fix/612-history-command

Conversation

@ndycode

@ndycode ndycode commented Jun 16, 2026

Copy link
Copy Markdown
Owner

Fixes #612.

Diagnosis

The report ("history not shared across accounts") and the auto-generated plan both frame this as per-account session isolation. Tracing the code shows that framing is wrong — the split is per-model_provider, and the data is never actually scattered:

  • Session history is purely local: rollout *.jsonl files under ~/.codex/sessions, indexed by ~/.codex/session_index.jsonl. There is no server-side / per-account session listing API anywhere in lib/ or scripts/ (the runtime proxy is a Responses passthrough only).
  • The index entry the wrapper builds (scripts/codex.js) is { id, thread_name, updated_at }no account field and no provider field. Nothing scopes history by account.
  • App bind rewrites the real ~/.codex/config.toml top-level model_provider to codex-multi-auth-runtime-proxy (lib/runtime/config-toml.ts, lib/runtime/app-bind.ts); the interactive wrapper runs codex in a shadow CODEX_HOME but junctions sessions/ and syncs session_index.jsonl back, so rollout files stay shared on disk.
  • Current Codex builds filter the /resume thread list by the active provider, so threads written under openai and under codex-multi-auth-runtime-proxy hide each other. Accounts rotating and the provider switch happen together, which is why it looks per-account.

This was reproduced on a real machine: 5 local sessions, 4 tagged model_provider: openai and 1 tagged codex-multi-auth-runtime-proxycodex resume shows only the subset matching the current provider, exactly the reported symptom.

This is documented upstream behavior, not a regression on main. The one caveat: the provider-filter step itself lives in the upstream codex binary (not in this repo), so it can't be unit-tested from here, but every local signal is consistent with it.

Change

Adds a read-only codex-multi-auth history command that reads the rollout files directly, bypassing the provider filter:

  • list (default when no subcommand) — every local session across all providers, newest first, showing updated_at, model_provider, id, thread name, cwd.
  • show <id> — provider/originator metadata + first user messages for one session.
  • --json on both.

Then codex resume <id> reopens any session.

Design notes:

  • Resolves the home via getCodexHomeDir() (honors CODEX_HOME; correct Windows path handling).
  • Rollout parsing is self-contained and tolerant: malformed/partial JSONL lines are skipped, a missing sessions/ dir yields an empty listing, and files without session_meta are ignored.
  • Dependency-injected fs/home for hermetic tests, matching the existing command style (commands/switch.ts).
  • Read-only: no network, no state mutation.

Wired into all four routing sources of truth (ACCOUNT_MANAGER_COMMANDS, the CLI handler map, the wrapper AUTH_SUBCOMMANDS set, and help/usage). Bare codex history to the official CLI is not intercepted — interception requires the multi-auth/auth prefix.

Docs: the troubleshooting row now covers CLI /resume (not just Desktop), explains the provider-vs-account distinction, and points at the new command; docs/reference/commands.md gets a table row, --json entry, and a dedicated section.

Testing

  • New test/codex-manager-history-command.test.ts — 12 cases: multi-provider listing, default-to-list, sort order, JSON shape, missing dir, malformed JSONL tolerance, no-session_meta skip, show metadata/preview/trim, unknown id, missing id, unknown subcommand, --help.
  • npm run build, typecheck, typecheck:scripts, eslint — all clean.
  • Full documentation.test.ts and codex-routing.test.ts (the alignment guards) pass.
  • End-to-end smoke run against real ~/.codex/sessions: surfaces all 5 sessions across both providers; list, show, JSON, and human output all correct on Windows.

🤖 Generated with Claude Code

note: greptile review for oc-chatgpt-multi-auth. cite files like lib/foo.ts:123. confirm regression tests + windows concurrency/token redaction coverage.

Greptile Summary

adds codex-multi-auth history — a read-only, provider-agnostic local session browser that reads ~/.codex/sessions rollout files directly, bypassing the upstream model_provider filter that hides threads when runtime rotation or app bind is active.

  • new command (lib/codex-manager/commands/history.ts): list (default) and show <id> subcommands, both with --json; dependency-injected fs/home for hermetic tests; windows separator-safe baseNameOf; malformed jsonl lines are skipped, missing session_meta records are dropped; the history --json bare-flag dispatch (previously broken) is fixed via the subcommand.startsWith(\"-\") branch.
  • wiring (account-manager-commands.ts, codex-manager.ts, scripts/codex-routing.js, help.ts): history added to all four routing sources of truth; the existing codex-routing.test.ts loop verifies ACCOUNT_MANAGER_COMMANDSAUTH_SUBCOMMANDS alignment.
  • docs (docs/reference/commands.md, docs/troubleshooting.md): troubleshooting row updated to cover both Desktop and CLI, explains the provider-vs-account distinction, and points to the new command; reference section and --json flag table updated with documentation.test.ts parity guard.

Confidence Score: 5/5

safe to merge — the change is read-only, performs no network calls, mutates no state, and is fully self-contained behind the new subcommand prefix

all four routing tables are updated consistently and the routing test loop guards alignment; the history --json bare-flag dispatch bug is fixed and covered by a new test; the two findings are display-only nits (thread name source and sort-order fallback) that do not affect correctness of the session listing or any downstream path

lib/codex-manager/commands/history.ts — threadName extraction and statMtime fallback worth a second look before the next release

Important Files Changed

Filename Overview
lib/codex-manager/commands/history.ts new read-only history command; solid dependency-injection pattern and windows path handling, but threadName extraction fires on any event_msg type (not just user_message) and statMtime fallback uses current time which can corrupt sort order
test/codex-manager-history-command.test.ts 12 test cases cover multi-provider listing, --json flag routing fix, windows paths, malformed jsonl tolerance, missing dir — missing a case for show <id> --json json shape validation
lib/codex-manager.ts minimal wiring change — adds history import and CLI handler map entry, consistent with existing command style
lib/codex-manager/account-manager-commands.ts adds history to ACCOUNT_MANAGER_COMMANDS; routing alignment is verified by the existing codex-routing.test.ts loop
scripts/codex-routing.js adds history to AUTH_SUBCOMMANDS so the wrapper routes it correctly; matches account-manager-commands.ts

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A["codex-multi-auth history [args]"] --> B{subcommand?}
    B -->|"--help / -h"| C[printHistoryUsage → exit 0]
    B -->|"no subcommand"| D[runHistoryList]
    B -->|"starts with '-'"| D
    B -->|"list"| D
    B -->|"show"| E[runHistoryShow]
    B -->|"unknown"| F[logError + usage → exit 1]
    D --> G[collectSessions]
    E --> G
    G --> H["join(getCodexHome(), 'sessions')"]
    H --> I[readDirRecursive → ROLLOUT_FILENAME_PATTERN files]
    I --> J["parseRollout × N (sync, tolerant)"]
    J --> K["sort by updatedAt desc (localeCompare)"]
    K --> L{--json?}
    L -->|yes list| M["JSON: {count, sessions[]} — HistorySessionSummary"]
    L -->|yes show| N["JSON: HistorySessionDetail (+ messages, cliVersion, path)"]
    L -->|no list| O[human table: updatedAt, provider, id, thread, cwd]
    L -->|no show| P[human detail: provider, originator, updated, cli, cwd, file, first messages]
Loading
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
flowchart TD
    A["codex-multi-auth history [args]"] --> B{subcommand?}
    B -->|"--help / -h"| C[printHistoryUsage → exit 0]
    B -->|"no subcommand"| D[runHistoryList]
    B -->|"starts with '-'"| D
    B -->|"list"| D
    B -->|"show"| E[runHistoryShow]
    B -->|"unknown"| F[logError + usage → exit 1]
    D --> G[collectSessions]
    E --> G
    G --> H["join(getCodexHome(), 'sessions')"]
    H --> I[readDirRecursive → ROLLOUT_FILENAME_PATTERN files]
    I --> J["parseRollout × N (sync, tolerant)"]
    J --> K["sort by updatedAt desc (localeCompare)"]
    K --> L{--json?}
    L -->|yes list| M["JSON: {count, sessions[]} — HistorySessionSummary"]
    L -->|yes show| N["JSON: HistorySessionDetail (+ messages, cliVersion, path)"]
    L -->|no list| O[human table: updatedAt, provider, id, thread, cwd]
    L -->|no show| P[human detail: provider, originator, updated, cli, cwd, file, first messages]
Loading

Comments Outside Diff (1)

  1. test/codex-manager-history-command.test.ts, line 815-837 (link)

    P2 missing vitest case for history --json without explicit subcommand

    the test suite covers ["list", "--json"] (line 683) and [] (line 657) but not ["--json"] alone. that exact invocation is the broken path described above — it would return exit 1 with an error message. adding a case runHistoryCommand(["--json"], deps) expecting code === 0 and valid JSON output would catch the regression once the dispatch logic is fixed.

    Prompt To Fix With AI
    This is a comment left during a code review.
    Path: test/codex-manager-history-command.test.ts
    Line: 815-837
    
    Comment:
    **missing vitest case for `history --json` without explicit subcommand**
    
    the test suite covers `["list", "--json"]` (line 683) and `[]` (line 657) but not `["--json"]` alone. that exact invocation is the broken path described above — it would return exit 1 with an error message. adding a case `runHistoryCommand(["--json"], deps)` expecting `code === 0` and valid JSON output would catch the regression once the dispatch logic is fixed.
    
    How can I resolve this? If you propose a fix, please make it concise.

    Fix in Codex

Reviews (2): Last reviewed commit: "fix(history): default to list for leadin..." | Re-trigger Greptile

Codex CLI/Desktop filter `/resume` threads by the `model_provider`
recorded in each rollout. While runtime rotation or app bind is active
the real config.toml provider becomes `codex-multi-auth-runtime-proxy`,
so sessions recorded under the native `openai` provider (and vice versa)
disappear from `codex resume`. Users report this as "history not shared
across accounts" (#612), but the split is by provider name, not account:
all rollout files still live side-by-side under ~/.codex/sessions.

Add `codex-multi-auth history`:

- `list` (default) reads ~/.codex/sessions rollout files directly and
  prints every session across all providers, most-recent first.
- `show <id>` prints provider/originator metadata and the first user
  messages for one session.
- `--json` on both for machine-readable output.

The command is read-only, makes no network calls, and resolves the home
via getCodexHomeDir() so it honors CODEX_HOME and Windows paths. Rollout
parsing tolerates malformed/partial JSONL lines and a missing sessions
dir. Wired into ACCOUNT_MANAGER_COMMANDS, the CLI handler map, the
wrapper AUTH_SUBCOMMANDS routing set, and help/usage. Docs updated:
the troubleshooting entry now covers CLI `/resume` (not just Desktop)
and points at the new command.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Credits must be used to enable repository wide code reviews.

@coderabbitai

coderabbitai Bot commented Jun 16, 2026

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Summary

This PR introduces a new read-only codex-multi-auth history command to resolve issue #612 (session history “missing” across rotated runtime/app binds) by viewing all locally stored sessions regardless of provider. Risk is minor from a security/data-loss standpoint because the command performs no network calls and makes no state mutations; regression coverage exists via a dedicated Vitest suite for listing/showing/routing and edge cases.

Key Changes

New Command: codex-multi-auth history [list|show <id>] [--json]

  • list (default; including when invoked as history --json): enumerates all local sessions across providers, sorted newest-first, showing updated_at, model_provider, session id, thread name, and cwd—explicitly avoiding the upstream /resume provider filtering that hides sessions created under other providers after runtime/app bind rewrites.
  • show <id>: displays provider/originator metadata and previews the initial user messages for a specific session (or full JSON when --json is set).
  • --json: supported on both list and show with machine-readable output.

Technical Approach

  • Reads rollout/session data directly from <codex-home>/sessions (default ~/.codex) and bypasses session_index.jsonl/provider scoping so all providers’ local sessions remain visible.
  • Resolves Codex home via getCodexHomeDir(), honoring CODEX_HOME with correct Windows path handling (and user-facing messages reflect the resolved location).
  • Parses JSONL tolerantly: skips malformed lines, ignores rollouts missing session_meta, and handles missing/unreadable sessions directories by returning an empty list (no crash).
  • Uses dependency injection (HistoryCommandDeps) for file system/home resolution and logging to support hermetic tests.
  • No network calls; read-only behavior with no mutations.

Routing/Integration

  • Registered into multiple dispatch paths: ACCOUNT_MANAGER_COMMANDS, the CLI handler map, the AUTH_SUBCOMMANDS routing allowlist, and CLI/help usage output.

Documentation Updates

  • docs/reference/commands.md: adds dedicated command reference for codex-multi-auth history, clarifying provider-agnostic local browsing and --json applicability.
  • docs/troubleshooting.md: expands runtime rotation/app bind troubleshooting to explain that /resume and local history visibility can be filtered by active model_provider (not account isolation), and points users to recovery steps using codex-multi-auth rotation unbind-app / rotation disable.

Test Coverage & Risk Assessment

  • 12 test cases in test/codex-manager-history-command.test.ts covering:
    • multi-provider discovery (not limited to active provider),
    • sort order (newest-first),
    • JSON output shape and provider field expectations,
    • JSONL tolerance (malformed lines, missing session_meta),
    • missing/unreadable sessions directory behavior (empty listing),
    • CODEX_HOME/Windows path override correctness,
    • history show rendering and error handling (missing/unknown ids),
    • routing/usage behaviors (unknown subcommand errors; --help works; defaulting to list for history --json).
  • Low risk: purely informational local reads; no data mutation and no external side effects.

Walkthrough

adds a codex-multi-auth history subcommand that reads local rollout jsonl files under ~/.codex/sessions without network calls or state mutation. supports history list (default, most-recent-first, --json flag) and history show <id>. wires into the cli handler map, routing allowlist, help text, and docs.

Changes

history subcommand implementation and integration

Layer / File(s) Summary
Session types and JSONL parsing foundation
lib/codex-manager/commands/history.ts
defines HistorySessionSummary, HistorySessionDetail, HistoryCommandDeps; implements filesystem traversal, line-by-line jsonl parsing with mtime/iso fallback, session collection sorted by recency.
List/show output and command dispatcher
lib/codex-manager/commands/history.ts
implements runHistoryList (json and human-readable), runHistoryShow (by id, with json mode), printHistoryUsage, and runHistoryCommand dispatcher with --help, default-to-list, and unknown-subcommand error path.
CLI handler registration and routing
lib/codex-manager.ts, lib/codex-manager/account-manager-commands.ts, scripts/codex-routing.js, lib/codex-manager/help.ts
registers history in CLI_COMMAND_HANDLERS, ACCOUNT_MANAGER_COMMANDS, and the AUTH_SUBCOMMANDS routing set; adds the usage line to printUsage.
Unit test coverage
test/codex-manager-history-command.test.ts
in-memory dep injection harness (createDeps), coverage for list multi-provider/sorting/--json/empty-dir/malformed-jsonl/missing-meta, show metadata rendering/message trimming/missing-id error, and routing for unknown subcommand and --help.
User documentation and doc tests
docs/reference/commands.md, docs/troubleshooting.md, test/documentation.test.ts
adds the history command to the advanced table, --json applies-to list, and the full reference section; updates the troubleshooting runtime rotation row; updates the doc test assertion for the --json row.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Notes for reviewers

windows path separatorslib/codex-manager/commands/history.ts:68–93 uses a regex against the rollout filename and path.join. if readDirRecursive returns windows-style backslash paths, the regex match against the rollout filename pattern could silently fail, resulting in zero sessions listed. the test at test/codex-manager-history-command.test.ts:79–232 creates windows paths but uses createDeps with a fake filesystem map, not the actual path separator. worth explicit testing with actual path.sep on windows.

concurrent writes during traversalparseRollout at lib/codex-manager/commands/history.ts:115–218 reads the whole file then iterates lines. if codex is actively appending to a rollout file mid-read, the last line will be a partial json fragment. the code skips malformed lines (test/codex-manager-history-command.test.ts:79–232 covers this), but a partial session_meta line would silently omit the entire session since session_meta is only accepted once. add a comment or test covering this edge case.

mtime fallback uncoveredtest/codex-manager-history-command.test.ts:1–78 injects getMtime returning a fixed date. there is no test verifying that when the timestamp field is present in the meta line, it takes precedence over mtime. that code path lives at lib/codex-manager/commands/history.ts:115–218 and is untested directly.

type definition for toSummarylib/codex-manager/commands/history.ts:265–270 strips messages and cliVersion from the summary type. the --json list test at test/codex-manager-history-command.test.ts:79–232 asserts provider is present and heavy fields absent, which is good. confirm the HistorySessionSummary type definition at lib/codex-manager/commands/history.ts:28–51 explicitly omits those fields rather than just undefined at runtime; otherwise callers serializing the object could emit nulls.

no end-to-end routing testscripts/codex-routing.js:27 adds "history" to AUTH_SUBCOMMANDS. test/codex-manager-history-command.test.ts:354–376 covers the dispatch inside runHistoryCommand, but there is no test exercising shouldHandleMultiAuthAuth with ["auth", "history", ...] args to confirm the routing script change is correct end-to-end.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 11.11% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed Title follows conventional commits format with type 'feat', scoped to 'history', summary is 'add provider-agnostic local session browser' (65 chars, lowercase imperative).
Description check ✅ Passed Description is comprehensive with diagnosis, change summary, design notes, and testing details, but missing explicit validation checklist markings and risk/rollback section.
Linked Issues check ✅ Passed PR fully addresses issue #612: provides read-only history browser bypassing provider filter, supports multi-provider session discovery, includes list/show subcommands with --json flag, and resolves CODEX_HOME handling.
Out of Scope Changes check ✅ Passed All changes are scoped to history command implementation and documentation. Four routing files, test file, and docs updates all directly support the new feature with no unrelated modifications.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

📋 Issue Planner

Built with CodeRabbit's Coding Plans for faster development and fewer bugs.

View plan used: #612

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/612-history-command
✨ Simplify code
  • Create PR with simplified code
  • Commit simplified code in branch fix/612-history-command

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

test/codex-manager-history-command.test.ts

Oops! Something went wrong! :(

ESLint: 10.0.0

Error: The 'jiti' library is required for loading TypeScript configuration files. Make sure to install it.
at /node_modules/eslint/lib/config/config-loader.js:145:10
at async loadTypeScriptConfigFileWithJiti (/node_modules/eslint/lib/config/config-loader.js:144:3)
at async loadConfigFile (/node_modules/eslint/lib/config/config-loader.js:265:11)
at async ConfigLoader.calculateConfigArray (/node_modules/eslint/lib/config/config-loader.js:588:23)
at async #calculateConfigArray (/node_modules/eslint/lib/config/config-loader.js:369:19)
at async Promise.all (index 0)
at async findFiles (/node_modules/eslint/lib/eslint/eslint-helpers.js:635:25)
at async ESLint.lintFiles (/node_modules/eslint/lib/eslint/eslint.js:1014:21)
at async Object.execute (/node_modules/eslint/lib/cli.js:386:14)
at async main (/node_modules/eslint/bin/eslint.js:175:19)


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Comment thread lib/codex-manager/commands/history.ts
Comment thread lib/codex-manager/commands/history.ts

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 5

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
test/documentation.test.ts (1)

349-382: 🧹 Nitpick | 🔵 Trivial | ⚡ Quick win

extend doc parity assertion for the new history section

line 360 validates --json coverage, but this test block does not assert that docs/reference/commands.md still contains the new ## \codex-multi-auth history`section and its usage lines. add those assertions to keep command-reference parity locked intest/documentation.test.ts:331`.

as per coding guidelines, “test/**/documentation.test.ts: test documentation parity, CLI command flags, config precedence, and governance policy in documentation.test.ts.”

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@test/documentation.test.ts` around lines 349 - 382, The test block is missing
assertions to verify that the new `history` command documentation exists in the
command reference. Add expect statements after line 360 to check that commandRef
contains the new `## \`codex-multi-auth history\`` section header and also
verify that it contains the appropriate usage line for the history command
(similar to how the test currently validates other commands like workspace and
fix). This ensures command-reference parity is maintained in the documentation
test coverage.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@docs/reference/commands.md`:
- Around line 233-255: The documentation describes sessions being read from a
fixed path `~/.codex/sessions`, but the runtime behavior in
`lib/codex-manager/commands/history.ts` resolves the codex home dynamically.
Update the description in the "Lists local Codex sessions" section to clarify
that sessions are read from `<codex-home>/sessions` (with the default being
`~/.codex/sessions`) to accurately reflect how the runtime resolves the session
directory path.

In `@lib/codex-manager/commands/history.ts`:
- Around line 273-275: The hardcoded path ~/.codex/sessions in the logInfo
message does not reflect the dynamically resolved Codex home directory when
CODEX_HOME is overridden. Replace the hardcoded path string "~/.codex/sessions"
with a dynamic path using join(resolved.getCodexHome(), "sessions") to ensure
users are directed to the correct location. This change must be applied at both
locations where this hardcoded path appears in the resolved.logInfo calls
(around line 274 and around line 360-363 in the history.ts file).
- Around line 373-383: The issue is that when `history --json` is called, the
`--json` flag is extracted as the subcommand instead of being treated as an
argument to the default `list` subcommand. In the runHistoryCommand function
around the subcommand extraction at line 373, check if the first element of args
starts with `--` or `-` (indicating it's a flag), and if so, skip the subcommand
extraction and treat the entire args array as arguments to the default list path
at line 381. This ensures that flags like `--json` are properly passed as
arguments to the list command rather than being misinterpreted as subcommands.
Additionally, add a regression test in
test/codex-manager-history-command.test.ts that covers the case
runHistoryCommand(["--json"], deps) to ensure this behavior remains stable and
that the json workflow functions correctly.

In `@test/codex-manager-history-command.test.ts`:
- Around line 45-73: The test suite lacks regression coverage for codex home
override behavior and Windows path resolution semantics. Add new test cases that
exercise the createDeps helper function with different home path configurations:
one test that injects a Windows-style home path (using backslashes and drive
letters) and another that uses a non-default home root directory. These tests
should verify that path joining and session discovery work correctly when the
home directory is overridden through the getCodexHome dependency, ensuring the
command properly resolves and handles both standard and non-standard home
directory paths.
- Around line 184-191: The existing test case covers the scenario where
readDirRecursive returns an empty list, but lacks a regression test for when
readDirRecursive throws an ENOENT error to represent a truly missing directory.
Add a new test case alongside the existing "reports an empty listing without
error when the sessions dir is missing" test that mocks readDirRecursive to
throw an ENOENT error, then verify that runHistoryCommand with the "list"
argument still exits with code 0 and reports "No local Codex sessions found" in
the output, ensuring the actual missing-directory failure path is covered.

---

Outside diff comments:
In `@test/documentation.test.ts`:
- Around line 349-382: The test block is missing assertions to verify that the
new `history` command documentation exists in the command reference. Add expect
statements after line 360 to check that commandRef contains the new `##
\`codex-multi-auth history\`` section header and also verify that it contains
the appropriate usage line for the history command (similar to how the test
currently validates other commands like workspace and fix). This ensures
command-reference parity is maintained in the documentation test coverage.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 663c11d7-7266-4238-9d47-61d591509dee

📥 Commits

Reviewing files that changed from the base of the PR and between 5a76b15 and dfabde2.

📒 Files selected for processing (9)
  • docs/reference/commands.md
  • docs/troubleshooting.md
  • lib/codex-manager.ts
  • lib/codex-manager/account-manager-commands.ts
  • lib/codex-manager/commands/history.ts
  • lib/codex-manager/help.ts
  • scripts/codex-routing.js
  • test/codex-manager-history-command.test.ts
  • test/documentation.test.ts
📜 Review details
🧰 Additional context used
📓 Path-based instructions (22)
lib/**/*.ts

📄 CodeRabbit inference engine (lib/AGENTS.md)

lib/**/*.ts: Runtime rotation code must preserve pass-through semantics except for auth/provider headers that intentionally change
Never import from dist/ in source tests or library code

Files:

  • lib/codex-manager/help.ts
  • lib/codex-manager/account-manager-commands.ts
  • lib/codex-manager.ts
  • lib/codex-manager/commands/history.ts
lib/**/*.{ts,tsx}

📄 CodeRabbit inference engine (lib/AGENTS.md)

Never suppress type errors

Files:

  • lib/codex-manager/help.ts
  • lib/codex-manager/account-manager-commands.ts
  • lib/codex-manager.ts
  • lib/codex-manager/commands/history.ts
!{dist/**,**/.*,**/node_modules/**}

📄 CodeRabbit inference engine (AGENTS.md)

Store source code in root index.ts, lib/, and scripts/ directories; never edit dist/ or local temp/cache directories as they are generated output

Files:

  • lib/codex-manager/help.ts
  • test/documentation.test.ts
  • lib/codex-manager/account-manager-commands.ts
  • docs/troubleshooting.md
  • scripts/codex-routing.js
  • docs/reference/commands.md
  • lib/codex-manager.ts
  • lib/codex-manager/commands/history.ts
  • test/codex-manager-history-command.test.ts
**/*.{ts,tsx,js,mjs,cjs}

📄 CodeRabbit inference engine (AGENTS.md)

Use ESM only with "type": "module" configuration and require Node >= 18.17

Files:

  • lib/codex-manager/help.ts
  • test/documentation.test.ts
  • lib/codex-manager/account-manager-commands.ts
  • scripts/codex-routing.js
  • lib/codex-manager.ts
  • lib/codex-manager/commands/history.ts
  • test/codex-manager-history-command.test.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

Do not use TypeScript type assertions (as any, @ts-ignore, or @ts-expect-error)

Files:

  • lib/codex-manager/help.ts
  • test/documentation.test.ts
  • lib/codex-manager/account-manager-commands.ts
  • lib/codex-manager.ts
  • lib/codex-manager/commands/history.ts
  • test/codex-manager-history-command.test.ts
**/*.{js,ts,tsx,jsx,json}

📄 CodeRabbit inference engine (README.md)

**/*.{js,ts,tsx,jsx,json}: Use CODEX_MULTI_AUTH_DIR environment variable to override the default settings and accounts storage root from ~/.codex/multi-auth/
Use CODEX_MULTI_AUTH_RUNTIME_ROTATION_PROXY=0/1 to disable or enable the default-on live Responses proxy rotation for forwarded Codex CLI/app sessions
Keep CODEX_MODE=0/1 environment variable for disabling/enabling Codex mode in runtime

Files:

  • lib/codex-manager/help.ts
  • test/documentation.test.ts
  • lib/codex-manager/account-manager-commands.ts
  • scripts/codex-routing.js
  • lib/codex-manager.ts
  • lib/codex-manager/commands/history.ts
  • test/codex-manager-history-command.test.ts
**/*.{js,ts,tsx,jsx}

📄 CodeRabbit inference engine (README.md)

**/*.{js,ts,tsx,jsx}: Implement stateful Responses background: true compatibility only when opt-in via backgroundResponses setting or CODEX_AUTH_BACKGROUND_RESPONSES=1 environment variable
Set request timeout behavior using CODEX_AUTH_FETCH_TIMEOUT_MS and stream stall timeout using CODEX_AUTH_STREAM_STALL_TIMEOUT_MS environment variables
Use CODEX_TUI_V2=0/1, CODEX_TUI_COLOR_PROFILE, and CODEX_TUI_GLYPHS environment variables to control terminal UI appearance and capabilities
Store accounts data in openai-codex-accounts.json file within the configured storage root, with per-project account files under ~/.codex/multi-auth/projects/<project-key>/
Store flagged accounts separately in openai-codex-flagged-accounts.json to support account recovery and repair workflows
Implement quota caching by writing to and reading from ~/.codex/multi-auth/quota-cache.json
Track runtime observability metrics in ~/.codex/multi-auth/runtime-observability.json with request counters, budget state, and multi-auth probe visibility
Record local usage in ~/.codex/multi-auth/usage/usage-ledger.jsonl using JSONL (newline-delimited JSON) format for each usage event
Store account policies in ~/.codex/multi-auth/account-policies.json to enable policy controls and account capability views
Store routing profiles in ~/.codex/multi-auth/routing-profiles.json for multi-auth routing configuration
Store budget guards in ~/.codex/multi-auth/budget-guards.json to implement runtime budget constraints and prevent over-spending
Store local client bridge tokens in ~/.codex/multi-auth/local-client-tokens.json with hashed values for /health, /v1/models, and /v1/responses endpoint protection
Implement all dashboard navigation using the specified hotkeys: Up/Down for movement, Enter for selection, 1-9 for quick switch, / for search, ? for help, Q for back/cancel
Implement account details dashboard with the specified hotkeys: S for set account, R for refresh/re-login, E fo...

Files:

  • lib/codex-manager/help.ts
  • test/documentation.test.ts
  • lib/codex-manager/account-manager-commands.ts
  • scripts/codex-routing.js
  • lib/codex-manager.ts
  • lib/codex-manager/commands/history.ts
  • test/codex-manager-history-command.test.ts
lib/**

⚙️ CodeRabbit configuration file

focus on auth rotation, windows filesystem IO, and concurrency. verify every change cites affected tests (vitest) and that new queues handle EBUSY/429 scenarios. check for logging that leaks tokens or emails.

Files:

  • lib/codex-manager/help.ts
  • lib/codex-manager/account-manager-commands.ts
  • lib/codex-manager.ts
  • lib/codex-manager/commands/history.ts
**

⚙️ CodeRabbit configuration file

**: # PROJECT KNOWLEDGE BASE

Generated: 2026-04-25
Commit: a87e005
Validated: 2026-06-10 against commit 98d9819 (repo audit; claims re-checked against the tree, content not regenerated)
Branch: main
Package version: 2.3.0

OVERVIEW

codex-multi-auth is a Codex CLI-first OAuth account manager and optional forwarding wrapper for the official Codex CLI. The installed codex-multi-auth entrypoint handles account-management commands locally, codex-multi-auth-codex forwards official Codex commands through this package's wrapper when explicitly used, and runtime rotation can route live Responses traffic through a localhost account-rotation proxy by default. The plugin-host entrypoint remains exported for compatibility, but the primary product surface is the account manager, optional wrapper, storage, runtime proxy, and repair tooling.

STRUCTURE

./
├── scripts/
│   ├── codex.js              # codex-multi-auth-codex wrapper, official CLI forwarder, shadow CODEX_HOME/runtime proxy setup
│   ├── codex-multi-auth.js   # standalone package CLI entrypoint
│   ├── codex-routing.js      # auth command and compatibility alias routing
│   ├── codex-bin-resolver.js # official Codex binary discovery
│   ├── codex-app-router.js   # persistent localhost router for packaged Codex app bind
│   └── codex-app-launcher.js # reversible user-level app launcher routing helper
├── index.ts                  # optional plugin-host runtime entry
├── lib/                      # core runtime logic (see lib/AGENTS.md)
│   ├── auth/                 # OAuth flow, PKCE, callback server
│   ├── runtime/              # Codex CLI/app integration helpers, app bind, live sync, runtime observability
│   ├── request/              # request transform, SSE, failover, backoff
│   ├── storage/              # path resolution, migrations, backups, restore, import/export
│   ├── codex-cli/            # Codex CLI state sync and writer helpers
│   ├── codex-manager/        # command modules and settin...

Files:

  • lib/codex-manager/help.ts
  • test/documentation.test.ts
  • lib/codex-manager/account-manager-commands.ts
  • docs/troubleshooting.md
  • scripts/codex-routing.js
  • docs/reference/commands.md
  • lib/codex-manager.ts
  • lib/codex-manager/commands/history.ts
  • test/codex-manager-history-command.test.ts
test/**/*.test.ts

📄 CodeRabbit inference engine (test/AGENTS.md)

test/**/*.test.ts: Write Vitest test suites with globals enabled (describe, it, expect)
Maintain 80%+ coverage threshold across statements, branches, functions, and lines
Use removeWithRetry() for Windows filesystem cleanup instead of bare fs.rm to handle EBUSY, EPERM, and ENOTEMPTY errors
Do not rely on dist/ in tests; use source files instead
Do not skip tests without justification
Relax lint rules for test files as configured in eslint.config.js

Files:

  • test/documentation.test.ts
  • test/codex-manager-history-command.test.ts
test/**/documentation.test.ts

📄 CodeRabbit inference engine (test/AGENTS.md)

Test documentation parity, CLI command flags, config precedence, and governance policy in documentation.test.ts

Files:

  • test/documentation.test.ts
test/**

⚙️ CodeRabbit configuration file

tests must stay deterministic and use vitest. demand regression cases that reproduce concurrency bugs, token refresh races, and windows filesystem behavior. reject changes that mock real secrets or skip assertions.

Files:

  • test/documentation.test.ts
  • test/codex-manager-history-command.test.ts
lib/**/account*.ts

📄 CodeRabbit inference engine (lib/AGENTS.md)

lib/**/account*.ts: Account health is 0-100 and should be updated through the account manager APIs
Email dedup uses normalizeEmailKey(): trim + lowercase

Files:

  • lib/codex-manager/account-manager-commands.ts
docs/troubleshooting.md

📄 CodeRabbit inference engine (docs/DOCUMENTATION.md)

Update docs/troubleshooting.md with new failure signatures or recovery steps

Files:

  • docs/troubleshooting.md
docs/**/*.md

📄 CodeRabbit inference engine (docs/STYLE_GUIDE.md)

docs/**/*.md: User-facing documentation should follow the page template: Title and one-line lead, Quick path commands, Core operational workflow, Troubleshooting or failure handling, and Related links
Use short sections and scan-friendly tables in documentation where they improve clarity
Prefer direct, actionable language in documentation
Use runnable command examples in documentation
Explain expected outcomes after critical commands in documentation
Keep terminology consistent with runtime names in documentation
Avoid speculative language when behavior is deterministic in documentation
Put the user problem in the first paragraph before implementation detail
Use descriptive page titles such as codex-multi-auth Features instead of generic titles on public docs
Do not repeat keyword lists in every section; search terms should appear only where they help a developer understand the page
Canonical command family is codex-multi-auth ...
Canonical runtime root is ~/.codex/multi-auth
Runtime rotation must be described as default-on unless the release policy changes
Legacy command/path references belong only in migration contexts in documentation
Compatibility aliases (codex multi auth, codex multi-auth, codex multiauth) belong only in command reference, troubleshooting, or migration contexts
Keep command flags aligned with runtime usage text in documentation
Avoid non-runnable command snippets in documentation
Avoid conflicting path guidance across documentation
Avoid legacy-first onboarding language in documentation

Documentation should follow the governance contract defined in DOCUMENTATION.md

Files:

  • docs/troubleshooting.md
  • docs/reference/commands.md
docs/**/troubleshooting.md

📄 CodeRabbit inference engine (docs/README.md)

Troubleshooting documentation should include recovery playbooks for install, login, switching, and stale state issues

Files:

  • docs/troubleshooting.md
docs/**

⚙️ CodeRabbit configuration file

keep README, SECURITY, and docs consistent with actual CLI flags and workflows. whenever behavior changes, require updated upgrade notes and mention new npm scripts.

Files:

  • docs/troubleshooting.md
  • docs/reference/commands.md

⚙️ CodeRabbit configuration file

docs/**: # Documentation Architecture

Canonical governance for repository documentation quality and consistency.


Documentation Layers

Layer Audience Primary goal
Product entry New operators and search visitors Explain the project quickly, prioritize the right concepts first, and complete first successful login/check
User operations Daily users Configure, run, recover, and report issues safely
Reference Power users and maintainers Exact command, setting, and path lookup
Development Contributors and maintainers Internal architecture, flow, tests, and ownership

Source of Truth Map

Scope File
Project entry README.md
Docs portal docs/README.md
Daily operator landing docs/index.md
Onboarding docs/getting-started.md
FAQ docs/faq.md
Public architecture overview docs/architecture.md
Feature map docs/features.md
Configuration guide docs/configuration.md
Troubleshooting guide docs/troubleshooting.md
Privacy and data handling docs/privacy.md
Upgrade and migration docs/upgrade.md
Command reference docs/reference/commands.md
Public API contract docs/reference/public-api.md
Error contract reference docs/reference/error-contracts.md
Settings reference docs/reference/settings.md
Storage path reference docs/reference/storage-paths.md
Docs style contract docs/STYLE_GUIDE.md
Docs governance (this file) docs/DOCUMENTATION.md
Architecture internals docs/development/ARCHITECTURE.md
Runtime rotation implementation guide docs/development/ARCHITECTURE.md
GitHub metadata guidance docs/development/GITHUB_DISCOVERABILITY.md
IA/findability audit (2026-03-01) docs/development/IA_FINDABILITY_AUDIT_2026-03-01.md
Config fields internals docs/development/CONFIG_FIELDS.md
Config flow internals `docs/development/CONF...

Files:

  • docs/troubleshooting.md
  • docs/reference/commands.md
scripts/{codex.js,codex-routing.js}

📄 CodeRabbit inference engine (AGENTS.md)

Do not bypass the official Codex CLI by reimplementing general Codex commands in the wrapper; forward non-auth commands to the official Codex CLI

Files:

  • scripts/codex-routing.js
scripts/**/*.js

📄 CodeRabbit inference engine (AGENTS.md)

Do not use bare recursive delete logic in Windows-sensitive scripts/tests without retry handling for transient EBUSY/EPERM/ENOTEMPTY failures

Files:

  • scripts/codex-routing.js
docs/reference/**/*.md

📄 CodeRabbit inference engine (docs/DOCUMENTATION.md)

Update relevant command/settings/path references in reference documentation when runtime changes occur

New flags/settings/paths must be reflected in docs/reference/*

Files:

  • docs/reference/commands.md
docs/reference/commands.md

📄 CodeRabbit inference engine (docs/DOCUMENTATION.md)

Verify CLI flags documented in references match runtime parser/usage output

Reference commands documentation should include commands, flags, and hotkeys

Files:

  • docs/reference/commands.md
docs/reference/**

⚙️ CodeRabbit configuration file

docs/reference/**: # Command Reference

Complete command, flag, and hotkey reference for codex-multi-auth.


Canonical Command Family

Primary operations use codex-multi-auth ....

Compatibility forms are supported for migrations and wrapper-routed environments:

  • codex-multi-auth auth ...
  • codex-multi-auth-codex auth ...
  • codex auth ... when this package's wrapper has explicitly been installed or aliased as codex
  • codex multi auth ...
  • codex multi-auth ...
  • codex multiauth ...

Start Here

Command Description
codex-multi-auth login Open interactive auth dashboard
codex-multi-auth status Print short runtime/account summary
codex-multi-auth check Run quick account health check

Daily Use

Command Description
codex-multi-auth list List saved accounts and active account
codex-multi-auth switch <index> Set active account by index and pin it for runtime routing
codex-multi-auth unpin Clear the manual pin set by switch and resume hybrid rotation
codex-multi-auth forecast Forecast best account by readiness/risk
codex-multi-auth best Pick and optionally sync the best account (clears any manual pin)
codex-multi-auth account ... Manage local account policy metadata
codex-multi-auth workspace <account> [workspace] List an account's tracked workspaces, or set its active workspace

Sticky session affinity: switch, unpin, and best all bump an
affinityGeneration counter in storage that the runtime rotation proxy
observes via the same mtime-cached read path it uses for the manual pin.
When the proxy sees a higher generation than its in-memory tracker, it
drops every entry in its session-affinity store. Net effect: a manual
change reaches the next desktop-app request even mid-conversation, instead
of being shadowed for up to 20 minutes by a per-thread account lock that
would otherwise glue t...

Files:

  • docs/reference/commands.md
🧠 Learnings (3)
📓 Common learnings
Learnt from: CR
Repo: ndycode/codex-multi-auth

Timestamp: 2026-06-16T11:59:30.173Z
Learning: Support canonical command family with primary operation using `codex-multi-auth ...` and compatibility forms including `codex-multi-auth auth ...`, `codex-multi-auth-codex auth ...`, `codex auth ...`, `codex multi auth ...`, `codex multi-auth ...`, and `codex multiauth ...`
Learnt from: CR
Repo: ndycode/codex-multi-auth

Timestamp: 2026-06-16T11:59:41.178Z
Learning: When opening a bug report for codex-multi-auth issues, attach the outputs of `codex-multi-auth report --json`, `codex-multi-auth doctor --json`, `codex --version`, `codex-multi-auth --version`, `npm ls -g codex-multi-auth`, and the failing command with full terminal output
Learnt from: CR
Repo: ndycode/codex-multi-auth

Timestamp: 2026-06-16T11:59:41.178Z
Learning: Use `codex-multi-auth login --device-auth` for authentication in remote, SSH, container, or headless shell environments where browser-based OAuth is unavailable
Learnt from: CR
Repo: ndycode/codex-multi-auth

Timestamp: 2026-06-16T11:59:41.178Z
Learning: Set `CODEX_MULTI_AUTH_RUNTIME_ROTATION_PROXY=1` to enable runtime rotation for a single process, or run `codex-multi-auth rotation enable` to enable it globally
Learnt from: CR
Repo: ndycode/codex-multi-auth

Timestamp: 2026-06-16T11:59:41.178Z
Learning: When app bind for runtime rotation causes Codex history to disappear, use `codex-multi-auth history` to list all local sessions across providers and `codex resume <id>` to reopen sessions from the new provider context
Learnt from: CR
Repo: ndycode/codex-multi-auth

Timestamp: 2026-06-16T11:59:41.178Z
Learning: Set `minRotationIntervalMs` to at least `60000` (default) to prevent rapid account rotation from triggering OpenAI's anti-abuse detection and token invalidation
Learnt from: CR
Repo: ndycode/codex-multi-auth

Timestamp: 2026-06-16T11:59:41.178Z
Learning: Set `model_reasoning_effort` in `~/.codex/config.toml` or pass `-c model_reasoning_effort=<level>` to CLI sessions to restore model speed control visibility when using runtime rotation
Learnt from: CR
Repo: ndycode/codex-multi-auth

Timestamp: 2026-06-16T11:59:41.178Z
Learning: Before uninstalling codex-multi-auth, run `codex-multi-auth uninstall` (with optional flags like `--dry-run`, `--json`, or `--clear-accounts`) to properly remove app bindings, OS launchers, plugin entries, and cached files before executing `npm uninstall -g codex-multi-auth`
Learnt from: CR
Repo: ndycode/codex-multi-auth

Timestamp: 2026-06-16T11:59:41.178Z
Learning: When Microsoft/Outlook SSO accounts are invalidated on every first request through the proxy due to different IP or device context, set `CODEX_AUTH_TOKEN_INVALIDATION_COOLDOWN_MS=600000` (10 minutes) and re-login
📚 Learning: 2026-06-04T06:14:18.093Z
Learnt from: ndycode
Repo: ndycode/codex-multi-auth PR: 510
File: test/scheduling-strategy-config.test.ts:1-1
Timestamp: 2026-06-04T06:14:18.093Z
Learning: In ndycode/codex-multi-auth, do not flag explicit imports from "vitest" (e.g., describe, it, expect, beforeEach/afterEach, etc.) in test files as issues—even if the Vitest config sets `globals: true`. The repo’s established convention is to keep these imports for consistency with neighboring tests; removing them would make files outliers.

Applied to files:

  • test/documentation.test.ts
  • test/codex-manager-history-command.test.ts
📚 Learning: 2026-06-04T06:14:24.975Z
Learnt from: ndycode
Repo: ndycode/codex-multi-auth PR: 510
File: test/runtime-rotation-proxy.test.ts:2478-2491
Timestamp: 2026-06-04T06:14:24.975Z
Learning: In ndycode/codex-multi-auth test files (e.g. `test/*.test.ts`), when creating V3 storage fixtures for accounts, it’s an intentional convention to use `as never` for deliberately minimal stored-account objects that only include `refreshToken`, `addedAt`, and `lastUsed`. Do not treat `as never` here as a type-safety problem: optional/other fields are expected to be populated by the runtime during execution, and the cast is used solely to keep the fixture minimal and consistent across existing tests.

Applied to files:

  • test/documentation.test.ts
  • test/codex-manager-history-command.test.ts
🔇 Additional comments (3)
lib/codex-manager.ts (1)

81-81: LGTM!

Also applies to: 595-595

lib/codex-manager/account-manager-commands.ts (1)

39-39: LGTM!

scripts/codex-routing.js (1)

27-27: LGTM!

Comment thread docs/reference/commands.md Outdated
Comment thread lib/codex-manager/commands/history.ts
Comment thread lib/codex-manager/commands/history.ts
Comment thread test/codex-manager-history-command.test.ts
Comment thread test/codex-manager-history-command.test.ts
…output

Address review feedback on #613:

- `history --json` (no explicit `list`) parsed `--json` as the subcommand
  and errored "Unknown history command". A leading `-`/`--` arg is now
  forwarded to the default `list` path, matching the documented
  `[list] [--json]` usage. (Greptile P1 / CodeRabbit major)
- User-facing "no sessions found" message and the reference docs hardcoded
  `~/.codex/sessions`; both now reflect the resolved `<codex-home>/sessions`
  so they are correct under a `CODEX_HOME` override.
- `collectSessions` now tolerates a throwing `readDirRecursive` (missing /
  unreadable sessions dir) instead of propagating, returning an empty list.
- Filename id-extraction is separator-agnostic so Windows-style rollout
  paths resolve regardless of host platform.

Adds regression tests: `history --json` default path, ENOENT-throwing
sessions dir, CODEX_HOME override (sessions dir + empty-listing message).

Skipped (noted on PR): Greptile P2 suggestion to look up the rollout file
by id in `show` rather than scanning all files — it is explicitly not a
correctness bug and the O(n) read is negligible for realistic histories;
a targeted glob rewrite adds risk for no user-visible benefit.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@ndycode

ndycode commented Jun 16, 2026

Copy link
Copy Markdown
Owner Author

Thanks for the reviews — pushed 939e6aa addressing the actionable findings:

  • history --json treated as unknown subcommand (Greptile P1 / CodeRabbit major): fixed. A leading -/-- arg now falls through to the default list path, so the documented [list] [--json] form works. Added a regression test (runHistoryCommand(["--json"], deps)).
  • Hardcoded ~/.codex/sessions under CODEX_HOME override (CodeRabbit): the empty-listing message now prints join(getCodexHome(), "sessions"), and docs/reference/commands.md now says <codex-home>/sessions (default ~/.codex/sessions). Added a CODEX_HOME-override test for both the resolved dir and the message.
  • Missing-directory failure path (CodeRabbit): collectSessions now tolerates a throwing readDirRecursive and returns an empty listing; added an ENOENT-throw regression test.
  • Windows path resolution (CodeRabbit): filename id-extraction is now separator-agnostic, and there's a Windows-style-home regression test.

Skipped — Greptile P2 (show scans all rollouts instead of direct filename lookup): it's explicitly flagged as "not a correctness bug." The id-in-filename lookup would require globbing the timestamp-prefixed name across the date-sharded tree, changing the parse path for no user-visible benefit at realistic session counts. Not worth the added surface area here; happy to revisit if deep-history latency becomes a real concern.

All green locally: build, typecheck, typecheck:scripts, eslint, and the full codex-manager-history-command (16), documentation, and codex-routing suites.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
test/codex-manager-history-command.test.ts (1)

302-327: 🛠️ Refactor suggestion | 🟠 Major | ⚡ Quick win

missing show --json test coverage.

line 302 tests show in text mode only. the help text at lib/codex-manager/help.ts:38 documents [--json] for both list and show, but this suite never validates runHistoryCommand(["show", "<id>", "--json"], deps) output structure or message inclusion behavior.

🧪 proposed test case

add after line 327:

+	it("emits machine-readable JSON for show with all messages", () => {
+		const deps = createDeps([
+			{
+				id: "019e9836-5001-7821-a9c2-3ffd26a1199b",
+				content: [
+					metaLine({ model_provider: "openai" }),
+					userMessageLine("message one"),
+					userMessageLine("message two"),
+					userMessageLine("message three"),
+					userMessageLine("message four"),
+				].join("\n"),
+			},
+		]);
+
+		const code = runHistoryCommand(
+			["show", "019e9836-5001-7821-a9c2-3ffd26a1199b", "--json"],
+			deps,
+		);
+
+		expect(code).toBe(0);
+		const payload = JSON.parse(allOutput(deps.logInfo));
+		expect(payload.id).toBe("019e9836-5001-7821-a9c2-3ffd26a1199b");
+		expect(payload.provider).toBe("openai");
+		expect(payload.messages).toHaveLength(4);
+	});
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@test/codex-manager-history-command.test.ts` around lines 302 - 327, The test
suite for the history command is missing coverage for the --json flag supported
by the show command. Add a new test case after the existing "shows provider
metadata and first user messages" test that validates the JSON output structure
and message inclusion behavior when calling runHistoryCommand with the --json
flag alongside the show command and ID, similar to the existing test but
verifying JSON format output instead of text mode output.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@test/codex-manager-history-command.test.ts`:
- Around line 302-327: The test suite for the history command is missing
coverage for the --json flag supported by the show command. Add a new test case
after the existing "shows provider metadata and first user messages" test that
validates the JSON output structure and message inclusion behavior when calling
runHistoryCommand with the --json flag alongside the show command and ID,
similar to the existing test but verifying JSON format output instead of text
mode output.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: f7b22877-a4c0-4126-b5f2-c651bec62beb

📥 Commits

Reviewing files that changed from the base of the PR and between dfabde2 and 939e6aa.

📒 Files selected for processing (3)
  • docs/reference/commands.md
  • lib/codex-manager/commands/history.ts
  • test/codex-manager-history-command.test.ts
📜 Review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Greptile Review
🧰 Additional context used
📓 Path-based instructions (16)
docs/reference/**/*.md

📄 CodeRabbit inference engine (docs/DOCUMENTATION.md)

Update relevant command/settings/path references in reference documentation when runtime changes occur

New flags/settings/paths must be reflected in docs/reference/*

Files:

  • docs/reference/commands.md
docs/reference/commands.md

📄 CodeRabbit inference engine (docs/DOCUMENTATION.md)

Verify CLI flags documented in references match runtime parser/usage output

Reference commands documentation should include commands, flags, and hotkeys

Files:

  • docs/reference/commands.md
docs/**/*.md

📄 CodeRabbit inference engine (docs/STYLE_GUIDE.md)

docs/**/*.md: User-facing documentation should follow the page template: Title and one-line lead, Quick path commands, Core operational workflow, Troubleshooting or failure handling, and Related links
Use short sections and scan-friendly tables in documentation where they improve clarity
Prefer direct, actionable language in documentation
Use runnable command examples in documentation
Explain expected outcomes after critical commands in documentation
Keep terminology consistent with runtime names in documentation
Avoid speculative language when behavior is deterministic in documentation
Put the user problem in the first paragraph before implementation detail
Use descriptive page titles such as codex-multi-auth Features instead of generic titles on public docs
Do not repeat keyword lists in every section; search terms should appear only where they help a developer understand the page
Canonical command family is codex-multi-auth ...
Canonical runtime root is ~/.codex/multi-auth
Runtime rotation must be described as default-on unless the release policy changes
Legacy command/path references belong only in migration contexts in documentation
Compatibility aliases (codex multi auth, codex multi-auth, codex multiauth) belong only in command reference, troubleshooting, or migration contexts
Keep command flags aligned with runtime usage text in documentation
Avoid non-runnable command snippets in documentation
Avoid conflicting path guidance across documentation
Avoid legacy-first onboarding language in documentation

Documentation should follow the governance contract defined in DOCUMENTATION.md

Files:

  • docs/reference/commands.md
!{dist/**,**/.*,**/node_modules/**}

📄 CodeRabbit inference engine (AGENTS.md)

Store source code in root index.ts, lib/, and scripts/ directories; never edit dist/ or local temp/cache directories as they are generated output

Files:

  • docs/reference/commands.md
  • test/codex-manager-history-command.test.ts
  • lib/codex-manager/commands/history.ts
docs/**

⚙️ CodeRabbit configuration file

keep README, SECURITY, and docs consistent with actual CLI flags and workflows. whenever behavior changes, require updated upgrade notes and mention new npm scripts.

Files:

  • docs/reference/commands.md

⚙️ CodeRabbit configuration file

docs/**: # Documentation Architecture

Canonical governance for repository documentation quality and consistency.


Documentation Layers

Layer Audience Primary goal
Product entry New operators and search visitors Explain the project quickly, prioritize the right concepts first, and complete first successful login/check
User operations Daily users Configure, run, recover, and report issues safely
Reference Power users and maintainers Exact command, setting, and path lookup
Development Contributors and maintainers Internal architecture, flow, tests, and ownership

Source of Truth Map

Scope File
Project entry README.md
Docs portal docs/README.md
Daily operator landing docs/index.md
Onboarding docs/getting-started.md
FAQ docs/faq.md
Public architecture overview docs/architecture.md
Feature map docs/features.md
Configuration guide docs/configuration.md
Troubleshooting guide docs/troubleshooting.md
Privacy and data handling docs/privacy.md
Upgrade and migration docs/upgrade.md
Command reference docs/reference/commands.md
Public API contract docs/reference/public-api.md
Error contract reference docs/reference/error-contracts.md
Settings reference docs/reference/settings.md
Storage path reference docs/reference/storage-paths.md
Docs style contract docs/STYLE_GUIDE.md
Docs governance (this file) docs/DOCUMENTATION.md
Architecture internals docs/development/ARCHITECTURE.md
Runtime rotation implementation guide docs/development/ARCHITECTURE.md
GitHub metadata guidance docs/development/GITHUB_DISCOVERABILITY.md
IA/findability audit (2026-03-01) docs/development/IA_FINDABILITY_AUDIT_2026-03-01.md
Config fields internals docs/development/CONFIG_FIELDS.md
Config flow internals `docs/development/CONF...

Files:

  • docs/reference/commands.md
**

⚙️ CodeRabbit configuration file

**: # PROJECT KNOWLEDGE BASE

Generated: 2026-04-25
Commit: a87e005
Validated: 2026-06-10 against commit 98d9819 (repo audit; claims re-checked against the tree, content not regenerated)
Branch: main
Package version: 2.3.0

OVERVIEW

codex-multi-auth is a Codex CLI-first OAuth account manager and optional forwarding wrapper for the official Codex CLI. The installed codex-multi-auth entrypoint handles account-management commands locally, codex-multi-auth-codex forwards official Codex commands through this package's wrapper when explicitly used, and runtime rotation can route live Responses traffic through a localhost account-rotation proxy by default. The plugin-host entrypoint remains exported for compatibility, but the primary product surface is the account manager, optional wrapper, storage, runtime proxy, and repair tooling.

STRUCTURE

./
├── scripts/
│   ├── codex.js              # codex-multi-auth-codex wrapper, official CLI forwarder, shadow CODEX_HOME/runtime proxy setup
│   ├── codex-multi-auth.js   # standalone package CLI entrypoint
│   ├── codex-routing.js      # auth command and compatibility alias routing
│   ├── codex-bin-resolver.js # official Codex binary discovery
│   ├── codex-app-router.js   # persistent localhost router for packaged Codex app bind
│   └── codex-app-launcher.js # reversible user-level app launcher routing helper
├── index.ts                  # optional plugin-host runtime entry
├── lib/                      # core runtime logic (see lib/AGENTS.md)
│   ├── auth/                 # OAuth flow, PKCE, callback server
│   ├── runtime/              # Codex CLI/app integration helpers, app bind, live sync, runtime observability
│   ├── request/              # request transform, SSE, failover, backoff
│   ├── storage/              # path resolution, migrations, backups, restore, import/export
│   ├── codex-cli/            # Codex CLI state sync and writer helpers
│   ├── codex-manager/        # command modules and settin...

Files:

  • docs/reference/commands.md
  • test/codex-manager-history-command.test.ts
  • lib/codex-manager/commands/history.ts
docs/reference/**

⚙️ CodeRabbit configuration file

docs/reference/**: # Command Reference

Complete command, flag, and hotkey reference for codex-multi-auth.


Canonical Command Family

Primary operations use codex-multi-auth ....

Compatibility forms are supported for migrations and wrapper-routed environments:

  • codex-multi-auth auth ...
  • codex-multi-auth-codex auth ...
  • codex auth ... when this package's wrapper has explicitly been installed or aliased as codex
  • codex multi auth ...
  • codex multi-auth ...
  • codex multiauth ...

Start Here

Command Description
codex-multi-auth login Open interactive auth dashboard
codex-multi-auth status Print short runtime/account summary
codex-multi-auth check Run quick account health check

Daily Use

Command Description
codex-multi-auth list List saved accounts and active account
codex-multi-auth switch <index> Set active account by index and pin it for runtime routing
codex-multi-auth unpin Clear the manual pin set by switch and resume hybrid rotation
codex-multi-auth forecast Forecast best account by readiness/risk
codex-multi-auth best Pick and optionally sync the best account (clears any manual pin)
codex-multi-auth account ... Manage local account policy metadata
codex-multi-auth workspace <account> [workspace] List an account's tracked workspaces, or set its active workspace

Sticky session affinity: switch, unpin, and best all bump an
affinityGeneration counter in storage that the runtime rotation proxy
observes via the same mtime-cached read path it uses for the manual pin.
When the proxy sees a higher generation than its in-memory tracker, it
drops every entry in its session-affinity store. Net effect: a manual
change reaches the next desktop-app request even mid-conversation, instead
of being shadowed for up to 20 minutes by a per-thread account lock that
would otherwise glue t...

Files:

  • docs/reference/commands.md
test/**/*.test.ts

📄 CodeRabbit inference engine (test/AGENTS.md)

test/**/*.test.ts: Write Vitest test suites with globals enabled (describe, it, expect)
Maintain 80%+ coverage threshold across statements, branches, functions, and lines
Use removeWithRetry() for Windows filesystem cleanup instead of bare fs.rm to handle EBUSY, EPERM, and ENOTEMPTY errors
Do not rely on dist/ in tests; use source files instead
Do not skip tests without justification
Relax lint rules for test files as configured in eslint.config.js

Files:

  • test/codex-manager-history-command.test.ts
**/*.{ts,tsx,js,mjs,cjs}

📄 CodeRabbit inference engine (AGENTS.md)

Use ESM only with "type": "module" configuration and require Node >= 18.17

Files:

  • test/codex-manager-history-command.test.ts
  • lib/codex-manager/commands/history.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

Do not use TypeScript type assertions (as any, @ts-ignore, or @ts-expect-error)

Files:

  • test/codex-manager-history-command.test.ts
  • lib/codex-manager/commands/history.ts
**/*.{js,ts,tsx,jsx,json}

📄 CodeRabbit inference engine (README.md)

**/*.{js,ts,tsx,jsx,json}: Use CODEX_MULTI_AUTH_DIR environment variable to override the default settings and accounts storage root from ~/.codex/multi-auth/
Use CODEX_MULTI_AUTH_RUNTIME_ROTATION_PROXY=0/1 to disable or enable the default-on live Responses proxy rotation for forwarded Codex CLI/app sessions
Keep CODEX_MODE=0/1 environment variable for disabling/enabling Codex mode in runtime

Files:

  • test/codex-manager-history-command.test.ts
  • lib/codex-manager/commands/history.ts
**/*.{js,ts,tsx,jsx}

📄 CodeRabbit inference engine (README.md)

**/*.{js,ts,tsx,jsx}: Implement stateful Responses background: true compatibility only when opt-in via backgroundResponses setting or CODEX_AUTH_BACKGROUND_RESPONSES=1 environment variable
Set request timeout behavior using CODEX_AUTH_FETCH_TIMEOUT_MS and stream stall timeout using CODEX_AUTH_STREAM_STALL_TIMEOUT_MS environment variables
Use CODEX_TUI_V2=0/1, CODEX_TUI_COLOR_PROFILE, and CODEX_TUI_GLYPHS environment variables to control terminal UI appearance and capabilities
Store accounts data in openai-codex-accounts.json file within the configured storage root, with per-project account files under ~/.codex/multi-auth/projects/<project-key>/
Store flagged accounts separately in openai-codex-flagged-accounts.json to support account recovery and repair workflows
Implement quota caching by writing to and reading from ~/.codex/multi-auth/quota-cache.json
Track runtime observability metrics in ~/.codex/multi-auth/runtime-observability.json with request counters, budget state, and multi-auth probe visibility
Record local usage in ~/.codex/multi-auth/usage/usage-ledger.jsonl using JSONL (newline-delimited JSON) format for each usage event
Store account policies in ~/.codex/multi-auth/account-policies.json to enable policy controls and account capability views
Store routing profiles in ~/.codex/multi-auth/routing-profiles.json for multi-auth routing configuration
Store budget guards in ~/.codex/multi-auth/budget-guards.json to implement runtime budget constraints and prevent over-spending
Store local client bridge tokens in ~/.codex/multi-auth/local-client-tokens.json with hashed values for /health, /v1/models, and /v1/responses endpoint protection
Implement all dashboard navigation using the specified hotkeys: Up/Down for movement, Enter for selection, 1-9 for quick switch, / for search, ? for help, Q for back/cancel
Implement account details dashboard with the specified hotkeys: S for set account, R for refresh/re-login, E fo...

Files:

  • test/codex-manager-history-command.test.ts
  • lib/codex-manager/commands/history.ts
test/**

⚙️ CodeRabbit configuration file

tests must stay deterministic and use vitest. demand regression cases that reproduce concurrency bugs, token refresh races, and windows filesystem behavior. reject changes that mock real secrets or skip assertions.

Files:

  • test/codex-manager-history-command.test.ts
lib/**/*.ts

📄 CodeRabbit inference engine (lib/AGENTS.md)

lib/**/*.ts: Runtime rotation code must preserve pass-through semantics except for auth/provider headers that intentionally change
Never import from dist/ in source tests or library code

Files:

  • lib/codex-manager/commands/history.ts
lib/**/*.{ts,tsx}

📄 CodeRabbit inference engine (lib/AGENTS.md)

Never suppress type errors

Files:

  • lib/codex-manager/commands/history.ts
lib/**

⚙️ CodeRabbit configuration file

focus on auth rotation, windows filesystem IO, and concurrency. verify every change cites affected tests (vitest) and that new queues handle EBUSY/429 scenarios. check for logging that leaks tokens or emails.

Files:

  • lib/codex-manager/commands/history.ts
🧠 Learnings (3)
📓 Common learnings
Learnt from: CR
Repo: ndycode/codex-multi-auth

Timestamp: 2026-06-16T12:16:15.166Z
Learning: Support canonical command family for codex-multi-auth: `codex-multi-auth ...`, `codex-multi-auth auth ...`, `codex-multi-auth-codex auth ...`, `codex auth ...` (when wrapper installed), `codex multi auth ...`, `codex multi-auth ...`, and `codex multiauth ...`
Learnt from: CR
Repo: ndycode/codex-multi-auth

Timestamp: 2026-06-16T12:16:15.166Z
Learning: Implement sticky session affinity by maintaining an `affinityGeneration` counter that the runtime rotation proxy observes via mtime-cached reads. When the proxy detects a higher generation than its in-memory tracker, drop every entry in the session-affinity store to ensure manual account changes reach the next desktop-app request instead of being shadowed by per-thread account locks
Learnt from: CR
Repo: ndycode/codex-multi-auth

Timestamp: 2026-06-16T12:16:15.166Z
Learning: Use local-only metadata in the usage ledger that does not contain prompts, tokens, auth headers, raw account emails, or raw sensitive account ids
Learnt from: CR
Repo: ndycode/codex-multi-auth

Timestamp: 2026-06-16T12:16:15.166Z
Learning: Persist account policy metadata with hashed policy keys derived from account identity; raw account ids and raw emails must not be stored in the policy file
Learnt from: CR
Repo: ndycode/codex-multi-auth

Timestamp: 2026-06-16T12:16:15.166Z
Learning: For storage-path resolution, implement and verify the chain: `process.cwd`, `findProjectRoot`, `resolveProjectStorageIdentityRoot`, `getProjectStorageKey`, `getProjectConfigDir`, `getProjectGlobalConfigDir`
Learnt from: CR
Repo: ndycode/codex-multi-auth

Timestamp: 2026-06-16T12:16:15.166Z
Learning: Implement sandbox validation that accepts paths inside home and temp directories but rejects escape-attempt paths outside the sandbox root
Learnt from: CR
Repo: ndycode/codex-multi-auth

Timestamp: 2026-06-16T12:16:15.166Z
Learning: Support CLI flags `--json` for machine-readable output on commands: verify-flagged, verify, why-selected, best, forecast, report, usage, budget, models, monitor, integrations, fix, doctor, config explain, debug bundle, history
Learnt from: CR
Repo: ndycode/codex-multi-auth

Timestamp: 2026-06-16T12:16:15.166Z
Learning: In non-TTY/manual shells, accept the full OAuth redirect URL on stdin for codex-multi-auth login --manual flows
Learnt from: CR
Repo: ndycode/codex-multi-auth

Timestamp: 2026-06-16T12:16:15.166Z
Learning: For the rotation proxy, return `codex_runtime_rotation_pool_exhausted` error code with a retry hint pointing to `codex-multi-auth rotation status` when every managed account is temporarily unavailable
Learnt from: CR
Repo: ndycode/codex-multi-auth

Timestamp: 2026-06-16T12:16:15.166Z
Learning: When packaged desktop app rotation is enabled and every account becomes unavailable, hard-fail with HTTP 503 status and `codex_pinned_account_unavailable` error code for pinned accounts
Learnt from: CR
Repo: ndycode/codex-multi-auth

Timestamp: 2026-06-16T12:16:15.166Z
Learning: Suppress browser launch when `CODEX_AUTH_NO_BROWSER=1` environment variable is set; false-like values such as `0` and `false` do not suppress browser launch by themselves
Learnt from: CR
Repo: ndycode/codex-multi-auth

Timestamp: 2026-06-16T12:16:15.166Z
Learning: For Codex desktop app launcher routing on Windows, retarget existing user-level Codex shortcuts and taskbar pins to the wrapper while backing up their original targets for restoration
Learnt from: CR
Repo: ndycode/codex-multi-auth

Timestamp: 2026-06-16T12:16:15.166Z
Learning: For Codex desktop app launcher routing on macOS, create or remove a user-level `Codex Multi Auth.app` wrapper wrapper because Dock entries cannot safely launch shell commands directly
Learnt from: CR
Repo: ndycode/codex-multi-auth

Timestamp: 2026-06-16T12:16:15.166Z
Learning: Support model speed/reasoning controls remaining Codex-owned; for wrapper-launched CLI sessions set `model_reasoning_effort` in `~/.codex/config.toml` or pass `-c model_reasoning_effort=<level>`
Learnt from: CR
Repo: ndycode/codex-multi-auth

Timestamp: 2026-06-16T12:16:15.166Z
Learning: Normalize account policy tag values to lowercase filesystem-safe labels
Learnt from: CR
Repo: ndycode/codex-multi-auth

Timestamp: 2026-06-16T12:16:32.799Z
Learning: Run `codex-multi-auth doctor --fix` followed by `codex-multi-auth check` and `codex-multi-auth forecast --live` as the initial recovery steps for Codex CLI multi-account install issues
Learnt from: CR
Repo: ndycode/codex-multi-auth

Timestamp: 2026-06-16T12:16:32.799Z
Learning: Verify Codex CLI and multi-auth package installation using platform-specific commands: `where` on Windows, `which` on macOS/Linux
Learnt from: CR
Repo: ndycode/codex-multi-auth

Timestamp: 2026-06-16T12:16:32.799Z
Learning: Uninstall the old scoped package `ndycode/codex-multi-auth` and install the current `codex-multi-auth` package globally
Learnt from: CR
Repo: ndycode/codex-multi-auth

Timestamp: 2026-06-16T12:16:32.799Z
Learning: Use `codex-multi-auth login --device-auth` for remote, SSH, container, or headless shell environments where browser-based OAuth is unavailable
Learnt from: CR
Repo: ndycode/codex-multi-auth

Timestamp: 2026-06-16T12:16:32.799Z
Learning: Re-login affected accounts when encountering `missing field id_token`, `refresh_token_reused`, or `token_expired` errors
Learnt from: CR
Repo: ndycode/codex-multi-auth

Timestamp: 2026-06-16T12:16:32.799Z
Learning: Re-run `codex-multi-auth switch <index>` and restart the session if account switching succeeds but the wrong account remains active
Learnt from: CR
Repo: ndycode/codex-multi-auth

Timestamp: 2026-06-16T12:16:32.799Z
Learning: Run `codex-multi-auth doctor --fix` and add at least one fresh account if all accounts appear unhealthy
Learnt from: CR
Repo: ndycode/codex-multi-auth

Timestamp: 2026-06-16T12:16:32.799Z
Learning: Enable runtime rotation using `codex-multi-auth rotation enable` or set `CODEX_MULTI_AUTH_RUNTIME_ROTATION_PROXY=1` environment variable
Learnt from: CR
Repo: ndycode/codex-multi-auth

Timestamp: 2026-06-16T12:16:32.799Z
Learning: Ensure `minRotationIntervalMs` is set to at least `60000` milliseconds (default) to avoid triggering OpenAI's anti-abuse detection during rapid account rotation
Learnt from: CR
Repo: ndycode/codex-multi-auth

Timestamp: 2026-06-16T12:16:32.799Z
Learning: Set `CODEX_AUTH_TOKEN_INVALIDATION_COOLDOWN_MS=600000` (10 minutes) and re-login if Microsoft/Outlook SSO accounts are invalidated on every first request through the proxy
Learnt from: CR
Repo: ndycode/codex-multi-auth

Timestamp: 2026-06-16T12:16:32.799Z
Learning: Run `codex-multi-auth rotation bind-app` to install the app bind if the packaged app still uses normal Codex routing
Learnt from: CR
Repo: ndycode/codex-multi-auth

Timestamp: 2026-06-16T12:16:32.799Z
Learning: Set `model_reasoning_effort` in `~/.codex/config.toml` or pass `-c model_reasoning_effort=<level>` to CLI flags when speed/reasoning controls are not visible with runtime rotation
Learnt from: CR
Repo: ndycode/codex-multi-auth

Timestamp: 2026-06-16T12:16:32.799Z
Learning: Run `codex-multi-auth rotation unbind-app` or `codex-multi-auth rotation disable` to remove app bind and restore official app config
Learnt from: CR
Repo: ndycode/codex-multi-auth

Timestamp: 2026-06-16T12:16:32.799Z
Learning: Run `codex-multi-auth list` once in a worktree to trigger migration into repo-shared storage if the worktree still asks for login
Learnt from: CR
Repo: ndycode/codex-multi-auth

Timestamp: 2026-06-16T12:16:32.799Z
Learning: Review the project storage rules in [reference/storage-paths.md](reference/storage-paths.md) if project-scoped storage is not in use for repository separation
Learnt from: CR
Repo: ndycode/codex-multi-auth

Timestamp: 2026-06-16T12:16:32.799Z
Learning: Run the complete diagnostics pack (`codex-multi-auth list`, `status`, `check`, `verify-flagged --json`, `forecast --live`, `fix --dry-run`, `report --live --json`, `doctor --json`) when troubleshooting issues
Learnt from: CR
Repo: ndycode/codex-multi-auth

Timestamp: 2026-06-16T12:16:32.799Z
Learning: Run the soft reset procedure (delete account and settings JSON files, then re-login) for Codex multi-auth recovery
Learnt from: CR
Repo: ndycode/codex-multi-auth

Timestamp: 2026-06-16T12:16:32.799Z
Learning: Run `codex-multi-auth uninstall` before `npm uninstall -g codex-multi-auth` to ensure complete cleanup of residual artifacts (plugin entry, cached node_modules, OS launcher, and app-bind state)
Learnt from: CR
Repo: ndycode/codex-multi-auth

Timestamp: 2026-06-16T12:16:32.799Z
Learning: Use `--dry-run` flag with `codex-multi-auth uninstall` to preview removal without touching the filesystem
Learnt from: CR
Repo: ndycode/codex-multi-auth

Timestamp: 2026-06-16T12:16:32.799Z
Learning: Use `--clear-accounts` flag with `codex-multi-auth uninstall` only when permanently leaving the package to irreversibly wipe stored credentials
Learnt from: CR
Repo: ndycode/codex-multi-auth

Timestamp: 2026-06-16T12:16:32.799Z
Learning: Include `codex-multi-auth report --json` and `codex-multi-auth doctor --json` outputs when opening bug reports for the codex-multi-auth package
Learnt from: CR
Repo: ndycode/codex-multi-auth

Timestamp: 2026-06-16T12:16:32.799Z
Learning: Include version information (`codex --version`, `codex-multi-auth --version`, `npm ls -g codex-multi-auth`) and full terminal output when reporting issues
📚 Learning: 2026-06-04T06:14:18.093Z
Learnt from: ndycode
Repo: ndycode/codex-multi-auth PR: 510
File: test/scheduling-strategy-config.test.ts:1-1
Timestamp: 2026-06-04T06:14:18.093Z
Learning: In ndycode/codex-multi-auth, do not flag explicit imports from "vitest" (e.g., describe, it, expect, beforeEach/afterEach, etc.) in test files as issues—even if the Vitest config sets `globals: true`. The repo’s established convention is to keep these imports for consistency with neighboring tests; removing them would make files outliers.

Applied to files:

  • test/codex-manager-history-command.test.ts
📚 Learning: 2026-06-04T06:14:24.975Z
Learnt from: ndycode
Repo: ndycode/codex-multi-auth PR: 510
File: test/runtime-rotation-proxy.test.ts:2478-2491
Timestamp: 2026-06-04T06:14:24.975Z
Learning: In ndycode/codex-multi-auth test files (e.g. `test/*.test.ts`), when creating V3 storage fixtures for accounts, it’s an intentional convention to use `as never` for deliberately minimal stored-account objects that only include `refreshToken`, `addedAt`, and `lastUsed`. Do not treat `as never` here as a type-safety problem: optional/other fields are expected to be populated by the runtime during execution, and the cast is used solely to keep the fixture minimal and consistent across existing tests.

Applied to files:

  • test/codex-manager-history-command.test.ts
🔇 Additional comments (6)
docs/reference/commands.md (1)

83-84: LGTM!

doc changes are accurate and consistent with the history command implementation. dynamic codex_home reference (lines 233–234) aligns with the code in lib/codex-manager/commands/history.ts:238; the --json flag applies-to list (line 94) matches the test assertion in test/documentation.test.ts:350–365; and the usage/output descriptions (lines 246–256) correctly match the behavior of runHistoryList and runHistoryShow.

Also applies to: 94-94, 233-256

lib/codex-manager/commands/history.ts (1)

94-103: LGTM!

Also applies to: 120-120, 243-250, 292-293, 378-380, 399-408

test/codex-manager-history-command.test.ts (4)

193-210: LGTM!


212-225: LGTM!


227-259: LGTM!


354-376: LGTM!

@ndycode
ndycode merged commit e763dc2 into main Jun 16, 2026
2 checks passed
ndycode added a commit that referenced this pull request Jun 16, 2026
Patch release adding the read-only `codex-multi-auth history` command
(#612, #613). No runtime-rotation, storage, or auth behavior changed.

- Bump version to 2.3.1 across package.json, package-lock.json,
  .codex-plugin/plugin.json, and AGENTS.md
- Add docs/releases/v2.3.1.md
- Promote v2.3.1 to current stable in README and docs portal; demote
  v2.3.0 to prior stable
- Add CHANGELOG entry

Full suite green (4936 passed, 3 skipped); typecheck clean.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[bug] history between accounts not shared

1 participant