Skip to content

Windows daemon support: Named Pipe transport and SCM service registration #1439

Closed

Description

@malibio

Overview

The daemon has a hard `compile_error!` guard on Windows (`packages/daemon/src/main.rs:49`). The Unix transport (`UnixListener` + `UnixListenerStream`) and service registration (launchd on macOS, systemd on Linux) have no Windows equivalents. This issue implements full Windows parity so the daemon compiles, runs, and auto-starts on Windows exactly as it does on macOS/Linux.

Problem Statement

Windows is excluded from the release build matrix because `nodespaced` cannot compile on Windows — the transport and service registration layers are Unix-only. Without this work, NodeSpace has no Windows desktop app.

Implementation Approach

Phase 1: Named Pipe transport

Add `#[cfg(windows)]` variants of `serve_headless` and `serve_grpc` in `packages/daemon/src/main.rs` using `tokio::net::windows::named_pipe::ServerOptions` in place of `tokio::net::UnixListener`. Wrap the pipe acceptor in a `futures::Stream` compatible with tonic's `serve_with_incoming_shutdown`.

Add a `#[cfg(windows)] pipe_name()` function as a sibling to the existing `#[cfg(unix)] socket_path()`. Pipe name: `\\.\pipe\nodespace-daemon`, overridable via `NODESPACED_SOCKET` env var for consistency with Unix.

Phase 2: Tauri gRPC client

Add a `#[cfg(windows)]` connection path in `packages/desktop-app/src-tauri/src/services/grpc_client.rs` using `Endpoint` over Named Pipe instead of UDS.

Phase 3: Windows SCM service registration

Add a Windows branch in `packages/desktop-app/src-tauri/src/daemon_setup.rs` using the `windows-service` crate. This requires a `service_main` entry point — the daemon binary must support both console mode (dev/direct invocation) and service mode (SCM-managed). Add `windows-service` as a Windows-only dependency in `packages/daemon/Cargo.toml`.

Phase 4: Remove guard and restore CI

Remove the `compile_error!` at `packages/daemon/src/main.rs:49` once everything compiles. Restore Windows to the release workflow matrix including WiX toolset install, Windows sidecar build, and Windows model download steps.

Acceptance Criteria

  • `cargo build --release --bin nodespaced --target x86_64-pc-windows-msvc` compiles without errors
  • Daemon binds a Named Pipe on Windows and accepts gRPC connections
  • Tauri app connects to the daemon via Named Pipe on Windows (no "background service not running" banner)
  • On first launch, daemon is registered as a Windows SCM service and starts automatically
  • On subsequent launches, app detects the running service and connects without re-registering
  • `NODESPACED_SOCKET` env var overrides the pipe name for dev and testing
  • Windows restored to release workflow — build produces both `.msi` and NSIS `.exe` installers
  • No regressions on macOS or Linux builds (`bun run test:all` passes)
  • Code passes `bun run quality:fix`

Technical Specifications

Reference Files

  • Transport (Unix): `packages/daemon/src/main.rs` — `serve_headless`, `serve_grpc`, `socket_path()`, `compile_error!` guard at line 49
  • Service registration: `packages/desktop-app/src-tauri/src/daemon_setup.rs` — launchd (macOS) and systemd (Linux) branches; Windows branch goes here
  • gRPC client: `packages/desktop-app/src-tauri/src/services/grpc_client.rs` — UDS connection logic to mirror for Named Pipe
  • Release workflow: `.github/workflows/release.yml` — Windows matrix entry, WiX step, sidecar build step removed in v0.2.0 release prep

New Dependency

`windows-service` crate — add as a Windows-only dependency:
```toml
[target.'cfg(windows)'.dependencies]
windows-service = "0.7"
```

Named Pipe path convention

  • Default: `\\.\pipe\nodespace-daemon`
  • Override: `NODESPACED_SOCKET` env var (mirrors Unix `NODESPACED_SOCKET` for socket path)

SCM entry point pattern

The `windows-service` crate requires `define_windows_service!` macro and a separate `service_main` fn. The binary detects at startup whether it was invoked by SCM or directly, and branches accordingly — same binary serves both modes.

Signal handling

`install_shutdown_handler` already has a `#[cfg(not(unix))]` fallback using `tokio::signal::ctrl_c` — no changes needed there.

Tray

`tray-icon` uses `tao` which supports Windows — no changes needed to the tray layer.

Non-Goals

  • Windows ARM support (x86_64-pc-windows-msvc only for now)
  • Windows code signing (separate concern)
  • Supporting Windows versions below Windows 10

Related Issues

Activity

  1. malibio commented on Jun 22, 2026

    @malibio
    CollaboratorAuthor

    Frontend: 140 passed (3885 tests)

  2. self-assigned this
    on Jun 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions