|
1 | | -# Codex Account Manager |
| 1 | +# Codex Manager |
2 | 2 |
|
3 | | -Manage multiple Codex accounts from one UI: switch the active `~/.codex/auth.json`, group accounts by status, and keep an eye on usage/refresh. |
| 3 | +A Zig-first desktop/web account manager for Codex with typed RPC, deterministic launch modes, and automatic quota-state transitions. |
4 | 4 |
|
5 | | -Built with SolidJS (frontend) + Zig (backend), rendered locally through WebUI Zig (SmallThingz/webui). |
| 5 | + |
| 6 | + |
| 7 | + |
| 8 | + |
6 | 9 |
|
7 | | -## What It Does |
| 10 | +## ⚡ Features |
8 | 11 |
|
9 | | -- Manage multiple accounts in one place (active / depleted / frozen) |
10 | | -- Switch the active account instantly (updates `~/.codex/auth.json`) |
11 | | -- Drag-and-drop reorder between buckets |
12 | | -- Pull usage/credits and show refresh timing |
13 | | -- Light/dark theme with persistence |
| 12 | +- Multi-account management with clear buckets: `active`, `depleted`, `frozen`. |
| 13 | +- Fast account switching (updates `~/.codex/auth.json`). |
| 14 | +- Drag-and-drop account movement across buckets. |
| 15 | +- Per-account usage refresh with immediate card updates. |
| 16 | +- Quota-driven lifecycle rules: |
| 17 | + - `0` remaining quota in active => auto-move to depleted. |
| 18 | + - non-zero quota in depleted => auto-move back to active. |
| 19 | +- Auto-refresh support for active and depleted flows. |
| 20 | +- Theme + UI preference persistence. |
14 | 21 |
|
15 | | -## Quick Start |
16 | | - |
17 | | -### Dev |
| 22 | +## 🚀 Quick Start |
18 | 23 |
|
19 | 24 | ```bash |
20 | 25 | zig build dev |
21 | 26 | ``` |
22 | 27 |
|
23 | | -This runs the frontend build (npm + Vite) and starts the app. |
24 | | - |
25 | | -### Modes |
| 28 | +This runs frontend build steps (TypeScript + Vite) and launches the app. |
26 | 29 |
|
27 | | -- Default: desktop-ish window (Chromium app-window when available) |
28 | | -- Force web mode: |
| 30 | +### Launch Modes |
29 | 31 |
|
30 | 32 | ```bash |
| 33 | +zig build dev -- --webview |
| 34 | +zig build dev -- --browser |
31 | 35 | zig build dev -- --web |
32 | 36 | ``` |
33 | 37 |
|
34 | | -If the app prints a `http://127.0.0.1:...` URL, you can always open it manually in any browser. |
| 38 | +- `--webview`: prefer native webview surface. |
| 39 | +- `--browser`: prefer app-window/browser-window mode. |
| 40 | +- `--web`: open in a normal browser tab. |
35 | 41 |
|
36 | | -## Requirements |
| 42 | +Default (no flag) uses ordered fallback: `webview -> browser window -> web tab`. |
37 | 43 |
|
38 | | -Build-time: |
39 | | -- Zig `0.15.2+` |
40 | | -- Node.js `20+` |
41 | | -- `npm` |
| 44 | +## 📦 Build / Install |
42 | 45 |
|
43 | | -Runtime: |
44 | | -- `curl` in `PATH` |
45 | | -- `codex` CLI in `PATH` |
46 | | -- A browser installed (Chromium-family recommended for the best desktop window behavior) |
47 | | - |
48 | | -## Build / Install |
49 | | - |
50 | | -Optimized local install: |
| 46 | +Optimized install: |
51 | 47 |
|
52 | 48 | ```bash |
53 | 49 | zig build install -Doptimize=ReleaseFast |
|
60 | 56 | ./zig-out/bin/codex-manager --web |
61 | 57 | ``` |
62 | 58 |
|
63 | | -Build the release matrix (writes to `zig-out/bin/`): |
| 59 | +Build release matrix: |
64 | 60 |
|
65 | 61 | ```bash |
66 | 62 | zig build build-all-targets |
67 | 63 | ``` |
68 | 64 |
|
69 | | -## How It Works (High Level) |
| 65 | +## 🧰 Requirements |
| 66 | + |
| 67 | +Build-time: |
| 68 | + |
| 69 | +- Zig `0.15.2+` |
| 70 | +- Node.js `20+` |
| 71 | +- `npm` |
| 72 | + |
| 73 | +Runtime: |
| 74 | + |
| 75 | +- `curl` in `PATH` |
| 76 | +- `codex` CLI in `PATH` |
| 77 | +- Browser installed (Chromium-family recommended for desktop-window behavior) |
| 78 | + |
| 79 | +## 🧠 Architecture (At a Glance) |
| 80 | + |
| 81 | +- **Frontend**: SolidJS SPA (`frontend/`). |
| 82 | +- **Backend**: Zig app (`src/`) serving local UI + handling all account state mutations. |
| 83 | +- **Bridge**: typed WebUI RPC surface via `webuiRpc.cm_rpc(...)`. |
| 84 | +- **State ownership**: backend-authoritative persistence for account/view/usage data. |
| 85 | + |
| 86 | +## 🗂️ Storage |
70 | 87 |
|
71 | | -- The Zig backend serves a local HTTP UI on `127.0.0.1` and exposes typed RPC. |
72 | | -- The frontend calls back into Zig via `globalThis.webui.call("cm_rpc", requestJson)` (with HTTP fallback to `/rpc`). |
73 | | -- Account state is stored locally; switching updates `~/.codex/auth.json`. |
| 88 | +Local app data directory: |
74 | 89 |
|
75 | | -## Storage |
| 90 | +- `accounts.json` — managed account records |
| 91 | +- `bootstrap-state.json` — boot snapshot + UI cache |
| 92 | +- `ui-theme.txt` — theme selection |
76 | 93 |
|
77 | | -Local app data directory files: |
78 | | -- `accounts.json` (managed accounts) |
79 | | -- `bootstrap-state.json` (UI bootstrap cache) |
80 | | -- `ui-theme.txt` (theme selection) |
| 94 | +Codex auth target: |
81 | 95 |
|
82 | | -Active Codex auth target: |
83 | 96 | - `~/.codex/auth.json` |
84 | 97 |
|
85 | | -## Testing |
| 98 | +## ✅ Testing |
86 | 99 |
|
87 | 100 | ```bash |
88 | 101 | zig build test |
89 | 102 | ``` |
90 | 103 |
|
91 | | -## Troubleshooting |
| 104 | +## 🔎 Troubleshooting |
92 | 105 |
|
93 | | -- UI opens but looks blank: |
94 | | - - Use the printed `http://127.0.0.1:...` URL in a browser to confirm the server is reachable. |
95 | | -- `Backend RPC unavailable in this session`: |
96 | | - - Launch through the app (`zig build dev`) and make sure `/webui.js` loads. |
97 | | -- Desktop window does not appear: |
98 | | - - Ensure a Chromium-based browser is installed (Chrome/Chromium/Brave/Edge). |
| 106 | +- App prints URL but no window appears: |
| 107 | + - Open the printed `http://127.0.0.1:...` URL directly in your browser. |
| 108 | +- Native webview mode fails on Linux: |
| 109 | + - Verify your WebKitGTK runtime/tooling for your distro. |
| 110 | + - Use `--browser` or `--web` as fallback. |
| 111 | +- RPC bridge unavailable at startup: |
| 112 | + - Ensure `webui_bridge.js` is injected and loaded by the served page. |
0 commit comments