Enable window commands in Agents window#315258
Merged
Merged
Conversation
- Remove IsSessionsWindowContext precondition and menu guards from New Window, Open Folder, Open..., Open Workspace from File, Open Recent, and New Window with Profile commands - In windowsMainService, prevent the Agents window from being reused when opening folders/workspaces by checking isSessionsWindow in doOpenFolderOrWorkspace, doOpenEmpty, and openInBrowserWindow Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
lszomoru
approved these changes
May 8, 2026
Contributor
Screenshot ChangesBase: Changed (5) |
Contributor
There was a problem hiding this comment.
Pull request overview
Enables standard window/workspace commands in the Agents (sessions) window by removing context guards that previously hid/blocked them, while ensuring those commands don’t repurpose the Agents window when they trigger opening a different workspace.
Changes:
- Removed
IsSessionsWindowContext.negate()preconditions/whenclauses so window/workspace commands appear and can run in the Agents window. - Updated
WindowsMainServiceto avoid reusing an Agents window when opening an empty window, folder, or workspace, and to avoid falling back to reusing the last active window if it is an Agents window.
Show a summary per file
| File | Description |
|---|---|
| src/vs/workbench/contrib/userDataProfile/browser/userDataProfile.ts | Allows “New Window with Profile” submenu to appear in the Agents window. |
| src/vs/workbench/browser/actions/workspaceActions.ts | Removes sessions-window guards from “Open Folder / Open… / Open Workspace…” actions and File menubar items. |
| src/vs/workbench/browser/actions/windowActions.ts | Removes sessions-window guards from “New Window” and “Open Recent” actions/menus. |
| src/vs/platform/windows/electron-main/windowsMainService.ts | Prevents reusing an Agents window for open-empty / open-folder / open-workspace flows and avoids lastActiveWindow fallback reuse when it’s an Agents window. |
Copilot's findings
Comments suppressed due to low confidence (1)
src/vs/platform/windows/electron-main/windowsMainService.ts:804
- This block repeats the same sessions-window contextWindowId handling as doOpenEmpty. Refactoring into a shared helper would reduce duplication and lower the risk of one open path behaving differently if this logic changes later.
const contextWindow = this.getWindowById(openConfig.contextWindowId); // fix for https://github.com/microsoft/vscode/issues/49587
if (contextWindow?.config?.isSessionsWindow) {
forceNewWindow = true; // do not replace the agents window
} else {
windowToUse = contextWindow;
- Files reviewed: 4/4 changed files
- Comments generated: 1
Comment on lines
+773
to
+777
| const contextWindow = this.getWindowById(openConfig.contextWindowId); // fix for https://github.com/microsoft/vscode/issues/97172 | ||
| if (contextWindow?.config?.isSessionsWindow) { | ||
| forceNewWindow = true; // do not replace the agents window | ||
| } else { | ||
| windowToUse = contextWindow; |
lszomoru
pushed a commit
that referenced
this pull request
May 8, 2026
- Remove IsSessionsWindowContext precondition and menu guards from New Window, Open Folder, Open..., Open Workspace from File, Open Recent, and New Window with Profile commands - In windowsMainService, prevent the Agents window from being reused when opening folders/workspaces by checking isSessionsWindow in doOpenFolderOrWorkspace, doOpenEmpty, and openInBrowserWindow Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.
This PR enables standard window commands (New Window, Open Folder, Open..., Open Workspace from File, Open Recent, New Window with Profile) in the Agents window.
Changes:
Remove
IsSessionsWindowContextguards — Removedpreconditionand menuwhenclauses that blocked these commands from appearing/running in the Agents window.Prevent Agents window from being reused — In
windowsMainService.ts, when opening a folder or workspace:doOpenFolderOrWorkspace/doOpenEmpty: If the context window is an Agents window, force opening in a new window instead of reusing it.openInBrowserWindow: Skip thelastActiveWindowfallback when it's an Agents window (handles native macOS menu Open Recent items which don't setcontextWindowId).