Skip to content

Automatically group Docker Swarm stack containers#506

Draft
bwateratmsft with Copilot wants to merge 4 commits into
mainfrom
copilot/add-support-for-swarm
Draft

Automatically group Docker Swarm stack containers#506
bwateratmsft with Copilot wants to merge 4 commits into
mainfrom
copilot/add-support-for-swarm

Conversation

Copilot AI commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

Docker Swarm stack containers carry the com.docker.stack.namespace label but lack com.docker.compose.project, so they appeared as ungrouped "individual containers" instead of grouping by stack like Compose projects do. Users had to manually configure groupBy: Label + groupByLabel: com.docker.stack.namespace as a workaround.

Changes

  • Grouping (ContainerProperties.ts): The default Compose Project Name grouping now falls back to the Swarm stack namespace label, so stack containers group under their stack name with no configuration. Extracted into a getComposeProjectGroup helper:

    export function getComposeProjectGroup(container: ListContainersItem): string {
        return getLabelGroup(container, composeProjectLabel, '')
            || getLabelGroup(container, swarmStackNamespaceLabel, NonComposeGroupName);
    }
  • Group commands (ContainerGroupTreeItem.ts): Compose-only commands (start/stop/restart/down/logs) require compose files that Swarm stacks don't have. contextValue now gates the composeGroup context on isComposeProjectGroup(), so these commands surface only for real Compose projects; stack groups still expand by default and keep the orchestration icon.

  • Updated the Compose Project Name property description, added unit tests for the grouping cases (compose / swarm / both / standalone), and added a CHANGELOG entry.

Note

The issue also mentioned stack-name prefixes in container names feeling redundant. This mirrors Compose exactly (e.g. project-service-1 grouped under project), which the extension intentionally does not strip, so naming is left unchanged for consistency.

Copilot AI changed the title [WIP] Add support for docker swarm container grouping Automatically group Docker Swarm stack containers Jun 17, 2026
Copilot AI requested a review from bwateratmsft June 17, 2026 18:47
@ElRadarNocturno

Copy link
Copy Markdown

Fue un instinto de mi curioaidad

@bwateratmsft bwateratmsft linked an issue Jul 20, 2026 that may be closed by this pull request
@bwateratmsft

Copy link
Copy Markdown
Collaborator

@copilot resolve the merge conflicts in this pull request

Copilot AI commented Jul 23, 2026

Copy link
Copy Markdown
Contributor Author

@copilot resolve the merge conflicts in this pull request

Merged main (a8d7d5c). The conflict was from the monorepo restructure that moved the extension into extensions/vscode-containers/; rename detection carried over my changes to ContainerProperties.ts, ContainerGroupTreeItem.ts, and the CHANGELOG, and I relocated the new unit test to extensions/vscode-containers/src/test/tree/containers/. Build (tsc --noEmit) and lint both pass.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Changelog is curated, please revert

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Updates the Containers explorer “Compose Project Name” grouping so Docker Swarm stack containers (which use com.docker.stack.namespace) are grouped automatically like Compose projects, while ensuring Compose-only group commands only appear for real Compose projects.

Changes:

  • Add getComposeProjectGroup() to derive a group name from com.docker.compose.project with a fallback to com.docker.stack.namespace.
  • Gate composeGroup context to real Compose projects to avoid showing Compose-only commands for Swarm stacks.
  • Add unit tests for compose/swarm/both/standalone grouping behavior and document the change in the changelog.

Reviewed changes

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

File Description
extensions/vscode-containers/src/tree/containers/ContainerProperties.ts Adds Swarm stack label fallback for “Compose Project Name” grouping and updates the property description.
extensions/vscode-containers/src/tree/containers/ContainerGroupTreeItem.ts Gates Compose-only commands via contextValue based on whether the group is actually a Compose project.
extensions/vscode-containers/src/test/tree/containers/ContainerProperties.test.ts Adds unit coverage for the new grouping helper across label combinations.
extensions/vscode-containers/CHANGELOG.md Notes the new automatic Swarm stack grouping behavior under Unreleased.

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

Comment on lines +39 to +41
private isComposeProjectGroup(): boolean {
return (this.ChildTreeItems as ContainerTreeItem[]).some(c => !!c.labels?.[composeProjectLabel]);
}
import { getCommonGroupIcon } from "../settings/CommonProperties";
import { ContainerProperty, getContainerStateIcon, NonComposeGroupName } from "./ContainerProperties";
import { ContainerProperty, composeProjectLabel, getContainerStateIcon, NonComposeGroupName } from "./ContainerProperties";
import { ContainerTreeItem } from "./ContainerTreeItem";
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.

Add support for swarm

4 participants