macOS: add menu-bar status item to the resident agent#24
Closed
m31-galaxy wants to merge 2 commits into
Closed
Conversation
The resident background agent runs as an accessory (no Dock icon), so it had no visible affordance — casting was only possible via the global hot key or relaunch. Add an NSStatusItem to the menu bar with a template SF Symbol glyph (wand.and.stars) and a menu offering "Cast Gesture" (funnels through the same request_show path as the hot key) and "Quit Hexecute". cocoa_setup_menu_bar is idempotent, runs on the main thread, and is wired in from runMain after the hot key registers. The status item is removed in cocoa_destroy. Exposed to Go via CocoaWindow.SetupMenuBar (macOS-only, not part of the platform.Window interface). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LjKPHZaHPxMhLXGe55hMeW
cgo compiles the Objective-C backend without ARC (manual reference counting). statusItemWithLength: returns an autoreleased item and the system status bar does not keep a reliable strong reference, so storing it in a global inside an @autoreleasepool left it to be deallocated when the pool drained — the menu-bar icon could fail to appear or vanish immediately. Retain it on creation and release it in cocoa_destroy. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LjKPHZaHPxMhLXGe55hMeW
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Stacked on top of #23 (base branch:
macos). Adds a menu-bar status item to the macOS resident background agent.The resident agent runs as an accessory app (
NSApplicationActivationPolicyAccessory,LSUIElement), so it has no Dock icon and previously offered no visible UI — casting was only possible via the global hot key or by relaunching the app. This adds a status item in the menu bar so the agent is discoverable and controllable.Changes
pkg/cocoa/cocoa.mHexStatusControllerwithcast:(funnels through the existingrequest_showpath — same as the hot key and relaunch) andquit:([NSApp terminate:]) actions.cocoa_setup_menu_bar(): creates anNSStatusItemwith a template SF Symbol glyph (wand.and.stars, matching the spell-casting metaphor; falls back to a✦title if unavailable) and a menu with Cast Gesture and Quit Hexecute. Idempotent; runs on the main thread.cocoa_destroy()removes the status item.pkg/cocoa/cocoa.h— declarescocoa_setup_menu_bar.pkg/cocoa/cocoa.go—CocoaWindow.SetupMenuBar()wrapper (macOS-only; intentionally not part of theplatform.Windowinterface).cmd/hexecute/run_darwin.go— callswindow.SetupMenuBar()fromrunMainafter the hot key registers.Notes
LSMinimumSystemVersion(11.0) inInfo.plist.[NSApp sendEvent:]incocoa_wait_for_show, which then drives the menu's own tracking loop.darwinand could not be compiled locally.gofmtand the non-darwingo build ./...are clean. The macOS CI job (added in Add macOS support with native Cocoa overlay window #23) will compile and link it.Verification (on macOS)
.appand launch the resident agent (hexecute --background).🤖 Generated with Claude Code
Generated by Claude Code