Enhance OpenRouter usage details rendering and percent calculation - #20
Open
toniher wants to merge 3 commits into
Open
Enhance OpenRouter usage details rendering and percent calculation#20toniher wants to merge 3 commits into
toniher wants to merge 3 commits into
Conversation
Adds a generic renderer for the codexbar CLI's usage.details array so OpenRouter's Credits/API key/Spend history breakdown shows up in the popup, gated behind a new show-provider-details setting. Any other provider that starts emitting details gets it for free; providers without it (Claude, Codex) are unaffected. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
When a provider reports a placeholder tier with usedPercent:0 and no windowSeconds (e.g. OpenRouter's balance tier), derive a meaningful usage percent from the Credits detail section instead. Add deriveCreditsPercent function to parse Used/Total or Remaining/Total from Credits rows, skip the tier entirely if no Credits section is available, and update the UI logic to use the derived percent or fall back to normalized usedPercent.
Add documentation explaining how to configure API keys (e.g. OPENROUTER_API_KEY) for the CodexBar CLI extension. Unlike shell dotfiles, environment variables must be set in systemd's user environment since GNOME Shell is started by the display manager rather than an interactive shell. Includes instructions for creating the environment.d configuration file, applying changes without full logout, and verifying the variable is accessible to GNOME Shell.
Member
|
Hello! |
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.
This pull request adds support for displaying provider-supplied detail sections (such as credits, spend history, and rate limits) in the CodexBar GNOME Shell extension. It introduces a new setting to control the visibility of these sections, improves the handling of balance-based providers like OpenRouter, and includes robust normalization and rendering logic for these details. Additionally, the documentation is updated to clarify API key setup for OpenRouter, and comprehensive tests are added for the new features.
Provider-supplied details display and normalization:
normalizeDetailSectionsinusageApi.jsto sanitize and flatten provider-suppliedusage.detailsarrays for safe rendering, dropping charts and handling edge cases. (Fcd7b7e9L30R30)deriveCreditsPercentinusageApi.jsto compute a meaningful usage percentage from "Credits" sections for providers that only report a balance (e.g., OpenRouter), improving the accuracy of the usage bar display. (Fcd7b7e9L30R30)extension.jsto render these normalized detail sections in the UI, with new styling instylesheet.css, and to use derived credits percent for degenerate tiers. [1] [2] [3] [4]Settings and preferences:
show-provider-details, defaulting to true, and exposed it in the preferences UI to allow users to toggle provider detail sections. [1] [2]Documentation:
systemduser environment for providers like OpenRouter, addressing common pitfalls with environment variables in GNOME Shell.Testing:
test_all_providers.jsto verify normalization, rendering, edge cases, and percent derivation for provider details, especially for OpenRouter's API output. [1] [2] [3]LLM Usage: Claude Code Opus 5, Sonnet 5