Suppress compose code lenses for documents outside the workspace - #544
Merged
Brandon Waterloo [MSFT] (bwateratmsft) merged 7 commits intoAug 13, 2026
Merged
Conversation
Copilot started work on behalf of
Brandon Waterloo [MSFT] (bwateratmsft)
July 22, 2026 18:36
View session
Copilot
AI
changed the title
[WIP] Fix code lens issue for files outside workspace
Suppress compose code lenses for documents outside the workspace
Jul 22, 2026
Copilot started reviewing on behalf of
Brandon Waterloo [MSFT] (bwateratmsft)
July 23, 2026 14:36
View session
Contributor
There was a problem hiding this comment.
Pull request overview
Prevents Compose service-startup code lenses (“Run All Services” / “Run Service”) from appearing for Compose documents opened outside any workspace folder, avoiding commands that would error because compose up requires the file to belong to a workspace folder.
Changes:
- Added
isDocumentInWorkspace/isDocumentInWorkspaceFoldersutilities to check whether a document URI belongs to an open workspace folder (with safe prefix matching). - Updated
ServiceStartupCodeLensProviderto gate lens emission on workspace membership (nowasync, returnsundefinedwhen out-of-workspace). - Expanded test infrastructure and coverage to simulate
workspace/workspaceFoldersand validate in/out/no-folder scenarios.
Reviewed changes
Copilot reviewed 5 out of 6 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| packages/compose-language-service/src/service/utils/isDocumentInWorkspace.ts | Adds workspace-folder membership checks (capability-aware) and a pure helper for unit testing. |
| packages/compose-language-service/src/service/providers/ServiceStartupCodeLensProvider.ts | Suppresses service-startup code lenses when the document is outside the workspace. |
| packages/compose-language-service/src/test/TestConnection.ts | Adds mock support for workspace/workspaceFolders via a configurable workspaceFolders field. |
| packages/compose-language-service/src/test/utils/isDocumentInWorkspace.test.ts | Unit tests for URI-within-folder logic (including prefix/sibling edge cases). |
| packages/compose-language-service/src/test/providers/ServiceStartupCodeLensProvider.test.ts | Integration tests for in-workspace/out-of-workspace/no-folders behavior. |
| packages/compose-language-service/bin/docker-compose-langserver | Adds the package bin entrypoint script for launching the language server. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Copilot started work on behalf of
Brandon Waterloo [MSFT] (bwateratmsft)
July 23, 2026 21:01
View session
Addresses PR feedback: - Mark isDocumentInWorkspaceFolders as @internal (exported only for tests) - Inline uriIsWithinFolder into isDocumentInWorkspaceFolders - Replace the raw string-prefix check with WHATWG URL parsing, comparing scheme, authority, and decoded path segments Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Brandon Waterloo [MSFT] (bwateratmsft)
approved these changes
Aug 13, 2026
Brandon Waterloo [MSFT] (bwateratmsft)
marked this pull request as ready for review
August 13, 2026 13:53
Brandon Waterloo [MSFT] (bwateratmsft)
requested a review
from a team
as a code owner
August 13, 2026 13:53
Brandon Waterloo [MSFT] (bwateratmsft)
approved these changes
Aug 13, 2026
The executable bit was flipped incidentally; the file content is unchanged, so revert it to keep the PR diff focused. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Patrick Verbrugge (patverb)
requested changes
Aug 13, 2026
Copilot started work on behalf of
Brandon Waterloo [MSFT] (bwateratmsft)
August 13, 2026 16:03
View session
Co-authored-by: bwateratmsft <36966225+bwateratmsft@users.noreply.github.com>
Brandon Waterloo [MSFT] (bwateratmsft)
approved these changes
Aug 13, 2026
Brandon Waterloo [MSFT] (bwateratmsft)
enabled auto-merge (squash)
August 13, 2026 16:20
Patrick Verbrugge (patverb)
approved these changes
Aug 13, 2026
Brandon Waterloo [MSFT] (bwateratmsft)
deleted the
copilot/fix-code-lens-error
branch
August 13, 2026 17:06
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Compose service-startup code lenses ("Run All Services" / "Run Service") were shown for compose files opened outside the current workspace, and running them errored because the underlying
compose upcommand requires the file to belong to a workspace folder.The
ServiceStartupCodeLensProvidernow consults the client's open workspace folders and only emits lenses when the document is contained within one of them.Changes
isDocumentInWorkspaceutility — Issues aworkspace/workspaceFoldersrequest (when the client advertises the capability) and checks whether the document URI falls under an open folder. Splits into an async, context-aware entry point and a pureisDocumentInWorkspaceFolders(uri, folders)for testability. Prefix matching is slash-normalized sofile:///workspacedoes not matchfile:///workspace-other.ServiceStartupCodeLensProvider— Nowasync; returnsundefinedwhen the document is outside all workspace folders.TestConnection— Answersworkspace/workspaceFoldersvia a settableworkspaceFoldersfield to support integration tests.Note on unsupported clients
When the client does not advertise the
workspaceFolderscapability, the check short-circuits totrueand lenses are shown as before. The issue discussion left this case open; keeping prior behavior avoids regressing clients that can't answer the request. In practice VS Code always advertises the capability, so the gate is active there.