Skip to content

Live Codex usage (fix 0%), OpenCode Go provider, multi-account Gemini + UI fixes - #6

Open
luispriet wants to merge 1 commit into
KodyMike:mainfrom
luispriet:feat/codex-live-opencode-go-gemini-multiaccount
Open

Live Codex usage (fix 0%), OpenCode Go provider, multi-account Gemini + UI fixes#6
luispriet wants to merge 1 commit into
KodyMike:mainfrom
luispriet:feat/codex-live-opencode-go-gemini-multiaccount

Conversation

@luispriet

Copy link
Copy Markdown

This adds the improvements I built locally on top of v1.1.0 (Fedora 44, KDE Plasma 6). All changes are backward-compatible; metadata bumped to 1.2.0.

Fix — Codex usage showed 0%

The Codex provider read the passive ~/.codex/sessions logs. Codex 0.139.0 emits a token_count whose rate_limits.limit_id == "premium" with null primary/secondary; the old fallback picked it, so used_percent fell back to 0. Now it queries the same live endpoint /status usesGET https://chatgpt.com/backend-api/codex/usage (ChatGPT OAuth from ~/.codex/auth.json, ChatGPT-Account-Id header). It's a plain GET (no token cost), read-only (never writes auth.json), and falls back to the local history (hardened to skip the null premium bucket) if the request fails.

Feature — OpenCode Go provider

Dollar-value limit windows ($12 / 5h, $30 / week, $60 / month, all configurable). OpenCode has no public usage API, so spend is a local estimate from ~/.local/share/opencode/opencode.db (read-only SQLite) and is clearly labeled "this machine (est.)". The monthly window is anchored to a configurable renewal day.

Feature — multiple Gemini accounts

Reads the primary ~/.gemini/oauth_creds.json plus any ~/.gemini/accounts/*.json → one card per account (labeled by email from the id_token). It refreshes expired tokens itself (via oauth2.googleapis.com/token) using gemini-cli's public OAuth client (installed-app credentials shipped in the gemini-cli package — not a user secret), so an account the CLI isn't actively using doesn't die when its token expires. JSON stays backward-compatible (top-level = first account, plus an accounts array).

Fixes

  • Stuck loading (grey refresh button, instead of values): isLoading was a manual +1/-1 counter, but Plasma's executable engine collapses identical in-flight sources, so the counter never returned to 0. Now derived from runner.connectedSources.length.
  • Popup clipped with many providers/accounts: content wrapped in a Flickable with a height cap → it scrolls instead of being cut off.

Happy to adjust naming, split into smaller PRs, or rework anything you prefer.

…UI fixes

- Codex: query live /backend-api/codex/usage instead of stale session logs (fixes 0%)
- OpenCode Go: dollar-value limit windows from local opencode.db (this-machine estimate)
- Gemini: multiple accounts (~/.gemini/accounts/*.json) + self-refresh via gemini-cli public OAuth client
- Fix: derive isLoading from connectedSources (manual counter desynced -> stuck loading)
- Fix: Flickable + height cap so the popup scrolls instead of clipping

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.

1 participant