Skip to content

feat(min): move session exec to own subcommand - #1186

Merged
twitchyliquid64 merged 1 commit into
mainfrom
tom/sftp
Aug 7, 2026
Merged

feat(min): move session exec to own subcommand#1186
twitchyliquid64 merged 1 commit into
mainfrom
tom/sftp

Conversation

@twitchyliquid64

@twitchyliquid64 twitchyliquid64 commented Aug 7, 2026

Copy link
Copy Markdown
Member
  • 💣 min session attach <sid> -c
  • Replace with min session exec <sid> <args>

Summary by CodeRabbit

  • New Features

    • Added min session exec <session> <command...> for running commands in sessions.
    • Session names and UUIDs support completion for command execution.
    • Commands preserve individual arguments during execution.
  • Changes

    • Removed the hidden command option from session attach; use session exec for non-interactive commands.
    • Interactive session attachment behavior remains unchanged.
  • Documentation

    • Updated session usage guidance and end-to-end examples for the new workflow.

Note

Add min session exec subcommand for non-interactive command execution in sessions

  • Introduces a new SessionCommand::Exec variant and ExecArgs struct, adding min session exec <session> <command...> as a dedicated CLI subcommand for running commands non-interactively in an existing session via SSH.
  • Removes the hidden command option from min session attach; attach is now purely interactive.
  • Renames attach_to_session to session_via_ssh in lib.rs, accepting a Vec<String> command; when empty, it performs an interactive attach (with TTY check), otherwise a non-interactive exec.
  • Updates stdout_is_data_contract in main.rs to treat session exec (not session attach) as the stdout contract path.
  • Behavioral Change: min session attach no longer accepts a command argument; callers must switch to min session exec.

Macroscope summarized d65a2d9.

@twitchyliquid64
twitchyliquid64 requested a review from a team as a code owner August 7, 2026 20:00
@coderabbitai

coderabbitai Bot commented Aug 7, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The CLI adds session exec for command execution, removes command execution from session attach, and shares SSH session handling between interactive attachment and non-interactive execution. SSH arguments remain separate, with updated tests, documentation, logs, and end-to-end checks.

Changes

Session execution flow

Layer / File(s) Summary
CLI command contract and dispatch
crates/minimal/src/lib.rs, crates/minimal/src/main.rs
Adds ExecArgs and SessionCommand::Exec. Removes the attach command option and dispatches session exec.
SSH command argument forwarding
crates/minimal-client/src/attach.rs, crates/minimal-tui/src/app.rs
Passes command arguments as slices. Non-interactive SSH invocations preserve separate argument boundaries.
Shared session SSH orchestration
crates/minimal/src/lib.rs
Adds cmd_exec and replaces the attach-specific helper with session_via_ssh. Interactive sessions use the TTY guard only when no command is supplied.
Callers, tests, and execution examples
crates/minimal/tests/cli.rs, crates/minimald/src/guest.rs, docs/concepts/sessions.md, scripts/session-e2e.sh
Updates attach callers, diagnostic text, documentation, and end-to-end checks to use session exec.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Sequence Diagram(s)

sequenceDiagram
  participant CLI
  participant cmd_exec
  participant session_via_ssh
  participant SSH
  CLI->>cmd_exec: receive session and command arguments
  cmd_exec->>session_via_ssh: resolve session and invoke SSH
  session_via_ssh->>SSH: forward separate command arguments
  SSH-->>CLI: return command output and exit status
Loading

Possibly related PRs

Suggested reviewers: norrietaylor

Poem

A rabbit checks each SSH cue,
And keeps command arguments true.
Attach stays clear; exec runs,
Tests follow beneath the sun.
Docs and logs now match the trail—
A carrot cheers each passing detail! 🐇

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description explains the behavioral change but omits the required Testing and Checklist sections. Add the required Testing section with commands and results, and add the Checklist with documentation and breaking-change status.
✅ Passed checks (4 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly summarizes the main change and follows the repository's Conventional Commit format.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch tom/sftp

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@crates/minimal-client/src/attach.rs`:
- Around line 133-134: Quote each command element in the loop building the SSH
remote command in crates/minimal-client/src/attach.rs, preserving argument
boundaries and shell safety. Update minimald::handle_exec to unquote or
otherwise normalize the routed command before applying the existing “min ”
prefix routing. In scripts/session-e2e.sh lines 318-332, invoke the shell cases
as argument vectors using sh -c with “echo EXEC_OK $PWD” and “exit 7”.

In `@crates/minimal/src/lib.rs`:
- Around line 207-209: Update the command argument definition in the session
exec CLI options to set required = true, ensuring an empty command is rejected
before reaching session_via_ssh. Keep trailing_var_arg behavior and existing
command parsing intact.

In `@docs/concepts/sessions.md`:
- Around line 235-237: Update the session execution documentation around the
`min session exec` example to state that `ExecArgs` supports arbitrary commands
and arguments non-interactively. Replace the `<session> min run <task>`-specific
syntax with `min session exec <session> <command> [args...]`, and remove the
claim that arbitrary commands require an interactive shell.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: fb571f08-3f71-47d6-8bb5-48d3d3fb9418

📥 Commits

Reviewing files that changed from the base of the PR and between 392551a and 5a0a6a6.

📒 Files selected for processing (8)
  • crates/minimal-client/src/attach.rs
  • crates/minimal-tui/src/app.rs
  • crates/minimal/src/lib.rs
  • crates/minimal/src/main.rs
  • crates/minimal/tests/cli.rs
  • crates/minimald/src/guest.rs
  • docs/concepts/sessions.md
  • scripts/session-e2e.sh

Comment thread crates/minimal-client/src/attach.rs
Comment thread crates/minimal/src/lib.rs
Comment thread docs/concepts/sessions.md Outdated
@twitchyliquid64
twitchyliquid64 merged commit d3ffd1e into main Aug 7, 2026
29 checks passed
@twitchyliquid64
twitchyliquid64 deleted the tom/sftp branch August 7, 2026 20:30
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