Skip to content

refactor: drop Desktop beta-settings check; gate hint on LogsTab flag#13755

Merged
glours merged 2 commits into
mainfrom
remove-logs-beta-settings-check
May 18, 2026
Merged

refactor: drop Desktop beta-settings check; gate hint on LogsTab flag#13755
glours merged 2 commits into
mainfrom
remove-logs-beta-settings-check

Conversation

@glours
Copy link
Copy Markdown
Contributor

@glours glours commented Apr 23, 2026

What I did
Docker Desktop is removing the "Enable Logs view" beta setting, so drop the /app/settings check and rely on /features alone. With the setting gate gone, the compose hook subprocess would print the Logs view hint regardless of LogsTab; add a flag check in handleHook. Consolidate engine-label discovery and feature-flag evaluation into internal/desktop.

Related issue

(not mandatory) A picture of a cute animal, if possible in relation to what you did
image

@glours glours marked this pull request as ready for review May 5, 2026 09:03
@glours glours requested a review from a team as a code owner May 5, 2026 09:03
@glours glours requested review from Copilot and ndeloof May 5, 2026 09:03
Copy link
Copy Markdown

@docker-agent docker-agent Bot left a comment

Choose a reason for hiding this comment

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

Assessment: 🟢 APPROVE

This is a clean, well-structured refactor. The changes correctly:

  • Move engine-label discovery from pkg/compose/desktop.go into internal/desktop.EndpointFromEngine (good consolidation)
  • Drop the now-removed /app/settings beta check and rely solely on /features via IsFeatureActive
  • Add IsFeatureActiveStandalone for the hook subprocess which has no existing API client
  • Gate all hint emission on the LogsTab flag in handleHook before encoding any response
  • Stub logsTabEnabled via TestMain so existing tests aren't affected, and add a dedicated TestHandleHook_FeatureFlagDisabledSuppressesHint test for the new gate

No bugs found in the changed code.

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

Refactors Docker Desktop integration gating to rely solely on Desktop feature flags (dropping the removed /app/settings beta setting check), and ensures the compose hook subprocess only emits the Logs view hint when the LogsTab feature flag is enabled.

Changes:

  • Centralized Docker Desktop engine-label endpoint discovery and feature-flag evaluation in internal/desktop.
  • Updated Compose Desktop integration checks to use the new centralized helpers.
  • Gated hook hint emission on the LogsTab feature flag and added coverage to suppress hints when disabled.

Reviewed changes

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

Show a summary per file
File Description
pkg/compose/desktop.go Switched Desktop endpoint/feature checks to centralized internal/desktop helpers.
internal/desktop/client.go Removed settings-based gating; added engine-label discovery and feature-flag gating helpers (including standalone mode).
internal/desktop/client_test.go Removed backend-socket derivation test (function removed); retains integration ping test.
cmd/compose/hooks.go Added LogsTab feature-flag gating before emitting Logs view hints from hook handler.
cmd/compose/hooks_test.go Updated tests for new handleHook signature and added test ensuring hints are suppressed when feature flag is disabled.

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

Comment thread cmd/compose/hooks_test.go Outdated

// TestMain stubs the Docker Desktop feature-flag check so handleHook tests
// don't attempt a live engine call. Individual tests can still override
// isFeatureEnabled with their own stub + t.Cleanup to restore.
Comment thread internal/desktop/client.go Outdated
Comment on lines +152 to +156
// EndpointFromEngine returns the Docker Desktop API socket address advertised
// by the engine in its Info labels, or "" when the active engine is not
// Docker Desktop.
func EndpointFromEngine(ctx context.Context, apiClient client.APIClient) (string, error) {
info, err := apiClient.Info(ctx, client.InfoOptions{})
@glours glours force-pushed the remove-logs-beta-settings-check branch from e547679 to 9874c52 Compare May 7, 2026 08:16
@glours glours self-assigned this May 12, 2026
ndeloof
ndeloof previously approved these changes May 18, 2026
glours added 2 commits May 18, 2026 11:07
Docker Desktop is removing the "Enable Logs view" beta setting, so drop
the /app/settings check and rely on /features alone. With the setting
gate gone, the compose hook subprocess would print the Logs view hint
regardless of LogsTab; add a flag check in handleHook. Consolidate
engine-label discovery and feature-flag evaluation into internal/desktop.

Signed-off-by: Guillaume Lours <glours@users.noreply.github.com>
Pass the active project name as the appId query parameter on the
docker-desktop://dashboard/logs deep link, both from the post-command
hint (compose up -d, compose logs) and the interactive nav menu
('l' key during compose up). The hook subprocess re-runs compose-go's
project loader so the name matches what the parent computed; it skips
the appId when -p, -f, --project-directory, --workdir, or --env-file
is set, since the hook payload does not carry their values. docker
logs stays unfiltered: the CLI hook contract does not expose the
positional container id.

Signed-off-by: Guillaume Lours <glours@users.noreply.github.com>
@glours glours force-pushed the remove-logs-beta-settings-check branch from 9874c52 to d0fe3e6 Compare May 18, 2026 09:09
@glours
Copy link
Copy Markdown
Contributor Author

glours commented May 18, 2026

/review

Copy link
Copy Markdown

@docker-agent docker-agent Bot left a comment

Choose a reason for hiding this comment

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

Assessment: 🟡 NEEDS ATTENTION

2 medium-severity findings in newly added code. Both concern the lack of a timeout on the logsTabEnabled network call in the hook subprocess — a pattern already established by the adjacent resolveAppID 250 ms guard. No high-severity or correctness bugs found.

Comment thread cmd/compose/hooks.go
return nil
}

