feat: add workspaceFile property to devcontainer.json for auto-open…#297244
Draft
briansilah wants to merge 2 commits intomicrosoft:mainfrom
Draft
feat: add workspaceFile property to devcontainer.json for auto-open…#297244briansilah wants to merge 2 commits intomicrosoft:mainfrom
workspaceFile property to devcontainer.json for auto-open…#297244briansilah wants to merge 2 commits intomicrosoft:mainfrom
Conversation
…ing workspace files When connecting to a remote environment (Codespace, Dev Container), there is no way to specify a `.code-workspace` file to open automatically. Users must manually find and open the workspace file after the default folder loads, causing a reload and poor first-run experience — especially in monorepos where workspace files are generated during lifecycle hooks. This adds a `customizations.vscode.workspaceFile` property to devcontainer.json that tells VS Code which `.code-workspace` file to open. If the file doesn't exist at connection time (e.g., still being generated by postCreateCommand), VS Code falls back to the folder and shows a warning notification. Changes: - Schema: add `workspaceFile` to devContainer.vscode and attachContainer schemas - Server: check workspace file existence in webClientServer, fallback to folder - Client: propagate `workspaceFileFallback` flag via IWorkbenchConstructionOptions - Contribution: show warning notification when fallback occurs - Tests: add server-side and browser-side tests Addresses microsoft/vscode-remote-release#3665 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Contributor
📬 CODENOTIFYThe following users are being notified based on files changed in this PR: @bpaseroMatched files:
|
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds support for automatically opening a .code-workspace file in remote environments (Dev Containers, Codespaces) by introducing a workspaceFile property in devcontainer.json. When the specified workspace file doesn't exist at connection time, VS Code falls back to opening the folder and displays a warning notification to the user.
Changes:
- Added
workspaceFileschema property to devcontainer.json (both incustomizations.vscodeand as deprecated top-level property) - Implemented server-side workspace file existence check with fallback logic in webClientServer
- Added
workspaceFileFallbackflag to IWorkbenchConstructionOptions API - Created RemoteWorkspaceFileFallbackNotifier contribution to display warning notification
- Added comprehensive test coverage for both server-side and browser-side logic
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| extensions/configuration-editing/schemas/devContainer.vscode.schema.json | Added workspaceFile property under customizations.vscode with pattern validation and deprecation notice for top-level property |
| extensions/configuration-editing/schemas/attachContainer.schema.json | Added workspaceFile property to attach container schema with pattern validation |
| src/vs/server/node/webClientServer.ts | Implemented workspace file existence check using fs.promises.stat, with fallback to folder URI and flag propagation |
| src/vs/workbench/browser/web.api.ts | Added workspaceFileFallback optional boolean property to IWorkbenchConstructionOptions interface |
| src/vs/workbench/contrib/remote/browser/remoteWorkspaceFileFallback.ts | Created notification contribution that displays sticky warning when workspace file fallback occurs |
| src/vs/workbench/contrib/remote/browser/remote.contribution.ts | Registered RemoteWorkspaceFileFallbackNotifier with WorkbenchPhase.AfterRestored |
| src/vs/server/test/node/webClientServer.test.ts | Added comprehensive server-side tests for workspace file fallback logic |
| src/vs/workbench/contrib/remote/test/browser/remoteWorkspaceFileFallback.test.ts | Added browser-side tests for notification behavior under various conditions |
Author
|
@microsoft-github-policy-service agree company="Microsoft" |
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.
Summary
customizations.vscode.workspaceFileproperty todevcontainer.jsonthat specifies a.code-workspacefile to open automatically when connecting to a remote environment (Codespace, Dev Container)postCreateCommand), VS Code falls back to the folder and shows a warning notificationFixes microsoft/vscode-remote-release#3665
📄 Full Spec Document — design rationale, architecture, edge cases, security, and compatibility analysis
Problem
When a Codespace or Dev Container opens, VS Code connects to the
workspaceFolderspecified indevcontainer.json. Many teams — particularly those with monorepos — generate.code-workspacefiles during lifecycle hooks (e.g.,postCreateCommand). There is currently no way to tell VS Code to automatically openthat workspace file. Users must:
.code-workspacefileThis creates a poor first-run experience, especially for large monorepos where the default folder view is overwhelming without workspace scoping.
Solution
Path is resolved relative to workspaceFolder. Must end in .code-workspace (schema-validated). If the file doesn't exist yet, VS Code falls back to the folder with a sticky warning notification.
Schema Changes (IntelliSense support)
Server Changes (workspace file fallback)
Client Changes (notification plumbing)
Tests
Data Flow
Server (webClientServer.ts)
→ receives --default-folder + --default-workspace from devcontainer CLI
→ fs.stat on workspace file
→ EXISTS: workspaceUri set → client opens workspace directly
→ MISSING: workspaceUri cleared, workspaceFileFallback=true → client opens folder + warning
Out of Scope (future work)
Test Plan