Skip to content

refactor: remove codex auto-takeover, unify to manual config (closes #83) - #88

Merged
ranxianglei merged 14 commits into
masterfrom
refactor/remove-codex-auto-takeover
Aug 10, 2026
Merged

refactor: remove codex auto-takeover, unify to manual config (closes #83)#88
ranxianglei merged 14 commits into
masterfrom
refactor/remove-codex-auto-takeover

Conversation

@ranxianglei

Copy link
Copy Markdown
Owner

Summary

Removes the Codex auto-takeover feature entirely. The auto-takeover button modified another app's config.toml, which breaks on Codex version upgrades (issue #83). Users now configure manually via a config snippet, consistent with the API-key client cards.

Changes

Deleted:

  • src/codex-takeover.ts (~400 lines) — state machine that rewrote ~/.codex/config.toml
  • tests/codex-takeover.test.ts — all takeover unit tests

Modified:

  • src/cli.ts — removed bili codex enable/disable/status subcommand + startup claimCodexTakeover/recoverStaleCodexTakeover calls
  • src/server.ts:
    • Removed GET /__bili/codex, POST /__bili/codex/enable, POST /__bili/codex/disable endpoints
    • resolveUpstream now uses resolveActiveCodexProvider() (reads config.toml directly) instead of takeover state
    • Removed !getCodexRouteState() gate on /codex/ — requests always allowed
    • Removed recordCodexRouteRequest activity tracking + shutdown cleanup
    • Added WS 426 for /codex/responses upgrade requests (Codex fast-fallback to HTTP POST)
  • src/web/client.ts — removed loadRouting/toggleRoute/copyRoute/routeState
  • src/web/page.ts — replaced Codex subscription card with manual-config card (matches API-key card style with copy button)
  • src/web/styles.ts — added .config-block style
  • tests/upstream-proxy-routing.test.ts — rewrote 2 tests to use CODEX_HOME instead of takeover state
  • tests/web-routing.test.ts — removed codex endpoint assertions, kept upstream/history/config tests

Kept intact:

  • src/codex-provider.ts — provider resolution
  • /codex/responses proxy endpoint + handling logic
  • Codex history feature (/__bili/codex-history endpoints)
  • All API-key client cards, Claude Code subscription, ZCode MITM cards

Validation

  • npm run typecheck — clean
  • npm test — 214 tests pass
  • npm run build — success

Closes #83

)

- Delete codex-takeover.ts (~400 lines) + tests
- Remove enable/disable/status CLI + API endpoints
- Remove web UI toggle button + route status badges
- Add manual config snippet + copy button (matches API-key card style)
- Add WS 426 for /codex/responses upgrade (fast-fallback)
- Always allow /codex/ requests (no takeover state gate)
- Cleanup note for users who previously auto-enabled
@ranxianglei
ranxianglei merged commit 52ebbf1 into master Aug 10, 2026
3 checks passed
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.

Codex route breaks on reserved openai provider ID and hides existing threads

1 participant