Skip to content

Skip registering a few more commands in agents#313649

Merged
mjbvz merged 1 commit intomicrosoft:mainfrom
mjbvz:dev/mjbvz/bare-urial
May 1, 2026
Merged

Skip registering a few more commands in agents#313649
mjbvz merged 1 commit intomicrosoft:mainfrom
mjbvz:dev/mjbvz/bare-urial

Conversation

@mjbvz
Copy link
Copy Markdown
Collaborator

@mjbvz mjbvz commented May 1, 2026

No description provided.

Copilot AI review requested due to automatic review settings May 1, 2026 04:54
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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() to Action2 preconditions for various file-related actions.
  • Added IsSessionsWindowContext.negate() as the when clause for several command palette contributions in files actions contributions.
  • Extended some existing preconditions (e.g., ActiveEditorContext, EmptyWorkspaceSupportContext, workspace state checks) with ContextKeyExpr.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

Comment on lines +794 to 801
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()
}]
Copy link

Copilot AI May 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
Comment on lines 212 to +220
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());
Copy link

Copilot AI May 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
@mjbvz mjbvz enabled auto-merge May 1, 2026 05:03
@mjbvz mjbvz merged commit 2f60cea into microsoft:main May 1, 2026
30 checks passed
@vs-code-engineering vs-code-engineering Bot added this to the 1.119.0 milestone May 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants