Skip to content

Start the systemd unit's daemon without --tray when no display is available - #4407

Merged
mstomar125 merged 2 commits into
mainfrom
linux-headless-unit
Nov 30, 2026
Merged

mstomar125 merged 2 commits into
mainfrom
linux-headless-unit

Conversation

@mstomar125

@mstomar125 mstomar125 commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

What

  • The systemd user unit the app writes now omits --tray when neither DISPLAY nor WAYLAND_DISPLAY is set (non-empty) in the app's environment; with a display it is unchanged. The choice is logged at install ("with --tray" / "headless, without --tray").
  • run-app guide: the --tray row now describes the fix; it states exactly what a scratch Linux launch shares with the real home (the enable symlink in ~/.config/systemd/user/default.target.wants/ and the nodespace.service name) and how to avoid it (the transient systemd-run --user unit already documented).

Why

Title: "A headless Linux install does not run the daemon with the tray flag, so it does not crash-loop without a display" and "A scratch launch of the app on Linux can get a service unit the user manager loads, and the run-the-app guide says how".

Daemon-side fallback

On Linux, when --tray is requested but neither DISPLAY nor WAYLAND_DISPLAY is set and non-empty in the daemon's own environment (the user manager's environment can lack the app's), the daemon logs a warning and runs headless. The decision is the pure tray_or_headless in packages/daemon/src/main.rs; only the wiring is cfg-gated to Linux (macOS/Windows unchanged).

Tests

cargo test -p nodespace-app-lib --lib systemd_enable_tests (10 pass): unit with tray ends in --tray; unit without has a bare ExecStart="..." and no --tray; systemd_wants_tray truth table (DISPLAY, WAYLAND_DISPLAY, neither, both empty).

Mutation checks

Unit: always-tray, never-tray, empty-counts-as-display, ignore-Wayland: each fails at least one new/updated test.

Daemon fallback (tray_fallback_tests, 3 tests): failing first (tray-ignores-display stub failed the headless test), then mutations: ignore display check, ignore requested, ignore Wayland, empty-counts-as-set; each fails a test.

Checks

cargo fmt --all --check clean; cargo clippy -p nodespace-app-lib -p nodespace-daemon --all-targets -- -D warnings clean (macOS host).

Not verified

  • The Linux-only wiring (effective_tray_mode) is not compiled on the macOS host; CI Linux builds cover it.
  • No run on a real Linux host (VM not used): the unit was not started under systemd, so "the daemon stays up with no display" rests on --tray being the only trigger of the GTK panic (as documented in the guide) plus the unit text test.
  • The check on a Linux desktop build is not done (none exists yet).
  • A unit written by an older build keeps --tray until the app re-registers.

🤖 Generated with Claude Code

mstomar125 and others added 2 commits November 30, 2026 08:05
…ilable

The app-written unit passed --tray unconditionally; on a host with no
DISPLAY or WAYLAND_DISPLAY the tray panics in GTK and Restart=on-failure
crash-loops the unit. The unit now omits the flag without a display, the
choice is logged, and the run-the-app guide states what a scratch launch
on Linux shares with the real home.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
The unit is written from the app's environment but started by the user
manager, whose environment may lack DISPLAY/WAYLAND_DISPLAY. On Linux the
daemon now runs headless with a warning in that case; the decision is a
pure function tested on every platform. Also fixes rustfmt of a test import.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@mstomar125
mstomar125 merged commit 27a94e4 into main Nov 30, 2026
@mstomar125
mstomar125 deleted the linux-headless-unit branch November 30, 2026 07:05
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