Add sandcat attach command to attach to already running container#52
Add sandcat attach command to attach to already running container#52adamw merged 2 commits intoVirtusLab:masterfrom
Conversation
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
There was a problem hiding this comment.
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
attachlibexec module that runsdocker compose ... execinto theagentservice as uservscode. - Adds an
_fallback for theattachmodule to catch unmatched subcommands. - Documents the new
sandcat attachworkflow 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.
| local compose_file | ||
| compose_file="$(find_compose_file)" | ||
|
|
||
| exec docker compose -f "$compose_file" exec -u vscode agent bash --login |
There was a problem hiding this comment.
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).
There was a problem hiding this comment.
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.
|
Nice, thanks :) |
Opens a login shell in the already-running agent container of the current project, using
find_compose_fileto target the right project even when multiple sandboxes run in parallel.Basically it's a "smart" alias to: