Skip to content

fix(codex): refresh selected account cards in open menus - #3715

Merged
steipete merged 13 commits into
steipete:mainfrom
sandeep780049:fix/codex-account-switch-blank-card-3709
Sep 18, 2026
Merged

steipete merged 13 commits into
steipete:mainfrom
sandeep780049:fix/codex-account-switch-blank-card-3709

Conversation

@sandeep780049

@sandeep780049 sandeep780049 commented Sep 17, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #3709. Selecting another Codex account could leave its usage card blank even after fetching succeeded because the refresh callback deferred the root-menu rebuild until tracking ended.

Schedule account data updates through the existing event-tracking/default run loop, preserving request coalescing, hosted submenus, and highlighted native commands. Recheck account and provider ownership before enqueueing and before rebuilding. Explicit interaction resumptions use the same tracking-safe path; ordinary plugin/manual refreshes retain their existing yielding task order. Fetching, credentials, and account activation stay in their existing layers.

Validation on b12e07cdd8f82b955f0c756c27d3be6e9dda8424: make test passed all 1,185 selections across 108 groups on the first attempt, without retries or timeouts; make check, 119 focused tests, and independent P0–P2 review passed. A freshly signed native test selects the attached B button in an actual tracking status menu, holds one synthetic fetch, then requires B and 17% in the attached card's screenshot/OCR before tracking returns. The baseline publishes that same usage but leaves the card blank. It uses contained fixtures and the real publication/ownership flow, without real provider access, scheduler overrides, manual rebuilds, or reparenting. Cleanup waits for the entire scoped refresh and widget task.

The images below were completely inspected and contain only synthetic data. Final native proof and source/binary provenance. CI for the validated fix passed. The subsequent main integration at befa45d8dabe4effd5809809f2720da85c8f098d retains the fix and native harness unchanged, with clean make check and independent P0–P2 integration review. A combined integration run at 22f32150a3461d28e9cea58d74123680b830d894 also passed all 1,200 selections across 111 groups without retries or timeouts, including this unchanged menu fix, the Claude progress candidate, and current provider changes. Current-head CI passed all checks.

Thanks @sandeep780049 for the original fix and investigation.

Before: fetched usage remains blank After: B usage appears while open
Baseline leaves the synthetic B usage card blank Final candidate shows synthetic B usage at 17 percent

Switching Codex accounts in the segmented layout cleared the published
usage and left the open menu card blank: the account-scoped refresh's
phase callbacks called the generic open-menu refresh, which defers
parent rebuilds while tracking and re-defers on its retry pass, so the
fetched usage was only rendered after closing and reopening the menu.

Route the phase callbacks through the switcher rebuild path instead.
It coalesces the rapid phase notifications into one in-place rebuild,
closes hosted subviews first like the selection rebuild, and clears
the tracking deferral, so the open card adopts the new account's
usage as soon as it arrives.

Adds a regression test asserting a post-fetch rebuild while the menu
stays open, and updates the provider gatekeeper allowlist for the
rerouted call.

Fixes steipete#3709.
@clawsweeper

clawsweeper Bot commented Sep 17, 2026 •

Copy link
Copy Markdown

🦞👀
ClawSweeper picked this up.

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

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@clawsweeper clawsweeper Bot added P2 Normal priority bug or improvement with limited blast radius. 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. labels Sep 17, 2026
@clawsweeper

clawsweeper Bot commented Sep 17, 2026 •

Copy link
Copy Markdown

Codex review: needs maintainer review before merge. Reviewed September 18, 2026, 8:56 AM ET / 12:56 UTC (Revision 15).

ClawSweeper review

What this changes

Refreshes the selected Codex account’s usage card while its menu remains open, preserving submenu interactions and adding regression coverage and native proof tooling.

Merge readiness

✅ Ready for maintainer review

The PR remains necessary: current main retains the deferred-refresh behavior. No actionable defects remain, and the native before/after evidence sufficiently demonstrates the fix.

Priority: P2
Reviewed head: befa45d8dabe4effd5809809f2720da85c8f098d

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) A focused repair with convincing native before/after evidence, interaction safeguards, and substantial regression validation.
Proof confidence 🦞 diamond lobster (5/6) ✨ media proof bonus Sufficient (screenshot): The inspected before/after captures and owner-recorded signed macOS run exercise the real account-selection, publication, scheduler, and attached-card rendering path with one synthetic delayed fetch; account B displays 17% before tracking returns. Relevant implementation and harness files remain unchanged at the reviewed head.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (screenshot): The inspected before/after captures and owner-recorded signed macOS run exercise the real account-selection, publication, scheduler, and attached-card rendering path with one synthetic delayed fetch; account B displays 17% before tracking returns. Relevant implementation and harness files remain unchanged at the reviewed head.
Evidence reviewed 8 items Current main still needs the fix: The current-main account refresh callback still invokes refreshOpenMenuIfStillVisible, which defers root-menu rebuilding during tracking.
Release comparison: The three affected menu implementation files have no differences between v0.60.5 and fetched main; neither contains this PR’s account-data scheduling change.
Scheduling and selection safeguards: The new helper checks account/provider selection before enqueueing and before execution, invalidates content, and reuses the existing tracking scheduler. The shared rebuild path preserves hosted submenus and defers highlighted native commands.
Findings None None.
Security None None.

