Skip to content

Show token allocation and cost per million in Overview - #2855

Open
Chipagosfinest wants to merge 64 commits into
steipete:mainfrom
Chipagosfinest:agent/token-cost-breakdown
Open

Show token allocation and cost per million in Overview#2855
Chipagosfinest wants to merge 64 commits into
steipete:mainfrom
Chipagosfinest:agent/token-cost-breakdown

Conversation

@Chipagosfinest

@Chipagosfinest Chipagosfinest commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Review order

This is a stacked follow-up to #2759.

  1. Merge Track multi-provider spend and model usage #2759 first.
  2. Review the token-allocation product delta in ff3374e and its lint-only follow-up eb12b5e.
  3. The later commits add only the opt-in production-component proof renderer, synthetic PNG evidence, and documentation. Their temporary capture-workflow plumbing is fully removed in the final tree.
PR Reviewer focus Merge order
#2759 Multi-provider spend history, Overview roster, local share/export First
#2855 Known-token allocation strip and same-row cost per 1M tokens Second

UI proof: baseline to allocation

Every value below is synthetic. The after images visibly say SYNTHETIC DATA · PRODUCTION COMPONENTS and render the production Overview summary/provider-row components at the real 310-point menu width.

Before: multi-provider Overview from #2759

Baseline multi-provider Overview from PR 2759

After: complete allocation

Exact 3/3 reporting, a provider-colored known-token strip, token shares, and approximate same-row cost per 1M tokens.

Complete token allocation and cost-per-million proof

After: partial data and a long roster

Six tracked providers remain visible. The summary becomes approximate, the missing rate stays unavailable, and the compact legend uses +3 overflow without hiding the provider rows.

Partial six-provider roster with unavailable rate and legend overflow

After: native currencies and a tiny positive rate

EUR and USD remain separate. A positive sub-cent normalized rate renders as <$0.01 / 1M, while its nonzero total spend remains visible as $0.04.

Native currency isolation and tiny positive rate proof

Existing share flow from #2759

This follow-up does not change local share/export. The base PR continues to own that experience.

Existing local share card from the base PR

Wide Settings proof · Narrow Settings proof · Allocation screenshot provenance and regeneration

What this changes

The Overview spend card now explains how known tokens are allocated instead of showing only a single total.

  • Adds a provider-colored segmented token strip with a compact top-three legend and overflow count.
  • Shows each provider row's share of known tokens.
  • Shows an approximate native-currency cost per 1M tokens only when cost and positive token data exist on the same row.
  • Uses a compact 146-point card when allocation exists and preserves the original 94-point height when it does not.
  • Animates only real allocation-value changes and disables that animation under Reduce Motion.

