Skip to content

refactor(cli): list workspaces with infer workspaces list - #1970

Merged
edenreich merged 1 commit into
mainfrom
feat/issue-1969
Nov 24, 2026
Merged

edenreich merged 1 commit into
mainfrom
feat/issue-1969

Conversation

@edenreich

@edenreich edenreich commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Closes #1969. Stacked on #1968, so its base is feat/daemon-stop. Merge #1968 first, and GitHub moves this PR onto main.

A workspace is a place sessions run, a concept of its own, yet #1968 put its listing under infer sessions beside the commands that act on one session. Workspaces now get their own command group:

infer workspaces list                          # every workspace in daemon.yaml and whether it is reachable
infer sessions run|stop|teleport <session-id>  # what infer sessions keeps
infer daemon stop                              # what infer daemon keeps, besides starting it
  • infer workspaces list prints what infer sessions workspaces printed: 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 sessions keeps run, stop and teleport.
  • The command and its test move from cmd/sessions to cmd/workspaces unchanged, apart from the list subcommand taking no arguments.
  • The docs, the examples' Taskfiles and READMEs, and the chat's error hint (check it with: infer workspaces list) use the new command. docs/commands-reference.md gets an infer workspaces section after infer sessions.

Verification

  • In tmux against the tokenless mock, with an isolated HOME and binding port:
    • infer workspaces list printed Edens-MBP - local agui true storage=jsonl version=dev under its header
    • infer sessions --help lists run, stop and teleport only
    • infer daemon stop stopped the daemon
  • TestPrintWorkspacesListsTheProtocol now runs in cmd/workspaces, and TestCommandTopology lists workspaces.
  • go test -race ./cmd/..., golangci-lint, the import check, markdownlint, and the pre-commit gate.
  • Not run: the Kubernetes teleport examples whose Taskfiles now call infer workspaces list, which need a cluster. The edit there is the command name only.

Cross-repo impact

@edenreich
edenreich requested a review from a team as a code owner November 24, 2026 16:32
@github-project-automation github-project-automation Bot moved this to Todo in 2026 Nov 24, 2026
@edenreich
edenreich added this pull request to stack #1971 November 24, 2026 16:37
Base automatically changed from feat/daemon-stop to main November 24, 2026 16:43
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
edenreich merged commit ca1690c into main Nov 24, 2026
6 checks passed
@edenreich
edenreich deleted the feat/issue-1969 branch November 24, 2026 16:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

[TASK] Refactor move the workspaces listing to infer workspaces

1 participant