Fix drag-and-drop and macOS sidecar startup#4636
Open
guitar24t wants to merge 2 commits into
Open
Conversation
Dropping an image on the window opened a browser download instead of
loading it, and the flasher sidecar failed to start on macOS 26.
Drag-and-drop:
- Add window-level dragenter/dragover/drop handlers that
preventDefault and force dataTransfer.dropEffect to 'copy', so
Chromium stops navigating/downloading the dropped file and fires
the drop event even over interactive <button> elements.
- Resolve the dropped path with webUtils.getPathForFile, since the
File.path property was removed in Electron 32+.
- Accept a drop anywhere on the window via a capture-phase window
listener plus a stable full-window overlay shown during a drag, so
the drop target is not a button whose DOM node swaps on hover.
- Deny renderer-initiated new windows and downloads in the main
process as a safety net.
macOS sidecar:
- Pin the pkg build target to node22.22.2; the bundled Node 20
runtimes segfault on macOS 26.
- Override @yao-pkg/pkg-fetch to ^3.5.33 (ships the Node 22 build)
and node-abi to ^4.31.0 (recognises Electron 37).
Additional api.ts fixes found while debugging:
- Parenthesise the ETCHER_SERVER_PORT fallback so an explicit port
env var is honoured instead of always selecting 3435.
- Remove the dead Windows env-reset block.
- Guard ws.on('message') with try/catch and stop throwing on an
unknown message type.
- Close the WebSocket and stop the heartbeat on connection error.
- Show a clear error when the sidecar never connects instead of
calling an undefined requestMetadata.
Change-type: patch
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Contributor
|
A repository maintainer needs to approve these workflow run(s). To approve, maintainers can either: • Submit an approval review on this pull request, OR • Submit a review comment starting with Then re-run the failed job(s) via the Checks tab above. Reviews must be on the specific commit SHA of the workflow run to be considered. |
The sidecar is now built with Node 22 and local development commonly runs on Node 24, so the previous Node 20-only range produced spurious EBADENGINE warnings. Widen the range to >=20 <25 (Node 20, 22 and 24). Change-type: patch Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
+1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Restores drag-and-drop image loading and gets the flasher sidecar
running again on recent macOS (tested on macOS 26). Two user-visible
bugs were addressed, plus several smaller issues found while debugging.
Drag-and-drop
Previously, dragging an image onto the window opened a browser-style
download instead of loading the image, and dropping on certain spots
(notably the "Flash from file" button) silently did nothing.
lib/gui/app/app.ts— window-leveldragenter/dragover/droplisteners (capture phase) that
preventDefault()and forcedataTransfer.dropEffect = 'copy'. This stops Chromium fromnavigating/downloading the dropped file, and the explicit
dropEffectmakes thedropevent fire even over interactive<button>elements (Chromium otherwise defaults the effect to'none'there and suppresses the event).lib/gui/etcher.ts—setWindowOpenHandlerdenies renderernew-window opens and a
will-downloadhandler cancels unexpecteddownloads, as a safety net for the old fall-through behaviour.
source-selector.tsx— the dropped path is now resolved withwebUtils.getPathForFile();File.pathwas removed in Electron32+ and the app runs on Electron 37, so it was always empty.
source-selector.tsx— the drop is accepted anywhere on thewindow via a capture-phase
windowlistener, plus a stablefull-window overlay shown only during a drag. The overlay keeps the
drop from landing on a button whose underlying DOM node is swapped
out on hover (rendition
ColouredButton↔Plain), which wasdisrupting the drag and preventing the drop from registering.
macOS sidecar startup
After drag-and-drop worked, the flasher sidecar (
etcher-util) failedwith
requestMetadata is not a function. The root cause: thepkg-built sidecar embedded Node 20.11.1, which segfaults onmacOS 26. Newer Node 20 builds segfault too; Node 22 runs cleanly.
forge.sidecar.ts— pin thepkgtarget tonode22.22.2.package.json—overridesbump@yao-pkg/pkg-fetchto^3.5.33(ships the Node 22 build) andnode-abito^4.31.0(older versions do not recognise Electron 37).
Additional fixes in
api.tsFound while debugging the sidecar:
ETCHER_SERVER_PORTfallback — operatorprecedence meant an explicit port env var was discarded and
3435was always used.
cmdsubprocess that had no effect).ws.on('message')in try/catch and stopthrowing on anunknown message type, so a bad frame can't crash the connection.
undefined
requestMetadata.Test plan
npm run makebuilds a macOS arm64 DMGdownloading
loads
🤖 Generated with Claude Code