[PR #6738] [client] Enable launch-on-login by default on fresh GUI installs #29848

Closed
opened 2026-08-05 08:09:08 -04:00 by saavagebueno · 0 comments
Owner

Original Pull Request: https://github.com/netbirdio/netbird/pull/6738

State: closed
Merged: Yes


Describe your changes

Enables the desktop UI's launch-on-login by default on genuinely fresh
installs, entirely from the signed GUI — no installer or updater ever writes an
autostart entry.

How it works

  • On the GUI's first interactive run, if the one-time autostartInitialized
    preferences marker is unset, the marker is persisted first (so a crash
    mid-flow degrades to "never enabled" rather than retrying login-item writes),
    then autostart is enabled once — subject to the guards below.
  • Enable only when: the platform supports autostart (Wails AutostartManager),
    MDM policy does not set the new disableAutostart key, and this is not an
    existing install. "Existing install" is detected in-GUI from a NetBird
    footprint on disk (profilemanager daemon config: default.json /
    config.json / state.json) or a pre-existing UI preferences file — so
    upgrading users are never mass-enabled, and a user's later disable in Settings
    is never overridden (the marker guarantees at-most-once, ever).
  • The autostart write itself goes through the existing Wails HKCU\...\Run
    (Windows) / SMAppService (macOS) / XDG autostart (Linux) toggle — the same
    path as the Settings switch.

Deliberately GUI-only. An earlier iteration used installer-written
breadcrumbs; that was dropped because the shipped Windows NSIS installer
(client/installer.nsis) does uninstall-then-install on upgrade, which deletes
$INSTDIR and would misread every upgrade as fresh. Keeping the decision in the
GUI avoids that and avoids AV-sensitive installer/updater registry writes. This
composes with #6735 (which stops the NSIS uninstaller from wiping the user's
autostart value on upgrade).

New MDM key disableAutostart is surfaced through the same managed-fields
plumbing as disableAutoConnect so the Settings toggle can be locked by policy.

Stack

Checklist

  • Is it a bug fix
  • Is a typo/documentation fix
  • Is a feature enhancement
  • It is a refactor
  • Created tests that fail without the change (if possible)
  • This change does not modify the public API, gRPC protocols, functionality behavior, CLI / service flags, or introduce a new feature — OR I have discussed it with the NetBird team beforehand (link the issue / Slack thread in the description). See CONTRIBUTING.md.

By submitting this pull request, you confirm that you have read and agree to the terms of the Contributor License Agreement.

Documentation

Select exactly one:

  • I added/updated documentation for this change
  • Documentation is not needed for this change (explain why)

Behavior-only default for a desktop UI setting that already exists and is
user-toggleable; no documented API or flag changes.

Docs PR URL (required if "docs added" is checked)

Paste the PR link from https://github.com/netbirdio/docs here:

https://github.com/netbirdio/docs/pull/__

Summary by CodeRabbit

  • New Features

    • Fresh installations now enable “launch on login” by default on supported desktop platforms.
    • Existing installations retain their current autostart behavior.
    • Administrators can disable the default through the disableAutostart managed policy.
  • Bug Fixes

    • Autostart initialization is performed only once, preventing repeated enablement attempts after failures or restarts.
**Original Pull Request:** https://github.com/netbirdio/netbird/pull/6738 **State:** closed **Merged:** Yes --- ## Describe your changes Enables the desktop UI's launch-on-login by default on genuinely fresh installs, entirely from the signed GUI — no installer or updater ever writes an autostart entry. **How it works** - On the GUI's first interactive run, if the one-time `autostartInitialized` preferences marker is unset, the marker is persisted **first** (so a crash mid-flow degrades to "never enabled" rather than retrying login-item writes), then autostart is enabled once — subject to the guards below. - Enable only when: the platform supports autostart (Wails `AutostartManager`), MDM policy does not set the new `disableAutostart` key, and this is **not** an existing install. "Existing install" is detected in-GUI from a NetBird footprint on disk (`profilemanager` daemon config: `default.json` / `config.json` / `state.json`) or a pre-existing UI preferences file — so upgrading users are never mass-enabled, and a user's later disable in Settings is never overridden (the marker guarantees at-most-once, ever). - The autostart write itself goes through the existing Wails `HKCU\...\Run` (Windows) / SMAppService (macOS) / XDG autostart (Linux) toggle — the same path as the Settings switch. **Deliberately GUI-only.** An earlier iteration used installer-written breadcrumbs; that was dropped because the shipped Windows NSIS installer (`client/installer.nsis`) does uninstall-then-install on upgrade, which deletes `$INSTDIR` and would misread every upgrade as fresh. Keeping the decision in the GUI avoids that and avoids AV-sensitive installer/updater registry writes. This composes with #6735 (which stops the NSIS uninstaller from wiping the user's autostart value on upgrade). New MDM key `disableAutostart` is surfaced through the same managed-fields plumbing as `disableAutoConnect` so the Settings toggle can be locked by policy. ## Issue ticket number and link ## Stack <!-- branch-stack --> ### Checklist - [ ] Is it a bug fix - [ ] Is a typo/documentation fix - [x] Is a feature enhancement - [ ] It is a refactor - [x] Created tests that fail without the change (if possible) - [ ] This change does **not** modify the public API, gRPC protocols, functionality behavior, CLI / service flags, or introduce a new feature — **OR** I have discussed it with the NetBird team beforehand (link the issue / Slack thread in the description). See [CONTRIBUTING.md](https://github.com/netbirdio/netbird/blob/main/CONTRIBUTING.md#discuss-changes-with-the-netbird-team-first). > By submitting this pull request, you confirm that you have read and agree to the terms of the [Contributor License Agreement](https://github.com/netbirdio/netbird/blob/main/CONTRIBUTOR_LICENSE_AGREEMENT.md). ## Documentation Select exactly one: - [ ] I added/updated documentation for this change - [x] Documentation is **not needed** for this change (explain why) Behavior-only default for a desktop UI setting that already exists and is user-toggleable; no documented API or flag changes. ### Docs PR URL (required if "docs added" is checked) Paste the PR link from https://github.com/netbirdio/docs here: https://github.com/netbirdio/docs/pull/__ <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Fresh installations now enable “launch on login” by default on supported desktop platforms. - Existing installations retain their current autostart behavior. - Administrators can disable the default through the `disableAutostart` managed policy. - **Bug Fixes** - Autostart initialization is performed only once, preventing repeated enablement attempts after failures or restarts. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
saavagebueno added the pull-request label 2026-08-05 08:09:08 -04:00
Sign in to join this conversation.
No Label pull-request
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: DYNR/netbird#29848