Skip to content

Start the launcher on demand, without a service - #376

Merged
hanthor merged 2 commits into
tuna-os:mainfrom
HuntedRaven7:launcher-on-demand-start
Nov 18, 2026
Merged

hanthor merged 2 commits into
tuna-os:mainfrom
HuntedRaven7:launcher-on-demand-start

Conversation

@HuntedRaven7

Copy link
Copy Markdown
Collaborator

What this solves

Bluefin's packaging PR included a compass.service, and its maintainer asked whether the launcher could work without a service on the machine. It already had most of the answer — compass start self-starts its engine, and login start runs compass start --hidden — but with no service and no login-start entry, the first press of the Super+Space shortcut (compass toggle) used to fail with "no Compass engine is listening".

Now the commands a person binds to a key start what they need and let it outlive the short-lived CLI process:

  • toggle / show: when no engine answers, spawn a detached compass start (new process group, null stdio) and wait for the engine's own DescribeWindow to report the window shown. The window is already visible, so nothing further is sent. An engine that is already up keeps the ordinary IPC path, including the honest "no launcher window is connected" refusal.
  • query: start a hidden session when there is a graphical session (so the launcher is ready for the next summon), or a headless serve --no-hotkey when there is not, then wait for readiness before querying.
  • hide / ping keep their existing no-engine refusal.

The existing UI lease makes concurrent cold starts safe. No new IPC, protocol bump, D-Bus name, socket activation or unsafe is added. packaging/systemd/compass.service stays as an optional packager fallback; nothing enables or requires it.

ADR-0023 records the decision, the alternatives (service requirement, default-on autostart, D-Bus/socket activation, a new WindowPresence request) and what would reopen it.

Tests

  • crates/compass/tests/activation_cli.rs: a cold query starts an engine that survives the command, is reused by later clients and stops on shutdown.
  • crates/compass/tests/cli.rs: updated for the readiness ping and added a check that a cold window command with no display explains why it cannot start.
  • cargo fmt --all -- --check, cargo clippy -p compass --all-targets -- -D warnings, cargo doc -p compass --no-deps (RUSTDOCFLAGS=-D warnings) and the compass test suites all pass locally. One pre-existing test (host_commands::tests::the_runner_finds_brew...) fails in this container because ksshaskpass is on PATH; it is unrelated to these changes.

Docs updated: docs/getting-started.md, packaging/README.md, docs/crates.md, ADR-0015's open question and the ADR index.

HuntedRaven7 and others added 2 commits November 18, 2026 14:03
Bluefin's packaging PR asked whether Compass can work with no compass.service
running. The systemd unit is only one of several start paths, but with no
service and no login-start entry the first hotkey press used to fail: toggle
was a pure IPC client and nothing was listening.

The summoning commands now start what they need and let it outlive them:
- toggle/show spawn a detached, visible 'compass start' when no engine
  answers, then wait for the engine's own DescribeWindow to report the
  window shown.
- query starts a hidden session with a display, or a headless 'serve' without
  one, and waits for readiness before querying.
- hide and ping keep their honest no-engine refusal, and an engine that is
  already up keeps the ordinary IPC path.

This adds no IPC, protocol bump, D-Bus activation or unsafe code; the UI lease
makes concurrent cold starts safe. The systemd unit stays as an optional
packager fallback. ADR-0023 records the decision.

@tuna-reef-hive tuna-reef-hive Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Decision needed: @hanthor should decide whether compass toggle, show and query may start a detached engine and window on demand, as the new ADR-0023 proposes, or whether packagers should have to supply a service or a login-start entry.

I found no code defect, but this PR is a policy decision. It adds a new ADR (docs/rust-engine/adr/0023-the-launcher-starts-on-demand.md) and makes CLI commands spawn a long-lived process, so it should not land without a maintainer's call.

What I read

  • crates/compass/src/activation.rs (new), the window_command and query call sites in lib.rs, session::listening (session.rs:35), and describe_window (serve/launch.rs:184).
  • The logic holds together: start() spawns compass start in its own process group with null stdio and polls listening. It reports a child that exits early with a failure, and it keeps waiting when a duplicate starter exits cleanly after losing the UI lease. window_open maps DescribeWindow to "on screen", which matches WindowState { open } (protocol.rs:1537).
  • The changes to tests/cli.rs follow from the new readiness Ping in window_command, and hide and ping still refuse without an engine.

Open question for the maintainer: the PR body states the motivation as a Bluefin packager's request for a launcher that works without compass.service. Whether the CLI should spawn a persistent daemon on first use (ADR-0023, with the alternatives it lists) is a product and packaging decision. The PR body does not point to an approval of it.

Low, docs accuracy — activation.rs, doc comment on ensure_window: it says an engine with a hidden window "gets the same treatment as a cold start". The only caller, window_command in lib.rs, calls it only when session::listening is false. A running engine with a hidden or missing window therefore still takes the ordinary "no launcher window is connected" path. The PR body says this is deliberate, so the comment should say the same.

Not verified: CI had not started on a2a06a4 when I read it (all checks queued). The PR says the compass suites pass locally, and I did not compile or run them.

— hive: agent=reviewer backend=claude model=claude-sonnet-5-5 effort=high claude=2.1.322

@tuna-reef-hive

Copy link
Copy Markdown

Hive status — updated in place; edits do not notify. Full history is in the Activity Monitor.

@HuntedRaven7 this PR is held at stage/071-needs-author and the hive will not merge it yet.

Why:

  • the review swarm returned requires_human: it has a question for you, not a fix for the hive
  • the reviewer asked you: hanthor should decide whether compass toggle, show and query may start a detached engine and window on demand, as the new ADR-0023 proposes, or whether packagers should have to supply a service or a login-start entry.

Next: the hive does not push to your branch. Push a new head (or reply here); CI and the review swarm re-run automatically and the PR returns to the normal path.

@hanthor hanthor left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Reviewed: cold toggle/show/query start a detached session (own process group, null stdio) only when no engine answers; the lease handles concurrent cold starts; no-display refuses with a clear message; ADR-0023 records the decision. All 31 checks green. Thanks!

@hanthor
hanthor merged commit 5b5787b into tuna-os:main Nov 18, 2026
31 checks passed
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.

2 participants