Skip to content

fix: align chart date labels with bars - #2977

Merged
steipete merged 3 commits into
mainfrom
fix/2974-chart-axis-labels
Aug 16, 2026
Merged

fix: align chart date labels with bars#2977
steipete merged 3 commits into
mainfrom
fix/2974-chart-axis-labels

Conversation

@steipete

Copy link
Copy Markdown
Owner

Summary

  • center status-menu x-axis date labels on the same tick positions as their bars
  • apply the shared alignment convention to cost history, usage breakdown, and plan utilization charts
  • add pure slot-geometry regression tests for the first and last labels
  • document the fix in the 0.50.1 changelog

Fixes #2974.

Root cause

The bars and axis marks already share the same x values, but the endpoint labels did not share the same horizontal anchor. Cost history and usage breakdown used .topLeading for the first date and .topTrailing for the last date, which placed a label edge at the bar's x coordinate. The label center therefore moved right by half the first label's width and left by half the last label's width. The plan-utilization chart had the same class of workaround as a fixed 24-point left offset on its trailing label.

This replaces those edge-specific adjustments with one centered anchor. Bar data, date domains, day-key conversion, and token/cost values are unchanged.

Tests

  • swift test --filter 'ChartAxisLabelLayoutTests|CostHistoryChartMenuViewTests|PlanUtilizationHistoryChartMenuViewTests|UsageBreakdownChartMenuViewTests' — 49 tests passed
  • source-blind geometry contract — 2 edge-center checks passed with different localized-label widths
  • structured autoreview — clean, no accepted/actionable findings
  • make check — passed on the issue branch's original origin/main; after rebasing onto current origin/main, it reaches SwiftLint and fails on the upstream-only UsageStoreWidgetSnapshotTests.swift type-body length (897 > 800). This PR does not modify that file.

@clawsweeper

clawsweeper Bot commented Aug 16, 2026

Copy link
Copy Markdown

🦞👀
ClawSweeper picked this up.

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

@clawsweeper clawsweeper Bot added merge-risk: 🚨 other 🚨 Merging this PR has meaningful risk outside the owned taxonomy. P2 Normal priority bug or improvement with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Aug 16, 2026
@clawsweeper

clawsweeper Bot commented Aug 16, 2026

Copy link
Copy Markdown

Codex review: needs changes before merge. Reviewed August 16, 2026, 9:10 AM ET / 13:10 UTC.

ClawSweeper review

What this changes

The branch replaces endpoint-specific date-label anchors in three status-menu charts with a shared centered anchor, adds geometry tests, and updates the changelog.

Merge readiness

Blocked by patch quality or review findings - 6 items remain

The latest merge commit left both prior coordinate defects unchanged: centering text on day-boundary ticks still leaves Cost History and Usage Breakdown endpoint labels half a slot from their unit: .day bars. Likely related person: steipete (high confidence).

Priority: P2
Reviewed head: c3d87424902537f6b66d5e2fd2abc84eb63ee1c7

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) The patch is narrowly scoped but retains two prior correctness blockers.
Proof confidence 🌊 off-meta tidepool Not applicable: This owner-authored PR is not subject to the external contributor proof gate; however, the repository’s UI-patch guidance still supports adding redacted freshly built status-menu evidence after the coordinate fix.
Patch quality 🦪 silver shellfish (2/6) 2 actionable review findings remain.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This owner-authored PR is not subject to the external contributor proof gate; however, the repository’s UI-patch guidance still supports adding redacted freshly built status-menu evidence after the coordinate fix.
Evidence reviewed 5 items Cost History retains boundary tick values: Bars use point.date with unit: .day, while labels receive unmodified model.axisDates built from first and last day-start dates. Centering text changes label geometry but not the tick coordinate.
Usage Breakdown has the same mismatch: Its bars use unit: .day, but the changed centered anchor remains attached to unchanged first/last day tick values.
Prior blockers remain unchanged: Both affected file contents hash identically between the prior reviewed head and the current PR head, so these are continued findings rather than late discoveries.
Findings 2 actionable findings [P2] Move Cost History ticks to day-slot centers
[P2] Move Usage Breakdown ticks to day-slot centers
Security None None.

How this fits together

Status-menu charts render daily history as bars with sparse x-axis labels. Date labels must use the same horizontal coordinate system as their corresponding bars.

flowchart LR
A[Daily history] --> B[Day-start dates]
B --> C[Day-slot bars]
B --> D[Axis tick positions]
D --> E[Centered labels]
C --> F[Status-menu chart]
E --> F
Loading