if !logsTabEnabled(ctx) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[MEDIUM] Missing timeout on logsTabEnabled call — hook subprocess may stall

logsTabEnabled calls IsFeatureActiveStandalone, which initializes a full Docker CLI and makes two sequential network calls: apiClient.Info(ctx) (to detect the Desktop engine label) and an HTTP request to the Desktop socket (/features). Neither the http.Client nor any wrapping context has an explicit short deadline.

The context passed in is cmd.Context(), which is a signal-cancellable context with no deadline. By contrast, the adjacent resolveAppID call is already guarded with a 250ms timeout (projectNameResolveTimeout), showing the authors recognized this pattern for latency-sensitive hook paths.

If the Desktop socket is present but slow (e.g., Desktop is starting up), both calls can block for an OS-level socket timeout — potentially several minutes — stalling the hook subprocess and delaying every docker compose up invocation.

Suggested fix: wrap the logsTabEnabled call in the same timeout pattern used for resolveAppID:

tabCtx, cancel := context.WithTimeout(ctx, 250*time.Millisecond)
defer cancel()
if !logsTabEnabled(tabCtx) {
    return nil
}

// callers without an existing engine API client (e.g. the compose plugin hook
// subprocess). It builds a Docker CLI using the ambient environment to
// resolve the active context, then delegates to IsFeatureActive.
func IsFeatureActiveStandalone(ctx context.Context, feature string) bool {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[MEDIUM] IsFeatureActiveStandalone performs blocking Docker CLI init with no context deadline

dockerCli.Initialize(cliflags.NewClientOptions()) does not accept a context, so the CLI initialization phase (config file reads, context resolution) is not cancellable. Subsequent calls (apiClient.Info(ctx) and the HTTP request to the Desktop /features endpoint) do respect the provided ctx, but the http.Client created in NewClient has no Timeout field — it relies entirely on context cancellation.

In the hook subprocess, ctx is cmd.Context() with no deadline, so a connected-but-unresponsive Desktop process can cause the HTTP call to block indefinitely. This is the deeper root cause of the timeout gap flagged at the handleHook call site.

Consider adding a short timeout at the call site (see cmd/compose/hooks.go), or add a defensive http.Client.Timeout to NewClient.

@glours glours merged commit c59e13c into main May 18, 2026
83 of 103 checks passed
@glours glours deleted the remove-logs-beta-settings-check branch May 18, 2026 15:28
tmeijn pushed a commit to tmeijn/dotfiles that referenced this pull request May 21, 2026
This MR contains the following updates:

| Package | Update | Change |
|---|---|---|
| [docker/compose](https://github.com/docker/compose) | patch | `v5.1.3` → `v5.1.4` |

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>docker/compose (docker/compose)</summary>

### [`v5.1.4`](https://github.com/docker/compose/releases/tag/v5.1.4)

[Compare Source](docker/compose@v5.1.3...v5.1.4)

#### What's Changed

##### ✨ Improvements

- feat: add stop lifecycle hook for external providers by [@&#8203;glours](https://github.com/glours) in [#&#8203;13779](docker/compose#13779)

##### 🐛 Fixes

- fix: route OCI artifact pulls through Docker Desktop HTTP proxy by [@&#8203;glours](https://github.com/glours) in [#&#8203;13770](docker/compose#13770)
- fix: restore stoppingEvent/stoppedEvent helpers for plugin stop hook by [@&#8203;glours](https://github.com/glours) in [#&#8203;13794](docker/compose#13794)
- fix(publish): flag literal inline environment values by [@&#8203;glours](https://github.com/glours) in [#&#8203;13760](docker/compose#13760)

##### 🔧  Internal

- ci: remove unused e2e job from merge workflow by [@&#8203;glours](https://github.com/glours) in [#&#8203;13740](docker/compose#13740)
- chore: update cagent-action to `v1.4.4` by [@&#8203;derekmisler](https://github.com/derekmisler) in [#&#8203;13745](docker/compose#13745)
- Change verb tense in Docker Compose reference documentation by [@&#8203;ryanjbonnell](https://github.com/ryanjbonnell) in [#&#8203;13773](docker/compose#13773)
- pkg/compose: go fix by [@&#8203;thaJeztah](https://github.com/thaJeztah) in [#&#8203;13782](docker/compose#13782)
- refactor: code deduplication and simplification by [@&#8203;ndeloof](https://github.com/ndeloof) in [#&#8203;13759](docker/compose#13759)
- fix: make e2e tests pass reliably locally with Docker Desktop by [@&#8203;glours](https://github.com/glours) in [#&#8203;13741](docker/compose#13741)
- refactor: drop Desktop beta-settings check; gate hint on LogsTab flag by [@&#8203;glours](https://github.com/glours) in [#&#8203;13755](docker/compose#13755)

##### ⚙️ Dependencies

- build(deps): bump github.com/mattn/go-shellwords from `1.0.12` to `1.0.13` by [@&#8203;dependabot](https://github.com/dependabot)\[bot] in [#&#8203;13731](docker/compose#13731)
- build(deps): bump github.com/docker/cli from `29.4.0+incompatible` to `29.4.2+incompatible` by [@&#8203;dependabot](https://github.com/dependabot)\[bot] in [#&#8203;13768](docker/compose#13768)
- build(deps): bump github.com/moby/moby/client from `0.4.0` to `0.4.1` by [@&#8203;dependabot](https://github.com/dependabot)\[bot] in [#&#8203;13752](docker/compose#13752)
- build(deps): bump github.com/docker/cli from `29.4.2+incompatible` to `29.4.3+incompatible` by [@&#8203;dependabot](https://github.com/dependabot)\[bot] in [#&#8203;13776](docker/compose#13776)
- build(deps): bump google.golang.org/grpc from `1.80.0` to `1.81.0` by [@&#8203;dependabot](https://github.com/dependabot)\[bot] in [#&#8203;13775](docker/compose#13775)
- build(deps):  update to `go 1.26.3` by [@&#8203;thaJeztah](https://github.com/thaJeztah) in [#&#8203;13783](docker/compose#13783)
- build(deps): bump google.golang.org/grpc from `1.81.0` to `1.81.1` by [@&#8203;dependabot](https://github.com/dependabot)\[bot] in [#&#8203;13791](docker/compose#13791)
- build(deps): bump github.com/compose-spec/compose-go/v2 from `2.10.2` to `2.11.0` by [@&#8203;dependabot](https://github.com/dependabot)\[bot] in [#&#8203;13798](docker/compose#13798)
- build(deps): bump github.com/docker/cli from `29.4.3+incompatible` to `29.5.1+incompatible` by [@&#8203;dependabot](https://github.com/dependabot)\[bot] in [#&#8203;13796](docker/compose#13796)
- build(deps): bump golang.org/x/sys from `0.42.0` to `0.44.0` by [@&#8203;dependabot](https://github.com/dependabot)\[bot] in [#&#8203;13788](docker/compose#13788)

#### New Contributors

- [@&#8203;ryanjbonnell](https://github.com/ryanjbonnell) made their first contribution in [#&#8203;13773](docker/compose#13773)

**Full Changelog**: <docker/compose@v5.1.3...v5.1.4>

</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 [Mend Renovate](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0My4xODYuNCIsInVwZGF0ZWRJblZlciI6IjQzLjE4Ni40IiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6WyJSZW5vdmF0ZSBCb3QiLCJhdXRvbWF0aW9uOmJvdC1hdXRob3JlZCIsImRlcGVuZGVuY3ktdHlwZTo6cGF0Y2giXX0=-->
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