Feat/codex rate limits pill toggle#9
Merged
urbanlama merged 3 commits intoMay 8, 2026
Conversation
Collaborator
Author
|
Hey @urbanlama — quick heads-up before you continue review. Master has had a fairly large audit-fix sweep over the past 24h (commits 62f794d through 9f406a7, ~10 commits, all CI-green on Linux/macOS/Windows × Node 20/22/24). Several of the 7 ultrareview findings I fixed in this branch are now resolved differently — and better — on master. To avoid merge churn, a rebase before further review would help. Ultrareview-bug status against current master
Suggested actiongit fetch origin
git rebase origin/master
# resolve conflicts in widget/src/main.ts, src/loaders/codex.ts,
# package.json — the rest should be cleanOnce rebased, the PR will be much smaller (obsolete commits can be dropped during interactive rebase) and conflict-free. Happy to help with the rebase if useful — just let me know. |
…refresh Adds `loadCodexRateLimits()` which scans ~/.codex/sessions newest-first for the most recent token_count event with a `rate_limits` payload, then projects it into a `CodexRateLimits` snapshot consumed by the dashboard and the desktop widget. Stale snapshots (resets_at in the past) are zeroed so a quiet user doesn't see a near-100% utilization that has silently rolled over since Codex last wrote to disk. `buildDashboardData` accepts the snapshot as a second arg and surfaces it on `DashboardData.codexRateLimits`. The CLI no longer persists Codex events to the store (they're cumulative-totals re-derived on every scan, so persisting double-counts) — `mergeFreshSourceEvents` overlays fresh Codex events on top of the persisted store at read time. Reconciled with master's audit-sweep work: - keeps `isValidTimestamp` in the codex loader entrypoint - exports `normalizeUsage` / `subtractUsage` / `RawUsage` for testing - preserves `writeJsonAndExit` (Bun --compile stdout flush on Windows) Test coverage: - normalizeUsage / subtractUsage unit tests (master) - loadCodexRateLimits integration tests covering staleness, missing rate_limits, plan_type=null (API-key auth) - loadCodexEvents integration test for cumulative-delta + cached-input splitting - aggregator pass-through smoke tests for codexRateLimits Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Adds `CodexUsage` + `CodexWindowUsage` mirrors of the TS interfaces in `src/types.ts`, projected from the sidecar's `codexRateLimits` JSON into `LocalUsageSummary.codex_usage`. The frontend reads this through the existing `fetch_local_usage` Tauri command — no new round-trip. Schema-drift safety: deserialization failures log to stderr instead of silently dropping the field, so a sidecar shape change surfaces as a "why is the Codex toggle null?" debug clue rather than a mystery. Re-applies the C16 widget error-recovery fix from master `fd4368c` — the backup branch I rebased from didn't include it, so the manual restore here is just a safety net (net-zero diff vs master for that hunk). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…mark The dashboard header rendered a stylized "T-coin in flames" SVG glyph that didn't match the widget's actual brand mark (the photoreal PNG in widget/src/assets/tokenbbq-icon.png). Embed the PNG at build time and serve it as a base64 data URL so the dashboard ships a single source of truth for the brand without depending on a runtime file path — external file paths don't survive Bun --compile (same constraint as the existing scripts/inline-wasm.mjs). - New `scripts/inline-dashboard-icon.mjs` reads the widget PNG and writes `src/dashboard-icon.ts` (gitignored). Uses `fileURLToPath(import.meta.url)` so it runs on Node 20.0+ — the CI matrix tests Node 20/22/24, and `import.meta.dirname` only landed in 20.11. - The build chain integrates the inliner the same way it integrates inline-wasm.mjs (chained `&&` in build/dev/lint/test/build:sidecar) rather than via prebuild/predev hooks, matching the existing pattern on master. - `dashboard.ts` drops the inline SVG glyph in favor of `<img>` with `DASHBOARD_BRAND_ICON_DATA_URL` (TOKENBBQ_LOGO_PATH override still wins). A small inline SVG favicon link replaces /favicon.ico 404s. Bundle grows ~1.8 MB; user-facing the dashboard now matches the widget. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
ae3771d to
21343b8
Compare
urbanlama
pushed a commit
that referenced
this pull request
May 8, 2026
`dateKey` and `monthKey` used `new Date(ts).toISOString().slice(0, N)`, which is UTC-formatted. For any user east of UTC, events recorded after local midnight ended up in the previous day's bucket; for users west of UTC, in the next day's. The heatmap and daily/monthly tables were silently shifted by one row. Replaced with local-time getters (`getFullYear`, `getMonth`, `getDate`) so each bucket carries the same calendar date the user would write down for the event. urbanlama had this fix on the fork branch as c7b0f30 but it was dropped during the PR #9 rebase. Verified: lint clean, 57/57 tests pass. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
urbanlama
pushed a commit
that referenced
this pull request
May 8, 2026
Minor bump rather than patch — three behavior changes are technically
breaking, even if pre-1.0 makes that less load-bearing:
• Server now binds 127.0.0.1 instead of 0.0.0.0 (LAN access removed)
• Tauri SettingsDisplay no longer ships the plaintext session_key
field to the renderer
• Pricing returns 0 for unknown models instead of fuzzy-matched
or input-rate-fallback prices
Plus the Codex rate-limits + dual-mode pill feature from PR #9 and
~14 audit-driven correctness/security fixes since v0.4.9.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
side-by-side Claude/Codex grid in the expanded panel
cache reads don't get double-counted)
buildDashboardData(Intl.DateTimeFormat hoisted out of per-event loop — 87×faster on 33k events), inline brand PNG so the header matches the widget, inline favicon
set-position+available-monitorscapabilities for persistent drag position,skipTaskbar: true,RIGHT_MARGIN: 0to snap to screen edgeWhy
Why are these changes needed?
Checklist
npm run buildsucceedssrc/loaders/index.tsandsrc/types.tsREADME.mdif user-facing changes