Repository navigation
refactor(cli): list workspaces with infer workspaces list - #1970
Merged
Merged
Conversation
4 tasks
edenreich
added a commit
that referenced
this pull request
Nov 24, 2026
…infer sessions (#1968) ## Summary The daemon is the process that hosts sessions, not the place to act on them. Yet `infer daemon` carried `workspaces`, `run`, `stop` and `teleport`, so `infer daemon stop` stopped one session, and nothing stopped the daemon itself. Cleaning up a daemon meant reading `~/.infer/run/daemon.pid` and killing it by hand, which is how a daemon from a stale build kept running members in the wrong mode during testing of #1963. Now `infer daemon` starts and stops the process, the session commands live under `infer sessions`, and a stop ends everything the daemon runs gracefully. ```bash infer daemon # start it infer daemon stop # stop it, and everything it runs, gracefully infer sessions workspaces # moved from infer daemon, unchanged infer sessions run|stop|teleport <session-id> # moved from infer daemon, unchanged ``` ### `infer daemon stop` - **It stops the daemon this user runs**, the one holding the lock on `~/.infer/run/daemon.pid`. It sends SIGTERM, waits for the daemon's own shutdown, and kills it if it still runs after a minute. - **A pid file no daemon holds is left alone.** A daemon that crashed leaves its file behind, and that pid may name another process by now, so the pid counts only while the daemon holds the file's lock. - **Stopping no daemon is not an error.** It prints `no infer daemon is running` and exits 0. - **It needs no binding**, so it also stops a daemon from another build that would refuse a client's hello. - `infer daemon` takes no arguments, so a leftover `infer daemon run <id>` fails instead of starting a daemon. ### `infer sessions` `workspaces`, `run`, `stop` and `teleport` move from `cmd/daemon` to `cmd/sessions` unchanged, apart from naming their argument `<session-id>`. The command tree now mirrors the bounded contexts: the daemon hosts the sessions context, it does not own its verbs. ### Everything the daemon runs shuts down gracefully - **Session workers** already did: the daemon sends each an `interrupt`, closes its stdin, and the worker ends its turn and cleans up. - **Scheduled, heartbeat and A2A runs and subagents did not.** `agentheadless.Run` started them with `exec.CommandContext`, whose cancel is a SIGKILL, so a run never got to stop its MCP servers, browser and background shells. `process.TerminateOnCancel` now sends SIGTERM and gives the run 25 seconds before a kill. `infer headless` already shuts down on SIGTERM. - **The scheduler left running jobs behind.** Each job ran on `context.Background()`, so a stop waited 30 seconds and then let the job run on for up to 30 minutes after the daemon exited. The scheduler now cancels its jobs on stop and waits for them. - **Windows** has no SIGTERM, so there `infer daemon stop` kills the daemon. Its session workers still clean up as their stdin closes, but one-shot runs outlive it. This is marked as a `shortcut:` on `daemon.Stop`, to be replaced by a stop frame over the binding once windows needs one. `infer daemon workspaces`, `run`, `stop <id>` and `teleport` are gone. Use `infer sessions workspaces`, `run`, `stop` and `teleport`. There are no deprecated aliases, since keeping them under `infer daemon` would keep the daemon tied to the session verbs. The docs, the examples' Taskfiles and READMEs, and the chat's error hint use the new commands. ## Verification - **End to end in tmux against the tokenless mock** (`INFER_GATEWAY_MOCK`, an isolated `HOME` and binding port), with three children of the daemon running: a chat session worker, a room member holding a `Write` call for approval, and a heartbeat run whose mock turn stalls forever. - `infer daemon stop` printed `stopped the infer daemon (pid 98322)` and returned in 0.13s, with no infer process left. - The daemon log shows every child running its own shutdown (`stopping background shell service`, `stopping job supervisor`, `shutting down agent containers`), the heartbeat run included, the member's pending approval moving to `Cancelled`, then `heartbeat service stopped` and `daemon stopped.` - A second `infer daemon stop` printed `no infer daemon is running`. - `TestStopStopsOnlyTheDaemonHoldingThePidFile`: no pid file, a pid file no daemon holds (its process is not signalled), and the daemon holding it (stopped, its pid returned). - `TestStopKillsAProcessThatIgnoresTheRequestOnceGracePasses`: a process that traps SIGTERM is killed once the grace passes, not before. - `TestACancelledRunShutsDownOnItsOwnBeforeAnyKill`: a cancelled run gets to run its SIGTERM handler. It fails without the change (`lines = ["ready"]`, killed before the handler ran). - `TestCommandTopology` lists `sessions`. `go test -race` for `cmd/...`, `internal/daemon`, `internal/platform/process`, `internal/agent/headless` and `internal/scheduler/...`, plus the pre-commit gate. - **Not run:** the Kubernetes teleport examples whose Taskfiles now call `infer sessions`, which need a cluster. The edit there is the command name only. ## Cross-repo impact - inference-gateway/docs#1307 updates the CLI page, `cli.md`: `infer daemon stop`, the session commands under `infer sessions`, and the workspace listing as `infer workspaces list`, which #1970 moves there from `infer sessions workspaces`. - inference-gateway/infrastructure: its README mentions `infer daemon teleport`. - A code search finds no use of these commands in the desktop app or the opentask extension, which talk to the daemon over the binding.
A workspace is a place sessions run, a concept of its own, yet its listing sat under infer sessions beside the commands that act on one session. infer workspaces list now prints what infer sessions workspaces printed: every workspace in daemon.yaml with its compute, kind, protocol, whether it is reachable and its details. infer sessions keeps run, stop and teleport. The docs, the examples' Taskfiles and READMEs and the chat's error hint use the new command. Verified in tmux against the tokenless mock: infer workspaces list printed the local workspace as reachable, and infer sessions lists run, stop and teleport only.
edenreich
force-pushed
the
feat/issue-1969
branch
from
November 24, 2026 16:43
f47c489 to
f12f811
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #1969. Stacked on #1968, so its base is
feat/daemon-stop. Merge #1968 first, and GitHub moves this PR ontomain.A workspace is a place sessions run, a concept of its own, yet #1968 put its listing under
infer sessionsbeside the commands that act on one session. Workspaces now get their own command group:infer workspaces listprints whatinfer sessions workspacesprinted: each workspace's name, compute, kind, protocol, whether it is reachable, and its details. It asks the running daemon over its binding, as before.infer sessionskeepsrun,stopandteleport.cmd/sessionstocmd/workspacesunchanged, apart from thelistsubcommand taking no arguments.check it with: infer workspaces list) use the new command.docs/commands-reference.mdgets aninfer workspacessection afterinfer sessions.Verification
HOMEand binding port:infer workspaces listprintedEdens-MBP - local agui true storage=jsonl version=devunder its headerinfer sessions --helplistsrun,stopandteleportonlyinfer daemon stopstopped the daemonTestPrintWorkspacesListsTheProtocolnow runs incmd/workspaces, andTestCommandTopologylistsworkspaces.go test -race ./cmd/...,golangci-lint, the import check, markdownlint, and the pre-commit gate.infer workspaces list, which need a cluster. The edit there is the command name only.Cross-repo impact
cli.md, for this PR and feat(daemon): add infer daemon stop and move the session commands to infer sessions #1968:infer workspaces listreplacesinfer daemon workspacesthere.