Product contract

  • Known-token denominator: percentages sum across known tokens; missing tokens make the mix explicitly partial.
  • Provider completeness: provider identity, not account-row count, determines coverage, so duplicate Codex accounts cannot hide a missing provider.
  • Currency isolation: token shares are currency-independent, while each rate retains its source row's native currency; rates are never blended.
  • Honest tiny values: positive sub-cent rates render as <$0.01 (or the currency's minimum visible unit), never $0.00.
  • Fail closed: invalid, negative, all-zero, non-finite-cost, or overflowing totals suppress unsupported output.
  • Overview scope: the provider preference controls rendered Overview rows; the global Usage & Spend summary and local share roster intentionally continue to cover all enabled/tracked providers, matching Track multi-provider spend and model usage #2759.

Verification

Exact head: 36cf2cdfb8088092a0eb792a3d6304521ceccbc0

  • Hosted production-component capture run 31526738125: the focused renderer passed and uploaded the three PNGs now committed here.
  • Final exact-head CI run 31528563507: all seven jobs passed, including both macOS Swift test shards, Linux x64/arm64, Linux musl, and lint.
  • Focused allocation tests cover percentages, absent providers, duplicate accounts, short coverage, mixed currencies, tiny positive rates, zero/invalid values, and integer overflow.
  • Native SwiftUI measurement covers both 94-point and 146-point summary-card states.
  • Local lint-macos passed: 22 locale catalogs / 1,392 English keys plus formatting checks.
  • Provider architecture catalog: 389 live anchors validated with zero mismatches.
  • Independent structured review of the proof delta found no Critical or Warning issues.
  • The earlier automated P2 was answered and resolved after tracing the intentional all-enabled-provider summary contract to commit 1483eda and the current “Overview rows” preference copy.

The renderer is opt-in and skips unless CODEXBAR_OVERVIEW_ALLOCATION_PROOF_DIR is set. Local Swift tests cannot reach the CodexBar target on this CLT-only Mac because the dependency toolchain cannot load PreviewsMacros; hosted macOS execution above is the runtime evidence.

@clawsweeper

clawsweeper Bot commented Aug 11, 2026

Copy link
Copy Markdown

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@Chipagosfinest
Chipagosfinest marked this pull request as ready for review August 11, 2026 05:11

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: eb12b5ea02

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread Sources/CodexBar/StatusItemController+Menu.swift

Copy link
Copy Markdown
Contributor Author

@Yuxin-Qiao this stacked follow-up is ready for review after #2759 lands.

Exact head eb12b5ea02c99d352fbd405873fc15cac6689727 has a fully green hosted CI run, and the PR body now includes the #2759 UI baseline captures, explicit merge/review order, exact two-commit incremental scope, product truthfulness boundaries, and screenshot provenance. The focused change adds the known-token allocation strip and same-row native-currency cost per 1M tokens; it does not change the base share flow.

@clawsweeper clawsweeper Bot added merge-risk: 🚨 compatibility 🚨 Merging this PR could break existing users, config, migrations, defaults, or upgrades. P3 Low-risk cleanup, docs, polish, ergonomics, or speculative feature. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Aug 11, 2026
@clawsweeper

clawsweeper Bot commented Aug 11, 2026

Copy link
Copy Markdown

Codex review: needs maintainer review before merge. Reviewed August 11, 2026, 11:21 PM ET / August 12, 2026, 03:21 UTC.

ClawSweeper review

What this changes

Adds a known-token allocation strip and same-row native-currency cost-per-million figures to the Overview spend card.

Merge readiness

⚠️ Ready for maintainer review - 3 items remain

Keep open for maintainer product-direction review: this is a proof-backed stacked feature branch whose base PR remains open, so it should be considered only after the base lands and the focused follow-up is rebased.

Priority: P3
Reviewed head: 36cf2cdfb8088092a0eb792a3d6304521ceccbc0
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) Strong focused UI evidence and exact-head validation support the feature, with product approval and stacked integration still needed before merge.
Proof confidence 🦞 diamond lobster (5/6) ✨ media proof bonus Sufficient (screenshot): Prepared screenshots visibly show the after-state production components in complete, partial, and mixed-currency scenarios; values are clearly marked synthetic.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (screenshot): Prepared screenshots visibly show the after-state production components in complete, partial, and mixed-currency scenarios; values are clearly marked synthetic.
Evidence reviewed 5 items Current Overview selection boundary: Current main resolves the Overview-row selection independently before building provider rows, so the PR’s intentional global-summary versus selected-row split is a product-scope choice rather than a mechanical correction.
Stacked implementation: The supplied PR context identifies the open base PR as the multi-provider history and Overview implementation; this follow-up’s focused feature commit is ff3374e.
After-fix UI proof: Four prepared images were inspected locally: the three after states visibly render production Overview components at menu width and disclose synthetic fixture data, including complete, partial-roster, and mixed-currency cases.
Findings None None.
Security None None.

How this fits together

CodexBar’s Overview turns enabled-provider snapshots into menu-bar status rows. The proposed spend summary derives token allocation and per-provider rates from local cost-history data before rendering the compact Overview card.

