CodexBar icon indicating copy to clipboard operation
CodexBar copied to clipboard

Fix manual refresh quota display

Open Zihao-Qi opened this issue 5 months ago β€’ 1 comments

Summary

Fixes a manual refresh display issue where quota values, reset countdowns, or pace text could temporarily show stale or inconsistent data while the menu still showed Refreshing….

The refresh UI now freezes the current visible quota card model when manual refresh starts, then keeps using that frozen model until refresh completes. This is provider-generic and covers both Claude and Codex paths.

Why

During manual refresh, the menu immediately switched to Refreshing…, but parts of the quota card could still be rebuilt from the store while the refresh was in flight. If the store exposed stale or intermediate snapshot data, the UI could temporarily show a different quota value before the refresh completed.

Details

  • Freeze manual-refresh card models by UsageProvider.
  • Keep frozen quota card models visible until manual refresh finishes.
  • Clear frozen models when refresh ends or app shutdown cleanup runs.
  • Use a refresh-aware quota timestamp so reset/pace text is evaluated against the snapshot timestamp while refreshing.
  • Align Codex projection and weekly pace evaluation with that same timestamp.
  • Replace duplicate-sensitive dictionary construction with a safer loop.
  • Add regression coverage for Codex and Claude.

Validation

  • swift test --filter StatusMenuPersistentRefreshTests
  • swift test --filter MenuCardRefreshTests
  • make check

Zihao-Qi avatar Jun 16 '26 16:06 Zihao-Qi

Codex review: needs real behavior proof before merge. Reviewed June 16, 2026, 1:19 PM ET / 17:19 UTC.

Summary The PR freezes provider quota card models during manual refresh, evaluates quota timing against a refresh-aware timestamp, clears frozen state on completion/shutdown, and adds Codex/Claude regression coverage.

Reproducibility: yes. at source level. Current main returns the fallback menu-card model while manual refresh is in flight, so a fallback rebuilt from intermediate store data can appear under the Refreshing subtitle.

Review metrics: 2 noteworthy metrics.

  • Changed surface: 9 files, +285/-34. The patch spans the live menu-card model path, preferences card rendering, manual refresh lifecycle cleanup, and regression tests.
  • Regression coverage: 1 test file added, 1 test file expanded. The new tests cover both standalone model timestamp behavior and controller-level frozen refresh behavior for Claude and Codex.

Merge readiness Overall: πŸ§‚ unranked krab Proof: πŸ§‚ unranked krab Patch quality: 🐚 platinum hermit Result: blocked until real behavior proof from a real setup is added.

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

Rank-up moves:

  • [P1] Add redacted real behavior proof from a running CodexBar build showing manual Refresh keeps the visible quota card stable while Refreshing and updates after completion.

Proof guidance:

  • [P1] Needs real behavior proof before merge: The PR body lists tests and make check only; please add a screenshot, recording, terminal output, or redacted live logs showing the after-fix manual refresh behavior, then update the PR body to trigger a fresh ClawSweeper review or ask a maintainer to comment @clawsweeper re-review.

Mantis proof suggestion A short desktop proof would directly show the visible menu behavior that unit tests cannot prove in a real tracked menu. A maintainer can ask Mantis to capture proof by posting this exact PR comment:

@openclaw-mantis visual task: verify CodexBar manual Refresh keeps quota values, reset text, and pace text stable while Refreshing, then updates after completion.

Risk before merge

  • [P1] The contributor has not provided after-fix real behavior proof from a running app, so maintainers cannot yet verify that the visible menu card stays stable during an actual manual refresh.

Maintainer options:

  1. Decide the mitigation before merge
    Land the focused frozen-model approach after real menu behavior proof confirms quota values, reset text, and pace text stay stable while Refreshing and then update cleanly after completion.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Next step before merge

  • [P1] The remaining blocker is contributor/maintainer real behavior proof rather than an automated code repair.

Security Cleared: The diff only changes Swift menu/model logic and tests; it does not alter dependencies, scripts, credentials, signing, CI permissions, or other supply-chain surfaces.

Review details

Best possible solution:

