Repository navigation
fix(menu): restore paste in macOS native dialogs - #12645
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughWalkthroughThe paste menu handler sends 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
CI runs unit shards on ubuntu-latest only, so the unpinned paste-routing test asserted "no native paste" vacuously: a double-route regression passed green on Linux. Cover darwin/linux/win32 explicitly so the exactly-once contract holds on every platform, and assert the item exists in the negative-only cases so a rename cannot pass them silently. Also document why the native first-responder fallback exists.
Jinwoo-H
left a comment
There was a problem hiding this comment.
Thanks — the diagnosis is exactly right: the custom handler owns the CmdOrCtrl+V accelerator, so once getFocusedWindow() returned null the keystroke had nowhere to go.
Verified end-to-end in a real Electron run. Worth recording for anyone who revisits this: our folder pickers are parented (dialog.showOpenDialog(mainWindow, …) in src/main/ipc/repos.ts), so the panel is a window-modal sheet rather than a separate window. getFocusedWindow() still returns null there, the native branch fires, and the clipboard text lands in Go to Folder — while a pre-fix build in the same harness drops it. That was the one assumption the fix rested on that wasn't yet proven.
Two changes pushed on top:
- The paste-routing test didn't pin
process.platform. We run unit shards onubuntu-latestonly, so the "exactly oneui:appMenuPaste, no native paste" assertion passed vacuously — I confirmed by mutation that a double-paste regression ships green on a Linux runner. It's nowit.each(['darwin','linux','win32']), which also keeps Linux/Windows coverage of the primary path (pinning to darwin alone would have removed it). - A
// Why:on the native branch, plusexpect(pasteItem).toBeDefined()in the negative-only cases so a rename can't pass them silently.
Kept the isMac guard exactly as you wrote it — worth noting it's load-bearing beyond platform parity: sendActionToFirstResponder is assigned unconditionally in Electron but only bound on macOS, and its type declaration is unconditional, so TypeScript wouldn't catch its removal.
The approach also matches what Electron's own role: 'paste' does internally, and mirrors the fallback the renderer already had (src/main/ipc/ui.ts → webContents.paste() when no Orca surface claims the paste) — the menu layer was the only link in that chain with a dead end instead of a delegation.
* fix(menu): restore paste in macOS native dialogs * test(menu): pin platform for paste routing coverage CI runs unit shards on ubuntu-latest only, so the unpinned paste-routing test asserted "no native paste" vacuously: a double-route regression passed green on Linux. Cover darwin/linux/win32 explicitly so the exactly-once contract holds on every platform, and assert the item exists in the negative-only cases so a rename cannot pass them silently. Also document why the native first-responder fallback exists. --------- Co-authored-by: Jinwoo-H <[email protected]>
Summary
BrowserWindowis focusedBrowserWindowis focusedThe custom Edit > Paste handler replaced the Electron paste role so terminal and native-chat surfaces could coordinate clipboard ownership. When a native macOS open/save panel owned focus,
BrowserWindow.getFocusedWindow()returnednulland the handler became a no-op.Screenshots
Before the fix, Cmd+V does not insert the clipboard path into the macOS Go to Folder field, while context-menu Paste remains available:
Testing
pnpm lintpnpm typecheckpnpm buildunder Node 24The new macOS regression test fails against upstream
mainand passes on this branch.AI Review Report
The AI coding-agent review and CodeRabbit checked exact-once routing, Electron focus behavior, and platform boundaries. No actionable code issues were found.
BrowserWindowstill receives exactly oneui:appMenuPaste; only the no-focused-window path callsMenu.sendActionToFirstResponder("paste:")CmdOrCtrl+Vaccelerator remains unchangedSecurity Audit
ui:appMenuPastemessagepaste:selector to the macOS first responderBrowserWindowis focused, preventing double routingNotes