Skip to content

feat: add attach background mode#321

Merged
ethanpailes merged 2 commits intoshell-pool:masterfrom
tobwen:feature/attach-background
Mar 2, 2026
Merged

feat: add attach background mode#321
ethanpailes merged 2 commits intoshell-pool:masterfrom
tobwen:feature/attach-background

Conversation

@tobwen
Copy link
Contributor

@tobwen tobwen commented Mar 2, 2026

Summary

Adds -b/--background flag to shpool attach for creating sessions with commands and immediate detach. resolves #320

Changes

  • Added -b/--background CLI flag (mutually exclusive with --attach-only)
  • Refactored attach_impl in libshpool/src/attach.rs to return connected client before pipe_bytes
  • Background mode skips interactive signal handling
  • Issues explicit detach after closing attach stream
  • Version mismatch handling is non-interactive in background mode

Behavior

With background flag:

  • Session creation and command initialization proceed normally
  • After closing attach stream, explicit detach is issued
  • Returns immediately without waiting for command completion
  • Error if attempting to attach to busy session with background flag

Rationale

Useful for:

  • Starting background jobs in named sessions for later monitoring
  • Automating session setup without manual intervention
  • Batch operations across multiple sessions

Testing

Run integration tests:

cargo test --test attach background

Tests

  • busy_background: Error when attaching to busy session with background flag
  • background_custom_cmd: Basic background command execution
  • busy_background_force: Validates -f + -b restriction

@google-cla
Copy link

google-cla bot commented Mar 2, 2026

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@tobwen tobwen force-pushed the feature/attach-background branch 4 times, most recently from f6830cb to ff107a2 Compare March 2, 2026 17:28
Copy link
Contributor

@ethanpailes ethanpailes left a comment

Choose a reason for hiding this comment

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

Just one little nit. Overall, this looks great. Seems like a good feature and the code and tests all look clean.

@ethanpailes
Copy link
Contributor

Looks like there are some lints that are grumpy at you. Feel free to just suppress the too-many-args one.

@tobwen tobwen force-pushed the feature/attach-background branch from ff107a2 to 2f688c8 Compare March 2, 2026 17:53
@tobwen tobwen force-pushed the feature/attach-background branch from 2f688c8 to 8aff798 Compare March 2, 2026 17:54
@ethanpailes
Copy link
Contributor

Looks like there are still some lint failures. To suppress the failure, you should add a #[clippy::allow(...)] block above the run method that has the lint failure (https://github.com/shell-pool/shpool/actions/runs/22588665489/job/65441921530?pr=321)

@tobwen
Copy link
Contributor Author

tobwen commented Mar 2, 2026

To suppress the failure, you should add a #[clippy::allow(...)] block above the run method that has the lint failure

Sorry for the noise. I added it now.

@ethanpailes
Copy link
Contributor

Looks like a flaky test since they passed before and the only change is a lint suppression. I'm just going to merge.

@ethanpailes ethanpailes merged commit 76a6acc into shell-pool:master Mar 2, 2026
5 of 7 checks passed
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.

[HAS PR] Feature Request: Add background mode to shpool attach

2 participants