Skip to content

Show the running device count in the menu bar - #2

Open
arthurrmp wants to merge 1 commit into
dipendra-sharma:mainfrom
arthurrmp:feat/menubar-device-count
Open

Show the running device count in the menu bar#2
arthurrmp wants to merge 1 commit into
dipendra-sharma:mainfrom
arthurrmp:feat/menubar-device-count

Conversation

@arthurrmp

@arthurrmp arthurrmp commented Aug 31, 2026

Copy link
Copy Markdown

Thanks for the app, it's genuinely useful.

This adds a count next to the menu bar icon so you can see how many devices are booted without opening the panel. I wanted it for myself, so opening it to see if it fits your project. Happy to gate it behind a setting if needed.

Tests pass, 74/74.

@arthurrmp arthurrmp changed the title Show the running device count in the menu bar, without polling Show the running device count in the menu bar Aug 31, 2026
The status item now carries a count of everything currently booted across
both platforms, so the number of running devices is readable without
opening the panel.

Keeping that count accurate while the panel is closed could have meant a
background timer, but both toolchains already record run state on disk:
CoreSimulator rewrites Devices/<UDID>/device.plist on every transition,
and the emulator creates <name>.avd/hardware-qemu.ini.lock at launch and
removes it on exit. DeviceDirectoryWatcher watches those directories with
vnode dispatch sources, so nothing runs until a device actually changes.
The plist is replaced atomically, so the enclosing directory is watched
rather than the file, whose inode does not survive the write.

The panel's own five second refresh loop is removed as well; it is now a
single refresh on open, since state arrives by event.

One bounded exception: an emulator writes its lock at launch but only
reports `device` to adb once the guest finishes booting, and that
transition touches no watched directory, so a refresh that still sees a
booting device schedules one more two seconds later until nothing is
booting.

The count is drawn into an NSImage rather than rendered as a SwiftUI
Label, which was re-rendering its text on a recurring tick and cost about
720 idle wakeups an hour for a number that changes a handful of times a
day.

Measured over fifteen minute idle windows: a fifteen second poll costs
~33 CPU-seconds an hour with 480 process spawns; this costs ~3, with zero
spawns, zero watcher events and zero idle wakeups.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@arthurrmp
arthurrmp force-pushed the feat/menubar-device-count branch from 62d71b8 to 4e3056f Compare August 31, 2026 04:49
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