Skip to content

wwrrj/Codex-Switcher

Repository files navigation

Codex Account Switcher Logo

Codex Account Switcher

Local-first Codex account switching, usage analytics, and token insight for Windows.

English · 简体中文

Tauri 2.11 React 18 Rust 1.77+ Windows Last commit

Important

This project is community-maintained and is not affiliated with or endorsed by OpenAI. Authentication files contain sensitive credentials. Never share auth.json, account backups, or your full .codex directory.

Overview

Codex Account Switcher keeps your Codex workflow local, fast, and visible:

  • Switch accounts without manual file handling.
  • Detect account email and subscription data from local authentication bytes.
  • Track 5-hour and 7-day quota windows with scheduled refresh.
  • Analyze local Codex token history with daily heatmaps, today totals, and a 14-day trend.
  • Keep account copies, settings, and backups inside your local Codex Home.

Screenshots

The screenshots below are taken from the latest build and redacted before publishing.

Account management screenshot Usage analytics screenshot Settings screenshot

Highlights

Feature Description
Account identity and health Detects email, subscription plan, Access token expiry, account health, and supports manual subscription overrides
Safe account switching Silently closes Codex, backs up auth.json, swaps credentials, reopens Codex, and records switch history
Usage query and cache Queries official usage windows, shows cached data on startup, refreshes on startup / switch / schedule, and can restore the previous account after checks
Local token analytics Scans local Codex records for total, daily, input, cached input, output, and reasoning tokens with heatmaps and 14-day trends
Smart quota scheduling Learns local usage patterns, recommends or accepts a manual 5-hour quota trigger time, tracks confidence, and pauses when ineffective
Tray and desktop experience Provides a custom title bar, remembered sidebar state, styled tray menu, quick switching, refresh actions, and app controls
Settings and local data control Supports custom Codex Home, CODEX_HOME detection, backup retention, usage notifications, refresh policy, and theme selection

Quick Start

Requirements

Run from Source

git clone https://github.com/wwrrj/Codex-Switcher.git
cd Codex-Switcher/react-vite
npm install
npx tauri dev

Build Installers

cd react-vite
npm install
npx tauri build

Build artifacts are written to:

react-vite/src-tauri/target/release/bundle/
├── msi/
└── nsis/

Usage

  1. Start the app. It automatically detects ~/.codex/auth.json and the active account.
  2. Add the current account to the pool. If the account is already saved, the app guides you through logging in to a new one.
  3. Select a target account and switch. The app closes Codex, backs up the credentials, replaces them, and reopens Codex.
  4. Open Usage Analytics to inspect the daily heatmap, today's tokens, and the latest 14-day trend.
  5. Adjust refresh intervals, backup retention, Codex Home, and theme in Settings.

How It Works

Codex reads the active authentication file from Codex Home. This app keeps each saved account in a separate directory and replaces the active auth.json during a switch.

~/.codex/
├── auth.json                    # Active credentials read by Codex
├── accounts/
│   └── user@example.com/
│       ├── auth.json            # Account copy managed by this app
│       └── meta.json            # Name, note, subscription, and metadata
├── config/
│   ├── settings.json
│   └── priorities.json
└── backups/                     # Automatic pre-switch backups

Switching flow:

flowchart LR
  A["Select account"] --> B["Silently close Codex"]
  B --> C["Back up active auth.json"]
  C --> D["Replace it with target auth.json"]
  D --> E["Reopen Codex"]
Loading

Data and Privacy

  • Authentication files and backups remain on your machine and are not uploaded to a server operated by this project.
  • Usage queries use local authentication data to call the official Codex usage endpoint.
  • Token statistics come from local Codex session records.
  • Saved auth.json copies are not additionally encrypted. Protect your operating-system account and Codex Home directory.
  • Remove ~/.codex/accounts and ~/.codex/backups when uninstalling if you want a full cleanup.

Tech Stack

Project Structure

Codex-Switcher/
├── react-vite/
│   ├── src/                     # React frontend
│   │   ├── components/
│   │   ├── lib/
│   │   └── store/
│   └── src-tauri/               # Rust / Tauri backend
│       ├── src/
│       └── tauri.conf.json
├── docs/
│   └── images/
└── README.md

Development and Verification

# Frontend production build
cd react-vite
npm run build

# Rust build and tests
cd src-tauri
cargo build
cargo test

# Complete desktop installers
cd ..
npx tauri build

Roadmap

  • Publish downloadable releases and changelogs
  • Add automated tests and CI
  • Complete cross-platform process management and packaging verification
  • Add data export and richer analytics
  • Provide optional encryption for sensitive account copies

Contributing

Issues and pull requests are welcome. Before submitting a change:

  1. Do not commit real auth.json, token data, email addresses, or local Codex data.
  2. Make sure the frontend build, Rust build, and tests pass.
  3. Follow Conventional Commits for commit messages.

Acknowledgements


If this project helps you, consider giving the repository a Star.