Skip to content

refactor(macos): single-owner hybrid status menu with live session cards and exec approvals - #130041

Merged
steipete merged 9 commits into
mainfrom
steipete/menu-redesign-stability-d3e211
Aug 26, 2026
Merged

steipete merged 9 commits into
mainfrom
steipete/menu-redesign-stability-d3e211

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

The macOS status-item menu was rendered by two systems fighting each other: SwiftUI MenuBarExtra(.menu) built the base items, then three injectors (MenuSessionsInjector ~1,450 LOC, MenuGatewaysInjector, nodes injection) hijacked the NSMenuDelegate and removed/re-inserted NSHostingView-backed rows while AppKit was tracking the open menu. Users saw flicker on control-channel changes and usage retries, width jumps on first open (rows measured against a guessed 320pt fallback before the menu window existed), hand-rolled hover highlight without keyboard navigation, ~15 leading icons with no grid, and duplicated notice rows. The menu had also accreted controls that no longer belong there: a "Send Heartbeats" toggle that flips a volatile in-memory gateway flag (heartbeats are cron-owned since #129881-era unification), a global Exec Approvals picker duplicating the Settings pane, and "Open Chat" opening a strict subset of the dashboard.

Why This Change Was Made

One owner, one rendering world (the CodexBar pattern): a StatusMenuController owns the NSStatusItem and NSMenu, builds content from a value-model StatusMenuDescriptor with stable row ids, and a StatusMenuRenderer reconciles updates in place — prefix/suffix id matching, hosted rootView swaps, native item updates, structural changes limited to the changed middle span inside a no-animation CATransaction. The menu is never rebuilt while open, so the flicker class is gone by construction. Hosted cards are used only where content is rich (header with capability strip, session cards with context rings, inline exec-approval cards, cost chart submenu); everything else is native NSMenuItems with SF Symbols and real key equivalents, which restores aligned icons, correct highlight, and keyboard navigation.

New capability: a live ExecApprovalQueueStore (seeded from exec.approval.list, kept current by exec.approval.requested/resolved events, expiry-timed) renders pending approvals inline on their session row with Deny / Allow-once honoring allowedDecisions — allow-always intentionally stays behind the modal prompt. Sessions show the same context ring as the web composer (16pt dial, quiet below 85%, warning→danger blend with a percent label above). Automations (cron summary), Usage, and Devices become native summary rows with submenus.

Removed on purpose: Send Heartbeats toggle (cron owns cadence; the volatile set-heartbeats flag also desyncs across gateway restarts — follow-up tracked separately), Exec Approvals picker (Settings → Exec Approvals pane is the enablement path), microphone submenu (lives in Voice settings), Open Chat (menu + dock menu; Quick Chat and the dashboard cover both use cases), the MenuBarExtraAccess dependency, and StatusItemMouseRouter (superseded by the controller's local event monitor).

User Impact

Right-click opens a stable, grid-aligned menu that updates in place. Capability toggles are one tinted strip; sessions are scannable cards with an at-a-glance context gauge; pending exec approvals are actionable directly from the menu bar instead of only via a transient modal; Automations/Usage/Devices are one glanceable row each. Left-click still opens the dashboard. ~30% shorter menu in like-for-like state.

Evidence

  • apps/macos: swift build green; full suite 1,821 tests across 185 suites passing (serialized run), plus new StatusMenuDescriptorTests, StatusMenuReconcileTests, ExecApprovalQueueStoreTests, ContextRingViewTests (28 targeted tests re-run green after review fixes).
  • Live proof on a Developer-ID-signed build in an isolated OPENCLAW_PROFILE=menuproof instance (operator's app untouched): right-click opens the menu (verified via a synthesized right-click through the event queue after the send-action fix), Settings opens from menu/dock/⌘, (verified via probe launch), before/after menu-window captures attached below (same unconfigured profile state on both sides).
  • Structured review: Codex (gpt-5.6-sol, high) on the full branch diff surfaced one real P0 — sendAction(on:) never fires for right-clicks — fixed by routing pointer clicks through a local event monitor (the previously shipped mechanism) and re-verified live; a second finding (menuWillOpen re-entrancy) fixed with the guard the old injector carried; a third (openWindow from hosted view) empirically refuted via probe. Approval-queue commit reviewed clean (0.98).
  • Gateway contract verified against source: exec.approval.list returns a bare array of {id, request, createdAtMs, expiresAtMs, approvalKind} (src/gateway/server-methods/approval-record-lookup.ts).
  • Production LOC +159 net (approval-queue capability +241; the menu redesign itself is −82); tests −275.

Screenshots: menu-before-redesign.png (old injected menu, 566pt) vs menu-after-redesign.png (owned hybrid menu, 383pt), both captured from the isolated profile in the unconfigured state.

menu-before-redesign

menu-after-redesign

@clawsweeper

clawsweeper Bot commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@openclaw-barnacle openclaw-barnacle Bot added the app: macos App: macos label Aug 26, 2026
@steipete
steipete marked this pull request as ready for review August 26, 2026 09:19
@openclaw-barnacle openclaw-barnacle Bot added size: XL maintainer Maintainer-authored PR labels Aug 26, 2026
NSControl's send-action mask ignores right mouse buttons, so the previous
sendAction(on: [.rightMouseUp]) wiring never fired and the menu was
unreachable by pointer. A local monitor now owns pointer routing (left =
dashboard, right = menu) — the same mechanism the shipped
StatusItemMouseRouter used — and menuWillOpen gained the re-entrancy
guard the old injector carried, since reconciling tracked rows can
re-enter the callback without a close.
@steipete
steipete force-pushed the steipete/menu-redesign-stability-d3e211 branch from fa79a7d to 51a0854 Compare August 26, 2026 09:22
@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Aug 26, 2026
@clawsweeper

clawsweeper Bot commented Aug 26, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 26, 2026, 8:49 AM ET / 12:49 UTC.

ClawSweeper review

What this changes

This PR replaces the macOS status-bar menu’s injector-based SwiftUI path with an AppKit-owned reconciled menu, adds session and execution-approval cards, and removes several legacy menu controls.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

Keep open for maintainer product review. The prior approval-race blocker is addressed: the menu now re-lists the gateway-owned queue after a losing resolution race, with a socket-boundary regression test; the remaining decision is whether removing established menu controls is intended for existing macOS operators.

Priority: P1
Reviewed head: 10029ada0d1f5e6e0254d5ea1ecd5e0a65eaf663
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The approval-race repair has focused boundary coverage and preserves Gateway authority; product acceptance of removed menu controls remains the material merge question.
Proof confidence 🌊 off-meta tidepool Not applicable: This maintainer PR is exempt from the external-contributor proof gate; its body nevertheless supplies isolated signed-build screenshots and describes an after-fix right-click verification.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This maintainer PR is exempt from the external-contributor proof gate; its body nevertheless supplies isolated signed-build screenshots and describes an after-fix right-click verification.
Evidence reviewed 5 items Approval-race repair: On resolution failure, the queue refreshes from the authoritative list instead of retaining a stale card; the nearby comment identifies the modal or another client as the losing-race case.
Regression coverage: The focused test simulates another presentation surface resolving first, then asserts the menu queue re-lists and becomes empty.
Gateway authority contract: The existing Gateway handler validates a requested decision against the live pending approval and resolves through the server-side manager; the macOS menu is an additional presentation client, not the authorization owner.
Findings None None.
Security None None.

Live Verification

Command: cd apps/macos && swift build

Result: FAIL (failed) — execution before step 1 run: terminal command did not produce output or exit within 30 seconds: "cd apps/macos && swift build"

terminal command did not produce output or exit within 30 seconds: "cd apps/macos && swift build"

Captured output:



















































Assertions:

  • FAIL expect_output: Build complete!

How this fits together

The macOS app subscribes to Gateway snapshots and approval events, projects them into a status-bar menu, and sends selected approval decisions back to the Gateway. The Gateway remains the authority that checks visibility, allowed decisions, and single resolution before execution continues.

flowchart LR
  Gateway[Gateway approval records] --> Events[Gateway events and list API]
  Events --> Queue[macOS approval queue]
  AppState[App and session state] --> Descriptor[Menu descriptor]
  Queue --> Descriptor
  Descriptor --> Renderer[AppKit menu renderer]
  Renderer --> Menu[Status-bar menu]
  Menu --> Resolve[Gateway resolution request]
  Resolve --> Gateway
Loading

Decision needed

Question Recommendation
Should existing macOS operators lose the legacy status-menu controls in favor of the streamlined menu and the replacement Settings, Quick Chat, dashboard, and cron paths? Accept the streamlined menu: Keep the removals and explicitly treat the documented replacement surfaces as the supported paths.

Why: The code and regression test address the approval race, but whether these established operator entry points should disappear is a product-scope decision rather than a mechanical correctness question.

Before merge

  • Resolve merge risk (P1) - Merging removes current-main menu entry points for heartbeats, the global approvals picker, microphone selection, and Open Chat; the PR describes alternatives, but maintainers should explicitly accept that existing macOS workflows move to other surfaces.
Agent review details

Security

None.

PR surface

Other -318. Total -318 across 42 files.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 0 0 0 0
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 42 4165 4483 -318
Total 42 4165 4483 -318

Review metrics

Metric Value Why it matters
Production versus tests production +159 net; tests -275 net The refactor deletes the injector implementation while adding the approval-queue capability; the positive production delta is tied to that new user-visible path.

Stored data model

Persistent data-model change detected: migration/backfill/repair: apps/macos/Tests/OpenClawIPCTests/ExecApprovalsUIRollbackTests.swift, serialized state: apps/macos/Tests/OpenClawIPCTests/MenuContentSmokeTests.swift, serialized state: apps/macos/Tests/OpenClawIPCTests/MenuSessionsInjectorTests.swift, serialized state: apps/macos/Tests/OpenClawIPCTests/StatusItemMouseRouterTests.swift. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Confirm the replacement paths (recommended)
    Accept the compatibility change only after confirming Settings, Quick Chat, dashboard, and cron cover the removed menu workflows for existing macOS users.
  2. Restore essential shortcuts
    Keep the new renderer but reintroduce any legacy control that maintainers consider a required status-menu workflow.

Technical review

Best possible solution:

Keep the single AppKit menu and gateway-authoritative approval resolution, while making a maintainer decision on the deliberate removal of the established menu controls and their replacement paths.

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

Not applicable as an issue reproduction: source inspection and the PR’s attached isolated-build evidence cover the proposed macOS behavior, while the focused queue test models the resolved-first race.

Is this the best way to solve the issue?

Mostly yes: server-side single resolution plus client-side authoritative re-listing is the right boundary for two presentation surfaces; the remaining question is the intended menu product scope.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add merge-risk: 🚨 compatibility: Current-main status-menu controls are intentionally removed or moved to other operator surfaces.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This maintainer PR is exempt from the external-contributor proof gate; its body nevertheless supplies isolated signed-build screenshots and describes an after-fix right-click verification.
  • remove rating: 🦐 gold shrimp: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.
  • remove status: ⏳ waiting on author: Current PR status label is status: 👀 ready for maintainer look.
  • remove merge-risk: 🚨 other: Current PR review merge-risk labels are merge-risk: 🚨 compatibility.

Label justifications:

  • P1: The PR changes the primary macOS status-menu workflow and execution-approval presentation path.
  • merge-risk: 🚨 compatibility: Current-main status-menu controls are intentionally removed or moved to other operator surfaces.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This maintainer PR is exempt from the external-contributor proof gate; its body nevertheless supplies isolated signed-build screenshots and describes an after-fix right-click verification.

Evidence

What I checked:

Likely related people:

  • steipete: Current-main blame covers the shared Gateway subscription path, and this PR’s final convergence repair is authored in the same macOS approval/menu area. (role: recent macOS area contributor; confidence: high; commits: a2cf17b461c6, 10029ada0d1f; files: apps/macos/Sources/OpenClaw/GatewayConnection.swift, apps/macos/Sources/OpenClaw/StatusMenuController.swift, apps/macos/Sources/OpenClaw/ExecApprovalQueueStore.swift)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Confirm the intentional removal and replacement paths for the legacy macOS menu controls.
  • Let exact-head macOS validation finish before merge.

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 (3 earlier review cycles)
  • reviewed 2026-08-26T09:32:45.333Z sha 2ef5406 :: found issues before merge. :: [P1] Make approval presentation single-owner
  • reviewed 2026-08-26T09:52:57.029Z sha 2ef5406 :: needs changes before merge. :: [P1] Route every approval to one macOS presentation owner
  • reviewed 2026-08-26T10:37:31.802Z sha 426d0dd :: found issues before merge. :: [P1] Make approval presentation single-owner

@clawsweeper clawsweeper Bot added merge-risk: 🚨 other 🚨 Merging this PR has meaningful risk outside the owned taxonomy. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. labels Aug 26, 2026
Periphery flagged the orphans the status-menu refactor left behind: the
ExecApprovalQuickMode enum and AppState's entire quick-mode read/retry
surface (its only consumer was the deleted menu picker; the Settings
pane owns exec-approval policy UI), SessionMenuLabelView,
TrackingAreaSupport, NodeMenuMultilineView, UpdateStatus.disabled, and
two fixture-only initializers. StatusMenuController.stop() is now wired
into applicationWillTerminate. The menu-highlight environment key moved
from the deleted view file into MenuItemHighlightColors.
@clawsweeper clawsweeper Bot removed the proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. label Aug 26, 2026
The status-menu queue and the modal prompter intentionally share the
gateway approval event stream: the gateway resolves each approval
exactly once, the resolved broadcast removes the card, and the modal
stays the active presentation owner while the menu is the passive,
ambient one. What was missing: when the menu's resolve loses the race
(modal or another client answered first), the gateway rejection left a
zombie card if the resolved event was dropped. Resolve failures now
re-list from the authoritative queue. Regression test simulates the
race at the socket boundary and fails pre-fix.
@steipete

Copy link
Copy Markdown
Contributor Author

Response to the review's two pre-merge items (both addressed in 10029ad):

Make approval presentation single-owner — intentional skip, with the underlying gap fixed. The dual consumption is by design, not an oversight: the modal prompter remains the active presentation owner (focus-demanding, immediate), while the status-menu card is a passive, ambient surface — its purpose is exactly the case where the modal was missed, dismissed, or timed out; without it a pending approval has no visible surface at all on the Mac. Single-resolution is owned where it belongs, server-side: the gateway resolves each approval id exactly once and rejects the loser, and the exec.approval.resolved broadcast removes the card from the queue. Routing events to one client-side owner would either delete the modal (a product change out of scope) or suppress the card exactly when it is most useful.

Ordering-boundary regression — applied. The review is right that the losing side of the race was under-handled: if the menu's resolve lost and the resolved broadcast was dropped (disconnect window), a zombie card could persist until expiry. Resolve failures now re-list from the authoritative exec.approval.list instead of parsing error text, and a new socket-boundary regression test simulates the modal winning server-side (resolve rejected, list emptied) and fails pre-fix.

The failed "Live Verification" step in the review harness was a 30-second output timeout on swift test (build time), not a test failure — the suite passes locally in ~11s after build.

@clawsweeper clawsweeper Bot added merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. 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. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. merge-risk: 🚨 other 🚨 Merging this PR has meaningful risk outside the owned taxonomy. labels Aug 26, 2026
@steipete
steipete merged commit 2b0da0e into main Aug 26, 2026
116 checks passed
@steipete
steipete deleted the steipete/menu-redesign-stability-d3e211 branch August 26, 2026 13:16
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 27, 2026
…rds and exec approvals (openclaw#130041)

* test(macos): add OPENCLAW_DEBUG_OPEN_MENU screenshot hook

* feat(macos): add live execution approval queue

* refactor(macos): replace menu injectors with owned status menu

* fix(macos): keep unconfigured menu header calm

* fix(macos): route status-item right-clicks through a local event monitor

NSControl's send-action mask ignores right mouse buttons, so the previous
sendAction(on: [.rightMouseUp]) wiring never fired and the menu was
unreachable by pointer. A local monitor now owns pointer routing (left =
dashboard, right = menu) — the same mechanism the shipped
StatusItemMouseRouter used — and menuWillOpen gained the re-entrancy
guard the old injector carried, since reconciling tracked rows can
re-enter the callback without a close.

* chore(i18n): refresh native inventory for status menu strings

* chore(macos): remove menu-refactor dead code

Periphery flagged the orphans the status-menu refactor left behind: the
ExecApprovalQuickMode enum and AppState's entire quick-mode read/retry
surface (its only consumer was the deleted menu picker; the Settings
pane owns exec-approval policy UI), SessionMenuLabelView,
TrackingAreaSupport, NodeMenuMultilineView, UpdateStatus.disabled, and
two fixture-only initializers. StatusMenuController.stop() is now wired
into applicationWillTerminate. The menu-highlight environment key moved
from the deleted view file into MenuItemHighlightColors.

* chore(macos): fix status-menu lint style and refresh i18n inventory

* fix(macos): converge approval cards after losing a resolution race

The status-menu queue and the modal prompter intentionally share the
gateway approval event stream: the gateway resolves each approval
exactly once, the resolved broadcast removes the card, and the modal
stays the active presentation owner while the menu is the passive,
ambient one. What was missing: when the menu's resolve loses the race
(modal or another client answered first), the gateway rejection left a
zombie card if the resolved event was dropped. Resolve failures now
re-list from the authoritative queue. Regression test simulates the
race at the socket boundary and fails pre-fix.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

app: macos App: macos maintainer Maintainer-authored PR merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: XL 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.

1 participant