flowchart LR
  A[Enabled provider snapshots] --> B[Spend history model]
  B --> C[Known-token allocation]
  C --> D[Overview spend card]
  D --> E[Menu-bar overview]
  B --> F[Local share summary]
Loading

Decision needed

Question Recommendation
Should Overview retain the proposed split where provider selection controls only visible rows while spend totals, allocation, and sharing cover every enabled or tracked provider? Accept the all-provider summary contract: Merge the base PR first, then rebase and land this allocation follow-up while retaining the explicitly documented summary-versus-row split.

Why: The code and contributor response establish that this is intentional, but choosing the permanent meaning of the Overview preference is a user-facing product decision.

Before merge

  • Resolve merge risk (P1) - The stacked design intentionally lets the Overview row preference affect rows while the spend summary and share payload cover all enabled or tracked providers; maintainers should explicitly accept that user-facing scope before merging.
  • Complete next step (P2) - A maintainer must choose the permanent Overview preference contract before the stacked branch can be safely integrated.
Agent review details

Security

None.

Review metrics

Metric Value Why it matters
Branch scope 79 files, +4,283 / -353 lines The submitted branch includes the still-open multi-provider base implementation as well as this follow-up.
Visible proof scenarios 3 after-state screenshots They cover complete reporting, partial long-roster behavior, and native-currency/tiny-rate output.

Merge-risk options

Maintainer options:

  1. Land as a reviewed two-stage change (recommended)
    Approve the summary scope, merge the base PR, then rebase this follow-up and rerun its exact-head validation before merge.
  2. Narrow the selection contract
    Keep the existing preference intuitive by making spend totals and allocation follow the selected Overview providers.

Technical review

Best possible solution:

After approving the all-provider summary contract, merge #2759 first, then rebase this focused allocation layer and recheck selected rows, global totals, and mixed-currency presentation together.

Do we have a high-confidence way to reproduce the issue?

Not applicable as a bug reproduction: this is a new UI capability, and the supplied exact-head production-component screenshots directly show its intended states.

Is this the best way to solve the issue?

Unclear pending product approval: the implementation is coherent, but maintainers must first choose whether global spend data may intentionally differ from the selected Overview rows.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 26ebaf9d5b09.

Labels

Label justifications:

  • P3: This is an optional Overview analytics enhancement rather than a reported regression or availability issue.
  • merge-risk: 🚨 compatibility: The branch defines a compatibility-sensitive meaning for the existing Overview provider-selection preference.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (screenshot): Prepared screenshots visibly show the after-state production components in complete, partial, and mixed-currency scenarios; values are clearly marked synthetic.
  • proof: sufficient: Contributor real behavior proof is sufficient. Prepared screenshots visibly show the after-state production components in complete, partial, and mixed-currency scenarios; values are clearly marked synthetic.
  • proof: 📸 screenshot: Contributor real behavior proof includes screenshot evidence. Prepared screenshots visibly show the after-state production components in complete, partial, and mixed-currency scenarios; values are clearly marked synthetic.

Evidence

What I checked:

  • Current Overview selection boundary: Current main resolves the Overview-row selection independently before building provider rows, so the PR’s intentional global-summary versus selected-row split is a product-scope choice rather than a mechanical correction. (Sources/CodexBar/StatusItemController+Menu.swift:568, 26ebaf9d5b09)
  • Stacked implementation: The supplied PR context identifies the open base PR as the multi-provider history and Overview implementation; this follow-up’s focused feature commit is ff3374e. (Sources/CodexBar/StatusItemController+MenuTypes.swift:36, ff3374e46398)
  • After-fix UI proof: Four prepared images were inspected locally: the three after states visibly render production Overview components at menu width and disclose synthetic fixture data, including complete, partial-roster, and mixed-currency cases. (36cf2cdfb808)
  • Exact-head validation: The supplied PR context reports all seven exact-head CI jobs passed, including both macOS Swift test shards, Linux builds, and lint. (36cf2cdfb808)
  • Local inspection limitation: Current-main sources and commit metadata were readable, but this partial clone could not retrieve some PR tree blobs because its promisor remote was unreachable; review of the follow-up code therefore relies on the supplied PR diff and exact-head evidence.

