Sessions
A session is the durable backing of a remote terminal: a PTY plus a ringbuffer plus an idle TTL. Sessions outlive the client. Detach with Ctrl+D and the session keeps running on the target machine; reattach interactively from anywhere with cmdop connect.
Interactive (live PTY) reattach today is done with cmdop connect <host>. The cmdop session attach <id> command currently prints the session’s metadata (shell, working directory) and marks it attached — an interactive shell takeover over session attach is on the roadmap, not yet implemented.
What a session is
When you cmdop connect vps-audi, the daemon spawns or reuses a session on vps-audi and gives you a live interactive terminal. The session owns the PTY, the running processes, and a scrollback ringbuffer. Closing the client doesn’t kill the session — it survives until you destroy it or the idle TTL expires.
Create / list
cmdop session create vps-audi --name deploy
cmdop session list # all your sessions
cmdop session list --host vps-audi
cmdop session list --jsonA bare cmdop connect vps-audi also creates a session implicitly — cmdop session create is for when you want to script the creation without attaching immediately.
Attach / detach
cmdop session attach 0193e2c1-7a8f-7b33-8c01 # prints metadata, marks attached
cmdop session attach deploy # by name (if unique on this host)
cmdop session detach 0193e2c1-7a8f-7b33-8c01cmdop session attach currently reports the session’s metadata and marks it attached; it does not yet open an interactive shell over the session. For a live terminal, use cmdop connect <host> — that reattaches to the running session interactively. Interactive takeover via session attach (including a --takeover flag to force-detach other clients) is planned, not yet implemented.
Save / restore
cmdop session save 0193e2c1-... --to ./session-snapshot.json
cmdop session restore --from ./session-snapshot.jsonsave snapshots the ringbuffer (last N lines) and PTY metadata. restore is for migrating session metadata between machines — rare, mostly for internal tooling.
Destroy
cmdop session destroy 0193e2c1-7a8f-7b33-8c01
cmdop session destroy --idle 24h # nuke all idle for >24hDestroy kills the PTY and removes the ringbuffer. Sessions also auto-expire after the configured idle TTL (default 7 days).
Triggers vs sessions
Both live under cmd/cmdop/cmds/session/ because both are stateful CLI concepts:
| Sessions | Triggers | |
|---|---|---|
| Trigger | Operator attach | Cron schedule |
| Lifetime | Idle TTL | Until disabled |
| Output | Live PTY | Logs + Board entry |
| Use for | Interactive work | Scheduled automation |
See ./trigger for the scheduled-task surface.
Inspecting session ringbuffers
cmdop session show 0193e2c1-... # metadata
cmdop session show 0193e2c1-... --tail 200 # last 200 lines of scrollbackUseful for “what was on screen 4 hours ago?” without reattaching.
Troubleshooting
- “Session shows attached but no input echoes” —
cmdop session attachreports metadata only; for a live interactive terminal usecmdop connect <host>. If another client holds the live PTY, detach it from that client (force-detach viasession attachtakeover is planned, not yet implemented). - “Session disappeared” — check the idle TTL in
~/.cmdop/config.yaml; default is 7 days. - “Cannot create session: target offline” — confirm the target with
cmdop connect --list; remote daemon must be running.