Hide project/services panels when not in a docker-compose project directory#776
Conversation
Co-authored-by: jesseduffield <8456633+jesseduffield@users.noreply.github.com>
There was a problem hiding this comment.
This should be moved after if gui.DockerCommand.InDockerComposeProject{ .., as otherwise containers from other projects would be incorrectly hidden.
…view Fixed forced project view
There was a problem hiding this comment.
Pull request overview
Adjusts LazyDocker’s side panels and container filtering so that when launched outside a docker-compose project directory, the UI doesn’t force the Projects/Services context and instead shows all containers in a flat list (restoring pre-v0.25 behavior and fixing hidden containers).
Changes:
- Hide the Projects and Services side panels when
InDockerComposeProjectis false. - Apply compose-project filtering in the Containers panel only when
InDockerComposeProjectis true. - Prevent the first visible side panel from being squashed to a fixed compact height unless it’s actually the Project panel.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| pkg/gui/project_panel.go | Hides Projects panel outside compose directories. |
| pkg/gui/services_panel.go | Hides Services panel outside compose directories (removes “any discovered services” exception). |
| pkg/gui/containers_panel.go | Limits project/standalone filtering to compose-project context so all containers show outside compose dirs. |
| pkg/gui/arrangement.go | Only applies compact-height treatment when the first side panel is the Project panel. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| // Only apply project and standalone filtering when we are inside a | ||
| // docker-compose project. Outside of a compose project all | ||
| // containers are shown in a flat list regardless of which compose | ||
| // project they belong to. | ||
| if gui.DockerCommand.InDockerComposeProject { | ||
| // This check must be inside the InDockerComposeProject guard: | ||
| // outside a compose project, services are still derived from | ||
| // container labels, so compose-managed containers from other | ||
| // projects would be incorrectly hidden. | ||
| // | ||
| // Note that this is O(N*M) time complexity where N is the number of services | ||
| // and M is the number of containers. We expect N to be small but M may be large, | ||
| // so we will need to keep an eye on this. | ||
| if !gui.Config.UserConfig.Gui.ShowAllContainers && !isStandaloneContainer(container) { | ||
| return false | ||
| } | ||
|
|
||
| // Filter by selected project. Containers with no project (truly | ||
| // standalone, not from any compose project) are always shown. | ||
| selectedProject := gui.getSelectedProjectName() | ||
| if selectedProject == "" { | ||
| selectedProject = gui.DockerCommand.LocalProjectName | ||
| } | ||
| if selectedProject != "" && container.ProjectName != "" && container.ProjectName != selectedProject { | ||
| return false | ||
| } | ||
| } |
There was a problem hiding this comment.
The filtering behaviour here changed significantly (project filtering is now conditional on InDockerComposeProject). Since this impacts which containers are visible, it would be good to add unit tests covering the Filter logic for (a) InDockerComposeProject=false => compose-labelled containers are not hidden, and (b) InDockerComposeProject=true with ShowAllContainers toggled and selectedProject set/unset to ensure the expected inclusion/exclusion.
This MR contains the following updates: | Package | Update | Change | |---|---|---| | [jesseduffield/lazydocker](https://github.com/jesseduffield/lazydocker) | patch | `v0.25.0` → `v0.25.2` | MR created with the help of [el-capitano/tools/renovate-bot](https://gitlab.com/el-capitano/tools/renovate-bot). **Proposed changes to behavior should be submitted there as MRs.** --- ### Release Notes <details> <summary>jesseduffield/lazydocker (jesseduffield/lazydocker)</summary> ### [`v0.25.2`](https://github.com/jesseduffield/lazydocker/releases/tag/v0.25.2) [Compare Source](jesseduffield/lazydocker@v0.25.0...v0.25.2) #### Changelog - [`697cd44`](jesseduffield/lazydocker@697cd44) Add some claude stuff - [`b17d474`](jesseduffield/lazydocker@b17d474) Fixed forced project view - [`e3c1c86`](jesseduffield/lazydocker@e3c1c86) Hide project/services panels when not in a docker-compose project - [`ebce4fc`](jesseduffield/lazydocker@ebce4fc) Initial plan - [`9134abe`](jesseduffield/lazydocker@9134abe) Merge pull request [#​776](jesseduffield/lazydocker#776) from jesseduffield/copilot/disable-forced-project-view - [`8106125`](jesseduffield/lazydocker@8106125) Merge pull request [#​795](jesseduffield/lazydocker#795) from ddibiasi/copilot/disable-forced-project-view - [`7e7aadc`](jesseduffield/lazydocker@7e7aadc) Merge pull request [#​797](jesseduffield/lazydocker#797) from jesseduffield/support-p-flag - [`3974f6f`](jesseduffield/lazydocker@3974f6f) Support -p flag and DRY up code - [`f5ff116`](jesseduffield/lazydocker@f5ff116) Use IsProjectScoped at remaining call sites + add test </details> --- ### Configuration 📅 **Schedule**: (UTC) - Branch creation - At any time (no schedule defined) - Automerge - At any time (no schedule defined) 🚦 **Automerge**: Enabled. ♻ **Rebasing**: Whenever MR is behind base branch, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this MR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this MR, check this box --- This MR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0My4xMzYuMiIsInVwZGF0ZWRJblZlciI6IjQzLjEzNi4yIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6WyJSZW5vdmF0ZSBCb3QiLCJhdXRvbWF0aW9uOmJvdC1hdXRob3JlZCIsImRlcGVuZGVuY3ktdHlwZTo6cGF0Y2giXX0=-->
v0.25's multi-project discovery caused the Projects and Services panels to always appear, even when launched outside a compose project. Containers were also filtered to the first discovered project, making other running containers invisible.
Changes
project_panel.go: AddedHidereturning!InDockerComposeProject— Projects panel only appears when inside a compose directory.services_panel.go: SimplifiedHidefrom!InDockerComposeProject && len(services) == 0to!InDockerComposeProject. The old check caused the panel to appear whenever other compose containers were running on the system.containers_panel.go: Project-based filtering now only applies whenInDockerComposeProjectis true — outside a compose project, all containers are shown in a flat list regardless of their compose project label.arrangement.go: The compact-size treatment (Size: 3) for the first side panel was unconditional. Now it only applies whensideWindowNames[0] == "project", preventing the Containers panel from being squashed to 3 lines when the Projects panel is hidden.Original prompt
📱 Kick off Copilot coding agent tasks wherever you are with GitHub Mobile, available on iOS and Android.