Add close option for compose group commands#363
Conversation
@microsoft-github-policy-service agree |
|
Apologies for how long it's taken to get to reviewing this--I haven't forgotten though! |
|
No worries! Please take your time 😄 |
There was a problem hiding this comment.
Pull request overview
Adds an opt-in close presentation option to TaskCommandRunnerFactory and applies it to several commands so their task terminals automatically close after completion (notably compose group start/stop/restart/down, plus additional image/registry/compose commands).
Changes:
- Extend
TaskCommandRunnerFactoryoptions withclose?: booleanand map it to VS Code taskpresentationOptions.close. - Enable auto-close for compose group lifecycle commands (start/stop/restart/down) and compose up/down flows.
- Enable auto-close for additional commands (image build/pull/push/run non-interactive, registry pull/logout).
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| extensions/vscode-containers/src/runtimes/runners/TaskCommandRunnerFactory.ts | Adds close option and sets task presentation close behavior. |
| extensions/vscode-containers/src/commands/registries/pullImages.ts | Sets close: true for registry image pulls. |
| extensions/vscode-containers/src/commands/registries/logOutOfDockerCli.ts | Sets close: true for docker CLI logout task. |
| extensions/vscode-containers/src/commands/images/runImage.ts | Sets close: !interactive for run image tasks. |
| extensions/vscode-containers/src/commands/images/pushImage/ImagePushStep.ts | Sets close: true for push image task. |
| extensions/vscode-containers/src/commands/images/pullImage.ts | Sets close: true for pull image tasks (including multi-select loop). |
| extensions/vscode-containers/src/commands/images/buildImage.ts | Sets close: true for image build task. |
| extensions/vscode-containers/src/commands/containers/composeGroup.ts | Passes close through to the task runner for compose group lifecycle commands. |
| extensions/vscode-containers/src/commands/compose/compose.ts | Sets close: true for compose task executions. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if (options.focus || options.close) { | ||
| const presentationOptions: vscode.TaskPresentationOptions = {}; | ||
| if (options.focus) { | ||
| presentationOptions.focus = true; | ||
| } | ||
| if (options.close) { | ||
| presentationOptions.close = true; | ||
| } | ||
| task.presentationOptions = presentationOptions; | ||
| } |
| const client = await ext.runtimeManager.getClient(); | ||
| const taskCRF = new TaskCommandRunnerFactory({ | ||
| taskName: client.displayName, | ||
| close: true, | ||
| }); |
| const client = await ext.orchestratorManager.getClient(); | ||
| const taskCRF = new TaskCommandRunnerFactory({ | ||
| taskName: client.displayName, | ||
| cwd: workingDirectory, | ||
| ...(close !== undefined && { close }), | ||
| }); |
| if (options.focus || options.close) { | ||
| const presentationOptions: vscode.TaskPresentationOptions = {}; | ||
| if (options.focus) { | ||
| presentationOptions.focus = true; | ||
| } | ||
| if (options.close) { | ||
| presentationOptions.close = true; | ||
| } | ||
| task.presentationOptions = presentationOptions; | ||
| } |
There was a problem hiding this comment.
It should be tested to be sure, but I'd be surprised if this was semantically any different from this, which is much cleaner reading IMO:
| if (options.focus || options.close) { | |
| const presentationOptions: vscode.TaskPresentationOptions = {}; | |
| if (options.focus) { | |
| presentationOptions.focus = true; | |
| } | |
| if (options.close) { | |
| presentationOptions.close = true; | |
| } | |
| task.presentationOptions = presentationOptions; | |
| } | |
| task.presentationOptions = { | |
| focus: options.focus, | |
| close: options.close, | |
| }; |
| const taskCRF = new TaskCommandRunnerFactory({ | ||
| taskName: client.displayName, | ||
| workspaceFolder: folder, | ||
| close: true, |
There was a problem hiding this comment.
I think at a minimum, this needs to be a setting (probably advanced tag, default false). Compose Up can include pulling and building images and that's something users may want to look back at after completion (even successful completion).
The same applies for probably all of these except for logOutOfDockerCli, which I think is fine to always close.
| const taskCRF = new TaskCommandRunnerFactory({ | ||
| taskName: client.displayName, | ||
| cwd: workingDirectory, | ||
| ...(close !== undefined && { close }), |
There was a problem hiding this comment.
Haven't tried but I think this would work?
| ...(close !== undefined && { close }), | |
| { close }, |
Summary
Adds support for auto-closing terminals after compose group commands (start, stop, restart, down).
Changes
closeoption toTaskCommandRunnerFactoryto control terminal auto-closecomposeGroupStart,composeGroupStop,composeGroupRestart,composeGroupDown) to passclose: trueTests
Related Issue
Closes #350