Skip to content

chore: upgrade Electron 28 → 45, electron-vite 2 → 6 and Vite 5 → 8 - #270

Open
tonyco97 wants to merge 8 commits into
mainfrom
chore/electron-upgrade
Open

tonyco97 wants to merge 8 commits into
mainfrom
chore/electron-upgrade

Conversation

@tonyco97

@tonyco97 tonyco97 commented Nov 23, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Upgrade Electron from 28.3.3 (EOL) to 45.4.1 (latest stable: Chromium 156, Node 24.22), move safeStorage to the async API so the app no longer uses anything removed in Electron 46, and upgrade the build tooling (electron-vite 2 → 6, Vite 5 → 8). It was built on top of #267 and is now rebased on main. It also includes two fixes by Edoardo Spadoni: errors when copying to the clipboard are caught and logged, and the macOS screen recording permission dialog is shown once, after the translations are loaded.

The goal is a like-for-like upgrade: every change below is there to keep NethLink behaving as it does on Electron 28.

Changes

Dependencies (package.json, package-lock.json)

  • electron ^28.2.0 → ^45.4.1.
  • Build tooling: electron-vite ^2.0.0 → ^6.0.0, vite ^5.0.12 → ^8.3.8, @vitejs/plugin-react ^4.2.1 → ^6.3.0, @types/node ^18 → ^24 (required by Vite 8, and it matches the Node.js inside Electron 45). Vite 8 bundles with Rolldown instead of esbuild + Rollup. Runtime dependencies are unchanged.
  • externalizeDepsPlugin() is removed from electron.vite.config.ts: it is deprecated, and electron-vite 6 externalizes dependencies by default for main and preload with the same logic.
  • postinstall now runs install-electron before electron-builder install-app-deps. Since Electron 42 the binary is no longer downloaded at install time, and electron-vite (2 and 6) reads node_modules/electron/path.txt directly, so without this npm run dev / npm start fail with Electron uninstall.
  • desktopName: "nethlink.desktop". This is the value Electron already uses by default (${app.name}.desktop), so nothing changes at runtime and protocol registration (tel:, callto:, nethlink:) keeps using the same desktop id. It lets electron-builder write StartupWMClass=nethlink, which matches the window class Electron 45 now derives from the desktop name (Electron 28 used NethLink). Without it, launchers that integrate the AppImage would no longer link the window to its icon.

API changes (src/main)

  • clipboard.readText('selection') → clipboard.selection.readText(). Electron 44 removed the type argument, so the old call silently read the CLIPBOARD instead of the PRIMARY selection on Linux (call shortcut). writeText is now async and is awaited.
  • console-message (PhoneIsland log forwarding) uses the event object. The positional arguments are deprecated (removal in 47). The log line format is unchanged (DEBUG/INFO/WARNING/ERROR).
  • The ready-to-show listener has no argument (typing only).
  • safeStorage uses the async API (isAsyncEncryptionAvailable, encryptStringAsync, decryptStringAsync). The sync methods are deprecated in 45 and removed in 46. The retry loop that waits for encryption, the stored format and the error handling are unchanged.

Linux: stay on XWayland (main.ts, electron.vite.config.ts)

  • Since Electron 38, apps run as native Wayland clients in Wayland sessions (Electron 28 ran on XWayland). On native Wayland, setPosition, setAlwaysOnTop, center and moveTop are not supported (BrowserWindow docs), which would break the phone island and the command bar.
  • app.commandLine.appendSwitch('ozone-platform', 'x11') is applied too late to work, so when Electron picks Wayland and no --ozone-platform* flag was passed, the app relaunches itself once with --ozone-platform=x11. For the AppImage it relaunches $APPIMAGE. The flag goes first so that second-instance still receives the tel: URL as the last argument.
  • In dev, electron-vite passes the same flag through ELECTRON_CLI_ARGS, so npm run dev keeps working (a relaunch would end the dev process). The flag is prepended to any arguments already passed with npm run dev -- -- <args>.

Docs: the minimum macOS version in the README is now 13 (Ventura). See the notes below.

Tests (Linux, Ubuntu GNOME Wayland session, against a real NethVoice)

I ran Electron 28 (build from #267) and Electron 45 (this branch) side by side.

  • npm ci from clean, npm run build (typecheck + build), eslint (0 errors, one warning fewer), prettier
  • Native modules load in Electron 45 (ABI 150): uiohook-napi (rebuilt from source), @nut-tree-fork/nut-js, koffi
  • Login, then WebRTC registration of the NethLink device
  • Real calls in both directions between an Electron 45 instance and an Electron 28 instance: answered, Opus, about 850 RTP packets each way, 0 lost, hangup OK
  • safeStorage, upgrade path: an account saved by Electron 28 (sync encryptString) auto-logs in with decryptStringAsync (shouldReEncrypt: false)
  • safeStorage, new data: fresh login and password update (UPDATE_PASSWORD) encrypt with encryptStringAsync; restart auto-logs in. On Linux the blob is byte-for-byte identical to the one Electron 28 writes, and it is stored in the same JSON shape
  • safeStorage, downgrade: Electron 28 auto-logs in with data written by the async API (both the fresh login and the password update)
  • No deprecation warnings left at runtime (--trace-deprecation)
  • Visual comparison for the same user (login, credentials, all six sidebar tabs, phone island ringing/incoming/in-call, screen share picker): same sizes and layout, the only differences are isolated anti-aliased text pixels (Chromium 120 → 156)
  • X11 window geometry and corner alpha of the frameless, transparent windows are identical (Electron 43 rounded corners do not apply to them); the phone island keeps _NET_WM_STATE_ABOVE and the same position
  • Screen share (in-app picker): both versions return a 1920x1200 monitor track
  • PRIMARY selection: Electron 45 clipboard.selection reads the same selection as Electron 28 readText('selection'). Without the fix, Electron 45 returns the CLIPBOARD content.
  • Notifications (renderer HTML5 and main process): same org.freedesktop.portal.Notification.AddNotification call
  • Tray: StatusNotifierItem registered. Electron 45 exposes the icon as IconName + IconThemePath instead of an inline pixmap.
  • Packaged AppImage (electron-builder 26): run without flags in a Wayland session, it relaunches as $APPIMAGE --ozone-platform=x11 ... and runs on X11, WM_CLASS matches StartupWMClass
  • tel: link through a second AppImage instance, relaunch included: the URL reaches the running instance and the call starts
  • npm run dev: Electron starts with --ozone-platform=x11 and does not relaunch

electron-vite 6 / Vite 8: build before vs after, both on Electron 45

To isolate the bundler change, I compared this build with the same code built by electron-vite 2 + Vite 5, both on Electron 45. Same Chromium, so any pixel difference would come from the bundler.

  • Main and preload: same CommonJS format and the same runtime requires. The files are larger only because Rolldown keeps the JSDoc comments; without comments and whitespace the code is slightly smaller (preload −1.8%, main −0.7%). CSS is byte-identical.
  • Pixel-identical (0 different pixels) for login, credentials, all six sidebar tabs, avatar menu, command bar and screen share picker. Two runs per build: the only differences were scroll and focus state, which also vary between two runs of the same build.
  • The console output of all windows is the same message set (only socket/call ids differ)
  • Real calls between the two builds in both directions: Opus, about 710 RTP packets each way, 0 lost; the phone island has the same shape in every state
  • Global shortcuts on a real X11 server (Xvfb), same results on both builds: the key-combo command bar opens and closes; the double-tap Ctrl command bar (uiohook-napi) opens and closes; the call shortcut copies the selected number (nut-js Ctrl+C, PRIMARY selection) and starts the call
  • Screen share: in-app picker (2 screens) and direct share (1 screen), same tracks
  • Notifications (renderer and main), tray item (same icon PNG hash)
  • safeStorage: an account saved by Electron 28 auto-logs in; Electron 28 auto-logs in with an account saved by this build
  • npm ci from clean (Electron download and native rebuild in postinstall), npm run build, eslint (0 errors), prettier
  • npm run dev with and without extra Electron arguments: X11, no relaunch, the app renders from the Vite 8 dev server (login identical to the build), real login and registration, the process exits cleanly. npm start (preview) works.
  • Packaged AppImage: relaunch on X11, auto-login, tel: from a second instance starts the call (same timing behavior as the electron-vite 2 build)

Notes for reviewers

  • Windows and macOS are not tested at runtime yet. CI (build-dev.yml) builds all of them: Windows x64, macOS arm64 and x64, Linux x64. On Windows uiohook-napi is rebuilt from source against Electron 45 (C++20) without errors. macOS builds are signed with the Developer ID certificate, and notarization is skipped as in every PR build. Windows builds of PRs are unsigned, as before.
  • Platform support: Electron 45 requires macOS 13+ (12 was dropped in 44, 11 in 38, 10.15 in 33) and Windows 10+, which is unchanged. The CI matrix only builds x64/arm64, so dropping ia32 has no effect.
  • macOS notifications now use UNNotification (Electron 42) and need a signed app. Release builds are signed; unsigned local builds will not show notifications.
  • safeStorage on Windows and macOS is verified only on Linux (GNOME keyring). Electron documents that the async API uses the same key stores (DPAPI, Keychain) and that data written by encryptString can be read by decryptStringAsync. Worth a check of auto-login after updating an existing install on both.
  • Developers need Node.js >= 22.12 (required by electron@45 and Vite 8). CI already uses Node 22.
  • On Wayland sessions the uiohook global hook does not see key events from native Wayland apps, the same as on Electron 28.

@tonyco97 tonyco97 changed the title chore: upgrade Electron from 28 to 45 chore: upgrade Electron from 28 to 45 and migrate safeStorage to the async API Nov 23, 2026
@tonyco97 tonyco97 changed the title chore: upgrade Electron from 28 to 45 and migrate safeStorage to the async API chore: upgrade Electron 28 → 45, electron-vite 2 → 6 and Vite 5 → 8 Nov 23, 2026
@tonyco97

Copy link
Copy Markdown
Collaborator Author

Test

PR: #270

Setup: NethVoice with two users (A and B) with a NethLink device each; NethLink installed from this PR's build on Windows, macOS (13+) and Linux (AppImage). Run each test case on all three platforms unless the title says otherwise. For the upgrade cases, start from an existing install of the current release with a saved account.

Test Case 1 - Upgrade keeps the saved account

  • Install this build over the current release without logging out: NethLink starts and logs in automatically, without asking for the password
  • Quit and restart NethLink: automatic login again
  • Reinstall the current release over this build: automatic login still works

Test Case 2 - Login, logout and password

  • Log out and log in again with username and password: login succeeds and the NethLink device registers (phone island ready)
  • Restart NethLink: automatic login
  • Change the password from NethLink, then restart: automatic login with the new password
  • If SSO is available, log in with SSO: login succeeds

Test Case 3 - Calls

  • A calls B from NethLink: B's phone island rings, B answers, audio works in both directions
  • Hold, mute and transfer during the call: they work as in the current release
  • Hang up from either side: the phone island closes on both
  • B misses a call from A: a missed-call notification is shown

Test Case 4 - Phone island window

  • During a call the phone island stays above all other windows, also above a full-screen app
  • Drag the phone island to another position: it moves and keeps the new position after the call ends and in the next call
  • Expand and collapse the phone island: same size and look as in the current release

Test Case 5 - Command bar

  • Open and close the command bar with the configured shortcut (default double-tap of the modifier key): it opens centered on the current screen and closes
  • Set a key-combo shortcut (e.g. Ctrl+Alt+K) and press it twice quickly: the command bar opens; again: it closes
  • Search a contact in the command bar and start a call: the call starts

Test Case 6 - Call the selected number

  • Set the call shortcut in the settings, select a phone number in another app (browser, text editor) and press the shortcut: NethLink calls that number
  • Select some text that is not a number and press the shortcut: no call starts

Test Case 7 - tel:, callto: and nethlink: links

  • With NethLink running, click a tel: link in a browser: NethLink calls that number
  • Same with a callto: link
  • With NethLink closed, click a tel: link: NethLink starts (the call may need a second click once it is ready, as in the current release)

Test Case 8 - Screen share

  • During a video call, start screen sharing: the picker shows screens and windows with thumbnails
  • Share a screen, then a window: the other side sees it
  • Cancel the picker: no sharing starts and the call continues
  • macOS: the screen recording permission prompt works as in the current release

Test Case 9 - Notifications and tray

  • Notifications (missed call, update available) are shown with the NethLink name and icon
  • macOS (signed build): notifications are shown
  • The tray / menu bar icon is shown, and its menu works (open NethLink, status, quit)

Test Case 10 - Linux specific

  • Ubuntu with GNOME on Wayland (default session): start the AppImage with a double click; NethLink works as on X11 (phone island always on top, can be dragged, command bar centered)
  • Ubuntu with an X11 session: same result
  • If the AppImage is integrated in the desktop (e.g. AppImageLauncher), the NethLink window is grouped under the NethLink icon in the dock

Test Case 11 - Regression check on the rest of the UI

  • Favourites, speed dials, last calls, queues, parking and about pages: same content and look as in the current release
  • Light and dark theme switch: both themes render as before
  • Settings and account menu: all items open and work

Base automatically changed from feat/queues to main November 23, 2026 13:08
tonyco97 and others added 7 commits November 23, 2026 14:12
Since Electron 44 clipboard.writeText returns a promise. A failed
write, for example with a value that is not a string, became an
unhandled rejection in the main process. Log it as a warning.

Assisted-by: Claude Code:Fable 5.2
The permissions are requested a first time at startup, before the
translations are loaded, so the screen recording dialog showed the
translation keys. It was then shown again by the request made before
the auto login.

Show the dialog only once the translations are ready, and one time.

Assisted-by: Claude Code:Fable 5.2
@tonyco97
tonyco97 force-pushed the chore/electron-upgrade branch from afc2333 to d062a78 Compare November 23, 2026 13:14
@github-actions

Copy link
Copy Markdown

Automatic builds from https://github.com/NethServer/nethlink/actions/runs/45181893284.
Commit: d062a78

Name Platform Link
win-app.exe Windows (x64) Link
macos-app-x64.dmg MacOS (x64) Link
macos-app-arm64.dmg MacOS (arm64) Link
linux-app.AppImage Linux (x64) Link

@github-actions

Copy link
Copy Markdown

Automatic builds from https://github.com/NethServer/nethlink/actions/runs/45210662641.
Commit: 9d2f64d

Name Platform Link
win-app.exe Windows (x64) Link
macos-app-x64.dmg MacOS (x64) Link
macos-app-arm64.dmg MacOS (arm64) Link
linux-app.AppImage Linux (x64) Link

This branch has not been deployed

No deployments
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