Skip to content

feat(desktop): official quota chip on the status bar - #93285

Open
lorencato23 wants to merge 4 commits into
NousResearch:mainfrom
lorencato23:feat/desktop-quota-chip
Open

feat(desktop): official quota chip on the status bar#93285
lorencato23 wants to merge 4 commits into
NousResearch:mainfrom
lorencato23:feat/desktop-quota-chip

Conversation

@lorencato23

Copy link
Copy Markdown

Summary

Depends on #93282. Review the latest commit after that CLI PR; this one only adds the desktop surface.

Test plan

  • python3 -m pytest tests/hermes_cli/test_usage_cmd.py tests/agent/test_account_usage.py tests/hermes_cli/test_status.py -q (28 passed)
  • Unit test for formatQuotaChip
  • After feat(cli): show official OAuth quota via hermes usage #93282 is available on a running backend: chip appears for signed-in Codex/Claude/OpenRouter
  • With only SuperGrok signed in, chip stays hidden

Add a script-friendly quota command that reuses fetch_account_usage()
for Codex, Claude, OpenRouter, and Nous. Surface the same snapshot as
a one-line summary on hermes auth status and hermes status --all.

Providers without a public quota API (including SuperGrok) report
unsupported instead of a guessed number. Failures stay unavailable
and do not crash status output.

Closes NousResearch#33094
Add GET /api/account-usage and a compact left-status-bar chip that
shows remaining Codex / Claude / OpenRouter / Nous windows. Cache is
five minutes, the render path does no network I/O, and a failed fetch
hides the chip.

Depends on the hermes usage helper from the previous commit. SuperGrok
stays unsupported — xAI does not publish a quota API.
@alt-glitch alt-glitch added type/feature New feature or request P3 Low — cosmetic, nice to have comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint comp/cli CLI entry point, hermes_cli/, setup wizard comp/desktop Electron desktop app (apps/desktop/*) provider/openai OpenAI / Codex Responses API provider/anthropic Anthropic native Messages API provider/openrouter OpenRouter aggregator provider/nous Nous Research API (OAuth) area/billing Account usage, credit usage, billing (cross-cutting) labels Aug 23, 2026
@Enough1122

Copy link
Copy Markdown
Contributor

AI code review — automated review for reference, author can ignore or act on any point.

Overall: well-structured feature — clean separation between fetch (agent/account_usage.py), reporting (hermes_cli/usage_cmd.py), the REST surface, and the desktop chip, with tests on both sides. Points to consider:

  1. agent/account_usage.py:~945-952 (compact_account_usage_line) — the reset rendering does string surgery on another formatter's output: _format_reset(window.reset_at).split(' (', 1)[0]. If _format_reset ever changes its parenthetical wording (or localizes it), this silently degrades or leaks half-sentences into hermes status. Prefer adding an explicit parameter (e.g. `_format_reset(reset_at, include_local=False)) so the one-line surface requests what it wants instead of parsing prose.

  2. hermes_cli/usage_cmd.py:~118-127 (usage_command, aggregate text path) — when *no* official provider reports ok (fresh install, no creds), the only output is the hardcoded "Grok unsupported" line and exit code 0. That reads like Grok is the notable problem when actually nothing is configured. Suggest printing an explicit "(no providers with usable quota credentials)" summary line, and/or including unavailable rows in text mode rather than silently skipping them.

  3. apps/desktop/src/app/shell/hooks/use-account-quota-item.tsx:11,17-23 — the chip polls every 5 minutes unconditionally, even while hidden because the payload never yields rows (no creds). Each tick makes the server fan out to up to four upstream quota APIs via account_usage_payload(None). Consider disabling the query until the first payload proves at least one ok provider (`enabled: ... on useQuery) or backing off after repeated empty responses.

  4. hermes_cli/web_server.py:15705-15716 — /api/account-usage triggers authenticated upstream fetches with stored OAuth tokens; please confirm it sits behind the same auth middleware/guard as the sibling `/api/* analytics endpoints (it's easy to miss when adding a route at this layer).

Minor: account-usage.ts:60 renders raw reset_at ISO timestamps in the tooltip; a relative-time format would match the CLI's polish.

Give _format_reset an include_local flag instead of splitting prose.
Print an explicit empty-install message instead of only Grok unsupported.
Show Claude and OpenRouter usage on hermes status --all and prefetch
those official windows in parallel.
Slow the chip to 30 minutes when no official windows are available so
a logged-out desktop does not fan out four quota APIs every 5 minutes.
Render tooltip resets as relative time, and document that
/api/account-usage uses the same /api/ auth gate as analytics.
@lorencato23

Copy link
Copy Markdown
Author

Follow-up — comentários de revisão

Os pontos de revisão foram incorporados no HEAD atual (38db2a923c5c): o chip usa backoff de 30 minutos quando não há quota visível e o tooltip usa reset relativo. O endpoint permanece protegido pelo mesmo gateway da API.

A validação Python compartilhada do recurso passou no PR dependente #93282: 28 testes focados passaram. A suíte desktop completa ainda depende das dependências Node deste checkout.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/billing Account usage, credit usage, billing (cross-cutting) comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint comp/cli CLI entry point, hermes_cli/, setup wizard comp/desktop Electron desktop app (apps/desktop/*) P3 Low — cosmetic, nice to have provider/anthropic Anthropic native Messages API provider/nous Nous Research API (OAuth) provider/openai OpenAI / Codex Responses API provider/openrouter OpenRouter aggregator type/feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants