Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 6, 2025

Description

When agent mode is disabled via organization policy (chat.agent.enabled setting managed and set to false), it should appear in the mode picker as a greyed-out option with a lock icon, not hidden entirely.

Changes

Core logic (chatModes.ts)

  • getBuiltinModes() now always includes ChatMode.Agent regardless of hasToolsAgent state
  • Added isAgentModePolicyDisabled() helper to detect policy-managed disabled state via IConfigurationService.inspect().policyValue

Mode picker UI (modePickerActionItem.ts)

  • Modified makeAction() to set enabled: false and add lock icon when agent mode is policy-blocked
  • Tooltip shows "Agent mode has been disabled by your administrator" for disabled state
  • Click action is no-op when disabled

Keyboard navigation (chatExecuteActions.ts)

  • ToggleChatModeAction.getNextMode() filters out policy-disabled modes from cycling (Ctrl+.)

Session validation (chatInputPart.ts)

  • validateAgentMode() switches users away from agent mode if it becomes policy-disabled mid-session
  • currentModeKind getter considers policy-disabled state for consistent fallback to Edit/Ask mode

Tests (chatModeService.test.ts)

  • Updated to reflect agent mode always present in builtin modes
  • Added tests for isAgentModePolicyDisabled() covering policy-enabled, policy-disabled, and no-policy scenarios

Policy Detection

export function isAgentModePolicyDisabled(configurationService: IConfigurationService): boolean {
	const inspection = configurationService.inspect<boolean>(ChatConfiguration.AgentEnabled);
	return inspection.policyValue !== undefined && inspection.policyValue === false;
}

Only treats as "disabled by admin" when both conditions are met:

  1. Policy value exists (organization-managed)
  2. Policy value is false

User-disabled settings without policy are unaffected.

Original prompt

Plan: Show Disabled Agent Mode in Mode Picker

When agent mode is disabled by administrator policy (setting is both disabled AND organization-managed), display it as a greyed-out option in the chat mode picker dropdown with a lock icon and tooltip stating "Agent mode has been disabled by your administrator." The option appears in the Built-In category but is non-clickable with no action on click.

Steps:

  1. Modify getBuiltinModes() in chatModes.ts to always include ChatMode.Agent in the returned array regardless of chatAgentService.hasToolsAgent value, ensuring agent mode always appears in the mode picker under Built-In modes.

  2. Add policy check helper in chatModes.ts or modePickerActionItem.ts to determine if chat.agent.enabled setting is both false AND managed by organization policy, using IConfigurationService to check if the setting has policy metadata indicating organization management.

  3. Update mode picker action creation in modePickerActionItem.ts - modify makeAction function to set enabled: false and add icon: Codicon.lock when agent mode is policy-blocked (both disabled AND org-managed), while keeping it enabled: true for normal user-disabled or enabled cases.

  4. Set tooltip for disabled agent mode in modePickerActionItem.ts to display "Agent mode has been disabled by your administrator" only when the mode has enabled: false due to organization policy, otherwise use the default agent description tooltip.

  5. Prevent mode switching to disabled modes in chatExecuteActions.ts ToggleChatModeAction.getNextMode() to filter out disabled modes when cycling through modes with keyboard shortcuts (Ctrl+.), ensuring only enabled modes are selectable.

  6. Update validateAgentMode() in chatInputPart.ts to switch users away from agent mode if it becomes policy-disabled mid-session, checking the same policy state and falling back to Edit or Ask mode.

Open Questions:

None - implementation is fully specified.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI self-assigned this Nov 6, 2025
Copilot AI and others added 3 commits November 6, 2025 18:03
- Modified getBuiltinModes() to always include ChatMode.Agent
- Added isAgentModePolicyDisabled() helper to check for org-managed disabled setting
- Updated mode picker to show agent mode as disabled with lock icon when policy-blocked
- Filtered policy-disabled agent mode from keyboard cycling in ToggleChatModeAction
- Enhanced validateAgentMode() to handle policy-disabled mid-session

Co-authored-by: pierceboggan <[email protected]>
- Updated test to reflect that agent mode is always present in builtin modes
- Added tests for isAgentModePolicyDisabled helper function
- Tests verify correct behavior for policy-enabled, policy-disabled, and no-policy scenarios

Co-authored-by: pierceboggan <[email protected]>
- Updated currentModeKind getter to also check for policy-disabled agent mode
- Ensures consistent fallback behavior when agent mode is unavailable

Co-authored-by: pierceboggan <[email protected]>
Copilot AI changed the title [WIP] Add greyed-out agent mode option to mode picker Show disabled agent mode in mode picker when blocked by organization policy Nov 6, 2025
Copilot AI requested a review from pierceboggan November 6, 2025 18:15
Copilot finished work on behalf of pierceboggan November 6, 2025 18:15
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.

2 participants