Skip to content

Use Electron's native loginItem API for start-at-login instead of the auto-launch package#33999

Open
hayaksi1 wants to merge 1 commit into
element-hq:developfrom
hayaksi1:pr/desktop-auto-launch
Open

Use Electron's native loginItem API for start-at-login instead of the auto-launch package#33999
hayaksi1 wants to merge 1 commit into
element-hq:developfrom
hayaksi1:pr/desktop-auto-launch

Conversation

@hayaksi1

Copy link
Copy Markdown
Contributor

Problem

The auto-launch npm package failed to actually launch the app at login on macOS — its
LaunchAgent plist path resolution for .app bundles is fragile and isn't refreshed across app
updates — while still reporting the option as enabled. So "start at login" looked like it worked
but didn't (#32303). The package is also unmaintained and required a local @types/auto-launch
patch to build.

Fix

Replace auto-launch with Electron's built-in app.setLoginItemSettings /
app.getLoginItemSettings:

  • macOS/LinuxopenAtLogin, with openAsHidden / --hidden carrying the start-minimised
    preference.
  • Windows → the login item points at the stable Squirrel Update.exe (--processStart)
    instead of the versioned executable, so it survives app updates.

The public AutoLaunch API (getState / setState / AutoLaunchState) is unchanged, so callers
are unaffected. This also lets us drop the auto-launch dependency, the @types/auto-launch
devDependency, and the patches/@types__auto-launch.patch workaround.

Tests

auto-launch.test.ts (Vitest, 6 passing) covers the state matrix (disabled / enabled / minimised)
and the platform-specific setLoginItemSettings options for Windows vs macOS/Linux.

Fixes #32303

Notes: Fixes "start at login" silently not working on macOS by using Electron's native loginItem API instead of the unmaintained auto-launch package.

Checklist

… auto-launch package

The auto-launch npm package failed to actually launch the app at login on macOS — its
LaunchAgent plist path resolution for .app bundles is fragile and isn't refreshed
across app updates — while still reporting the option as enabled, so "start at login"
appeared to work but didn't (element-hq#32303). It is also unmaintained and required a local
@types/auto-launch patch.

Replace it with Electron's built-in app.setLoginItemSettings / app.getLoginItemSettings.
On Windows the login item points at the stable Squirrel Update.exe (--processStart)
rather than the versioned executable so it survives updates; openAsHidden / --hidden
carry the start-minimised preference. The public AutoLaunch API (getState / setState /
AutoLaunchState) is unchanged, so callers are unaffected.

Drops the auto-launch dependency, its @types/auto-launch devDependency, and the
associated patch.
@hayaksi1 hayaksi1 requested review from a team as code owners June 27, 2026 07:37
@github-actions github-actions Bot added the Z-Community-PR Issue is solved by a community member's PR label Jun 27, 2026

@t3chguy t3chguy left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This looks to have no migration path to keep the user's previous preference? That'd likely be a blocker. Also what would happen if the user had auto-launch enabled previously, given node auto-launch is gone would they be unable to disable it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Z-Community-PR Issue is solved by a community member's PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Start at login not working

2 participants