Skip to content

fix: match Windows login items when the executable path contains spaces - #54364

Merged
MarshallOfSound merged 1 commit into
mainfrom
fix-win-login-items-space-path
Sep 25, 2026
Merged

MarshallOfSound merged 1 commit into
mainfrom
fix-win-login-items-space-path

Conversation

@codebytere

@codebytere codebytere commented Sep 25, 2026 •

Copy link
Copy Markdown
Member

Description of Change

Fixes #53911.

After this change app.getLoginItemSettings() on Windows finds the entries setLoginItemSettings() wrote when the executable path contains a space (C:\Program Files\..., a user profile with a space), and executableWillLaunchAtLogin reports true for them.

The lookup ran the executable path through CommandLine::FromString, which splits an unquoted path at the first space, so it never matched the quoted Run values that setLoginItemSettings() writes and returned no launchItems.

The lookup now compares the path as a plain executable path, stripping surrounding quotes if the caller passed them, and the two existing quote-stripping sites share one helper. A spec round-trips an entry whose path contains spaces.

Checklist

Release Notes

Notes: Fixed app.getLoginItemSettings() not finding login items on Windows when the executable path contains spaces.

getLoginItemSettings() parsed the lookup path as a command line, so an
unquoted path with a space was cut at the space and never matched the
quoted Run entries that setLoginItemSettings() writes.
@codebytere codebytere added semver/patch backwards-compatible bug fixes target/43-x-y PR should also be added to the "43-x-y" branch. target/44-x-y PR should also be added to the "44-x-y" branch. target/45-x-y PR should also be added to the "45-x-y" branch. labels Sep 25, 2026
@MarshallOfSound MarshallOfSound removed target/43-x-y PR should also be added to the "43-x-y" branch. target/44-x-y PR should also be added to the "44-x-y" branch. labels Sep 25, 2026
@MarshallOfSound
MarshallOfSound merged commit 076972c into main Sep 25, 2026
148 of 152 checks passed
@release-clerk

release-clerk Bot commented Sep 25, 2026

Copy link
Copy Markdown

Release Notes Persisted

Fixed app.getLoginItemSettings() not finding login items on Windows when the executable path contains spaces.

@MarshallOfSound
MarshallOfSound deleted the fix-win-login-items-space-path branch September 25, 2026 16:12
@trop

trop Bot commented Sep 25, 2026

Copy link
Copy Markdown
Contributor

I was unable to backport this PR to "45-x-y" cleanly;
you will need to perform this backport manually.

@trop trop Bot added needs-manual-bp/45-x-y and removed target/45-x-y PR should also be added to the "45-x-y" branch. labels Sep 25, 2026
@trop

trop Bot commented Sep 26, 2026

Copy link
Copy Markdown
Contributor

@codebytere has manually backported this PR to "45-x-y", please check out #54419

codebytere added a commit that referenced this pull request Sep 26, 2026
…es (#54419)

fix: match Windows login items when the executable path contains spaces (#54364)

getLoginItemSettings() parsed the lookup path as a command line, so an
unquoted path with a space was cut at the space and never matched the
quoted Run entries that setLoginItemSettings() writes.

(cherry picked from commit 076972c)
@trop trop Bot added merged/45-x-y PR was merged to the "45-x-y" branch. and removed in-flight/45-x-y labels Sep 26, 2026
@trop

trop Bot commented Oct 22, 2026

Copy link
Copy Markdown
Contributor

@codebytere has manually backported this PR to "44-x-y", please check out #55207

codebytere added a commit that referenced this pull request Oct 22, 2026
…es (#55207)

* fix: match Windows login items when the executable path contains spaces (#54364)

getLoginItemSettings() parsed the lookup path as a command line, so an
unquoted path with a space was cut at the space and never matched the
quoted Run entries that setLoginItemSettings() writes.

(cherry picked from commit 076972c)

* test: use a vitest matcher in the login item spec
@trop trop Bot added merged/44-x-y PR was merged to the "44-x-y" branch. and removed in-flight/44-x-y labels Oct 22, 2026
Noah-Tervalon-Nvidia pushed a commit to NVIDIA/Personal-AI-Router that referenced this pull request Nov 16, 2026
)

## Description

On Windows, turning on **Settings > Service > Launch at login** did not
stick: the switch went back to off straight after the click. The Run
entry was written, so PAIR did start at sign-in, but the switch showed
off, and turning it off again from Settings was not possible.

The cause is in Electron 42. `app.getLoginItemSettings()` finds this
app's Run entries by comparing them with the running executable, and it
parses that path as a command line without quoting it. An install under
`C:\Program Files\PAIR\PAIR.exe` therefore reads as `C:\Program`,
nothing matches, and Electron reports `launchItems: []` and
`executableWillLaunchAtLogin: false` for the entry it has just written.
The switch reads `executableWillLaunchAtLogin`, so it shows off. macOS
and Linux do not use this path, and an unpackaged build never writes the
entry, which is why it only showed up on installed Windows builds.

Upstream fixed this in
[electron/electron#54364](electron/electron#54364),
released in 44.10.0 and 45.0.0. It was not backported to 42 or 43.

Changes in `desktop/src/electron/login-item.ts`:

- `readLoginItem` passes the executable path in quotes on Windows
(`path: "\"<execPath>\""`). Electron 42 then parses it correctly, and
44.10+ strips the quotes, so this keeps working after an upgrade.
- `planLoginItem` no longer compares `launchItems[].args` with the
arguments it wants. Electron leaves switches such as `--hidden` out of
`args`, so once the entry was visible, an entry written with `--hidden`
looked current after **Start minimized to tray** was turned off, and
`--hidden` stayed in the Run value. `openAtLogin`, Electron's exact
comparison of the whole Run value under the wanted arguments, now
decides whether the entry is current, and `launchItems` is used only to
see whether the user disabled it.

Because the entry is now visible, the documented Task Manager behavior
also works on these installs: an entry disabled in Task Manager reads
off, and PAIR does not re-enable it at the next launch.

## Release intent

<!-- pair-release-intent:v1 -->
### Changelog title
Launch at login stays on after enabling it on Windows

### Changelog body
- On Windows, turning on Launch at login in Settings > Service now keeps
the switch on. Before, the switch went back to off even though PAIR was
set to start at sign-in, and it could not be turned off from Settings.
- Turning Start minimized to tray on or off on Windows now updates the
startup entry straight away.
- A startup entry disabled in Windows Task Manager or the startup apps
settings now reads off in Settings, and PAIR leaves it off.

### Bumps
- services: patch
- nvpair-cluster-manager: none
- nvpair-engine-manager: none
- nvpair-errors: none
- nvpair-job-scheduler: none
- nvpair-manual-nodes: none
- nvpair-node-info: none
- nvpair-node-scanner: none
- nvpair-node-settings: none
- nvpair-proxy: none
- nvpair-tui: none
- nvpair-ui-broker: none
- nvpair-workload-manager: none
<!-- /pair-release-intent:v1 -->

`services: patch` carries the desktop-only fix into the changelog; no
service binary changes.

## Scope

Included: the Windows read in `readLoginItem`, the Windows "is the entry
current" decision in `planLoginItem`, and the unit tests. The test
fixture for a Run entry now reports `args: []`, which is what Electron
returns, and new cases cover turning Start minimized off.

Excluded, as follow-ups:

- Upgrading Electron to 44.10 or later. The quoted path can be dropped
after that, but it is harmless if left.
- A Run entry for `PAIR.exe` that PAIR did not create (machine-wide
under `HKLM`, or a per-user entry under another name) makes the switch
read on, and PAIR cannot remove it. The installer never writes one. This
is unchanged on install paths without spaces.
- An entry left at a previous install path stays invisible to Electron,
so a Task Manager opt-out on it is not seen. Unchanged by this PR.

## Validation

Windows 11, from `desktop/`:

- `npx vitest run tests/modular/launch-at-login.test.ts
tests/modular/startup-preferences.test.ts`: 184 passed. Against the
previous `login-item.ts`, 6 fail, including the two new Start minimized
cases.
- `npm run typecheck`: passed.
- `npx eslint` and `npx prettier --check` on both changed files: passed.
- `npm run dead-code:check`: passed.

Real Electron 42.10.0: the bundled `login-item.ts` ran as a packaged app
(`isPackaged: true`) from `%TEMP%\PAIR Repro\PAIR.exe`, a path with a
space, replaying the `service:set-startup` handler and the launch
reconcile, and reading the Run value with `reg query`. The harness used
its own Run value name, and both `Run` and `StartupApproved\Run` were
clean afterwards.

| Step | Before | After |
| --- | --- | --- |
| Turn Launch at login on | entry written, switch shows **off** | entry
written, switch shows **on** |
| Relaunch | switch shows **off** | switch shows **on** |
| Turn Launch at login off | nothing removed, entry stays | entry
removed |
| Turn Start minimized off | `--hidden` kept until a relaunch |
`--hidden` removed straight away |
| Turn Start minimized on | `--hidden` not added until a relaunch |
`--hidden` added straight away |
| Entry disabled in Task Manager, then launch | `keep` | `opt-out`,
switch reads off |

Not yet done: a test under `C:\Program Files`, which needs an installed
build, and an actual sign-out and sign-in.

## Risk

Windows only. macOS, Linux and unpackaged builds are unchanged. The Run
value PAIR writes is unchanged; only how PAIR reads it back changed.
With the entry visible, the Task Manager opt-out handling, which already
existed but never triggered on `Program Files` installs, now runs. It
matches the documented behavior in `docs/getting-started.mdx`.

## Checklist

- [x] I have read the [Contributing
Guidelines](https://github.com/NVIDIA/Personal-AI-Router/blob/main/CONTRIBUTING.md).
- [x] Every commit is signed off (`git commit -s`), certifying the
[Developer Certificate of Origin](https://developercertificate.org/).
- [x] New or existing tests cover the change.
- [x] Relevant documentation is updated. `docs/getting-started.mdx`
already describes this behavior, so no change is needed.
- [x] I checked the diff, changed filenames, and commit messages for
credentials, private data, internal URLs, internal issue identifiers,
and generated artifacts.
- [x] I recorded the validation commands and results above.
- [x] I declared version bumps in the release-intent block above.
`services/versions.json` is written by automation — do not edit it by
hand.

Signed-off-by: Chris Kelsey <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

46-x-y merged/44-x-y PR was merged to the "44-x-y" branch. merged/45-x-y PR was merged to the "45-x-y" branch. semver/patch backwards-compatible bug fixes

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

getLoginItemSettings() fails to detect Windows launchItems when executable path contains spaces

2 participants