Skip to content

Move system tray ownership to nodespaced daemon #241

Closed

Description

@malibio

Overview

Under ADR-031 (daemon-client architecture), system tray ownership moves from the Tauri desktop application to nodespaced. The daemon manages the tray icon, tray menu, and UI lifecycle — spawning, focusing, and quitting the Tauri window as directed by tray menu actions.

This delivers the same user experience as the original issue (OneDrive-style background service) but with the correct implementation location: the daemon process that owns the RocksDB lock and all services.

Problem Statement

The original issue placed tray ownership in the Tauri app. Under ADR-031:

  • nodespaced is the long-running background process that must stay alive
  • The Tauri app is a thin UI shell — a gRPC client that can be spawned and killed by the daemon
  • Tray ownership in the Tauri app means the daemon cannot manage UI lifecycle; the tray dies when the UI dies

Proposed Solution

nodespaced runs the system tray using the tray-icon crate (cross-platform, no Tauri dependency). The tray manages the UI window lifecycle: spawn Tauri on "Open NodeSpace", focus if already running, and clean up on "Quit".

Acceptance Criteria

  • nodespaced starts a system tray icon on startup
  • Tray menu: "Open NodeSpace", "Status" (shows connected clients count), "Quit"
  • "Open NodeSpace" spawns the Tauri UI if not running, or focuses it if running
  • "Quit" gracefully shuts down nodespaced and all connected clients
  • Closing the Tauri window hides it (does not quit the daemon or the tray)
  • Tray icon updates to reflect daemon health (running / error state)
  • Works on macOS (primary), with Linux and Windows as secondary targets
  • Tests pass (bun run test:all)
  • Code passes bun run quality:fix

Technical Specifications

Files to create/modify

  • packages/daemon/src/tray.rs (NEW) — tray setup, menu definition, event handler
  • packages/daemon/src/main.rs — initialize tray on daemon startup, pass UI binary path
  • packages/desktop-app/src-tauri/src/main.rs — remove existing tray code; handle close → hide behavior via Tauri window event

Crate

tray-icon crate (cross-platform system tray, does not require Tauri):

# packages/daemon/Cargo.toml
tray-icon = "0.14"

Tray menu structure

Open NodeSpace
─────────────
Status: X clients connected
─────────────
Quit

UI lifecycle management

The daemon holds the path to the Tauri binary. On "Open NodeSpace":

  1. Check if a Tauri window is already connected (via active gRPC client list)
  2. If connected: send a focus event via gRPC stream
  3. If not connected: std::process::Command::new(tauri_binary_path).spawn()

Existing Tauri tray code to remove

  • packages/desktop-app/src-tauri/src/tray.rs — delete
  • References in packages/desktop-app/src-tauri/src/main.rs — remove tray setup

Dependencies

  • Daemon binary must exist (nodespaced binary setup issue)

Related Issues

Activity

  1. added
    enhancement
    on Oct 12, 2025
  2. changed the title [-]Add Background Service Mode with System Tray (OneDrive-style)[/-] [+]Move system tray ownership to nodespaced daemon[/+] on May 17, 2026
  3. malibio commented on May 17, 2026

    @malibio
    CollaboratorAuthor

    Architecture update: tray moves to nodespaced (ADR-031)

    Under ADR-031 (daemon-client architecture), the system tray can no longer live in the Tauri app. The Tauri app is now a thin UI shell (gRPC client) that can be spawned/killed. nodespaced is the persistent background process and the correct owner of the tray icon.

    • Implementation location changes: packages/daemon/src/tray.rs instead of src-tauri/src/tray.rs
    • Crate changes: tray-icon (no Tauri dep) instead of Tauri's built-in tray API
    • The user-facing behavior (hide-to-tray, tray menu, background persistence) is unchanged

    The existing Tauri tray code (src-tauri/src/tray.rs) will be deleted as part of this work.

  4. added and removed
    enhancement
    on May 17, 2026
  5. self-assigned this
    on May 17, 2026
  6. malibio commented on May 17, 2026

    @malibio
    CollaboratorAuthor

    Baseline test results before starting work on issue #241:

    Frontend: 3918 passed (128 test files), 0 failures
    Duration: 47.70s

    Starting implementation: moving system tray ownership from Tauri desktop app to nodespaced daemon per ADR-031.

  7. added a commit that references this issue on Jun 22, 2026
    af6d074
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