Repository navigation
refactor(macos): single-owner hybrid status menu with live session cards and exec approvals - #130041
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
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.
fa79a7d to
51a0854
Compare
|
Codex review: needs maintainer review before merge. Reviewed August 26, 2026, 8:49 AM ET / 12:49 UTC. ClawSweeper reviewWhat this changesThis 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 readinessKeep 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 Review scores
Verification
Live VerificationCommand: Result: FAIL (failed) — execution before step 1 Assertions:
How this fits togetherThe 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
Decision needed
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
Agent review detailsSecurityNone. PR surfaceOther -318. Total -318 across 42 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Technical reviewBest 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. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (3 earlier review cycles)
|
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.
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.
|
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 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 The failed "Live Verification" step in the review harness was a 30-second output timeout on |
|
Merged via squash.
|
…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.
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 theNSMenuDelegateand removed/re-insertedNSHostingView-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
StatusMenuControllerowns theNSStatusItemandNSMenu, builds content from a value-modelStatusMenuDescriptorwith stable row ids, and aStatusMenuRendererreconciles updates in place — prefix/suffix id matching, hostedrootViewswaps, native item updates, structural changes limited to the changed middle span inside a no-animationCATransaction. 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 nativeNSMenuItems with SF Symbols and real key equivalents, which restores aligned icons, correct highlight, and keyboard navigation.New capability: a live
ExecApprovalQueueStore(seeded fromexec.approval.list, kept current byexec.approval.requested/resolvedevents, expiry-timed) renders pending approvals inline on their session row with Deny / Allow-once honoringallowedDecisions—allow-alwaysintentionally 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-heartbeatsflag 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), theMenuBarExtraAccessdependency, andStatusItemMouseRouter(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 buildgreen; full suite 1,821 tests across 185 suites passing (serialized run), plus newStatusMenuDescriptorTests,StatusMenuReconcileTests,ExecApprovalQueueStoreTests,ContextRingViewTests(28 targeted tests re-run green after review fixes).OPENCLAW_PROFILE=menuproofinstance (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).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).exec.approval.listreturns a bare array of{id, request, createdAtMs, expiresAtMs, approvalKind}(src/gateway/server-methods/approval-record-lookup.ts).Screenshots:
menu-before-redesign.png(old injected menu, 566pt) vsmenu-after-redesign.png(owned hybrid menu, 383pt), both captured from the isolated profile in the unconfigured state.