How this fits together

CodexBar’s menu controller turns account-scoped usage updates into visible account cards. This change schedules those updates during macOS menu tracking while preserving selection and interaction guards.

flowchart TD
  A[Account tab selected] --> B[Account usage refresh]
  B --> C[Check current account and provider]
  C --> D[Coalesced tracking scheduler]
  D --> E{Submenu or command highlighted?}
  E -->|Yes| F[Wait for interaction to finish]
  F --> D
  E -->|No| G[Update open account card]
Loading

Before merge

None.

Agent review details

Security

None.

Review metrics

Metric Value Why it matters
Production and test LOC Production +77/-27; tests +614/-19 The production growth supports tracking-safe scheduling; most added code provides isolated regression coverage and native rendering proof.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #3709
Summary: This PR is the implementation candidate for the blank selected-account card; the related feature requests are distinct.

Members:

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

Technical review

Best possible solution:

Use the existing tracking scheduler for selected-account updates and explicit interaction resumptions while preserving ordinary refresh ordering.

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

Yes. Current main routes delayed account updates through a tracking-deferred rebuild, matching the reported blank-card sequence and supplied native baseline; this review did not execute the scenario.

Is this the best way to solve the issue?

Yes. Reusing the existing run-loop scheduler repairs rendering without expanding account fetching, changing credentials, or adding settings.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 0ead0d6787e8.

Labels

Label justifications:

  • P2: Repairs a bounded account-card refresh defect with an existing provider-switch workaround.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (screenshot): The inspected before/after captures and owner-recorded signed macOS run exercise the real account-selection, publication, scheduler, and attached-card rendering path with one synthetic delayed fetch; account B displays 17% before tracking returns. Relevant implementation and harness files remain unchanged at the reviewed head.
  • proof: sufficient: Contributor real behavior proof is sufficient. The inspected before/after captures and owner-recorded signed macOS run exercise the real account-selection, publication, scheduler, and attached-card rendering path with one synthetic delayed fetch; account B displays 17% before tracking returns. Relevant implementation and harness files remain unchanged at the reviewed head.
  • proof: 📸 screenshot: Contributor real behavior proof includes screenshot evidence. The inspected before/after captures and owner-recorded signed macOS run exercise the real account-selection, publication, scheduler, and attached-card rendering path with one synthetic delayed fetch; account B displays 17% before tracking returns. Relevant implementation and harness files remain unchanged at the reviewed head.

Evidence

What I checked:

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

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 (14 earlier review cycles; latest 8 shown)
  • reviewed 2026-09-17T22:13:30.211Z sha f5878b9 :: needs real behavior proof before merge. :: [P1] [P1] Move run-loop pumping out of the async test body | [P2] [P2] Capture and assert the usage card instead of the first view
  • reviewed 2026-09-17T22:34:46.261Z sha 8a47209 :: needs real behavior proof before merge. :: [P2] [P2] Capture and assert the usage card instead of the first view
  • reviewed 2026-09-17T22:57:12.252Z sha 37411dc :: needs real behavior proof before merge. :: [P2] [P2] Capture and assert the usage card instead of the first view
  • reviewed 2026-09-18T10:10:34.667Z sha 8b4832e :: blocked before merge. :: none
  • reviewed 2026-09-18T10:41:44.660Z sha b12e07c :: needs maintainer review before merge. :: none
  • reviewed 2026-09-18T11:10:32.491Z sha b12e07c :: needs maintainer review before merge. :: none
  • reviewed 2026-09-18T12:09:03.734Z sha befa45d :: needs maintainer review before merge. :: none
  • reviewed 2026-09-18T12:36:18.911Z sha befa45d :: needs maintainer review before merge. :: none

Address review feedback on the first attempt: routing the refresh
phase callbacks through the switcher path would dismiss an open hosted
chart submenu when a delayed phase landed. Add a dedicated helper that
bumps the content version as a data-only invalidation and schedules an
in-place rebuild: coalesced, deferred during native highlight, skipped
while a hosted submenu is open, and reconciled when it closes.

Also seed the changelog entry and cover the helper's submenu
preservation contract with a focused regression test.
@sandeep780049

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Sep 17, 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 exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

The account-scoped refresh can publish unrelated data-only
invalidations after the final rebuild (widget snapshots, readiness
resyncs), so asserting a fully-settled state at the end over-constrains
the regression. The defect's crisp signal is a rebuild happening after
the fetch resolves while the menu stays open.
Follow the repo's native-proof convention (AboutUpdateCommandProofTests,
ClaudeWeeklyLabelsNativeProofTests): when CODEXBAR_ACCOUNT_SWITCH_PROOF_DIR
is set with keychain prompt suppression, the test runs the real account-
switch scheduling path with card rendering enabled and captures before/
after PNGs of the usage card plus a transcript, asserting the fetched
usage is published and the open hosted submenu survives.

