feat: Separate daemon and show UI into their own commands and add additional utility commands #45

Merged
javif89 merged 26 commits from feat/waycast-commands into master 2026-07-06 22:56:02 +00:00
Owner

Replaces Waycast's implicit "first call starts the daemon, later calls show the UI" behavior with an explicit subcommand-driven CLI. This resolves the previous ambiguity where your keybind to show the launcher could accidentally start the daemon.

What changed

CLI is now subcommand-required (src/main.rs)

  • command went from Option<Command> to a required Command — running bare waycast no longer does anything implicit.
  • main now returns Result<(), StartupError> and dispatches to handlers in the new cmd module.
  • The old start_waycast() flow — which relied on the singleton lock to decide "start daemon vs. send show" — is gone, along with its TODOs about ownership hacks and latency.

New src/cmd/mod.rs module houses one handler per command and owns StartupError (moved out of main.rs, expanded with DaemonNotRunning, TokioRuntimeFailed, and DataError variants).

New commands

Command Behavior
waycast daemon Explicitly starts the daemon (creates XDG dirs, initializes config, shows the "Waycast started" notification, runs the app). If already running, warns and exits 0.
waycast show Connects to the socket and sends show. This is what a keybind should be bound to.
waycast status Pings the daemon; prints "Waycast is running" or logs that it's not.
waycast cache clear Opens a writable DB connection on a current-thread Tokio runtime and clears the cache table.
waycast config Prints the resolved AppConfig (debug format).
waycast version Unchanged behavior, moved into cmd.

Supporting changes

  • Ping protocol (src/socket.rs, src/app.rs): new AppMessage::Ping + "ping" socket command; daemon logs receipt. Backs status.
  • Socket error handling (src/socket.rs): removed the unused SocketCommand enum; added a SocketError type. WaycastSocketCient::new / send_show / send_ping now return Result instead of .expect()-panicking on a missing daemon — the reason status can cleanly report "not running."
  • Cache repo (src/core/data/cache.rs): added CacheRepository::clear() (truncate the cache table).
  • systemd unit (modules/home-manager/waycast.nix): ExecStart now runs <exe> daemon instead of bare exe, matching the new explicit start.
  • devenv (devenv.nix): run script uses unquoted $@ so subcommands/args pass through to the binary.

Notes for reviewers

  • Ping is fire-and-forget: status reports success once the write succeeds; the daemon never sends a reply back, so "running" really means "socket accepted the write." Good enough for diagnosis, not a true health check.
  • A new sqlx .sqlx/query-*.json offline cache file is included for the clear query.
  • AppError typo fix: ApplicationErorApplicationError.

Depends on #38 being merged first so this can target master.

Closes #18

Replaces Waycast's implicit "first call starts the daemon, later calls show the UI" behavior with an explicit subcommand-driven CLI. This resolves the previous ambiguity where your keybind to show the launcher could accidentally start the daemon. ## What changed **CLI is now subcommand-required (`src/main.rs`)** - `command` went from `Option<Command>` to a required `Command` — running bare `waycast` no longer does anything implicit. - `main` now returns `Result<(), StartupError>` and dispatches to handlers in the new `cmd` module. - The old `start_waycast()` flow — which relied on the singleton lock to decide "start daemon vs. send show" — is gone, along with its TODOs about ownership hacks and latency. **New `src/cmd/mod.rs` module** houses one handler per command and owns `StartupError` (moved out of `main.rs`, expanded with `DaemonNotRunning`, `TokioRuntimeFailed`, and `DataError` variants). ## New commands | Command | Behavior | |---|---| | `waycast daemon` | Explicitly starts the daemon (creates XDG dirs, initializes config, shows the "Waycast started" notification, runs the app). If already running, warns and exits `0`. | | `waycast show` | Connects to the socket and sends `show`. This is what a keybind should be bound to. | | `waycast status` | Pings the daemon; prints "Waycast is running" or logs that it's not. | | `waycast cache clear` | Opens a writable DB connection on a current-thread Tokio runtime and clears the `cache` table. | | `waycast config` | Prints the resolved `AppConfig` (debug format). | | `waycast version` | Unchanged behavior, moved into `cmd`. | ## Supporting changes - **Ping protocol** (`src/socket.rs`, `src/app.rs`): new `AppMessage::Ping` + `"ping"` socket command; daemon logs receipt. Backs `status`. - **Socket error handling** (`src/socket.rs`): removed the unused `SocketCommand` enum; added a `SocketError` type. `WaycastSocketCient::new` / `send_show` / `send_ping` now return `Result` instead of `.expect()`-panicking on a missing daemon — the reason `status` can cleanly report "not running." - **Cache repo** (`src/core/data/cache.rs`): added `CacheRepository::clear()` (`truncate the cache table`). - **systemd unit** (`modules/home-manager/waycast.nix`): `ExecStart` now runs `<exe> daemon` instead of bare exe, matching the new explicit start. - **devenv** (`devenv.nix`): `run` script uses unquoted `$@` so subcommands/args pass through to the binary. ## Notes for reviewers - **Ping is fire-and-forget**: `status` reports success once the write succeeds; the daemon never sends a reply back, so "running" really means "socket accepted the write." Good enough for diagnosis, not a true health check. - A new sqlx `.sqlx/query-*.json` offline cache file is included for the `clear` query. - `AppError` typo fix: `ApplicationEror` → `ApplicationError`. Depends on #38 being merged first so this can target master. Closes #18
javif89 requested review from xbazzi 2026-07-06 18:48:10 +00:00
javif89 changed target branch from refactor/app-container to master 2026-07-06 22:38:44 +00:00
javif89 force-pushed feat/waycast-commands from 8e4eb05b03 to 42cebbf0cd 2026-07-06 22:40:47 +00:00 Compare
xbazzi approved these changes 2026-07-06 22:55:02 +00:00
xbazzi left a comment

lgmt 🫡

lgmt 🫡
javif89 merged commit 115c36365c into master 2026-07-06 22:56:02 +00:00
javif89 deleted branch feat/waycast-commands 2026-07-06 22:56:04 +00:00
Sign in to join this conversation.
No description provided.