Skip registering a few more commands in agents#313649
Conversation
There was a problem hiding this comment.
Pull request overview
This PR further scopes Workbench command/menu registrations so that several file/workspace/layout commands are not exposed in the Agent Sessions window (via IsSessionsWindowContext.negate()), reducing command palette/menu noise in that environment.
Changes:
- Added
IsSessionsWindowContext.negate()toAction2preconditions for various file-related actions. - Added
IsSessionsWindowContext.negate()as thewhenclause for several command palette contributions in files actions contributions. - Extended some existing preconditions (e.g.,
ActiveEditorContext,EmptyWorkspaceSupportContext, workspace state checks) withContextKeyExpr.and(..., IsSessionsWindowContext.negate()).
Show a summary per file
| File | Description |
|---|---|
| src/vs/workbench/contrib/files/browser/fileActions.ts | Adds sessions-window negation to multiple file action preconditions (some combined via ContextKeyExpr.and). |
| src/vs/workbench/contrib/files/browser/fileActions.contribution.ts | Hides additional file commands from the Command Palette in sessions windows by adding when: IsSessionsWindowContext.negate(). |
| src/vs/workbench/browser/actions/workspaceActions.ts | Prevents some workspace actions from being available in sessions windows by extending preconditions. |
| src/vs/workbench/browser/actions/layoutActions.ts | Hides certain layout commands from sessions windows via preconditions and menu when clauses. |
Copilot's findings
- Files reviewed: 4/4 changed files
- Comments generated: 2
| precondition: IsSessionsWindowContext.negate(), | ||
| toggled: ContextKeyExpr.and(IsMacNativeContext.toNegated(), ContextKeyExpr.notEquals(`config.${MenuSettings.MenuBarVisibility}`, 'hidden'), ContextKeyExpr.notEquals(`config.${MenuSettings.MenuBarVisibility}`, 'toggle'), ContextKeyExpr.notEquals(`config.${MenuSettings.MenuBarVisibility}`, 'compact')), | ||
| menu: [{ | ||
| id: MenuId.MenubarAppearanceMenu, | ||
| group: '2_workbench_layout', | ||
| order: 0 | ||
| order: 0, | ||
| when: IsSessionsWindowContext.negate() | ||
| }] |
There was a problem hiding this comment.
workbench.action.toggleMenuBar is now gated in the action’s precondition and the menubar menu item’s when, but the separate Title Bar context menu contribution below still has a when that doesn’t include IsSessionsWindowContext.negate(). In a sessions window this will likely leave a disabled “Menu Bar” entry visible. Consider adding the same sessions-window negation to that Title Bar context menu when as well so the command is consistently hidden there too.
| id: COPY_PATH_COMMAND_ID, | ||
| title: nls.localize2('copyPathOfActive', "Copy Path of Active File"), | ||
| category: Categories.File | ||
| }); | ||
| }, IsSessionsWindowContext.negate()); | ||
| appendToCommandPalette({ | ||
| id: COPY_RELATIVE_PATH_COMMAND_ID, | ||
| title: nls.localize2('copyRelativePathOfActive', "Copy Relative Path of Active File"), | ||
| category: Categories.File | ||
| }); | ||
| }, IsSessionsWindowContext.negate()); |
There was a problem hiding this comment.
These commands are now hidden from the Command Palette in sessions windows, but COPY_PATH_COMMAND_ID / COPY_RELATIVE_PATH_COMMAND_ID are also contributed to MenuId.EditorTitleContext earlier in this file via appendEditorTitleContextMenuItem(...) without an IsSessionsWindowContext guard. If the intent is to keep these out of agent sessions windows entirely, consider also AND-ing IsSessionsWindowContext.negate() into the when used for those editor-title context menu items.
No description provided.