Skip to content

Build status menu asynchronously to keep clicks responsive#64

Open
scriptease wants to merge 1 commit into
dsmelov:masterfrom
scriptease:master
Open

Build status menu asynchronously to keep clicks responsive#64
scriptease wants to merge 1 commit into
dsmelov:masterfrom
scriptease:master

Conversation

@scriptease

Copy link
Copy Markdown

Problem

Clicking the status bar icon blocks the main thread while the menu is built: menuNeedsUpdate synchronously scans simulator directories, parses per-app plists (O(apps × bundles) reads in Application.buildMetadata), and loads/scales/rounds every app icon. With several simulators/apps the menu takes noticeably long to appear, and a second click gets queued behind the first — causing a laggy open/close ping-pong.

Change

  • Menus.updateApplicationMenu now populates the menu instantly from a cached snapshot and triggers a refresh.
  • All heavy work (simulator scan, plist parsing, icon loading) moved to gatherContent() on a background queue (.userInitiated).
  • populate(menu,with:) does only cheap NSMenuItem construction on the main thread; when the scan completes, the open menu is refreshed in place.
  • First-ever open (no cache yet) shows a disabled "Loading Simulators…" placeholder plus the service items.
  • A dedup guard ensures rapid clicks trigger at most one concurrent scan.

Menu now opens/closes immediately on every click; content updates a beat later on first open and stays fresh on every subsequent open.

🤖 Generated with Claude Code

Menu content (simulator/app scan, plist parsing, icon loading) is now
gathered on a background queue and cached. Clicking the status icon
populates the menu instantly from cache (or a "Loading Simulators…"
placeholder on first open) and refreshes in place when the scan
completes, instead of blocking the main thread on every click.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant