Avoid retaining menu refresh state
Summary
- Avoid retaining
StatusItemControllerand the open menu for the full Codex account-scoped refresh task. - Keep the existing phase-change callback guarded by weak captures so menu refreshes only run while the menu/controller still exist.
Proof
swiftlint --strict Sources/CodexBar/StatusItemController+Menu.swiftswift build --build-tests 2>&1 | tee /tmp/codexbar-menu-capture-build.log! rg -q "ImplicitStrongCapture|weak ownership of capture" /tmp/codexbar-menu-capture-build.log
Notes
- This is intentionally separate from the logging performance PR.
@clawsweeper re-review
๐ฆ๐งน ClawSweeper re-review requested.
I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.
Re-review progress:
- State: Complete
- Detail: The targeted re-review finished, the durable review comment was updated, and the synced verdict was routed.
- Run: https://github.com/openclaw/clawsweeper/actions/runs/27735370932
- Updated: 2026-06-18T04:32:10.078Z
@clawsweeper re-review
Codex review: needs real behavior proof before merge. Reviewed June 18, 2026, 11:47 PM ET / 03:47 UTC.
Summary
The PR changes Codex account-scoped menu refresh to capture UsageStore and SettingsStore directly while keeping the controller/menu weak, and adds an in-flight controller-deallocation regression test.
Reproducibility: yes. at source level: current main strongly captures self in the account-scoped refresh task until the async store refresh completes. I did not run a live app reproduction because this is a read-only review and live provider validation was not requested.
Review metrics: 1 noteworthy metric.
- Patch size: 2 files changed, 99 additions, 6 deletions. The diff is limited to one menu-controller lifecycle path plus one focused regression test file.
Merge readiness Overall: ๐ง unranked krab Proof: ๐ง unranked krab Patch quality: ๐ฆ diamond lobster Result: blocked until real behavior proof is added.
Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.
Rank-up moves:
- [P1] Post redacted after-fix proof from a freshly built CodexBar run showing Codex account switching still refreshes the open menu after the lifecycle change.
- After adding proof, update the PR body so ClawSweeper re-reviews automatically; if it does not, ask a maintainer to comment
@clawsweeper re-review.
Proof guidance:
- [P1] Needs real behavior proof before merge: The PR body contains test/check claims only; please add a short recording, screenshot/video where visible, terminal/live output, linked artifact, or redacted runtime log from a freshly built app, redacting private details, then update the PR body to trigger a fresh review.
Mantis proof suggestion A short visible CodexBar menu proof would directly show the account-switch refresh behavior that unit tests cannot prove in a running app. A maintainer can ask Mantis to capture proof by posting this exact PR comment:
@openclaw-mantis visual task: verify CodexBar account switching still refreshes the open menu after the weak-capture lifecycle change.
Risk before merge
- [P1] The PR still lacks after-fix real behavior proof from a running CodexBar build, so maintainers cannot verify the live account-switch/open-menu refresh path beyond source inspection and tests.
Maintainer options:
- Require visible menu proof before merge (recommended)
Ask for a short recording, terminal/live output, linked artifact, or redacted runtime log from a freshly built app showing the after-fix Codex account-switch refresh behavior. - Accept source-level confidence
Maintainers can merge on source review and the focused regression test while explicitly owning the missing live-menu proof risk. - Pause until proof exists
Leave the PR open until the external proof gate is satisfied or a maintainer decides this lifecycle cleanup is no longer worth carrying.
Next step before merge
- [P1] The remaining blocker is contributor or maintainer live proof from a running app, which an automated repair PR cannot supply for this external branch.
Security Cleared: No security or supply-chain concern found; the diff is limited to Swift app/test lifecycle code and does not touch secrets, dependencies, CI, release scripts, or package resolution.
Review details
Best possible solution:
Land the narrow lifecycle fix after redacted real behavior proof demonstrates the Codex account-switch/open-menu refresh path in a freshly built CodexBar app.
Do we have a high-confidence way to reproduce the issue?
Yes, at source level: current main strongly captures self in the account-scoped refresh task until the async store refresh completes. I did not run a live app reproduction because this is a read-only review and live provider validation was not requested.
Is this the best way to solve the issue?
Yes. Capturing the long-lived stores directly while keeping the controller/menu weak is the narrowest maintainable fix for the retain behavior, and the active-account guard before refreshing the open menu is preserved.
AGENTS.md: found and applied where relevant.
Codex review notes: model internal, reasoning high; reviewed against a3ea16743560.
Label changes
Label justifications:
P3: This is a focused lifecycle cleanup and regression test around Codex menu refresh behavior with limited blast radius.merge-risk: ๐จ other: Green tests do not prove the visible menu/account-switch behavior still refreshes correctly in a real running app after the weak-capture lifecycle change.rating: ๐ง unranked krab: Overall readiness is ๐ง unranked krab; proof is ๐ง unranked krab and patch quality is ๐ฆ diamond lobster.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 contains test/check claims only; please add a short recording, screenshot/video where visible, terminal/live output, linked artifact, or redacted runtime log from a freshly built app, redacting private details, then update the PR body to trigger a fresh review.
Evidence reviewed
What I checked:
- Repository policy read: AGENTS.md was read fully; its focused menu-test guidance, Swift concurrency caution, and no-live-provider-probe constraints applied to this read-only review. (
AGENTS.md:1, a3ea16743560) - No maintainer notes directory: The checkout has
.agents/skillsfiles but no.agents/maintainer-notes/directory to apply for this PR. (a3ea16743560) - Current main retain path: Current main starts the account-scoped refresh with
Task { @MainActor in ... self.store.refreshCodexAccountScopedState(...) }, so the task strongly captures the status controller until the refresh returns. (Sources/CodexBar/StatusItemController+Menu.swift:1086, a3ea16743560) - History for current path: Blame ties the current Codex visible-account selection refresh task to commit 06fea2c897cc in the v0.36.1-era Codex account/menu work. (
Sources/CodexBar/StatusItemController+Menu.swift:1086, 06fea2c897cc) - PR weakens controller/menu lifetime: The PR head captures
storeandsettingsfor the async refresh while using weakcontrollerandmenucaptures only for phase-change menu callbacks. (Sources/CodexBar/StatusItemController+Menu.swift:1086, 13fd9690084d) - Store-owned refresh method:
refreshCodexAccountScopedStateis aUsageStoremethod that owns the refresh phases; the controller is only needed for optional open-menu refresh callbacks. (Sources/CodexBar/Providers/Codex/UsageStore+CodexAccountState.swift:33, a3ea16743560)
Likely related people:
- steipete: Blame ties the current Codex visible-account selection refresh task to commit 06fea2c897cc in the v0.36.1-era Codex account/menu work. (role: introduced behavior; confidence: high; commits: 06fea2c897cc; files:
Sources/CodexBar/StatusItemController+Menu.swift,Sources/CodexBar/Providers/Codex/UsageStore+CodexAccountState.swift) - Yuxin-Qiao: Recent merged work touched the same menu controller file for Codex quota visibility during refresh switchback. (role: recent area contributor; confidence: medium; commits: 421bf576abc0; files:
Sources/CodexBar/StatusItemController+Menu.swift) - elijahfriedman: Recent merged menu-item interaction work touched the same menu controller file, making this a nearby routing signal rather than ownership proof. (role: recent adjacent contributor; confidence: low; commits: cbf406032104; files:
Sources/CodexBar/StatusItemController+Menu.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-reviewcomments, 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-reviewor@clawsweeper re-runon an open PR or issue to request a fresh review only. - Maintainers can also comment
@clawsweeper reviewto 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 explainto ask for more context, or@clawsweeper stopto stop active automation.
@clawsweeper re-review
๐ฆ๐งน ClawSweeper re-review requested.
I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.
@clawsweeper re-review
Exact-head maintainer proof for 13fd9690084d581cab9e17ba2a94f1e037747a58:
- Hosted CI passed all four macOS shards, Linux x64/arm64 builds and tests, aggregate lint, and security checks.
swift test --filter StatusMenuCodexSwitcherTestspassed 22 tests, including the blocked in-flight refresh deallocation regression.make checkpassed with no format, lint, package, parser, release-guard, or locale findings.- Whole-branch autoreview against the final base was clean, confidence 0.82.
- The refresh task keeps only the stores alive; controller and menu references remain weak through the task and phase callback.
Ready to land.