Skip to content

Add sandcat attach command to attach to already running container#52

Merged
adamw merged 2 commits intoVirtusLab:masterfrom
mostr:cli/attach
Apr 20, 2026
Merged

Add sandcat attach command to attach to already running container#52
adamw merged 2 commits intoVirtusLab:masterfrom
mostr:cli/attach

Conversation

@mostr
Copy link
Copy Markdown
Contributor

@mostr mostr commented Apr 20, 2026

Opens a login shell in the already-running agent container of the current project, using find_compose_file to target the right project even when multiple sandboxes run in parallel.

Basically it's a "smart" alias to:

docker compose -f <compose_file> exec -u vscode agent bash --login

Opens a login shell in the already-running agent container of the
current project, using find_compose_file to target the right project
even when multiple sandboxes run in parallel.

    docker compose -f <compose_file> exec -u vscode agent bash --login
Copilot AI review requested due to automatic review settings April 20, 2026 15:36
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds a new sandcat attach CLI command to open a login shell in an already-running agent container for the current project (reusing find_compose_file to target the project’s compose file).

Changes:

  • Introduces a new attach libexec module that runs docker compose ... exec into the agent service as user vscode.
  • Adds an _ fallback for the attach module to catch unmatched subcommands.
  • Documents the new sandcat attach workflow in the main README.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
cli/libexec/attach/attach Implements the attach command using find_compose_file + docker compose exec.
cli/libexec/attach/_ Adds module fallback behavior for unmatched attach subcommands.
README.md Documents how to attach to an already-running container using sandcat attach.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread cli/libexec/attach/attach Outdated
Comment thread cli/libexec/attach/attach Outdated
Comment on lines +12 to +15
local compose_file
compose_file="$(find_compose_file)"

exec docker compose -f "$compose_file" exec -u vscode agent bash --login
Copy link

Copilot AI Apr 20, 2026

Choose a reason for hiding this comment

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

There are Bats tests for other CLI modules (e.g. run, restart-proxy), but this new attach command has no test coverage. Add a cli/test/attach/attach.bats test that stubs docker and asserts the exact docker compose -f <compose_file> exec ... invocation (and, if you keep arg-forwarding, that args are passed through correctly).

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Not sure we need tests for simple command that is basically an alias?

When arguments are provided, pass them through to docker compose exec
instead of always running bash --login. No-arg invocation keeps the
bash --login default.
@adamw adamw merged commit 4a223bf into VirtusLab:master Apr 20, 2026
2 checks passed
@adamw
Copy link
Copy Markdown
Member

adamw commented Apr 20, 2026

Nice, thanks :)

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.

3 participants