Skip to content

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

Closed
Chipagosfinest wants to merge 66 commits into
steipete:mainfrom
Chipagosfinest:agent/token-cost-breakdown
Closed

Show token allocation and cost per million in Overview#2855
Chipagosfinest wants to merge 66 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 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
@Chipagosfinest

Copy link
Copy Markdown
Contributor Author

@Yuxin-Qiao @steipete could you also take a look at this focused follow-up after #2759?

Exact head 36cf2cdfb8088092a0eb792a3d6304521ceccbc0 has all 9 checks passing, zero unresolved threads, and accepted production-component screenshot proof. It remains intentionally stacked: merge #2759 first, then rebase and rerun integration CI before considering this one.

@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed proof: sufficient Contributor real behavior proof is sufficient. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. labels Aug 14, 2026
@Chipagosfinest

Copy link
Copy Markdown
Contributor Author

The stacked token-allocation PR is refreshed at exact head 60554b937a3595cda524d08c52b9f5a2735d3e85 on the resolved #2759 tree.

  • GitHub reports CLEAN / MERGEABLE against current main (3a848565bcd28426f680821de985fc1fc01e7068).
  • Hosted CI is fully green: both macOS test shards, Linux x64/arm64/musl, lint, aggregate, and GitGuardian.
  • git range-diff confirms all eight original feature commits remain patch-identical after integration.
  • The incremental scope remains the intended 10 files for allocation UI, arithmetic/layout tests, and synthetic screenshot proof; independent review found no blockers and there are zero unresolved threads.

Merge order remains #2759 first, then #2855. @Yuxin-Qiao @steipete — ready for maintainer review. No merge action was taken.

Copy link
Copy Markdown
Contributor

Thanks for the detailed updates and for looping me in. Just to clarify, I’m not a maintainer of CodexBar and don’t have authority to approve or merge these PRs, so I may not be the right person to make the product-scope decision. I’ll leave that to the repository maintainers. Apologies for any confusion, and thank you for the thorough work.

@Chipagosfinest

Copy link
Copy Markdown
Contributor Author

Closing this cumulative stacked PR in favor of the focused Overview foundation in #3023. Token allocation is intentionally deferred until that smaller slice lands, then it can be rebuilt from current main as an independent follow-up without inheriting the 79-file stack. The branch remains preserved.

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. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants