Skip to content

Fix popover closing instantly on macOS 27 - #97

Merged
devxoul merged 1 commit into
mainfrom
fix/macos27-popover-instant-close
Sep 21, 2026
Merged

devxoul merged 1 commit into
mainfrom
fix/macos27-popover-instant-close

Conversation

@devxoul

@devxoul devxoul commented Sep 21, 2026 •

Copy link
Copy Markdown
Owner

Summary

Fixes #96. On macOS 27, the popover flashes open and closes immediately, which reads as "the app doesn't launch at all" since Allkdic is an LSUIElement app with no Dock icon and no window.

Root Cause

AppDelegate.setupEventMonitor() installs a global mouse monitor matching [.leftMouseUp, .leftMouseDown] that calls closePopover(). Global monitors are documented as not receiving events routed to your own app, but on macOS 27 the .leftMouseUp of the very click that opens the popover is delivered to this monitor anyway. The sequence becomes: status item click -> openPopover() -> .leftMouseUp -> global monitor -> closePopover().

@mirinae312 diagnosed this on #96 with a diagnostic build (log + call stack) and confirmed with an A/B test that excluding .leftMouseUp keeps the popover open on macOS 27. Thanks for narrowing this down!

Fix

Narrow the monitor mask to .leftMouseDown only.

- NSEvent.addGlobalMonitorForEvents(matching: [.leftMouseUp, .leftMouseDown]) { [weak self] _ in
+ NSEvent.addGlobalMonitorForEvents(matching: .leftMouseDown) { [weak self] _ in
    self?.closePopover()
  }

Outside-click dismissal is unchanged: a press outside the popover already triggers closePopover() before its release ever arrives, so .leftMouseUp was redundant for dismissal. closePopover() also guards on popover.isShown, so a stray mouse-down before the popover is shown is a no-op.

Alternative considered

Removing the global monitor entirely and relying on popover.behavior = .transient, which by documentation closes the popover on outside interaction. Rejected for now: the monitor has been in place since 2014 as the safety net for clicks in other apps, and removing it risks a "popover stays open" regression on some macOS version nobody here can currently test. Narrowing the mask is the smaller, evidence-backed change.

Testing

  • xcodebuild build — build succeeds (code signing disabled locally; no Mac Development cert on this machine)
  • xcodebuild test — 45 tests, 0 failures (KeyBindingTests 25, PopupRequestTests 20)
  • make lint — the changed file passes; the only lint error is pre-existing in the Tuist-generated TuistBundle+Allkdic.swift, untouched here
  • Not verified on macOS 27. This machine runs macOS 26.5.2, so the fix could not be reproduced or confirmed locally — it relies on @mirinae312's diagnostic build and A/B test on macOS 27골든 게이트 업데이트 이후로 작동을 하지 않는 것 같습니다 ㅠㅠ #96. Please confirm on macOS 27 before release.
  • Manual regression on macOS 26 (outside click, app switch, Escape, re-clicking the icon, clicking another status item) is still worth doing before release.

No automated regression test was added: the monitor is installed inside AppDelegate at launch, and the existing test target only covers pure-logic types — asserting on an NSEvent.EventTypeMask constant would be a tautology.

Fixes #96


Summary by cubic

Fixes the Allkdic popover closing instantly on macOS 27, which made the app seem to never launch (it has no Dock icon or window).

The global mouse monitor listened for both .leftMouseUp and .leftMouseDown and called closePopover(). On macOS 27, the .leftMouseUp of the click that opens the popover also reaches this monitor, so the popover closed right after appearing (#96). Narrowing the monitor to .leftMouseDown only keeps outside-click dismissal working, because a press outside already closes the popover before its release arrives.

Testing

Written for commit dea5355. Summary will update on new commits.

Review in cubic

The global mouse monitor watched both `.leftMouseUp` and `.leftMouseDown`.
On macOS 27 the `.leftMouseUp` of the click that opens the popover is also
delivered to that monitor, so `closePopover()` ran immediately after
`openPopover()` and the popover flashed shut.

Watching `.leftMouseDown` alone keeps outside-click dismissal intact, since
a press outside already closes the popover before its release arrives.

Fixes #96

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 1 file

Re-trigger cubic

@typeey typeey Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The mask reduction is correctly scoped: outside left-clicks still call closePopover() on mouse-down, while issue #96 records a macOS 27 A/B test confirming that excluding the opening mouse-up prevents the failure. Head CI passes lint, build, and all tests; although those tests cannot exercise OS event routing, the targeted manual evidence and narrow regression surface support approval.

@devxoul
devxoul merged commit 49513a5 into main Sep 21, 2026
2 checks passed
@devxoul
devxoul deleted the fix/macos27-popover-instant-close branch September 21, 2026 02:13
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.

macOS 27골든 게이트 업데이트 이후로 작동을 하지 않는 것 같습니다 ㅠㅠ

1 participant