Likely related people:

  • Peter Steinberger: Current-main blame attributes the Overview menu construction and row-selection boundary to the released baseline. (role: current Overview-area contributor; confidence: medium; commits: 330ae4384b18; files: Sources/CodexBar/StatusItemController+Menu.swift, Sources/CodexBar/StatusItemController+MenuTypes.swift)
  • Alec Gutman: The feature history identifies the all-provider Overview spend contract as the direct predecessor to this follow-up. (role: introduced the stacked all-provider summary contract; confidence: medium; commits: 1483eda0676a, ff3374e46398; files: Sources/CodexBar/StatusItemController+Menu.swift, Sources/CodexBar/StatusItemController+MenuTypes.swift)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Obtain maintainer direction on the Overview selection contract.
  • Merge the base PR, rebase this follow-up, and refresh the exact-head validation.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (7 earlier review cycles)
  • reviewed 2026-08-11T05:59:43.596Z sha eb12b5e :: needs real behavior proof before merge. :: none
  • reviewed 2026-08-11T18:38:19.271Z sha 485dfa8 :: needs real behavior proof before merge. :: none
  • reviewed 2026-08-11T19:03:39.219Z sha acac451 :: needs real behavior proof before merge. :: none
  • reviewed 2026-08-11T19:18:10.967Z sha d35c5fa :: needs real behavior proof before merge. :: none
  • reviewed 2026-08-11T19:39:55.531Z sha 36cf2cd :: needs maintainer review before merge. :: none
  • reviewed 2026-08-11T20:08:02.749Z sha 36cf2cd :: needs maintainer review before merge. :: none
  • reviewed 2026-08-11T20:16:50.226Z sha 36cf2cd :: needs maintainer review before merge. :: none

@clawsweeper clawsweeper Bot added the merge-risk: 🚨 automation 🚨 Merging this PR could break CI, automerge, proof capture, label sync, or automation. label Aug 11, 2026
@clawsweeper clawsweeper Bot added proof: sufficient Contributor real behavior proof is sufficient. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. merge-risk: 🚨 automation 🚨 Merging this PR could break CI, automerge, proof capture, label sync, or automation. labels Aug 11, 2026
@Chipagosfinest

Copy link
Copy Markdown
Contributor Author

@Yuxin-Qiao @clawsweeper ready for maintainer review / re-review.

  • Exact head: 36cf2cdfb8088092a0eb792a3d6304521ceccbc0
  • Exact-head CI: all seven jobs passed
  • PR body now links the Track multi-provider spend and model usage #2759 baseline directly to three freshly built production-component captures: complete allocation, partial six-provider roster with unavailable rate, and native-currency/tiny-rate handling
  • The screenshots use synthetic fixtures, visibly disclose that provenance, and have a committed opt-in regeneration path
  • Independent structured review found no Critical or Warning issues

This remains stacked behind #2759; the review order and focused product commits are called out at the top of the PR.

@Chipagosfinest

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Exact head 36cf2cdfb8088092a0eb792a3d6304521ceccbc0 is fully green in CI run 31528563507. The PR body now includes the freshly built complete, partial/long-roster, unavailable-rate, and native-currency screenshot proof requested in the previous review.

@clawsweeper

clawsweeper Bot commented Aug 11, 2026

Copy link
Copy Markdown

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Aug 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-risk: 🚨 compatibility 🚨 Merging this PR could break existing users, config, migrations, defaults, or upgrades. P3 Low-risk cleanup, docs, polish, ergonomics, or speculative feature. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. proof: sufficient Contributor real behavior proof is sufficient. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant