Skip to content

Add visible cost scale labels to cost charts - #1898

Merged
steipete merged 4 commits into
steipete:mainfrom
FNDEVVE:feat/cost-chart-yaxis-labels
Jul 5, 2026
Merged

steipete merged 4 commits into
steipete:mainfrom
FNDEVVE:feat/cost-chart-yaxis-labels

Conversation

@FNDEVVE

@FNDEVVE FNDEVVE commented Jul 4, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Adds visible, honest cost scales to every cost-chart surface while keeping token-only and partially populated widget histories unit-safe.

Closes #1854.

Maintainer improvements

  • Detailed history uses leading currency ticks and plot-aligned date axes.
  • Inline and widget charts reserve a label gutter above the bars, so the maximum never covers the peak.
  • One shared scale model normalizes against the observed positive maximum; a $0.50 maximum now renders as a full-height $0.50 bar instead of using a hidden $1 domain.
  • One shared compact currency formatter keeps sub-dollar cents and removes unnecessary decimals for whole-unit maxima.
  • Inline labels respect normal and highlighted menu contrast.
  • Widget history chooses one unit for the entire chart: cost only when every point contains cost, otherwise tokens with no currency label.
  • Invalid, zero, and negative values cannot distort the scale.

Proof

  • Focused chart/formatter/widget suite: 101 tests passed.
  • make check: SwiftFormat clean; SwiftLint 0 violations; repository checks clean.
  • Structured autoreview: clean, no actionable findings.
  • Full make test: all 47 shards passed on the exact head below.
  • ./Scripts/compile_and_run.sh: release bundle packaged, relaunched, and remained running.
  • Source-blind runtime validation confirmed the fresh bundle, running process, visible in-bounds menu extra, and successful click. Pixel assertions were blocked by the host's locked secure desktop; the deterministic focused suite covers sub-dollar, zero, large-dollar, and mixed-unit fixtures.

Exact head: bc5777e53ab9ecd840eb7a29172870604b238c3e

Screenshots

Detailed cost chart before the maintainer scale/gutter refinements:

Cost history with visible currency scale

Inline and widget coverage supplied by the contributor:

Cost labels across CodexBar chart surfaces

Contributor

Thanks @FNDEVVE for the feature direction, implementation, and visual proof.

…teipete#1854)

Show dollar-scale y-axis labels on the cost history chart so the range
is visible at a glance without hovering. Replace the hand-rolled
full-width HStack x-axis with Swift Charts' built-in chartXAxis so
labels align with the plot area, not the container edge.

Y-axis:
- AxisMarks(position: .leading) with currency-formatted labels
- Compact whole-dollar formatting (, 57, ,515) for values >= ;
  cents preserved for nonzero sub-dollar values (.50) to avoid
  duplicate ticks
- Empty ticks for flat/no data
- yAxisTickValues: [] for <=0, [0, max] for <, [0, mid, max] for >=

X-axis:
- Built-in chartXAxis with AxisMarks(values: model.axisDates)
- Edge anchors: first label .topLeading, last label .topTrailing
- Prevents right-side label clipping that the old HStack caused

Tests: 4 new focused tests covering tick value selection and compact
formatter behavior.
@clawsweeper

clawsweeper Bot commented Jul 4, 2026 •

Copy link
Copy Markdown

Codex review: needs real behavior proof before merge. Reviewed July 5, 2026, 12:56 AM ET / 04:56 UTC.

Summary
This PR adds cost scale labels to the detailed cost chart, inline mini bars, and widget usage history, plus shared scale/formatter helpers, tests, and a screenshot asset.

Reproducibility: yes. for the review finding from source inspection: the PR adds the inline max-cost label as a conditional row, while live dashboard layout compatibility still ignores point values and label visibility. For the requested enhancement, current main source confirms the scale labels are missing.

Review metrics: 3 noteworthy metrics.

  • Changed files: 11 files; 385 additions, 65 deletions. The PR spans app UI, widget UI, shared formatting/scale helpers, tests, and a screenshot asset.
  • Chart surfaces: 3 renderers changed. The diff affects the detailed Swift Charts view, inline mini bars, and the widget history chart.
  • Focused tests: 10 tests added or extended. Logic coverage now spans tick selection, compact formatting, currency propagation, scale math, and widget cost-mode selection.

Root-cause cluster
Relationship: fixed_by_candidate
Canonical: #1854
Summary: This PR is the candidate implementation for the open request to add visible cost scale labels to cost charts.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge readiness
Overall: 🦪 silver shellfish
Proof: 🦪 silver shellfish
Patch quality: 🦐 gold shrimp
Result: blocked until stronger real behavior proof is added.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

  • [P1] Fix or reserve the inline label layout state so live menu-card refreshes cannot clip it.
  • [P2] Add a redacted screenshot or recording from a real build showing the widget chart label and mixed cost/token fallback.
  • After adding proof, update the PR body so ClawSweeper re-reviews automatically, or ask a maintainer to comment @clawsweeper re-review.

Proof guidance:

  • [P1] Needs stronger real behavior proof before merge: Screenshot proof covers detailed and inline/menu labels, but not the widget extension label or mixed cost/token fallback changed by this PR. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Mantis proof suggestion
A short visual task would materially help verify the detailed, inline, and widget chart labels in compact UI surfaces. A maintainer can ask Mantis to capture proof by posting this exact PR comment:

@openclaw-mantis visual task: verify detailed, inline, and widget cost chart scale labels render without clipping, including mixed cost/token widget data.

Risk before merge

  • [P1] Merging as-is can ship an inline max-cost label that appears during a compatible live refresh without the menu-card layout recognizing that an extra row was added.
  • [P2] The available screenshot proof does not demonstrate the widget extension chart label or the mixed cost/token fallback changed by this PR.
  • [P1] The linked request is broader than the compact max-only labels used on inline/widget charts, so maintainers should confirm that UX scope before closing the linked issue.

Maintainer options:

  1. Fix and prove chart label layout (recommended)
    Before merge, track or reserve the inline label state and add redacted real-build proof for the widget label and mixed cost/token fallback.
  2. Narrow the linked request
    If compact max labels are not enough for inline or widget charts, keep the linked issue open or split the remaining chart-scale UX scope into a follow-up.

Next step before merge

  • [P1] Needs contributor or maintainer proof plus a small layout-compatibility fix before merge; ClawSweeper repair should not be queued while the real-behavior proof gate is unresolved.

Security
Cleared: The diff changes SwiftUI rendering, shared formatting helpers, tests, and a PNG screenshot without touching dependencies, secrets, networking, CI, or release scripts.

Review findings

  • [P2] Track the inline cost label in layout compatibility — Sources/CodexBar/InlineUsageDashboardContent.swift:848-849
Review details

Best possible solution:

Track or reserve the inline scale-label layout state, add redacted real-build proof for detailed, inline, and widget chart labels including the widget mixed-data fallback, then land if maintainers accept compact max labels on the smaller chart surfaces.

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

Yes for the review finding from source inspection: the PR adds the inline max-cost label as a conditional row, while live dashboard layout compatibility still ignores point values and label visibility. For the requested enhancement, current main source confirms the scale labels are missing.

Is this the best way to solve the issue?

No, not yet: the implementation direction is narrow and well tested, but it should first make the inline label layout state stable or tracked and add widget proof. Maintainer UX acceptance of compact max labels on mini renderers remains the final product call.

Full review comments:

  • [P2] Track the inline cost label in layout compatibility — Sources/CodexBar/InlineUsageDashboardContent.swift:848-849
    The max-cost label now appears as an extra row only when currencyCode exists and the observed max is positive, but hasCompatibleDashboardLayout still treats dashboards with the same point ids/labels as layout-compatible. A refresh from all-zero to positive cost can reuse the live menu-card layout while adding the label row, so track label visibility/max-cost state or reserve the gutter unconditionally.
    Confidence: 0.82

Overall correctness: patch is incorrect
Overall confidence: 0.82

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 71a768b58e47.

Label changes

Label justifications:

  • P3: This is a low-risk UI readability enhancement, with remaining blockers limited to visual/layout correctness and proof.
  • merge-risk: 🚨 other: Green tests do not prove the new compact chart labels avoid clipping or that the widget fallback behaves correctly in a real UI.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🦐 gold shrimp.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs stronger real behavior proof before merge: Screenshot proof covers detailed and inline/menu labels, but not the widget extension label or mixed cost/token fallback changed by this PR. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
  • proof: 📸 screenshot: Contributor real behavior proof includes screenshot evidence. Screenshot proof covers detailed and inline/menu labels, but not the widget extension label or mixed cost/token fallback changed by this PR.
Evidence reviewed

What I checked:

Likely related people:

  • steipete: Recent current-main history owns much of the menu-card, inline dashboard, widget, and height-cache surface, and the PR branch includes a maintainer commit reshaping the chart scale implementation. (role: recent area contributor; confidence: high; commits: e437044c32ba, cee403b71a6b, 125c38167957; files: Sources/CodexBar/InlineUsageDashboardContent.swift, Sources/CodexBar/MenuCardHeightFingerprint.swift, Sources/CodexBarWidget/CodexBarWidgetViews.swift)
  • Elijah Friedman: Recent merged cost-history chart work adjusted date-axis clipping and dynamic menu-card sizing in the same detailed chart surface. (role: recent chart behavior contributor; confidence: medium; commits: 20a4357ad544, 2fd41efd4ac3; files: Sources/CodexBar/CostHistoryChartMenuView.swift, Tests/CodexBarTests/CostHistoryChartMenuViewTests.swift)
  • FNDEVVE: Beyond authoring this PR, prior merged history from this contributor touched widget usage snapshots and CodexBarWidgetViews. (role: recent adjacent widget contributor; confidence: medium; commits: 37e42252c37d; files: Sources/CodexBarWidget/CodexBarWidgetViews.swift, Sources/CodexBarCore/WidgetSnapshot.swift, Tests/CodexBarTests/CodexBarWidgetProviderTests.swift)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

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.

How this review workflow works
  • 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.
Review history (10 earlier review cycles; latest 8 shown)
  • reviewed 2026-07-04T18:54:52.813Z sha 45291b6 :: needs maintainer review before merge. :: none
  • reviewed 2026-07-04T19:11:09.770Z sha facf367 :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-04T19:22:37.202Z sha facf367 :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-04T19:28:47.913Z sha facf367 :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-04T19:35:16.748Z sha facf367 :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-04T19:40:41.060Z sha facf367 :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-05T04:32:46.071Z sha bc5777e :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-05T04:50:25.849Z sha bc5777e :: needs real behavior proof before merge. :: [P2] Track the new label in menu-card layout sizing

@FNDEVVE

FNDEVVE commented Jul 4, 2026

Copy link
Copy Markdown
Contributor Author

ClawSweeper status: review started.

I am starting a fresh review of this pull request: Add y-axis tick labels and plot-aware x-axis to cost history chart This is item 1/1 in the current shard. Shard 0/1.

This placeholder means the worker is alive and reading the current context. I will edit this same comment with the actual review when the claws are done clicking.

Crustacean status: shell secured, claws on keyboard, evidence pebbles being sorted.

Wake up crab!

@FNDEVVE

FNDEVVE commented Jul 4, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jul 4, 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: the existing ClawSweeper review comment will be edited in place when the review finishes.

@clawsweeper

clawsweeper Bot commented Jul 4, 2026

Copy link
Copy Markdown

🦞👀
ClawSweeper picked this up.

Command router queued. I will update this comment with the next step.

@FNDEVVE
FNDEVVE marked this pull request as draft July 4, 2026 18:50
@FNDEVVE

FNDEVVE commented Jul 4, 2026

Copy link
Copy Markdown
Contributor Author

Expanding, ETA: ~1 hour

@clawsweeper clawsweeper Bot added proof: sufficient Contributor real behavior proof is sufficient. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. 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. P3 Low-risk cleanup, docs, polish, ergonomics, or speculative feature. merge-risk: 🚨 other 🚨 Merging this PR has meaningful risk outside the owned taxonomy. labels Jul 4, 2026
Extend the cost-chart scale work from steipete#1898 to the two remaining
custom bar renderers:

- InlineUsageDashboardModel gains an optional currencyCode field;
  the four currency dashboard builders (costHistory, claudeAdminAPI,
  crossModel, openRouter) populate it, token/points dashboards stay nil.
- MiniUsageBars overlays a compact max-cost label at topTrailing when
  currencyCode is set and max cost > 0, mirroring CostHistoryChartMenuView.
- Widget UsageHistoryChart now picks one explicit mode per chart via
  UsageHistoryChartMode.isCostMode (true only when every point has
  costUSD), fixing a latent mixed-unit bug where bars could mix dollars
  and tokens. Adds a max-cost label in cost mode.
- Three widget call sites pass currencyCode through.
- Tests cover currencyCode propagation and the cost-mode predicate.
@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. 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. labels Jul 4, 2026
@FNDEVVE
FNDEVVE marked this pull request as ready for review July 4, 2026 19:16
@FNDEVVE

FNDEVVE commented Jul 4, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jul 4, 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: the existing ClawSweeper review comment will be edited in place when the review finishes.

@FNDEVVE FNDEVVE changed the title Add y-axis tick labels and plot-aware x-axis to cost history chart Add visible cost scale labels to cost charts Jul 4, 2026
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Jul 5, 2026
@steipete

steipete commented Jul 5, 2026

Copy link
Copy Markdown
Owner

Exact-head proof for bc5777e:

  • Required CI: all checks passed on this head.
  • Focused coverage: 101 tests passed across cost-history, inline-dashboard, widget, formatter, and snapshot suites.
  • Repository validation: make check passed; make test passed all 47 shards.
  • Review: autoreview completed with no actionable findings.
  • UI: deterministic production-view renders verified detailed, inline, and widget cost scales in light, dark, and highlighted menu states, including sub-dollar, large-value, rightmost-peak, and mixed token/cost cases.
  • Runtime: a freshly packaged CodexBar bundle launched and remained running.

Native pixel capture was unavailable after the desktop session locked; deterministic production-view renders and fresh-bundle runtime proof cover the changed surfaces without claiming a locked-session screenshot.

@steipete
steipete merged commit f1de700 into steipete:main Jul 5, 2026
10 checks passed
chriscoveries pushed a commit to chriscoveries/CodexBar that referenced this pull request Oct 12, 2026
Add compact cost scale labels to detailed history charts, inline usage bars, and widgets. Keep labels truthful to the plotted domain, reserve layout space to avoid peak-bar overlap, and use consistent currency formatting across surfaces.

Co-authored-by: FND <fndevve@proton.me>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-risk: 🚨 other 🚨 Merging this PR has meaningful risk outside the owned taxonomy. 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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add y-axis tick labels to cost charts

2 participants