Land the focused frozen-model approach after real menu behavior proof confirms quota values, reset text, and pace text stay stable while Refreshing and then update cleanly after completion.

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

Yes at source level. Current main returns the fallback menu-card model while manual refresh is in flight, so a fallback rebuilt from intermediate store data can appear under the Refreshing subtitle.

Is this the best way to solve the issue?

Mostly yes. Freezing the visible provider model while preserving layout compatibility matches the existing live-model seam; the remaining blocker is real behavior proof, not a known code defect.

AGENTS.md: found and applied where relevant.

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

Label changes

Label changes:

  • add P2: This is a normal-priority UI correctness fix for manual quota refresh display with limited blast radius.
  • add rating: πŸ§‚ unranked krab: Overall readiness is πŸ§‚ unranked krab; proof is πŸ§‚ unranked krab and patch quality is 🐚 platinum hermit.
  • add status: πŸ“£ needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: The PR body lists tests and make check only; please add a screenshot, recording, terminal output, or redacted live logs showing the after-fix manual refresh behavior, then update the PR body to trigger a fresh ClawSweeper review or ask a maintainer to comment @clawsweeper re-review.

Label justifications:

  • P2: This is a normal-priority UI correctness fix for manual quota refresh display with limited blast radius.
  • rating: πŸ§‚ unranked krab: Overall readiness is πŸ§‚ unranked krab; proof is πŸ§‚ unranked krab and patch quality is 🐚 platinum hermit.
  • status: πŸ“£ needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: The PR body lists tests and make check only; please add a screenshot, recording, terminal output, or redacted live logs showing the after-fix manual refresh behavior, then update the PR body to trigger a fresh ClawSweeper review or ask a maintainer to comment @clawsweeper re-review.
Evidence reviewed

What I checked:

  • AGENTS.md policy read: The repository policy was read fully and applies here because this PR touches menu UI behavior and adds focused model/state tests rather than live provider probes. (AGENTS.md:1, ac01d73625ee)
  • Current main in-flight behavior: On current main, MenuCardRefreshMonitor returns the fallback model while manual refresh is in flight, so any fallback rebuilt from intermediate store data can be displayed while the subtitle says Refreshing. (Sources/CodexBar/MenuCardRefreshMonitor.swift:22, ac01d73625ee)
  • PR implementation path: The PR adds begin/end manual refresh APIs, stores frozen models by UsageProvider, and only uses a frozen model when it remains compatible with the hosted layout. (Sources/CodexBar/MenuCardRefreshMonitor.swift, dac73259c023)
  • Prior review comment addressed: The earlier Codex review asked the author to keep the frozen model behind the existing layout-compatibility gate; the second PR commit is titled "Honor refresh card layout compatibility" and the current diff includes that guard. (Sources/CodexBar/MenuCardRefreshMonitor.swift, dac73259c023)
  • Regression coverage: The diff adds a new MenuCardRefreshTests file and expands StatusMenuPersistentRefreshTests for frozen quota values, incompatible layout fallback, and snapshot-timestamp pace evaluation. (Tests/CodexBarTests/StatusMenuPersistentRefreshTests.swift, dac73259c023)
  • Proof gate: The PR body lists focused tests and make check, but it does not include a screenshot, recording, terminal/live output, logs, or other real app proof of the visible manual-refresh behavior. (dac73259c023)

