Repository navigation
Start the launcher on demand, without a service - #376
Conversation
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.
There was a problem hiding this comment.
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), thewindow_commandandquerycall sites inlib.rs,session::listening(session.rs:35), anddescribe_window(serve/launch.rs:184).- The logic holds together:
start()spawnscompass startin its own process group with null stdio and pollslistening. 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_openmapsDescribeWindowto "on screen", which matchesWindowState { open }(protocol.rs:1537). - The changes to
tests/cli.rsfollow from the new readinessPinginwindow_command, andhideandpingstill 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
|
Hive status — updated in place; edits do not notify. Full history is in the Activity Monitor. @HuntedRaven7 this PR is held at Why:
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
left a comment
There was a problem hiding this comment.
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!
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 startself-starts its engine, and login start runscompass 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 detachedcompass start(new process group, null stdio) and wait for the engine's ownDescribeWindowto 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 headlessserve --no-hotkeywhen there is not, then wait for readiness before querying.hide/pingkeep 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
unsafeis added.packaging/systemd/compass.servicestays 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
WindowPresencerequest) and what would reopen it.Tests
crates/compass/tests/activation_cli.rs: a coldquerystarts an engine that survives the command, is reused by later clients and stops onshutdown.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 becauseksshaskpassis onPATH; 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.