Skip to content

feat: report attachments in shpool list --json#379

Open
GeoffChurch wants to merge 4 commits into
shell-pool:masterfrom
GeoffChurch:feat/list-attachments
Open

feat: report attachments in shpool list --json#379
GeoffChurch wants to merge 4 commits into
shell-pool:masterfrom
GeoffChurch:feat/list-attachments

Conversation

@GeoffChurch

Copy link
Copy Markdown
Contributor

Issue Link

Discussion #378

AI Policy Ack

Please ack that you have read the AI Policy
and explain your use of AI to generate this PR.

ack

I vibe coded the initial draft, and then iterated on that with both meats and vibes.

This PR was:

  • mostly or completely vibe coded
  • mostly or completely meat coded
  • bit of both

Description

In the shpool list --json output, add an attachments field to each session with each attachment's original template string (e.g. "{workspace}-edit" or "htop") and its attach proc pid. Currently, a session has at most one attachment, but it's provided here as a list in case #40 comes to fruition.

For example,

$ shpool list --json
{
  "sessions": [
    { "name": "myproj-edit", "status": "Attached",     "attachments": [ { "template": "{workspace}-edit", "pid": 1234 } ], ... },
    { "name": "myproj-term", "status": "Disconnected", "attachments": [],                                                  ... },
    { "name": "htop",        "status": "Attached",     "attachments": [ { "template": "htop",             "pid": 4321 } ], ... }
  ]
}

External tools can then check or signal the attach proc using the pid field, and relate variables (from shpool var list) to sessions and attachments using the template field (e.g. a TUI could preview which attachments would respond to a proposed variable change).

Note that, while attachments is a list in the JSON output, in the code it's an Option (not a Vec), to avoid the footgun of e.g. assuming a premature Vec will always be of length <= 1. An eventual #40-like change would force an explicit, self-contained migration to Vec to pass typechecking. There might even be an argument in favor of making it a nullable field in the JSON, instead of a list.

@ethanpailes ethanpailes left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks pretty good, just a few comments, no major refactor asks.

Comment thread libshpool/src/daemon/server.rs Outdated
Comment thread libshpool/src/daemon/server.rs Outdated
Comment thread libshpool/src/daemon/server.rs Outdated
Comment thread shpool-protocol/src/lib.rs Outdated
@ethanpailes

Copy link
Copy Markdown
Contributor

I squeezed out a release on you again so you'll need to rebase.

@GeoffChurch GeoffChurch force-pushed the feat/list-attachments branch from a73d7c0 to 5ce84e6 Compare June 9, 2026 19:40
This patch adds a per-session `attachments` list to `shpool list --json`. Each attachment reports the session name template the client attached with (e.g. `{workspace}-edit`) and the pid of its `shpool attach` process, so external tools can e.g. show how attachments would be affected by a `shpool var set`, or offer to SIGKILL an attach process.

Currently, a session has at most one attachment, but it is reported as a list in case shpool later supports multiple attachments (shell-pool#40).
Leaves room for e.g. `Attachment::start_cmd_template` by not using a broad name like `Attachment::template`
@GeoffChurch GeoffChurch force-pushed the feat/list-attachments branch from 5ce84e6 to 19103b1 Compare June 9, 2026 20:04
The attachment is maintained/read in lockstep with the timestamps, so it can live in the same struct behind the same lock.

Rename `SessionLifecycleTimestamps` to `SessionLifecycleState` since it now holds more than timestamps.

Encapsulate the lock as a private field in a new `SessionLifecycle` type.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants