CodexBar icon indicating copy to clipboard operation
CodexBar copied to clipboard

[Codex spend] Hover preview selects a different bar than the one under the pointer

Open Yoroin opened this issue 3 months ago • 2 comments

Summary

In the Codex status-menu usage/spend chart, the bar under the pointer and the detail preview do not consistently refer to the same day/bar. The preview can show a different date than the bar being inspected.

The attached screenshot shows the Codex chart in Tokens mode with the detail preview reporting:

  • 2026-08-19
  • $0.06
  • 1.1M tokens
  • gpt-5.6-luna

Environment

  • CodexBar 0.53.0 (build 125)
  • macOS
  • Provider: Codex
  • Chart: status-menu usage/spend chart
  • Metric: Tokens

Expected behavior

The hover/selection preview should always describe the exact bar currently under the pointer, including the same day, token count, cost, and model breakdown.

Actual behavior

The chart and the hover detail can point to different bars/dates. This makes it difficult to tell which day's spend and token totals are being inspected.

Sanitized local diagnostic summary

This is a local cache summary only; no raw logs, account identifiers, session IDs, prompts, or local paths are included.

day         model          input_tokens  cached_tokens  output_tokens  requests  authoritative_cost_nanos
2026-08-18  gpt-5.6-luna   42484030      38335104       145855         364       0
2026-08-19  gpt-5.6-luna   1118105       929024         5822           15        0

The local scan currently reports 11 complete files and 1 incomplete file. The screenshot's displayed cost is an estimate; the cache has no authoritative cost for these Luna rows.

Possible implementation lead

The current chart path maps the pointer through ChartProxy.value(atX:), chooses the nearest date key, and then separately checks the bar position. Sparse days, day-bucketing, or calendar/time-zone differences may allow the selected key and visible bar to diverge. Existing hover tests cover bar-width acceptance and DST spacing, but not exact pointer-to-bar identity for sparse daily data.

Relevant source path: https://github.com/steipete/CodexBar/blob/main/Sources/CodexBar/CostHistoryChartMenuView.swift#L792-L827

Reproduction

  1. Open the Codex status-menu usage/spend chart.
  2. Select the Tokens view.
  3. Move the pointer across several bars, especially the last few bars or a chart with missing days.
  4. Compare the bar under the pointer with the date/model/token/cost shown in the detail preview.
Image

Yoroin avatar Aug 19 '26 01:08 Yoroin

Codex review: keeping this open for maintainer follow-up; there is still a little grit to resolve. Reviewed August 18, 2026, 9:47 PM ET / August 19, 2026, 01:47 UTC.

Summary Current main contains the geometry-based hover repair, but the latest release is v0.53.0 and predates it. Per this repository’s conservative onboarding policy, leave manual closure to a maintainer rather than auto-closing this resolved report.

Reproducibility: no. current-main reproduction was run; current source and focused tests show the former separate selection path has been replaced by one bar-frame identity.

Ways to help us reproduce this

  • Add a screenshot or short recording showing the behavior.
  • Add expected vs actual behavior.
  • Share version, platform, channel/provider, and relevant config details.

Maintainer decision needed

Question Recommendation
Should this report be manually closed now as fixed on main, or remain open until the next release ships the repair? Close as fixed on main: Manually close now, noting that the repair will be available in the next release.

Why: The repository onboarding profile forbids automatic closure, and the fix is newer than the latest release.

Next step No repair PR is needed; a maintainer should decide whether to close the main-fixed report before release publication.

Review details

Best possible solution:

Ship the existing repair in the next release, then manually close this report as fixed.

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

No current-main reproduction was run; current source and focused tests show the former separate selection path has been replaced by one bar-frame identity.

Is this the best way to solve the issue?

Yes—the current implementation is the narrow maintainable fix because preview and highlight share the same selected bar geometry.

AGENTS.md: found and applied where relevant.

Remaining risk / open question:

  • Users on v0.53.0 can still encounter the mismatch until a release includes commit 71d823110568b0acb40b3c39d663b145e817d5ac.

Codex review notes: model internal, reasoning high; reviewed against a32989c750e6; fix evidence: commit 71d823110568, main fix timestamp 2026-08-18T11:39:04-07:00.

Label changes

Label changes:

  • add P2: The mismatch impairs accurate interpretation of daily usage but does not block the application.
  • add impact:ux-friction: The chart preview can make users inspect the wrong day’s data.
  • add issue-rating: 🦪 silver shellfish: Current issue advisory state selects this label.
  • add clawsweeper:not-repro-on-main: Current issue advisory state selects this label.
  • add clawsweeper:no-new-fix-pr: Current issue advisory state selects this label.
  • add clawsweeper:needs-maintainer-review: Current issue advisory state selects this label.

Label justifications:

  • P2: The mismatch impairs accurate interpretation of daily usage but does not block the application.
  • impact:ux-friction: The chart preview can make users inspect the wrong day’s data.
Evidence reviewed

What I checked:

Likely related people:

  • Peter Steinberger: Authored the current-main commit that introduced the hover-selection repair. (role: recent chart-area contributor; confidence: high; commits: 71d823110568; files: Sources/CodexBar/CostHistoryChartMenuView.swift, Sources/CodexBar/ChartBarHoverSelection.swift)
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.

clawsweeper[bot] avatar Aug 19 '26 01:08 clawsweeper[bot]

This is the same half-day hover offset reported in #3040: the charts drew .day-unit bars centered on the calendar interval midpoint while hover hit-testing and the detail preview mapped from startOfDay, so the preview could describe a neighboring day. Fixed on main by #3049, which derives exact bar frames from calendar-day intervals plus plot insets and shares that geometry between drawing, hit-testing, and the highlight — the cost, credits, and usage-breakdown charts all use the unified path now.

The fix ships in 0.54.0 (releasing today). Please update and reopen with a screenshot if the preview still names a different day than the bar under the pointer on ≥0.54.0.

steipete avatar Aug 19 '26 15:08 steipete