CodexBar icon indicating copy to clipboard operation
CodexBar copied to clipboard

Avoid retaining menu refresh state

Open ProspectOre opened this issue 5 months ago โ€ข 4 comments

Summary

  • Avoid retaining StatusItemController and 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.swift
  • swift 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.

ProspectOre avatar Jun 16 '26 07:06 ProspectOre

@clawsweeper re-review

ProspectOre avatar Jun 16 '26 07:06 ProspectOre

๐Ÿฆž๐Ÿงน 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[bot] avatar Jun 16 '26 07:06 clawsweeper[bot]

@clawsweeper re-review

ProspectOre avatar Jun 18 '26 03:06 ProspectOre

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:

  1. 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.
  2. Accept source-level confidence
    Maintainers can merge on source review and the focused regression test while explicitly owning the missing live-menu proof risk.
  3. 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:

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-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 18 '26 04:06 clawsweeper[bot]

@clawsweeper re-review

ProspectOre avatar Jun 18 '26 05:06 ProspectOre

๐Ÿฆž๐Ÿงน 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[bot] avatar Jun 18 '26 05:06 clawsweeper[bot]

@clawsweeper re-review

ProspectOre avatar Jun 18 '26 19:06 ProspectOre

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 StatusMenuCodexSwitcherTests passed 22 tests, including the blocked in-flight refresh deallocation regression.
  • make check passed 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.

steipete avatar Jun 19 '26 05:06 steipete