Repository navigation
fix(desktop): keep a press on the floating icon from activating Rome - #1281
Conversation
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
left a comment
There was a problem hiding this comment.
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_msgSendis 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, andkoffi.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.jsonly needsbuild/koffi/<triplet>/koffi.nodeplus Node built-ins, so excludingdoc/,lib/,src/,vendor/and the non-darwin binaries is safe. The.nodefiles 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 |
| }); | ||
| win = created; | ||
|
|
||
| // Without this, pressing the icon activates Rome, and becoming active hides |
There was a problem hiding this comment.
[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
left a comment
There was a problem hiding this comment.
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"], |
There was a problem hiding this comment.
[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.
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 itsstyleMaskgetter 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
respondsToSelector:confirms it exists. If a macOS release drops it, the icon goes back to activating Rome, Rome logs a warning, and nothing crashes.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
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..app(electron-builder --dir): koffi loads fromapp.asar.unpacked, 3 of 3 drags move the icon with Finder frontmost, and a click brings Rome to the front.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
supportsFloatingPill. This fix may cover it too, but it has not been run there.🤖 Generated with Claude Code