Skip to content

[Feature]: serve /usage rows should include pace, like usage --json and macOS serve /usage #1057

Open

Description

@DreamyTalesPAN

Existing issues

  • I searched existing issues and did not find a duplicate.

Problem or use case

codexbar serve answers /usage with rows that carry only provider, source, usage and cost. They never carry the pace object, although:

  • Win-CodexBar's own codexbar usage --json adds it (rust/src/cli/usage/render.rs, json_result["pace"]), and
  • macOS CodexBar's codexbar serve /usage includes it (checked against 0.82.0: CLIServeCommand.swift → serveUsageOutput → the same ProviderPayload.pace as usage --json).

So a script or app that polls serve cannot read the reserve/deficit the tray panel shows (stage, delta, expected used percent, "lasts until reset"), even though the data is already computed for usage --json. The only ways around it are to run a separate usage --json per provider and refresh, or to recompute pace from the raw windows and drift from the app's own rules (provider pace capability, weekly work days).

Checked against v0.70.0 and main (1d3c130): rust/src/cli/serve/data.rs fetch_usage_row builds the row from the four keys above, and grep -i pace rust/src/cli/serve finds only the dashboard snapshot, where pace exists only per entry of accounts (--all-accounts), not on the provider row.

Related: #640 (CLI parity with macOS), #953 (serve --all-accounts), #939 (HTTP server in Settings).

Proposed solution

Add the same optional pace key to each successful /usage row, built with the helper usage --json already uses (lane_pace / pace_json, honoring weekly_progress_work_days):

{
  "provider": "claude",
  "source": "oauth",
  "usage": { ... },
  "cost": { ... },
  "pace": {
    "primary": { "stage": "...", "deltaPercent": 0, "expectedUsedPercent": 0, "willLastToReset": true, "etaSeconds": null, "summary": "..." },
    "secondary": { ... }
  }
}
  • Omit pace when no window yields one (same rule as usage --json).
  • Error rows are unchanged.
  • Document it next to /usage in docs/CLI.md and add a test beside the existing /usage row tests in rust/src/cli/serve.

Affected area

  • CLI

Alternatives considered

  • codexbar usage --json per provider: has pace, but it is one process per read and uses the longer completeness window that serve deliberately avoids.
  • Recomputing pace from usage.primary / usage.secondary on the client: duplicates the pace rules and diverges from them.
  • /dashboard/v1/snapshot: pace is only on accounts[] and needs --all-accounts.

Visual details

None; JSON output only.

Activity

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions