Repository navigation
Description
Overview
The CI/CD pipeline produces a `.dmg` via `tauri build`. Currently only the Tauri app is bundled. `nodespaced` (the daemon) and `nodespace` (the CLI) need to be included in the `.dmg` and `nodespaced` must be registered as a launchd user agent so it starts at login and survives UI window close.
Problem Statement
Under ADR-031, `nodespaced` owns the RocksDB lock, all business logic, the system tray, and background compute (embeddings, local agent). The Tauri app is a thin gRPC client. If `nodespaced` is not running before the Tauri app launches, the UI cannot connect and all operations fail.
A sidecar approach (Tauri spawns `nodespaced` as a child process) would tie the daemon lifecycle to the UI window — defeating the purpose of the daemon architecture. The daemon must survive UI close so the local agent, embeddings, and (future) sync continue running headlessly.
The correct macOS pattern is a launchd user agent: registered in `~/Library/LaunchAgents/`, starts at login, restarts on crash, independent of any window.
Proposed Solution
- Bundle `nodespaced` and `nodespace` as Tauri sidecar binaries inside the `.app`
- On first launch, the Tauri app extracts both binaries to `
/.nodespace/bin/` and writes a launchd plist to `/Library/LaunchAgents/app.nodespace.daemon.plist` - Load the plist via `launchctl load` so `nodespaced` starts immediately (no reboot required)
- On subsequent launches, check if `nodespaced` is already running before attempting to start it
- Add `~/.nodespace/bin` to `$PATH` suggestion in first-run UI so `nodespace` CLI is accessible from the terminal
Acceptance Criteria
- `nodespaced` binary bundled as Tauri sidecar in `tauri.conf.json`
- `nodespace` CLI binary bundled as Tauri sidecar in `tauri.conf.json`
- On first launch, both binaries extracted to `~/.nodespace/bin/`
- launchd plist written to `~/Library/LaunchAgents/app.nodespace.daemon.plist` on first launch
- Plist uses correct socket path (`~/.nodespace/daemon.sock`) matching Switch nodespaced IPC transport from TCP to Unix Domain Sockets #1176
- `launchctl load` called after plist write — daemon starts without requiring logout/login
- Subsequent launches detect running daemon (check socket exists + gRPC ping) before attempting start
- Tauri app shows clear error state if daemon is not reachable after 5s timeout
- `tauri build` succeeds and `.dmg` contains all three binaries
- CI/CD pipeline builds and signs all three binaries
- `bun run quality:fix` passes
Technical Specifications
Reference Files
- `packages/desktop-app/src-tauri/tauri.conf.json` — add `externalBin` entries for sidecars
- `packages/desktop-app/src-tauri/src/main.rs` — first-launch setup logic
- `packages/daemon/src/main.rs` — socket path must match plist `NODESPACED_SOCKET` env var (from Switch nodespaced IPC transport from TCP to Unix Domain Sockets #1176)
- `packages/cli/Cargo.toml` — CLI binary name: `nodespace`
launchd plist template
```xml
Label app.nodespace.daemon ProgramArguments /Users/USERNAME/.nodespace/bin/nodespaced EnvironmentVariables NODESPACED_SOCKET /Users/USERNAME/.nodespace/daemon.sock NODESPACED_DB_PATH /Users/USERNAME/.nodespace/database/nodespace RunAtLoad KeepAlive StandardOutPath /Users/USERNAME/.nodespace/logs/nodespaced.log StandardErrorPath /Users/USERNAME/.nodespace/logs/nodespaced-error.log \`\`\`Tauri sidecar configuration (`tauri.conf.json`)
```json
{
"tauri": {
"bundle": {
"externalBin": [
"bin/nodespaced",
"bin/nodespace"
]
}
}
}
```
First-launch setup sequence (Tauri `setup` hook)
- Check if `~/.nodespace/bin/nodespaced` exists and matches current version
- If not: extract sidecar binaries to `~/.nodespace/bin/`, set `chmod +x`
- Check if `~/Library/LaunchAgents/app.nodespace.daemon.plist` exists
- If not: write plist with resolved home directory paths, call `launchctl load`
- Wait up to 5s for `~/.nodespace/daemon.sock` to appear
- Ping daemon via gRPC `GetDiagnostics` — show error state if unreachable
CLI PATH guidance
First-run UI shows a one-time notice:
"Add NodeSpace CLI to your terminal: add `~/.nodespace/bin` to your `$PATH`"
With a copy button for the shell export line. No automatic `$PATH` mutation.
Dependencies
- Switch nodespaced IPC transport from TCP to Unix Domain Sockets #1176 (UDS socket path — plist must use same `NODESPACED_SOCKET` value)
Related Issues
- Switch nodespaced IPC transport from TCP to Unix Domain Sockets #1176 (UDS transport — socket path used in plist)
- Move system tray ownership to nodespaced daemon #241 (system tray owned by nodespaced — daemon must be running for tray to appear)
Non-Goals
- Windows installer (separate issue when Windows target is concrete)
- Homebrew formula (future)
- Auto-update mechanism (Tauri updater is separate)
- Remote/multi-user daemon access
Activity
malibio commentedon May 19, 2026
Frontend baseline: 129 passed, 3921 tests
malibio commentedon May 19, 2026
Code Review — PR Branch
worktree-issue-1179-bundle-nodespaced-launchdOverall Assessment
This is a well-structured implementation that correctly solves the core problem: registering
nodespacedas a launchd user agent so it survives UI window close. The module decomposition (daemon_setup.rs) is clean, the error-handling philosophy (non-fatal with UI emission) is appropriate for a setup hook, and the CI step correctly gates sidecar builds to macOS. There are several issues that need to be addressed before merge — one blocker, two improvements, and a few nits.Findings
[Critical/Blocker]
daemon_setup.rshas no#[cfg(target_os = "macos")]guard — will fail to compile on Windowsdaemon_setup.rsusestokio::net::UnixStream,std::os::unix::fs::PermissionsExt,libc::getuid(), and hard-codesLibrary/LaunchAgents/— all macOS/Unix-only APIs. The module is declared unconditionally inlib.rs:The Windows build matrix in
release.ymlwill attempt to compile this module.tokio::net::UnixStreamis not available on Windows,std::os::unix::fs::PermissionsExtdoes not exist there, andlibc::getuidis not a Windows symbol. This will produce a compile error on the Windows runner.Fix: Add
#[cfg(target_os = "macos")](or#[cfg(unix)]) to the module declaration inlib.rsand to all call sites that referencedaemon_setup:And wrap the setup call and the Tauri command registration accordingly.
[Improvement]
Committed empty binary placeholders are fragile and will cause signing failures on macOS
Four empty (0-byte) files are committed to
packages/desktop-app/src-tauri/binaries/. Tauri'sexternalBinbundler copies these files into the.appbundle. Apple'scodesignwill then attempt to sign the empty files as Mach-O binaries. A 0-byte file is not a valid Mach-O, so notarization will fail at thestaplestep.The CI workflow correctly overwrites these files before
tauri build, so a properly-sequenced CI run will work. But the commit itself represents a hazard:tauri buildwithout the CI pre-step will embed the empty files, causing an opaque signing failure.tauri-action) could silently re-introduce the bug.Recommended fix: Add
packages/desktop-app/src-tauri/binaries/nodespace*to.gitignoreand add abuild.rscheck (or a CI pre-check step) that aborts with a helpful message if the files are still empty at build time. The CI workflow already builds the real binaries into that path — they just should not be tracked in git.Binary extraction always overwrites on every non-healthy launch; should be version-gated
The acceptance criterion explicitly states: "check if
~/.nodespace/bin/nodespacedexists and matches current version." The currentextract_sidecarunconditionally copies the bundle binary to the destination whenever the socket is not healthy — including on app version upgrades where the daemon crashed for an unrelated reason. Unnecessary binary extraction on every crash restart has two drawbacks:fdopen (benign on macOS due to HFS+ semantics, but fragile).Recommended fix: Before copying, compare the source and destination sizes (cheap) or a SHA-256 digest (correct). Only extract if they differ. This also satisfies the stated acceptance criterion.
[Nit]
launchctl load -wis a legacy interface on macOS 10.11+Apple deprecated the
load/unloadsubcommands in favour ofbootstrap/bootout(macOS 10.11) and formally documentedkickstartas the restart mechanism. The current code already useskickstartfor the reload path, which is correct. The initialloadcall should ideally use:launchctl bootstrap gui/501 ~/Library/LaunchAgents/app.nodespace.daemon.plistThis is a minor robustness concern —
loadstill works on all macOS versions in scope (14.0+), but the deprecation warning in macOS 15 server logs may confuse operators.Nit:
plist_path.parent().unwrap()inwrite_plistplist_pathis always constructed aslaunch_agents_dir(&home).join(PLIST_FILENAME), so.parent()will never beNone. However,.unwrap()is a code smell in production Rust. Replace with.ok_or_else(|| anyhow::anyhow!("plist path has no parent"))?)for consistency with the rest of the error handling in this file.Nit: Socket path duplicated across three locations
The literal
.nodespace/daemon.sock/.nodespace/daemon.sockappears independently in:daemon_setup.rs:23(DAEMON_SOCKET_PATHconstant)lib.rs:53(check_daemon_statuscommand — hardcoded inline)watcher.rs:63-64(separate resolution helper)The constant in
daemon_setup.rsis not re-used inlib.rsorwatcher.rs. Extract to a sharedconstants.rsor re-export fromdaemon_setupso a future socket path change is a one-line edit.Acceptance Criteria Status
nodespacedbinary bundled as Tauri sidecarnodespaceCLI binary bundled as Tauri sidecar~/.nodespace/bin/on first launch~/Library/LaunchAgents/on first launch~/.nodespace/daemon.sock)launchctl loadcalled after plist writedaemon-statusevent but frontendapp-shell.sveltehas no listener; the event is silently droppedtauri buildsucceeds and.dmgcontains all three binariesbun run quality:fixpassesThe missing frontend error state ("daemon-status" event emitted but not consumed) means the app will silently proceed to a blank/broken state if the daemon does not come up. The issue spec requires a "clear error state" — this is an incomplete acceptance criterion, but it is lower severity than the Windows compile blocker since macOS is the only target for this release.
Summary
Block on: Platform guard for
daemon_setupmodule (Windows compile failure).Fix before merge: Empty binary placeholders in git (signing/notarization hazard).
Nice to have before merge: Version-gated binary extraction; frontend daemon error state.
Post-merge: Socket path constant deduplication;
launchctl bootstrapmigration;unwrapcleanup.Fix cross-window hierarchy sync rendering (eager lazy client, reparen…
Bundle nodespaced and nodespace sidecars; register launchd agent on f…
Fix cross-window hierarchy sync rendering (eager lazy client, reparen…