Before merge

  • Move Cost History ticks to day-slot centers (P2) - barCenteredAnchor only centers the label around model.axisDates, which still holds day-start values. BarMark(..., unit: .day) is centered inside that day slot, so first and last labels remain half a slot left of their bars. Shift these axis values to day-slot centers instead of changing only the label anchor.
  • Move Usage Breakdown ticks to day-slot centers (P2) - This has the same unresolved date-axis mismatch: the changed anchor centers text at an unchanged day-boundary tick while unit: .day bars occupy day-slot centers. Use slot-center tick dates so endpoint labels identify the correct bars.
  • Resolve merge risk (P1) - Merging now leaves the two daily charts visibly misaligned at their endpoints because their label ticks remain at day boundaries rather than bar-slot centers.
  • Complete next step (P2) - The two P2 coordinate fixes are narrow and mechanical; this owner-authored PR must remain open for repair.
  • Improve patch quality - Move Cost History and Usage Breakdown ticks to their day-slot centers and extend focused endpoint tests.
  • Improve patch quality - Attach a redacted screenshot or recording from a freshly built status menu showing the first and last labels centered under their bars.

Findings

  • [P2] Move Cost History ticks to day-slot centers — Sources/CodexBar/CostHistoryChartMenuView.swift:184
  • [P2] Move Usage Breakdown ticks to day-slot centers — Sources/CodexBar/UsageBreakdownChartMenuView.swift:94
Agent review details

Security

None.

Review metrics

Metric Value Why it matters
Affected chart views 3 chart views changed; 2 retain a day-slot mismatch A shared anchor is applied across chart types with different x-axis coordinate models.
Code and test delta production +22/-68; tests +34/-13 Most of the patch removes endpoint workarounds, so endpoint rendering proof remains important.

Merge-risk options

Maintainer options:

  1. Correct daily tick coordinates (recommended)
    Move Cost History and Usage Breakdown axis tick values to the same day-slot centers as their bars, then retain the shared centered anchor.

Technical review

Best possible solution:

Use slot-midpoint dates for Cost History and Usage Breakdown endpoint ticks, retain centered anchors, and demonstrate first/last label alignment in the real status menu.

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

Yes—source inspection establishes the mismatch: daily bars use unit: .day while label ticks remain day-start dates.

Is this the best way to solve the issue?

No—the branch centers text at the existing tick but does not move the tick to the bar’s day-slot center; Plan Utilization’s numeric-index chart does not share this defect.

Full review comments:

  • [P2] Move Cost History ticks to day-slot centers — Sources/CodexBar/CostHistoryChartMenuView.swift:184
    barCenteredAnchor only centers the label around model.axisDates, which still holds day-start values. BarMark(..., unit: .day) is centered inside that day slot, so first and last labels remain half a slot left of their bars. Shift these axis values to day-slot centers instead of changing only the label anchor.
    Confidence: 0.96
  • [P2] Move Usage Breakdown ticks to day-slot centers — Sources/CodexBar/UsageBreakdownChartMenuView.swift:94
    This has the same unresolved date-axis mismatch: the changed anchor centers text at an unchanged day-boundary tick while unit: .day bars occupy day-slot centers. Use slot-center tick dates so endpoint labels identify the correct bars.
    Confidence: 0.96

Overall correctness: patch is incorrect
Overall confidence: 0.96

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 361c9d679c99.

Labels

Label justifications:

  • P2: The remaining defect is a visible chart-layout problem with limited user impact.
  • merge-risk: 🚨 other: The two daily-chart endpoint labels remain based on day-boundary ticks rather than bar-slot centers.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🌊 off-meta tidepool and patch quality is 🦪 silver shellfish.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Not applicable: This owner-authored PR is not subject to the external contributor proof gate; however, the repository’s UI-patch guidance still supports adding redacted freshly built status-menu evidence after the coordinate fix.

Evidence

Acceptance criteria:

  • [P1] swift test --filter 'ChartAxisLabelLayoutTests|CostHistoryChartMenuViewTests|UsageBreakdownChartMenuViewTests|PlanUtilizationHistoryChartMenuViewTests'.
  • [P1] make check.

What I checked:

Likely related people:

  • steipete: Current-main history attributes the daily chart implementation to this owner, who also authored the PR’s chart-label change. (role: feature introducer and current chart-area contributor; confidence: high; commits: 636775c2e2aa, 3894180aaf8b; files: Sources/CodexBar/CostHistoryChartMenuView.swift, Sources/CodexBar/UsageBreakdownChartMenuView.swift, Sources/CodexBar/PlanUtilizationHistoryChartMenuView.swift)

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 (2 earlier review cycles)
  • reviewed 2026-08-16T11:45:51.434Z sha 3894180 :: needs changes before merge. :: [P2] Move date-axis values to day-slot centers
  • reviewed 2026-08-16T12:26:21.269Z sha 3dbdf01 :: needs changes before merge. :: [P2] Move date-axis values to day-slot centers | [P2] Align Usage Breakdown ticks with its day bars

@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 Aug 16, 2026
@steipete
steipete merged commit b9ae578 into main Aug 16, 2026
9 checks passed
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. P2 Normal priority bug or improvement with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cost history chart: x-axis date labels misaligned with bars (Aug 16 label ~2 slots left of its bar)

1 participant