Skip to content

fix(desktop): keep a press on the floating icon from activating Rome - #1281

Merged
zoolsher merged 1 commit into
mainfrom
fix/desktop-pill-activation
Oct 23, 2026
Merged

zoolsher merged 1 commit into
mainfrom
fix/desktop-pill-activation

Conversation

@zoolsher

Copy link
Copy Markdown
Contributor

What this PR does

On macOS 26.6, every press on the floating icon activates Rome. Becoming active hides the icon, so a trackpad drag (three-finger or press-and-drag) never starts. Rome comes to the front instead. A click looked fine only because activation raises Rome anyway. The icon's page never received the press.

The cause is electron/electron#53889. Electron's type: "panel" window reports the non-activating style from its styleMask getter but never sets it, so the window server activates the app on the press. The issue reports this on macOS 27, which is why #462 keeps the icon off there. A trace on macOS 26.6.2 shows the same thing for trackpad presses. The upstream fix (electron/electron#54807, open) applies only to macOS 27.

This sets AppKit's _setPreventsActivation: on the icon's window once, through koffi, before the window is shown.

Design & Invariants

  • Pressing, clicking or dragging the icon leaves the frontmost app frontmost. Only a click raises Rome, through the icon's own click handling.
  • The private method is called only after respondsToSelector: confirms it exists. If a macOS release drops it, the icon goes back to activating Rome, Rome logs a warning, and nothing crashes.
  • The native FFI module loads only when the icon window is created, which happens only on macOS. Other platforms never open it.
  • The packaged app carries koffi's loader and its two macOS binaries (2.8 MB), not its sources or the other platforms' binaries (29 MB).

Considered and rejected: a small native addon in the repo, which adds a native build step for one message send; and turning the icon off on macOS 26.6 and later until upstream ships a fix, which removes the feature.

Test plan

  • macOS 26.6.2, real trackpad, debug build with event logging: before the change, a click, a three-finger drag and a press-and-drag each logged an app activation and no pointerdown. After it, 11 of 11 drags were recognized as drags with no activation, and a click opened Rome through the icon's click handler.
  • Unpacked dev build, synthetic mouse drags with Finder frontmost: the icon follows the cursor exactly and Finder stays frontmost.
  • Packaged unsigned .app (electron-builder --dir): koffi loads from app.asar.unpacked, 3 of 3 drags move the icon with Finder frontmost, and a click brings Rome to the front.
  • Unit tests: the flag is set, and nothing is sent when the method is missing or the view has no window.
  • Signed and notarized build. The existing entitlements already allow unsigned executable memory and disable library validation.

Exercised on a MacBook (macOS 26.6.2, Electron 44.9.3) with a separate profile. Synthetic drags were posted as CGEvents.

Not in this PR

  • macOS 27 stays off in supportsFloatingPill. This fix may cover it too, but it has not been run there.

🤖 Generated with Claude Code

Electron's panel window only reports the non-activating style and never
sets it, so on macOS 26.6 a press on the floating icon activates Rome,
which hides the icon before the press reaches the page. Set AppKit's
_setPreventsActivation: on the icon's window through koffi, guarded by
respondsToSelector:. See electron/electron#53889.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

@zoolsher zoolsher left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Code Review: ✅ APPROVE

This PR stops a press on the floating icon from activating Rome on macOS 26.6. It does this by sending AppKit's private -[NSWindow _setPreventsActivation:] to the icon's window through koffi. The diagnosis is credible: Electron's type: "panel" window never actually sets the non-activating style (electron/electron#53889). The fix targets that cause directly, and the PR explains why it rejected the alternatives (an in-repo native addon, or turning the feature off). Note: the code-review-expert skill was not registered in this environment, so I followed the system-prompt workflow by hand.

I checked the code against the full source and koffi 2.16.3's published package:

  • Native calls: objc_msgSend is bound once per call shape (pointer, BOOL and void signatures), which is correct on arm64, where the variadic call is not allowed. getNativeWindowHandle() returns a buffer holding the NSView pointer, and koffi.decode(view, "void *") reads it correctly.
  • Error handling: the call is guarded by respondsToSelector:, and both the "method missing" and "runtime failed to load" cases log a warning and leave things as they were.
  • Lazy loading: koffi is loaded on demand, the bundle is CommonJS, and koffi is marked external in esbuild.
  • Packaging: koffi's index.js only needs build/koffi/<triplet>/koffi.node plus Node built-ins, so excluding doc/, lib/, src/, vendor/ and the non-darwin binaries is safe. The .node files are smart-unpacked, which matches the packaged-build test.
  • Signing: the entitlements already disable library validation.

The one open item is the signed and notarized build, which the PR already lists as unchecked. Overall the change is small, contained and easy to reverse.

Verdict: APPROVE — The fix is narrow, protected by a respondsToSelector check and a try/catch, tested and packaged correctly; the only finding is an optional P3 comment fix.

1 finding(s) posted as inline comments below.

Severity Category File Title
P3 code-quality packages/desktop/src/main/floating-pill.ts Earlier type: "panel" comment now contradicts the new one

Automated review by RomeOS Code Review · commit 08cd4ef

});
win = created;

// Without this, pressing the icon activates Rome, and becoming active hides

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

[P3] code-quality — Earlier type: "panel" comment now contradicts the new one

The BrowserWindow options still say type: "panel" means "clicking it does not activate Rome". The new block below explains that this is not true on current macOS without preventActivation. Consider rewording the panel comment, for example "An NSPanel, made non-activating by preventActivation below", so a future reader doesn't remove the FFI call as redundant.

@yunfanye yunfanye left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review: 🛑 REQUEST_CHANGES

The targeted AppKit workaround fits the existing window lifecycle, but only the production bundler externalizes koffi. Beyond-the-diff verification found that the development build now fails.

The three isolated unit tests passed, and an esbuild reproduction confirmed the development-build failure. macOS runtime behavior and signed/notarized builds were not independently exercised.

Verdict: REQUEST_CHANGES — The new dependency breaks the desktop development build because its bundler configuration was not updated.

1 finding(s) posted as inline comments below.

Severity Category File Title
P1 build packages/desktop/scripts/build.mjs Externalize koffi in the development build too

Automated review by RomeOS Code Review · commit 08cd4ef · Full review history

sourcemap: false,
minify: true,
external: ["electron", "better-sqlite3"],
external: ["electron", "better-sqlite3", "koffi"],

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

[P1] build — Externalize koffi in the development build too

This updates only the production configuration; scripts/dev.mjs still externalizes just electron and better-sqlite3. Consequently, pnpm dev:desktop attempts to bundle koffi's native binaries and fails before Electron launches with No loader is configured for ".node" files (reproduced with the development esbuild settings), regardless of whether the icon is enabled. Add koffi to the development configuration's external list as well.

@zoolsher
zoolsher merged commit a111f0a into main Oct 23, 2026
15 checks passed
@zoolsher
zoolsher deleted the fix/desktop-pill-activation branch October 23, 2026 12:26
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