Skip to content

feat(widgets): add secure Codex usage widget - #1064

Merged
amnweb merged 1 commit into
amnweb:mainfrom
skywalker23241:feat/codex-usage-app-server
Aug 24, 2026
Merged

feat(widgets): add secure Codex usage widget#1064
amnweb merged 1 commit into
amnweb:mainfrom
skywalker23241:feat/codex-usage-app-server

Conversation

@skywalker23241

@skywalker23241 skywalker23241 commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

Summary

  • add a native yasb.codex_usage.CodexUsageWidget that shows remaining Codex rate-limit capacity
  • query Codex through app-server (account/rateLimits/read) instead of reading ~/.codex/auth.json or calling a private ChatGPT endpoint
  • derive window labels from windowDurationMins, so different window lengths and missing secondary windows render correctly
  • keep the header and available rate-limit windows visible while moving the lower content into a fixed-height QStackedWidget
  • provide horizontally paged Overview, Resets, Models, and Activity views with mouse-accessible Fluent navigation, tooltips, accessible names, stable page height, and session-local page retention
  • use larger default fonts and compact, consistent spacing based on the Claude Usage widget so the popup remains readable without custom CSS
  • add menu.show_overview, show_models, show_activity, show_resets, and show_details switches; hidden or data-less pages are omitted and navigation disappears when only one page remains
  • preserve show_token_usage compatibility and keep the fixed rate-limit area working when all optional pages are disabled
  • make refresh, previous-page, next-page, and stale icons configurable while continuing to use Segoe Fluent Icons
  • show optional account reset-credit metadata (count, title, and expiration) when a recent Codex CLI reports rateLimitResetCredits; redeemable credit IDs are deliberately discarded and no consume action is exposed
  • hide the taskbar progress indicator when the selected alternate window is unavailable, restoring it when a valid window is selected
  • retain refresh animation/status, live/cached/error states, token totals, model breakdown, activity heatmap, month navigation, callbacks, tooltips, progress bars, cache fallback, and missing-secondary handling
  • update only the Codex Usage documentation and replace the popup screenshot with a new random UUID filename

Screenshots

Taskbar widget

Codex Usage widget in the YASB bar

Compact paged details popup

Codex Usage details popup

Maintainer feedback addressed

  • default popup is compact instead of stacking every section vertically
  • default typography, control sizes, padding, and spacing are readable at common Windows scaling levels
  • optional sections can be disabled independently
  • icons are configuration-driven and use the existing Fluent icon approach
  • screenshot filename uses a new random UUID
  • root README.md remains unchanged
  • generated schema.json remains unchanged

Context

This is an alternative implementation to #1031. It delegates subscription authentication entirely to Codex CLI/app-server and never handles access tokens.

Test plan

  • ruff format .
  • ruff format --check .
  • ruff check .
  • git diff --check
  • Python compilation for the widget, validation model, and service
  • confirmed no diff in README.md or schema.json
  • live app-server test against a signed-in ChatGPT account
  • verified reset-credit normalization drops the opaque redeemable ID
  • Qt construction/synchronization smoke tests for paged navigation and reset-credit cards
  • verified single-page navigation hiding, missing token data, missing secondary limits, and empty optional-page behavior
  • visually verified the compact popup in YASB 2.0.6 at 125% Windows scaling
  • verified refresh feedback, model bars, token totals, and the activity heatmap remain functional

Authentication and privacy

The widget requires a recent Codex CLI and an existing ChatGPT-backed codex login. It never opens auth.json, and it does not read, log, copy, or cache credentials. Optional token statistics scan only structured model/timestamp/token-count metadata from the current user's local Codex session files; prompt and response content is not parsed or retained, and nothing is uploaded. Set show_token_usage: false to disable local history scanning.

Reset-credit support stores only display metadata such as count, title, status, and timestamps. It intentionally discards the backend credit ID and does not expose the protocol's consume operation.

