Skip to content

Usage: see every AI plan's limits and balances from the ☰ menu #7

Closed

Description

@promptclickrun

Summary

Add a Usage screen to bighelp that shows how much of each AI plan or balance you've used, for every AI tool on the connected Hermes computer: Claude, Codex, GitHub Copilot, OpenCode, OpenRouter, DeepSeek, Nous Portal, Google AI Studio, and any Hermes provider plugin that reports usage.

You open it from the bottom of the ☰ menu. It appears as a Liquid Glass sheet with one card per provider: plan, usage bars with reset times, balances, and a link to manage the account.

The host side is done. The bighelp plugin finds the tools on its own and does all the provider calls. The app only reads one route.

Why

People run several AI subscriptions and keys at once: Claude Code, Codex, Copilot, OpenRouter credits and so on. Today they check each one in a different app or website. bighelp already talks to the computer they all run on, so it can show them together in one place, on the phone.

What people see

Entry point

  • A Usage row at the bottom of the ☰ menu (BighelpMenu), below Go to and Recent.
    • Symbol: gauge.with.dots.needle.50percent
    • Detail line: "Plans and balances on this computer"
    • UI test id: menu.usage
  • It's for everyone, not behind Nerd Mode.
  • Don't add a second menu or a Settings copy. This is the one place.

The sheet

  • Liquid Glass modal (medium and large detents, grabber visible), matching the app's existing glass surfaces (BighelpSurface, FloatingTabBar).
  • Header
    • Host name
    • "Updated 2 min ago"
    • A refresh button
    • Pull to refresh
  • One card per provider, in the plugin's order. The provider the current agent chats with comes first and carries an "In use by agent name" badge.
    • Logo from ProviderLogoStore, with an SF Symbol fallback.
    • Name, and plan as a small badge (e.g. "Pro", "Max 5x", "Enterprise").
    • Windows, one bar each:
      • label (e.g. "Session (5 hours)", "Week")
      • percent used
      • "Resets in 3 h 12 min" (relative time from resetsAt)
      • optional detail line (e.g. "250,000 of 1,000,000 used")
    • Bar color changes at 75% and 90% used. Use theme colors, not raw red and yellow.
    • Facts: label and value rows, already formatted by the plugin (e.g. "Balance · $25.00", "Last 30 days · $42.10 · 45 sessions").
    • A small "via Codex CLI / Hermes" line from detectedVia.
    • "Manage" opens manageUrl in the browser.
    • approximate: true adds a quiet "about" before the numbers. Copilot's CLI fallback rounds.
  • Status cards (anything but ok): show the plugin's plain message instead of numbers.
    • signInNeeded: e.g. "Claude Code's sign-in has expired. Open Claude Code on this computer to refresh it."
    • notShared: e.g. Google AI Studio, "Your API key works. Google shows AI Studio usage only on its website." Keep the Manage link.
    • error: message plus a retry.
    • Keep these visually lighter than working cards. Don't make them look like failures of the app.
  • Empty state: "No AI tools found on host." Then a short line on what's detected: coding tools installed on the computer (Claude Code, Codex, Copilot, OpenCode, Gemini CLI) and providers set up in Hermes.
  • Older plugin (feature missing from /native/context): "Update the bighelp plugin on host to see usage." Add a button into the existing Settings › Hosts plugin update flow (HostPluginUpdateModel).
  • Offline or host unreachable: show the last result from this session with its age, plus the usual connection message.

Plugin contract (summary)