Likely related people:

  • steipete: Local blame and PR 1458 history tie this handle to hardening the manual refresh lifecycle and nearby menu-card behavior. (role: recent area contributor; confidence: high; commits: 87e6e26270b2, 371c7489695a, 06fea2c897cc; files: Sources/CodexBar/MenuCardRefreshMonitor.swift, Sources/CodexBar/StatusItemController+Actions.swift, Sources/CodexBar/MenuCardView.swift)
  • hhh2210: PR 1458 shows this handle authored the commit that added in-place manual refresh feedback and the original live subtitle bridge this PR extends. (role: introduced live feedback behavior; confidence: high; commits: d1c96c3ac4a6; files: Sources/CodexBar/MenuCardView.swift, Sources/CodexBar/StatusItemController+Actions.swift, Tests/CodexBarTests/StatusMenuPersistentRefreshTests.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.

clawsweeper[bot] avatar Jun 16 '26 17:06 clawsweeper[bot]

Local proof against the Codex usage-bar flicker reported in #1329, run on June 16, 2026 PT at head dac73259:

$ swift test --filter StatusMenuPersistentRefreshTests
Suite StatusMenuPersistentRefreshTests passed after 1.056 seconds.
Test run with 22 tests in 1 suite passed after 1.056 seconds.

The passing suite includes the Codex regression case:

Test "manual refresh keeps frozen quota even if menu rebuilds before completion" passed
$ swift test --filter MenuCardRefreshTests
Suite MenuCardRefreshTests passed after 0.031 seconds.
Test run with 1 test in 1 suite passed after 0.031 seconds.

This covers the source-level behavior for keeping quota values stable while manual refresh is in flight. It maps to the current #1329 follow-up symptom where Codex OAuth usage bars transiently vanish/flicker during refresh. A visual run is still useful for the exact menu proof requested by review automation.

ProspectOre avatar Jun 17 '26 05:06 ProspectOre

@openclaw-mantis visual task: verify CodexBar manual Refresh keeps quota values, reset text, and pace text stable while Refreshing, then updates after completion.

ProspectOre avatar Jun 17 '26 05:06 ProspectOre

Maintainer proof on improved head b9a8c5ef:

  • Removed the generic snapshot-timestamp rewrite found by autoreview; background refreshes now keep reset and pace timing current.
  • swift test --filter 'StatusMenuPersistentRefreshTests|MenuCardRefreshTests': 22 tests passed.
  • make check: passed.
  • Autoreview: clean, no actionable findings.
  • Built and launched the exact branch bundle with ad-hoc signing. Peekaboo successfully opened the CodexBar status item at its verified on-screen frame. Accessibility showed the complete existing card content, Refresh action, and stable menu rows; invoking Refresh retained the existing card content while the live provider requests ran and completed successfully.
  • macOS Screen Recording permission is unavailable in this session, so the proof is Accessibility state plus live unified-log completion rather than a screenshot. Accessibility and event-synthesis permissions are granted.

Exact-head CI is now running on the pushed branch.

steipete avatar Jun 17 '26 08:06 steipete

Maintainer proof on exact updated head 57f022b6:

  • Merged current main and preserved the focused manual-refresh fix.
  • swift test --filter 'StatusMenuPersistentRefreshTests|MenuCardRefreshTests': 22 tests passed.
  • make check: passed with zero SwiftLint violations.
  • Autoreview: clean, no accepted/actionable findings.
  • Packaged and launched the exact branch bundle with ad-hoc signing.
  • Accessibility captured the populated Codex card, invoked the in-place Refresh row, and immediately confirmed the same account, plan, cost, token, credit, and status rows remained visible.
  • Unified logs then showed the live refresh issuing multiple successful HTTP 200 requests.

Screen Recording permission is unavailable on this host, so the live proof used Accessibility inspection, event synthesis, and live network completion logs rather than a screenshot.

steipete avatar Jun 17 '26 09:06 steipete

Final integrated proof on exact head 9bf12fc7 after landing #1589:

  • Resolved the sole changelog conflict while preserving both entries; no source conflict occurred.
  • swift test --filter 'StatusMenuPersistentRefreshTests|MenuCardRefreshTests|MenuCardViewRecyclingTests': 41 tests passed.
  • make check: passed with zero SwiftLint violations.
  • Autoreview against current main: clean, no accepted/actionable findings.
  • Packaged and launched the exact branch bundle.
  • Accessibility captured the populated Codex card before Refresh, invoked the in-place Refresh row, and confirmed every visible account, plan, cost, token, credit, and status row remained unchanged immediately afterward.
  • Unified logs recorded repeated successful HTTP 200 completions during that refresh.

Screen Recording permission is unavailable on this host, so proof uses Accessibility inspection, event synthesis, and live network completion logs.

steipete avatar Jun 17 '26 10:06 steipete