fix: align chart date labels with bars - #2977
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs changes before merge. Reviewed August 16, 2026, 9:10 AM ET / 13:10 UTC. ClawSweeper reviewWhat this changesThe 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 Priority: P2 Review scores
Verification
How this fits togetherStatus-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
Before merge
Findings
Agent review detailsSecurityNone. Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest 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 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:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 361c9d679c99. LabelsLabel justifications:
EvidenceAcceptance criteria:
What I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (2 earlier review cycles)
|
…abels # Conflicts: # CHANGELOG.md
Summary
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
.topLeadingfor the first date and.topTrailingfor 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 passedmake check— passed on the issue branch's originalorigin/main; after rebasing onto currentorigin/main, it reaches SwiftLint and fails on the upstream-onlyUsageStoreWidgetSnapshotTests.swifttype-body length (897 > 800). This PR does not modify that file.