A dispatch-only workflow runs the proof on a macOS runner and uploads
the artifacts as merge evidence.
@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Sep 17, 2026
@clawsweeper clawsweeper Bot added merge-risk: 🚨 automation 🚨 Merging this PR could break CI, automerge, proof capture, label sync, or automation. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. labels Sep 17, 2026
@sandeep780049

Copy link
Copy Markdown
Contributor Author

Native macOS proof (revision 3) — request fulfilled

Ran the account-switch flow on a real macOS 26 GitHub Actions runner (real AppKit, menu card rendering enabled, no test scheduler or rebuild mocks for the scheduling path): workflow run.

Transcript (from proof/3709-artifacts, PNGs before-account-switch.png / after-account-switch.png in the same branch):

before select: published email live@example.com
selected managed account; published email <nil>            ← card cleared during switch
pre-fetch drained; rebuilds 1
fetch resumed with managed@example.com snapshot (17%)
after fetch: published email managed@example.com           ← usage lands while menu is still open
hosted submenu still open after fetch: true                ← open chart submenu survives
parent rebuilds while submenu open: 0                      ← rebuild skipped while chart is open (preserved)
after submenu close: total parent rebuilds 2               ← deferred rebuild reconciles on chart close

Assertions in the run (all passing): new account's usage published into the still-open menu, hosted chart submenu preserved across the delayed rebuild, parent menu never closed, deferred parent rebuild lands after the submenu closes. Before/after renders of the actual menu card are captured as PNGs.

Also validated in the same macOS run: StatusMenuCodexSwitcherTests (incl. the new regression test) and StatusMenuOpenRefreshTests (incl. the new hosted-submenu reconciliation test) — 55 tests, 0 failures.

@clawsweeper clawsweeper Bot removed the merge-risk: 🚨 automation 🚨 Merging this PR could break CI, automerge, proof capture, label sync, or automation. label Sep 17, 2026
@steipete steipete changed the title fix(codex): rebuild open menu when account-scoped refresh phases land fix(codex): refresh selected account cards in open menus Sep 18, 2026
@clawsweeper clawsweeper Bot added proof: sufficient Contributor real behavior proof is sufficient. and removed status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Sep 18, 2026
@clawsweeper clawsweeper Bot added 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 Sep 18, 2026
@steipete

Copy link
Copy Markdown
Owner

Native before/after verification used a signed test host on macOS 27.0 (26A428), an actual tracking status menu, its attached B button, and exactly one held synthetic account fetch. The baseline publishes B's 17% usage but leaves the card blank; candidate 8b4832e665606d4de151569f151dba5de2be16e3 shows B and 17% before tracking returns. The harness waits for the complete scoped refresh and widget task before cleaning up.

Both complete captures were inspected and contain only synthetic data. No real provider or credential access, scheduler override, manual menu rebuild, or reparented card was used. Full-suite follow-up and CI are still in progress.

Baseline after fetch Candidate after fetch
Baseline still has a blank usage card Candidate shows synthetic B account usage at 17 percent

Image SHA-256: before 93ec39de09eaa6380be65c6df1a2a019cf119d42c53e1463bd0ae1d5fe2c4ff5; after 81fe7fe0c2526f5396335cfddaf95941b3513acd46b322968b76d9f53431a572.

@clawsweeper clawsweeper Bot added proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. labels Sep 18, 2026
@steipete

Copy link
Copy Markdown
Owner

Final local validation passed on b12e07cdd8f82b955f0c756c27d3be6e9dda8424:

  • make test: all 1,185 selections across 108 groups passed on the first attempt, with no retries or timeouts (1,123 seconds).
  • make check: zero violations. Independent P0–P2 review is clean. The 119 focused menu, plugin, cleanup and architecture tests passed.
  • Freshly signed native StatusMenuCodexAccountSwitchNativeProofTests passed on macOS 27.0 (26A428). The attached B button starts exactly one held synthetic fetch; the attached card shows B and 17% while the same menu tracks. The complete scoped refresh and widget task are drained before fixture cleanup. No real account/provider access or scheduler override is used.

The full-suite check exposed an ordering regression in an earlier draft: applying the tracking scheduler to every ordinary refresh could rebuild plugin cards before queued store observations settled. The final change limits that scheduler to account updates and explicit interaction resumptions, preserving the original ordinary refresh ordering. The unchanged plugin regression now passes. An adjacent cleanup test now awaits its owned sequence tasks instead of polling for an impossible load count.

Baseline after-fetch capture remains unchanged. The new final-source capture below was fully inspected and contains only synthetic data. Its clean source tree is 7d978b48f52f1562be841e30c05e80ca8c708bc8; signed test-binary SHA-256 is 5a7f95e736a87fe81abdeaa7865ef5d9f4fa5ac8a1b0e9eaa9292e9435a0ff0d.

Final-head CI is still pending; this PR has not been merged yet.

Final source: synthetic account B usage appears at 17 percent while the menu stays open

@steipete
steipete merged commit 19cafac into steipete:main Sep 18, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P2 Normal priority bug or improvement with limited blast radius. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. proof: sufficient Contributor real behavior proof is sufficient. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Codex account switch leaves the usage card blank in segmented layout until a provider round-trip

2 participants