Add OpenCodexBar plugin - #435
Open
wy3z wants to merge 3 commits into
Open
Conversation
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.
Plugin
wy3z/opencodex-barplugin.toml)What it does
I wanted a quick way to keep an eye on my local OpenCodex instance without opening its dashboard all the time, so I put together OpenCodexBar.
It adds a small bar indicator and an attached panel with two views:
There is already a CodexBar-based meter in the marketplace, but this one is aimed at people running OpenCodex. It talks to OpenCodex's Management API directly instead of installing or calling the CodexBar CLI, so the panel reflects the accounts and providers from the OpenCodex instance you already have running. It also goes a bit further than the quota view: you can jump straight to the OpenCodex control panel, see today's requests, tokens, and estimated cost, browse a 30-day activity grid, and break usage down by provider and model.
There is a small service behind both views. It is the only part that handles the Management API credential; the widget and panel only exchange normalized snapshot, command, and action state, with the credential removed. Account selection and reset-credit use are validated against the latest snapshot, confirmed in the panel, and followed by a forced quota refresh.
External dependencies
GETrequests. Confirmed account actions usePUT /api/codex-auth/activeandPOST /api/codex-auth/reset-credits/consume.OPENCODEX_ADMIN_AUTH_TOKEN, or from the configuredadmin_token_fileif the environment variable is unavailable. The plugin writes no local files; confirmed account actions mutate OpenCodex state.xdg-open: used by the link button to open the OpenCodex dashboard. It is called with an argument array rather than through a shell, and nothing else is spawned.As a small safety guard, plain HTTP is only allowed for loopback addresses. Anything remote has to use HTTPS.
Testing
I tested this against my live OpenCodex 2.31.0 setup on Hyprland:
usage,panel, andserviceentries and checked that the bar widget rendered.noctalia msg panel-toggle wy3z/opencodex-bar:panel.Automated checks:
lua tests/test_service.lua— 12 tests, 0 failuresnoctalia plugins lint— 0 errors, 0 warningsCurrent community validator — passed
Tested on Niri
Tested on Hyprland
Tested on Sway
Tested on another compositor:
Noctalia version tested against: v5.0.0
Plugin API level: 24
Screenshots / Videos
Accounts
Usage
Checklist
Ready-for-review requirement: Every box in this section must be checked. If any statement is not true, keep the
pull request as Draft. An explanation does not replace a required check.
idafter the/inplugin.tomlexactly.plugin.toml,README.md,thumbnail.webp, andtranslations/en.json.README.mdfollows theREADME template, documents
every entry id and dependency, and includes exact panel IPC commands and launcher prefixes where applicable.
thumbnail.webpwith the thumbnail generator.versionfollows semver and is bumped in this PR;plugin_apiis the oldest API level this plugin requires.understand that language well enough to review and maintain it (no unreviewed machine/LLM translations).
catalog.toml; CI generates it.Code review attestation
Plugins run as trusted, unsandboxed Luau in the user's session. Confirm:
Ready-for-review requirement: Every attestation below must be checked.
licensedeclared inplugin.toml.