@skywalker23241
skywalker23241 force-pushed the feat/codex-usage-app-server branch 4 times, most recently from 86bdb3a to e2a9304 Compare August 20, 2026 03:13
@skywalker23241
skywalker23241 marked this pull request as ready for review August 20, 2026 03:14
@amnweb

amnweb commented Aug 20, 2026

Copy link
Copy Markdown
Owner

It looks like your "codex" can't read the Contributing Page :)

image

And don't change the readme.

@skywalker23241

skywalker23241 commented Aug 21, 2026

Copy link
Copy Markdown
Contributor Author

;( mb, my Codex and Claude missed the contributing guidelines before opening the PR.

I'll revert the changes to schema.json and the README, and make sure to follow the guidelines going forward.

Thanks for pointing it out!

@skywalker23241
skywalker23241 force-pushed the feat/codex-usage-app-server branch 2 times, most recently from 21f36f4 to a4907f1 Compare August 21, 2026 01:22
@amnweb

amnweb commented Aug 21, 2026

Copy link
Copy Markdown
Owner

But why hardcoded icons? This looks really bad.
image

And it would be really nice if you could clean up this style a little bit and follow the other docs. Also, please use a random UUID for the image name. This is important for the docs site.

@skywalker23241

skywalker23241 commented Aug 21, 2026

Copy link
Copy Markdown
Contributor Author

You're right — the icons shouldn't be hardcoded. I'll replace them with the appropriate dynamic icon references, clean up the format and styles, and rename the image using a random UUID.

Thanks for the clarification. I'll update the PR accordingly.

Also, I have to admit—I’m a little jealous of that mountain of Codex credits 😄 Mine would probably disappear before it finished reading the contributing guidelines.

I just realized those Codex credits are probably from a test environment, That explains the impressive balance. :)

@skywalker23241
skywalker23241 force-pushed the feat/codex-usage-app-server branch 2 times, most recently from 22e9fd4 to 0ee2bc3 Compare August 21, 2026 07:05
@amnweb

amnweb commented Aug 21, 2026

Copy link
Copy Markdown
Owner

I just realized those Codex credits are probably from a test environment, That explains the impressive balance. :)

Yes, from the test, but I don't know which screens you are using, the font is so small it's almost invisible. When creating the default style and config, try to use a proper style as the default one because many users don't know anything about styling and CSS. Also, I'm not sure if it's a smart idea to ship with this type of layout. Maybe you can add a toggle or a way to disable some sections, it is so long, taking up 70-80% of my screen height.
image

@skywalker23241

Copy link
Copy Markdown
Contributor Author

When creating the default style and config, try to use a proper style as the default one because many users don't know anything about styling and CSS. Also, I'm not sure if it's a smart idea to ship with this type of layout. Maybe you can add a toggle or a way to disable some sections, it is so long, taking up 70-80% of my screen height.

Happy Monday! :) Your feedback is spot on — the default layout should be readable and compact for users who may not customize the CSS themselves.

I’m considering turning the lower sections into a horizontally switchable view, so users can move between them without the popup taking up most of the screen height. I’ll also improve the default font sizes and spacing, then push the changes to this PR.

Thanks for the helpful suggestions!

@amnweb

amnweb commented Aug 24, 2026

Copy link
Copy Markdown
Owner

Let me know when it's ready to merge. Also, before that, just squash the commits into a single one.

@skywalker23241
skywalker23241 force-pushed the feat/codex-usage-app-server branch from d21a8ff to b39dbe6 Compare August 24, 2026 12:34
@skywalker23241

Copy link
Copy Markdown
Contributor Author

Hi I’ve pushed the requested updates and squashed the PR history into a single commit as requested. It’s now ready for your final review and merge. Thanks again for the helpful feedback!

@amnweb
amnweb merged commit 47af040 into amnweb:main Aug 24, 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.

2 participants