Skip to content

Keep the Mac app syncing and notifying from the menu bar - #1817

Merged
robertying merged 8 commits into
mainfrom
claude/project-thread-fuv05m
Nov 24, 2026
Merged

robertying merged 8 commits into
mainfrom
claude/project-thread-fuv05m

Conversation

@robertying

Copy link
Copy Markdown
Owner

Requested by Rui · project thread

What

On the Mac, learnX now checks for new content and sends notifications on a timer of its own while it runs, including with no window open, and stays in the menu bar so it can keep running.

  • Sync timer. macOS doesn't launch apps for BGTaskScheduler tasks and runs them unreliably even while the app is open, so on the Mac setUpBackgroundFetch no longer registers the system task. Instead runInMenuBar() (called from index.js) starts a 15-minute JS timer that runs the same sync as the system task, with a longer budget. A shared in-flight guard (runSync) keeps the timer, the system task, and the menu's Check for New Content from running two syncs at once.
  • Menu bar item (new modules/menubar, plus an AppKit plugin ios/MacMenuBar loaded from the app's PlugIns, like MacPreview). It's always shown while learnX runs, with the same menu as the Windows tray: Open learnX, Check for New Content, and Quit learnX, titled in the app's language. Its icon is the X of the app icon, drawn as a template image.
  • No window, no Dock icon. Closing the last window keeps learnX running in the menu bar; the Dock icon and app menus show only while a window is open.
  • Open at Login (Settings, Mac only) registers learnX with SMAppService.mainApp. When macOS opens it as a login item, it starts the React Native host without a window, so it syncs from the menu bar only. A login item the user turned off in System Settings opens System Settings to allow it there.
  • Notification settings explain on the Mac that learnX checks every 15 minutes while running and point to Open at Login.

The native fingerprint changes (new pod), so ota-fingerprint.json is updated.

Tests

  • Jest: the Mac timer and its shared guard with the system task, the menu's Check for New Content, no menu bar off the Mac, useLoginItem on the Mac, and the Settings and Notification settings captions.
  • Swift Testing (module): the window and Dock state, the hidden login launch, the Open at Login state machine, the icon outline, and the module functions and their no-ops off the Mac.
  • Mac UI test (MenuBarUITests): closing the last window leaves learnX running in the menu bar, Open learnX brings a window back, and Quit learnX quits it. Open at Login isn't run there, since it would add a real login item.

Generated by Claude Code

claude and others added 8 commits November 24, 2026 08:25
macOS never launches an app for its background tasks, and doesn't run them
reliably while it's open, so new notices, files and assignments were never
notified about on the Mac. learnX now syncs there every 15 minutes while it
runs, also with its windows closed, with a longer budget since nothing ends
the run. Settings › Notifications says so on the Mac.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
learnX's menu bar item stays while it runs, with Open learnX, Check for New
Content and Quit learnX, as the Electron app's tray does on Windows, so it
keeps syncing and notifying with no window open. The Dock shows learnX only
while a window is open. Open at Login (Settings) adds it as a login item;
opened that way it starts without a window, with JS running for the sync.

AppKit's status item, activation policy and launch event come from a new
AppKit bundle the Mac app embeds, as Quick Look's does.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
On Mac Catalyst, SystemLoginItem registers with SMAppService, so the test
that turns it on would add the test host to the Mac's login items. There
it only reads the state.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
React Native's root view factory takes launchOptions:, so the Mac
Catalyst build failed to compile the login item launch.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The module's AsyncFunctions call static functions that the tests call
directly, as other modules do, and the tests cover what the menu bar and
Open at Login do on iPhone and iPad, where there's no plugin or login
item. This keeps the native line coverage above its minimum.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The app menu has a Quit learnX of its own, which a search of every menu
item finds first, so the test looks in the menu bar item's menu.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@robertying
robertying merged commit f2ab419 into main Nov 24, 2026
14 checks passed
@robertying
robertying deleted the claude/project-thread-fuv05m branch November 24, 2026 10:03
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.

2 participants