Skip extension host restart when adding the first folder to an empty window - #334812
Open
Arunachalam Nachiappan (arun-357) wants to merge 2 commits into
Open
Conversation
Copilot started reviewing on behalf of
Arunachalam Nachiappan (arun-357)
September 6, 2026 16:06
View session
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The restart guard affects unrelated and remote empty-workspace transitions, and the relauncher behavior lacks regression coverage.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
Prevents extension-host restarts when adding the first folder to an empty window.
Changes:
- Skips workspace-entry and relauncher restarts for empty-to-folder transitions.
- Adds native workspace editing regression tests.
File summaries
| File | Description |
|---|---|
workspaceEditingService.ts |
Conditionally skips extension-host restart. |
relauncher.contribution.ts |
Suppresses restart when no prior first folder existed. |
nativeWorkspaceEditingService.test.ts |
Tests restart behavior for empty and folder windows. |
Review details
- Files reviewed: 3/3 changed files
- Comments generated: 2
- Review effort level: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| if (!stopped) { | ||
| return; | ||
| // Skip extension host restart when coming from an empty window (#319944) | ||
| const fromEmptyWorkspace = this.contextService.getWorkbenchState() === WorkbenchState.EMPTY; |
Comment on lines
+347
to
+348
| if (hadFirstFolder) { | ||
| this.extensionHostRestarter.schedule(); // buffer calls to extension host restart |
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.
Fixes #319944
Problem
When a window has no folder open and you Add Folder to Workspace, VS Code restarts the extension host. If Copilot Chat (or another session) is in progress, you get Please confirm restart of extensions — A session is in progress. Confirming kills the chat.
N→N+1folders in an existing multi-root workspace does not restart the host.0→1should behave the same.Two restarts fire on that transition:
NativeWorkspaceEditingService.enterWorkspace— reasonOpening a multi-root workspace(empty window always creates an untitled workspace and enters it).WorkspaceChangeExtHostRelauncher— reasonChanging workspace folders(first folder goes from none → one, for the deprecatedworkspace.rootPathAPI).Skipping only (1) is not enough. Local logs still showed the veto from (2):
Fix
Skip the extension host restart on the 0→1 path only. Storage switch, backup reinit, and
onDidEnterWorkspacestill run. Changing the first folder later (A → B) still restarts the host. Folder → multi-root and remote windows are unchanged.workspaceEditingService.ts— do not stop/start the EH when coming fromWorkbenchState.EMPTY:relauncher.contribution.ts— do not schedule a restart when there was no previous first folder:Notes:
$acceptWorkspaceData(MainThreadWorkspace), same asN→N+1.ChatSessionStorejoiningonDidEnterWorkspace.ExtensionStoragePaths) stays bound to the empty-window workspace id until the next real EH restart. Workbench storage is switched withpreserveData. Extensions that only readrootPathinactivate()can stay stale until then (same class of issue as in-place folder add).Tests
nativeWorkspaceEditingService.test.tsenterWorkspacedoes not callstopExtensionHosts/startExtensionHostsenterWorkspacestill restarts the hostHow to test
./scripts/code.shwith no folder (empty window).Regression: open a single folder, add a second folder via Add Folder to Workspace — EH restart for
enterWorkspacestill applies. In an existing multi-root workspace, adding another folder (not replacing the first) still does not restart.