Skip to content

feat(menubar): expose combined multi-device usage in menubar-json (#566)#567

Open
ozymandiashh wants to merge 1 commit into
getagentseal:mainfrom
ozymandiashh:feat/menubar-combined-usage
Open

feat(menubar): expose combined multi-device usage in menubar-json (#566)#567
ozymandiashh wants to merge 1 commit into
getagentseal:mainfrom
ozymandiashh:feat/menubar-combined-usage

Conversation

@ozymandiashh

Copy link
Copy Markdown
Contributor

Summary

Addresses #566 (data layer). The macOS menubar reads codeburn status --format menubar-json, which only reflects the local machine. Combined multi-device usage existed only in the terminal codeburn devices command. This exposes combined + per-device usage through the menubar-json contract so the menubar can mirror the combined dashboard. The menubar UI toggle itself is a follow-up Swift PR.

What changed

  • Refactor: extract the per-device summary + combined reduce that was inline in renderDevices (src/sharing/host.ts) into a reusable pure summarizeDeviceUsage(results, window?). renderDevices now formats from it with byte-identical output (existing tests unchanged). Error/unreachable devices are excluded from the combined sums but kept in perDevice; deviceCount counts all, reachableCount counts those that responded.
  • Contract: optional combined?: CombinedUsage on MenubarPayload (per-device list + combined totals incl. calls/sessions). Absent by default, so existing consumers are unaffected.
  • CLI: --scope local|combined on status (default local). combined builds the local payload, pulls paired devices via pullDevices (per-peer failures isolated into error rows, never block), and attaches the summary.
  • Correctness guards: reject --scope combined with --days (non-contiguous, not representable over the sharing UsageQuery) and with --provider/--project/--exclude (the sharing query carries no filters, so peers would report unfiltered usage). Window-scope the combined cache-token sum to the selected period (cache lives in the 365-day daily history; current carries no cache counts).

Testing

  • npx vitest run tests/sharing/host.test.ts tests/menubar-json.test.ts tests/cli-status-menubar.test.ts -> 28/28. New cases: summarizeDeviceUsage combined totals + error-row exclusion + window-scoped cache; MenubarPayload omits combined by default and accepts the documented shape; CLI attaches combined for --scope combined (and omits it for local); CLI rejects --scope combined with --days/--provider/--project/--exclude.
  • npx tsc --noEmit clean; semgrep hot-path rule -> 0 findings.
  • Full suite: the only failing test is the pre-existing overview.test.ts thousands-separator case, which fails on non-US locales independent of this change (reproduces on main).

Notes

  • Combined is a coarse rollup (cost / calls / sessions / tokens / cache) + per-device breakdown, matching the terminal "Combined" row, not the full per-model/per-project breakdown.
  • Follow-up Swift PR: the menubar Local/Combined toggle + caching/timeout so a combined refresh never blocks the badge on a slow peer.

…tagentseal#566)

The macOS menubar reads `codeburn status --format menubar-json`, which only
ever reflected the local machine. Multi-device "Combined" usage existed only in
the terminal `devices` command. This exposes combined + per-device usage through
the menubar-json contract so the menubar can mirror the combined dashboard.

- Extract the per-device summary + combined reduce that was inline in
  renderDevices into a reusable pure `summarizeDeviceUsage(results, window?)`.
  Error/unreachable devices are excluded from the combined sums (kept in
  perDevice); deviceCount counts all, reachableCount counts the reachable ones.
  renderDevices now formats from it with byte-identical output.
- Add an optional `combined?: CombinedUsage` block to MenubarPayload (perDevice
  list + combined totals incl. calls/sessions). Absent by default.
- Add `--scope local|combined` to `status` (default local). `combined` builds the
  local payload, pulls paired devices (pullDevices isolates per-peer failures),
  and attaches the summary.
- Correctness guards: reject `--scope combined` with `--days` (non-contiguous,
  not representable over the sharing query) and with `--provider`/`--project`/
  `--exclude` (the sharing query carries no filters, so peers would report
  unfiltered usage). Window-scope the cache-token sum to the selected period
  (cache lives in 365-day daily history; current carries no cache counts).

TS/CLI only. The menubar Local/Combined toggle + render is a follow-up.
@ozymandiashh

Copy link
Copy Markdown
Contributor Author

@iamtoruk I think you might be interested in these, I think you are eligible.
https://claude.com/contact-sales/claude-for-oss
https://openai.com/ro-RO/form/codex-for-oss/

@iamtoruk

Copy link
Copy Markdown
Member

@ozymandiashh For Anthropic, we have already been selected, and I am in their OSS program. For OpenAI, I have applied. Let's see.

@ozymandiashh

Copy link
Copy Markdown
Contributor Author

congrats

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