POST /api/plugins/loopdy/native/usage/list

  • Uses the normal native headers: If-Match (context ETag) and X-Loopdy-Request-ID.
  • Body: {"agentId": "<current agent>", "refresh": false}.
  • Needs native-provider-usage-v1 in /native/context features.
{
  "agentId": "default",
  "fetchedAt": "2026-10-01T18:00:00Z",
  "cached": false,
  "providers": [
    {
      "id": "claude",
      "name": "Claude",
      "status": "ok",
      "message": null,
      "plan": "Pro",
      "detectedVia": ["cli"],
      "activeInHermes": true,
      "windows": [
        {"label": "Session (5 hours)", "usedPercent": 42.0, "resetsAt": "2026-10-01T21:00:00Z", "detail": null},
        {"label": "Week", "usedPercent": 61.0, "resetsAt": "2026-10-04T09:00:00Z", "detail": null}
      ],
      "facts": [],
      "manageUrl": "https://claude.ai/settings/usage",
      "approximate": false
    },
    {
      "id": "openrouter",
      "name": "OpenRouter",
      "status": "ok",
      "message": null,
      "plan": null,
      "detectedVia": ["hermes"],
      "activeInHermes": false,
      "windows": [],
      "facts": [{"label": "Balance", "value": "$25.00"}, {"label": "Spent this month", "value": "$3.40"}],
      "manageUrl": "https://openrouter.ai/settings/credits",
      "approximate": false
    }
  ]
}
  • status: ok, signInNeeded, notShared or error. Treat an unknown status like error with its message.
  • ids: stable, used for logos and test ids. Values: claude, codex, codex-hermes (only when Hermes uses a different ChatGPT account than the Codex CLI), copilot, gemini, opencode, openrouter, deepseek, nous, hermes-<provider>. Unknown ids must still render.
  • Times: UTC, whole seconds, ending in Z. The default ISO8601DateFormatter parses them.
  • Caching:
    • The host caches for 5 minutes.
    • refresh: true skips the cache, but not more than once every 15 seconds. cached: true tells you which you got.
    • Each provider gets up to 20 seconds. A slow one comes back as error with "took too long", so the whole call finishes in about 20 seconds at most (typically 1–3 seconds).
  • Response size: a few KB. Use the usual 196 KB native response cap.
  • Privacy: no keys, emails or account IDs are ever in the response. Nothing needs redacting on the phone.

Implementation plan

  1. Route: add .usageList to the native route table in DirectHermesNativeContext.swift.
    • path usage/list, feature native-provider-usage-v1
    • isMutation: false, maximumResponseBytes: 196_608
  2. Models: ProviderUsageSnapshot, ProviderUsageReport, ProviderUsageWindow and ProviderUsageFact.
    • Decodable and tolerant: unknown statuses, missing optional fields, extra keys.
    • Clamp usedPercent to 0–100.
  3. Client and store: an @Observable store keyed by host and agent.
    • Load when the sheet opens. Refresh from the button or pull (refresh: true).
    • On 412 context_changed, reload context once and retry, the same way board requests do.
    • Keep the last good result in memory while a refresh runs, so the sheet never flashes empty.
  4. Menu row in BighelpMenu, shown whenever a host is connected. The sheet handles the older-plugin case.
  5. Sheet UI: ProviderUsageSheet plus card and bar components in the design system, and reuse existing ones where possible.
    • Put large lists behind BighelpDeferredSection, like other big screens. See "Device-only SwiftUI stack overflow" in the notes.
  6. Plugin pin: once bighelp-plugin#63 is merged and released, set BighelpNotificationPluginVersion to 2.18.0 and BighelpNotificationPluginRevision to the merge commit, together with the plugin ref in .github/workflows/ios-ci.yml.
  7. Demo data: -use-demo-fixtures gets a usage fixture that covers every status, a Codex/Codex (Hermes) pair, an approximate Copilot card, a long plan name, 0% and 100% bars, and a missing resetsAt.

Accessibility

  • Each bar is one VoiceOver element. Example: "Claude, session, 42 percent used, resets in 3 hours 12 minutes."
  • Facts read as "label, value".
  • Dynamic Type up to the accessibility sizes: bars stay full width and labels wrap.
  • Reduce Transparency falls back to the solid surface. Increase Contrast keeps bar colors distinguishable, and color is never the only signal (the percent is always in text).
  • The Manage link is announced as a link that opens outside the app.

Acceptance criteria

  • Usage is at the bottom of ☰ and opens a Liquid Glass sheet.
  • The current agent's provider is first and badged. Switching agents changes which one is first.
  • Every status renders with its message, and notShared or signInNeeded cards keep their Manage link.
  • Refresh works, shows "Updated just now", and doesn't spin forever when the host throttles (cached: true).
  • Older plugin: a clear update prompt that leads into the existing update flow. No raw error text.
  • Unknown provider ids and statuses render without crashing.
  • Looks right on iPhone 16 Pro and Pro Max, light and dark, largest Dynamic Type, and with Reduce Transparency.
  • Plugin version and revision are pinned together in Info.plist and CI.

Testing

  • Unit: decoding (real 2.18.0 sample, unknown fields and statuses), percent clamping, relative reset text, sort and badge logic, and the store's retry on context_changed.
  • UI (demo fixtures): open from menu.usage, check each status card, and capture screenshots on iPhone 16 Pro and Pro Max.
  • Release small-stack walkthrough: the new sheet must open without the device-only stack overflow (Release build, 1 MB stack harness).
  • Live: against a real host with the plugin branch. Check that numbers match each provider's own page (Claude /usage, ChatGPT Codex usage, GitHub Copilot settings).

Known limits (host side, by design)

  • Google AI Studio has no usage API for API keys, so the card only confirms the key works and links to AI Studio's usage page.
  • Borrowed logins aren't refreshed. The plugin never refreshes another tool's saved sign-in: those refresh tokens rotate, so refreshing would sign the tool out. An expired Claude Code login shows "open Claude Code once" instead.
  • Copilot: numbers are exact from GitHub. The Copilot CLI fallback is rounded and marked approximate.
  • OpenCode: shows local spend from opencode stats (7 and 30 days). Only OpenCode Go has plan limits.

Later (not in this issue)

  • A Home Screen or Lock Screen widget with the top one or two bars.
  • An optional alert when a limit passes 90%.
  • A usage history chart over time (the host keeps no history today).
  • Apple Watch complication.

Activity

  1. added
    type: feature
    Backlog
    on Sep 27, 2026
  2. promptclickrun commented on Sep 28, 2026

    @promptclickrun
    OwnerAuthor

    Shipped in bighelp 2.3.0 (26) (TestFlight), with the bighelp plugin 2.18.0 (promptclickrun/bighelp-plugin#63, merged). The app pins that version and revision in Info.plist and CI together. The route contract now lives on the plugin's main branch: docs/PROVIDER_USAGE.md.

    What shipped

    • One card per provider, with its brand logo, name, plan badge and an "In use" badge. The provider the current agent uses comes first.
    • A bar for each limit window, with the percent left and "Resets in …". Facts appear as label/value rows. There's a "On this computer / In Hermes" line and a Manage link.
    • signInNeeded, notShared and error cards show the plugin's message and keep Manage. Unknown ids and statuses still render.
    • Refresh button and pull to refresh. While a refresh runs, the last result stays on screen. If a refresh fails, the card says "Couldn't refresh. Showing the last result."
    • On an older plugin, a clear "update the plugin" prompt that leads into the existing update flow in Settings.
    • Dedicated Claude and Codex logos, kept apart from the Anthropic and OpenAI API logos. The logo site serves them too.
    • Demo fixtures cover every status, plus an approximate Copilot card.

    Changed from the plan above (owner's direction)

    • Entry points:
      • "See provider usage" in a chat's ⋯ menu
      • "Provider usage" under Go to in the ☰ menu
      • A gauge button at the top right of the chat's Context window pop-up
    • Presentation: a Liquid Glass overlay instead of a detent sheet. Close it with the X or by tapping outside. It scrolls only when it doesn't fit.
    • Settings › Provider Usage lets you show or hide each configured provider, and the choice is saved. With no choices saved, all providers show, and one set up later shows until you turn it off.

    Tested

    • Unit tests: decoding, clamping, reset text, ordering, hide preferences, and the retry after a context change.
    • UI tests: every entry point, dark mode, and hiding a provider.
    • Release 1 MB-stack walkthrough: the overlay and its Settings page open against a real host with no crash.
    • Live check: against a Mac running plugin 2.18.0.

    Still for later, as listed above: widget, 90% alert, history chart, Watch.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Backlogtype: feature

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions