Skip to content

Keep the daemon running after the window closes; PATH step reports what it wrote (closes #3822, closes #3823) - #3828

Merged
malibio merged 2 commits into
mainfrom
issue-3822-3823-daemon-lifecycle-path-step
Oct 15, 2026
Merged

malibio merged 2 commits into
mainfrom
issue-3822-3823-daemon-lifecycle-path-step

Conversation

@malibio

@malibio malibio commented Oct 15, 2026

Copy link
Copy Markdown
Collaborator

What

  • Keep the daemon running after the app window closes; only the tray Quit stops it #3822: window close, Cmd+Q and the red traffic-light button end the UI only. graceful_shutdown no longer stops the daemon; the tray Quit remains the explicit stop (and closes the UI). Removed signal_daemon_to_stop (both platforms). The CLI's not-running error names how to start it. The Windows spawn was already detached; launchd/systemd own the service.
  • Onboarding PATH step: report what it wrote, check the real PATH, and cover the user's shell #3823: the onboarding PATH step checks whether nodespace really resolves (check_cli_on_path), writes the login shell's rc file (creating it; fish and other shells covered), detects and removes across the same file set (.zshrc, .bash_profile, .bashrc, .profile, fish config), reports written/created/unchanged per file, and says open terminals need a restart. Settings shows Remove only when NodeSpace's own line exists.

Docs: architecture/daemon-cli-lifecycle.md updated in nodespace-docs; cloud-sync's "keeps syncing while the window is closed" is now true as written.

Test

bun run test:changed passed (frontend, scripts, browser, types, node-types, Rust nextest).

🤖 Generated with Claude Code

@malibio

malibio commented Oct 15, 2026

Copy link
Copy Markdown
Collaborator Author

Code Review Summary

Verdict: REQUEST CHANGES (daemon half is good; one real bug and a test gap on the PATH half). Self-approval is blocked, so this is posted as a comment review.

The #3822 half is clean and minimal: the daemon-stop call is deleted outright (no flag, no dead code), pid-file cleanup stays, tray Quit is untouched, the CLI error names the start paths, and SuccessfulExit: false / systemd Restart=on-failure / the Windows DETACHED_PROCESS | CREATE_NEW_PROCESS_GROUP spawn already make the daemon independent of the app process. The binary-update path (kill_running_daemon on a changed or corrupted binary in ensure_daemon_running) still replaces a daemon that now outlives the app, so a stale daemon after an app update is handled on next launch. The #3823 half is a solid rewrite (one known-file set for detect/write/remove, per-file outcomes, fish syntax, injected inputs for testing), but has a macOS bash targeting bug and no frontend test coverage for the new banner.

Findings

Critical Issues

  • None blocking the daemon lifecycle.

Suggested Improvements (should fix before merge)

  • [Improvement/bug] onboarding.rs target_rc_file, LoginShell::Bash arm: bashrc.exists() || !cfg!(target_os = "macos") picks ~/.bashrc on macOS whenever it exists and ~/.bash_profile does not. Terminal.app and iTerm open login shells, which read ~/.bash_profile / ~/.profile and never ~/.bashrc unless sourced. The wizard would report "Added to ~/.bashrc" and a new terminal still would not resolve nodespace: the exact silent failure Onboarding PATH step: report what it wrote, check the real PATH, and cover the user's shell #3823 exists to remove. On macOS the bash target should be ~/.bash_profile unconditionally; the .bashrc branch is only right on Linux. No test covers the Bash arm; add one, passing the OS as a parameter rather than cfg! so both shapes are testable.
  • [Improvement] Frontend tests untouched (7 files changed, zero tests): the diff adds the pathResult banner (Created / Added to / Already in, the restart note), changes the "already configured" copy, and splits the settings card into pathExportPresent / pathAlreadyConfigured / neither. The onboarding-wizard*.test.ts mocks still return status objects with no pathExportPresent, and configure_path mocks resolve undefined (works only because of pathResult?.files ?? []). Add: a wizard test where configure_path returns a created file plus restartRequired and the banner shows the path and restart note; an alreadyOnPath case; an integrations-settings test for the three button states; and add pathExportPresent to the shared mock status objects so they match the wire shape. Rust gaps: Bash arm, symlinked rc file, remove_from_path flipping path_configured.
  • [Improvement] Settings card inconsistent after Add: pathAlreadyConfigured now means "resolves on this process's augmented PATH". After "Add to PATH" writes an rc file this stays false while pathExportPresent becomes true, so the badge says "Not configured" while the button reads "Remove from PATH" next to a success banner. Badge should use pathAlreadyConfigured || pathExportPresent.
  • [Improvement] check_onboarding_status cost: its own doc says it runs on every launch just to read completed, and it now spawns /usr/libexec/path_helper plus nodespace --version (no timeout) each time, even for finished users. Compute the two PATH fields only when !onboarding_completed, or move them to get_integrations_status, the only other consumer. A hung nodespace --version should not sit on the launch path.
  • [Improvement] "Resolves on the login-shell PATH" is approximated: check_cli_on_path augments with /usr/local/bin, /opt/homebrew/bin, ~/.local/bin, ~/.cargo/bin, ~/go/bin, ~/.npm-global/bin regardless of the user's shell, so a nodespace in ~/.cargo/bin the shell never adds reports "already configured" and the step is skipped. Fine for the Homebrew case, but the field docs ("on the user's shell PATH") overstate it.
  • [Improvement] path_configured = true when nothing was written: configure_path sets the flag even when already_on_path (cask), while its doc says "only when the PATH is in place". Set it only when files is non-empty.
  • [Improvement] Windows: configure_path now errors on Windows while check_onboarding_status still probes, so a Windows user hits a failing PATH step (previously it faked success). Skip the step on Windows (do not push 'path') or confirm the error state has a Skip; the message also names no actual folder.

Edge cases checked

  • Symlinked rc files: tokio::fs::write follows the link, so dotfile-manager setups get the line in the real file. A dangling symlink is reported Created; acceptable.
  • ZDOTDIR is ignored (zsh target always ~/.zshrc); worth a one-line comment, not a fix.
  • A commented-out marker line counts as present (pre-existing, same in removal).
  • Removal now writes an empty file as empty rather than "\n": good.

Stale comments / docs

  • No remaining references to signal_daemon_to_stop; module and test comments updated. Nothing else in the packages claims window close stops the daemon.

Nitpicks

  • Nit: graceful_shutdown_leaves_daemon_tests asserts !contains("kill"); a future comment with that word fails it. taskkill / stop_daemon / SIGTERM is more targeted.
  • Nit: CLI message ends "Quitting from the tray stops it." which reads like a start instruction; reword "(The tray's Quit stops the daemon.)".

Acceptance criteria

#3822: window close/Cmd+Q leaves daemon (met, by deletion); tray Quit stops both (unchanged, wiring tests present); relaunch attaches (existing healthy no-op); launchd/systemd/Windows independence (met, pre-existing flags); CLI message (met); tests updated (met at source-text level; the Verify launchctl scenario needs a manual run); docs landed separately.
#3823: reports written/created/unchanged (met); right rc for SHELL (met except the macOS bash bug); step only when CLI doesn't resolve (confirm-only banner; met); same file set for detect/write/remove (met); restart note (met); uninstall over all files (met). Rust tests cover missing file, existing file, already present, CLI on PATH, non-zsh/bash; frontend coverage is the gap.

@malibio malibio left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Review posted in the comment above. Verdict: REQUEST CHANGES (macOS bash rc target bug, missing frontend tests for the PATH banner and settings states, plus smaller improvements). The daemon-lifecycle half (#3822) looks good.

@malibio

malibio commented Oct 15, 2026

Copy link
Copy Markdown
Collaborator Author

Review addressed

Fixed

  • macOS bash target: always ~/.bash_profile on macOS (login shells skip .bashrc); extracted bash_target with a test.
  • Probe cost: check_onboarding_status (the app shell's every-launch call) runs the nodespace --version probe only while onboarding is incomplete; get_integrations_status always probes.
  • path_configured is no longer set when the CLI already resolves by other means.
  • Settings badge counts our own rc line (pathAlreadyConfigured || pathExportPresent), so it agrees with the Remove button after an Add.
  • Frontend tests: new onboarding-wizard-path-reporting.test.ts (created / added-to banner, restart note, failure keeps Skip, already-on-PATH offers nothing).
  • Nits: sharper graceful_shutdown test needles; CLI message no longer mentions tray Quit; probe doc comment states it is an approximation.

Skipped

  • Windows: configure_path errors honestly there and the step already shows the error with Skip available, so no step-hiding logic. Revisit if Windows users hit it in practice.
  • ZDOTDIR: out of scope; zsh users with a relocated rc file are no worse off than before.

bun run test:changed passes.

Re-Review Decision

Decision: NO RE-REVIEW NEEDED

Rationale: Small, targeted fixes with direct tests; no new architecture or behavior beyond what the review requested.

malibio and others added 2 commits October 15, 2026 22:57
…eport what it wrote (closes #3822, closes #3823)

Window close and Cmd+Q end the UI only; the tray Quit is the one way to stop the daemon, and the CLI's not-running error names how to start it. The onboarding PATH step checks whether nodespace really resolves, writes the login shell's rc file (creating it), covers every rc file the installer may use, reports what it changed, and says open terminals need a restart.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@malibio
malibio force-pushed the issue-3822-3823-daemon-lifecycle-path-step branch from 004a180 to 8ba1343 Compare October 15, 2026 20:57
@malibio
malibio merged commit fad4480 into main Oct 15, 2026
@malibio
malibio deleted the issue-3822-3823-daemon-lifecycle-path-step branch October 15, 2026 20:58
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.

1 participant