Skip to content

Port upstream 0.61.0: CLI provider history line with provenance and token totals - #708

Open
Finesssee wants to merge 1 commit into
port/upstream-0.61.0from
port/micro-0.61.0-cli-history-line
Open

Finesssee wants to merge 1 commit into
port/upstream-0.61.0from
port/micro-0.61.0-cli-history-line

Conversation

@Finesssee

Copy link
Copy Markdown
Collaborator

Summary

codexbar usage text output now shows provider-supplied history the way upstream 0.61.0 does: the source period, the provider's own spend total with its cost provenance (reported, estimated, includes estimates), and an input-plus-output token total. For OpenRouter Activity the line changes from

Last 30 days (UTC): $1.25

to

Last 30 days (UTC): $1.25 (reported) · 15 tokens

Found by the 0.60.4-0.69.0 port gap audit.

Upstream reference

  • Upstream 0.61.0 changelog: "CLI: show successful provider-supplied history in usage text and full terminal cards ... preserving source periods, currencies, known zero values, and cost provenance (related to Stop discarding OpenRouter spend history when reasoning tokens exceed completion tokens steipete/CodexBar#3717)".
  • Upstream PR fix(cli): show provider history without truncating cards steipete/CodexBar#3737, commit 52e951285 (CLIRenderer.liveHistoryLine, CLICardsRenderer, Tests/CodexBarTests/CLILiveHistoryTests.swift).
  • Provenance rule from Sources/CodexBarCore/Plugins/ProviderPluginSnapshotMapper.swift at v0.61.0: any BYOK estimate makes the window estimated, or mixed when metered spend is also present; otherwise vendor metered. Token total is prompt plus completion (reasoning stays a separate counter), from openrouter.js.
  • Token formatting follows UsageFormatter.tokenCountString (K/M/B, promoted at the point where the lower unit would round to 1000).

Ported

  • CostSnapshot gains display-only history_tokens and provenance (both #[serde(skip)], so the cost JSON contract is unchanged, matching upstream's "ordinary usage JSON retains its contract").
  • OpenRouter Activity parsing records the token total and provenance after duplicate-row dedupe, so the same row is never counted twice.
  • cli/usage/render.rs renders the history line for always_visible spend snapshots with no limit (the existing path). Other providers that use that path (Fireworks, Replicate, Typesafe) set neither field, so their output is unchanged.
  • Empty successful Activity renders a known zero: $0.00 (reported) · 0 tokens.

Deferred

  • Full terminal cards: Win-CodexBar has no CLICardsRenderer equivalent, so there is nothing to extend.
  • Grok token-only history line: upstream does not attach Grok local-session history in the CLI fetch path (the app store publishes it), and CostSnapshot.used is not optional here, so a tokens-only line with no amount cannot be modeled without a wider change. The renderer itself handles tokens whenever a provider supplies them. grok/local_sessions.rs is left as is.
  • docs/ description of the CLI line: not added; the CHANGELOG entry covers it.

Validation

All with cargo +1.98.0, E-core wrappers, slot-5:

  • cargo fmt --all: clean
  • cargo clippy --workspace --all-targets -- -D warnings: pass (both manifests)
  • cargo test -p codexbar history: 39 passed
  • cargo test -p codexbar (full): 2167 passed, 0 failed, 1 ignored
  • New tests: cli/usage_tests.rs (provenance labels, known zero, singular token, currency, token compaction boundaries, JSON contract unchanged) and providers/openrouter/activity.rs (token total and provenance from upstream's three fixture scenarios, empty history, duplicate rows not double counted)
  • Frontend not touched; Tauri crate compiled under clippy but its tests were not run.

Affected areas

  • CLI (codexbar usage text output)
  • Provider: OpenRouter (Activity parsing)
  • Desktop UI / tray / settings / float bar

UI proof

Not applicable (CLI text output only).

@coderabbitai

coderabbitai Bot commented Sep 30, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: 7db3cb00-adbf-4eed-a1e1-bb4cf3eac99d

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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.

1 participant