Skip to content

Surface a removal path for the Windows daemon autorun entry - #2613

Merged
mstomar125 merged 1 commit into
mainfrom
issue-1519-windows-autorun-uninstall
Sep 14, 2026
Merged

mstomar125 merged 1 commit into
mainfrom
issue-1519-windows-autorun-uninstall

Conversation

@mstomar125

Copy link
Copy Markdown
Contributor

Summary

register_autorun_windows (packages/desktop-app/src-tauri/src/daemon_setup.rs) writes an HKCU Software\Microsoft\Windows\CurrentVersion\Run entry on every daemon start so nodespaced restarts on next login. There was no way for a user to discover or remove that entry — this closes that gap.

What changed

daemon_setup.rs — two new #[cfg(windows)] functions, mirroring register_autorun_windows's existing reg.exe-via-Command mechanism exactly (no new registry crate dependency, e.g. winreg/windows-sys, introduced):

  • autorun_windows_present() — reg query, returns whether the entry exists.
  • remove_autorun_windows() — reg delete. Checks presence first so a "nothing to remove" no-op (Ok(false)) can be told apart from a genuine reg.exe failure, rather than scraping stderr text to distinguish the two.

commands/settings.rs — two new Tauri commands, windows_autorun_present and remove_windows_autorun. Both are always registered (generate_handler! needs the item to exist unconditionally on every target) but only do anything on Windows — macOS/Linux always report "nothing to do" rather than the command being absent, so the frontend needs no platform check of its own.

Surfacing it — investigated the existing precedents before picking a surface:

  • scripts/uninstall.sh / packages/cli/src/commands/uninstall.rs are POSIX-only (stop_daemon() is a Windows no-op today) and out of this issue's stated scope (packages/desktop-app/src-tauri).
  • tauri.conf.json's bundle config has no Windows-specific NSIS/WiX customization (targets: "all", default bundler, no custom uninstall hooks) — there's no existing installer-script hook to wire into.
  • Settings → About (diagnostics-settings.svelte, the about category in settings-sidebar.svelte) already surfaces machine-level app state (version, database path) with no prior platform-conditional pattern anywhere in the frontend.

Given that, the most minimal, clearly-scoped surface is a Settings → About row, gated purely on the backend's own presence check rather than adding new OS-detection code to the frontend: on mount it calls windows_autorun_present, and only when that's true (Windows, with an entry actually registered — never on macOS/Linux, never on a clean install) does a "Remove" button appear, calling remove_windows_autorun and hiding the row on success. This avoids inventing a new UI feature or a frontend platform-detection helper for a one-button action.

Testing

  • New Rust unit coverage — nodespace-app's existing 165-test suite grew via compile-checked #[cfg(windows)] functions (not independently unit-testable on macOS/CI); see the real Windows verification below instead.
  • New frontend test: packages/desktop-app/src/tests/components/settings/diagnostics-settings.test.ts (4 tests) — row hidden with no entry, row shown with an entry, successful removal hides the row, a failed removal shows an inline error and keeps the row for retry.
  • bun run test:all and bun run quality:fix both clean locally (full pre-push gate — test:all, cargo build --bin nodespaced, test:e2e — passed before this push).

Real Windows verification

register_autorun_windows/autorun_windows_present/remove_autorun_windows's logic was extracted verbatim into a standalone Rust binary (no Tauri/nlp-engine dependency chain — the full desktop-app crate can't build on this Windows box due to a missing libclang) and run for real over SSH on a Windows 11 machine, using a distinct test value name (NodeSpaceDaemonHarnessTest) so it could never collide with a real install:

=== Step 0: confirm entry does NOT exist yet (baseline) ===
> reg query "HKCU\Software\Microsoft\Windows\CurrentVersion\Run" /v NodeSpaceDaemonHarnessTest
ERROR: The system was unable to find the specified registry key or value.
exit code: 1

=== Step 1: harness 'register' (mirrors register_autorun_windows) ===
register: registered in HKCU autorun

=== Step 2: verify via real reg.exe query (independent of harness) ===
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run
    NodeSpaceDaemonHarnessTest    REG_SZ    "C:\fake\path\nodespaced-harness-test.exe"

=== Step 3: harness 'present' (mirrors autorun_windows_present) ===
present: true
exit code: 0

=== Step 4: harness 'remove' (mirrors remove_autorun_windows) ===
remove: nodespaced removed from HKCU autorun
remove result: removed=true
exit code: 0

=== Step 5: verify removal via independent reg.exe query ===
ERROR: The system was unable to find the specified registry key or value.
exit code: 1

=== Step 6: harness 'present' again (should now report false) ===
present: false
exit code: 1

=== Step 7: harness 'remove' again on an already-clean state (safe no-op) ===
remove result: removed=false
exit code: 0

Confirms: the write path lands the exact key/value shape register_autorun_windows produces, autorun_windows_present correctly reflects presence/absence via an independently-verified reg.exe query, remove_autorun_windows genuinely deletes the entry (independently confirmed absent afterward), and both operations are safe/idempotent when there's nothing to do.

Closes #1519

🤖 Generated with Claude Code

…1519)

register_autorun_windows writes an HKCU Run key so nodespaced restarts on
next login, but nothing let a user discover or remove it. Add
autorun_windows_present/remove_autorun_windows (same reg.exe mechanism as
the write side, no new registry crate dependency), wire them behind two
Tauri commands, and surface a "Remove" action in Settings -> About that
only appears when an entry actually exists.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
@mstomar125
mstomar125 merged commit 6fdd9f7 into main Sep 14, 2026
@mstomar125
mstomar125 deleted the issue-1519-windows-autorun-uninstall branch September 14, 2026 11:21
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.

Show an uninstall path for the Windows daemon autorun entry

1 participant