Skip to content

fix(minimald): plumb errors for spawning/attaching to session shells - #383

Merged
twitchyliquid64 merged 1 commit into
mainfrom
tom/session-sandbox
Jun 12, 2026
Merged

fix(minimald): plumb errors for spawning/attaching to session shells#383
twitchyliquid64 merged 1 commit into
mainfrom
tom/session-sandbox

Conversation

@twitchyliquid64

@twitchyliquid64 twitchyliquid64 commented Jun 11, 2026

Copy link
Copy Markdown
Member

Plumb error handling/values through the session shell attach/spawn path, and surface an error to the user.

For example, a sensible error for not having a minimal.toml in the worktree:

xxx@dsktp:~/minimal$ MINIMAL_SESSION_ID=019eb7a0-36d9-7d41-8286-265d76e9b3ab ssh -o SendEnv=MINIMAL_SESSION_ID -o ProxyCommand='socat - UNIX-CONNECT:/home/xxx/.local/state/minimal/providers/local-0/ssh.sock'         -o 'StrictHostKeyChecking=no' -o 'UserKnownHostsFile=/dev/null' local
Warning: Permanently added 'local' (ED25519) to the list of known hosts.
Error attaching to session: init of minimal context: minimal.toml: minimal.toml not found
Connection to local closed.
xxx@dsktp:~/minimal$ 

Summary by CodeRabbit

  • Bug Fixes
    • Improved handling of SSH attach failures: users now receive clear error feedback and channels are closed gracefully on failure.
    • Added validation to ensure terminal/PTY settings are present before attachment to prevent invalid session attempts.
    • Increased startup reliability by ensuring session workspace directories are created during initialization.

@coderabbitai

coderabbitai Bot commented Jun 11, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 471611fb-4ed7-4e57-8810-667acdc64eed

📥 Commits

Reviewing files that changed from the base of the PR and between 85095d1 and 494170e.

📒 Files selected for processing (2)
  • crates/minimald/src/connection.rs
  • crates/minimald/src/session.rs
🚧 Files skipped from review as they are similar to previous changes (2)
  • crates/minimald/src/connection.rs
  • crates/minimald/src/session.rs

📝 Walkthrough

Walkthrough

Threads attach errors through the session actor by introducing a public AttachError, returning Result from SessionHandle::attach and Session::attach, minting hosts with Result propagation, and having the connection handler report attach failures to SSH channels and close them.

Changes

SSH Channel Attach Error Handling

Layer / File(s) Summary
AttachError and actor message plumbing
crates/minimald/src/session.rs
Adds public AttachError enum and updates SessionMessage::Attach to carry a oneshot::Sender<Result<(), AttachError>>. Ensures session workspace directory is created before actor startup and forwards attach results via the actor handler.
Session attach validation and retry
crates/minimald/src/session.rs
Session::attach now returns Result<(), AttachError>, validates PTY presence (NoPty), derives WinSize, attempts host attach, and re-mints the session host on attach failure while preserving Result-based error flow.
Host minting and launcher errors
crates/minimald/src/session.rs
Session::mint_session_host and both session_launcher implementations return Result, mapping context creation and spawn failures to AttachError::ContextCreationFailed / AttachError::SpawnFailed instead of unwrapping.
Public API and connection integration
crates/minimald/src/session.rs, crates/minimald/src/connection.rs
SessionHandle::attach awaits the actor oneshot and returns Result<(), AttachError>. ConnectionHandler::shell_request captures the session handle, checks the attach Result, writes an error to the SSH channel and closes it on failure.

Sequence Diagram(s)

sequenceDiagram
  participant SSHClient
  participant ConnectionHandler
  participant SessionHandle
  participant SessionActor
  participant SessionHost
  SSHClient->>ConnectionHandler: open channel and shell request
  ConnectionHandler->>SessionHandle: attach(channel, config)
  SessionHandle->>SessionActor: send SessionMessage::Attach with oneshot
  SessionActor->>SessionHost: attempt attach with WinSize
  alt attach succeeds
    SessionHost-->>SessionActor: Ok
    SessionActor-->>SessionHandle: Ok
    SessionHandle-->>ConnectionHandler: Ok
  else attach fails
    SessionHost-->>SessionActor: Err(AttachError)
    SessionActor-->>SessionHandle: Err(AttachError)
    SessionHandle-->>ConnectionHandler: Err(AttachError)
    ConnectionHandler-->>SSHClient: write error to channel and close channel
  end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

Suggested reviewers

  • 0chroma
  • evanspearman
  • norrietaylor

Poem

🐰 A rabbit hops through async lanes,
Threads of Result in tidy chains,
Where AttachError speaks its name,
Channels close and logs reclaim,
Hops done — the session stays humane.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately captures the main change: adding error handling (plumbing errors) for session shell spawning and attachment operations, which is the core purpose of this PR.
Docstring Coverage ✅ Passed Docstring coverage is 90.91% which is sufficient. The required threshold is 80.00%.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

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

@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: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 7518bbc9-544a-4cf6-a900-84f2774b8013

📥 Commits

Reviewing files that changed from the base of the PR and between 56f9449 and 85095d1.

📒 Files selected for processing (2)
  • crates/minimald/src/connection.rs
  • crates/minimald/src/session.rs

Comment thread crates/minimald/src/session.rs
@twitchyliquid64
twitchyliquid64 merged commit c8258a5 into main Jun 12, 2026
28 checks passed
@twitchyliquid64
twitchyliquid64 deleted the tom/session-sandbox branch June 12, 2026 02:17
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