Skip to content

Commit 4f31a97

Browse files
[cherry-pick] add hint for chat.permissions.default and agents input fix (#311434)
Co-authored-by: vs-code-engineering[bot] <vs-code-engineering[bot]@users.noreply.github.com> Co-authored-by: Justin Chen <54879025+justschen@users.noreply.github.com>
1 parent d54fe8e commit 4f31a97

File tree

3 files changed

+37
-8
lines changed

3 files changed

+37
-8
lines changed

src/vs/sessions/contrib/chat/browser/agentHostSessionConfigPicker.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -188,9 +188,17 @@ async function confirmAutoApproveLevel(value: string, dialogService: IDialogServ
188188
custom: {
189189
icon: isAutopilot ? Codicon.rocket : Codicon.warning,
190190
markdownDetails: [{
191-
markdown: new MarkdownString(isAutopilot
192-
? localize('agentHostAutoApprove.autopilot.warning.detail', "Autopilot will auto-approve all tool calls and continue working autonomously until the task is complete. This includes terminal commands, file edits, and external tool calls. The agent will make decisions on your behalf without asking for confirmation.\n\nYou can stop the agent at any time by clicking the stop button. This applies to the current session only.")
193-
: localize('agentHostAutoApprove.bypass.warning.detail', "Bypass Approvals will auto-approve all tool calls without asking for confirmation. This includes file edits, terminal commands, and external tool calls.")),
191+
markdown: new MarkdownString(
192+
localize(
193+
'agentHostAutoApprove.warning.detailWithDefaultSetting',
194+
"{0}\n\nTo make this the starting permission level for new chat sessions, change the [{1}](command:workbench.action.openSettings?%5B%22{1}%22%5D) setting.",
195+
isAutopilot
196+
? localize('agentHostAutoApprove.autopilot.warning.detail', "Autopilot will auto-approve all tool calls and continue working autonomously until the task is complete. This includes terminal commands, file edits, and external tool calls. The agent will make decisions on your behalf without asking for confirmation.\n\nYou can stop the agent at any time by clicking the stop button. This applies to the current session only.")
197+
: localize('agentHostAutoApprove.bypass.warning.detail', "Bypass Approvals will auto-approve all tool calls without asking for confirmation. This includes file edits, terminal commands, and external tool calls."),
198+
ChatConfiguration.DefaultPermissionLevel,
199+
),
200+
{ isTrusted: { enabledCommands: ['workbench.action.openSettings'] } },
201+
),
194202
}],
195203
},
196204
});

src/vs/sessions/contrib/copilotChatSessions/browser/permissionPicker.ts

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import { ISessionsManagementService } from '../../../services/sessions/common/se
1616
import { ISessionsProvidersService } from '../../../services/sessions/browser/sessionsProvidersService.js';
1717
import { renderIcon } from '../../../../base/browser/ui/iconLabel/iconLabels.js';
1818
import { ThemeIcon } from '../../../../base/common/themables.js';
19-
import { ChatConfiguration, ChatPermissionLevel } from '../../../../workbench/contrib/chat/common/constants.js';
19+
import { ChatConfiguration, ChatPermissionLevel, isChatPermissionLevel } from '../../../../workbench/contrib/chat/common/constants.js';
2020
import Severity from '../../../../base/common/severity.js';
2121
import { MarkdownString } from '../../../../base/common/htmlContent.js';
2222
import { IOpenerService } from '../../../../platform/opener/common/opener.js';
@@ -77,6 +77,15 @@ export class PermissionPicker extends Disposable {
7777
render(container: HTMLElement): HTMLElement {
7878
this._renderDisposables.clear();
7979

80+
// Initialize the picker to reflect the configured default permission level
81+
// (`chat.permissions.default`) whenever it is (re-)rendered. If enterprise
82+
// policy disables global auto-approval, clamp to Default regardless of the
83+
// configured default so we never show an elevated level the user can't pick.
84+
const policyRestricted = this.configurationService.inspect<boolean>(ChatConfiguration.GlobalAutoApprove).policyValue === false;
85+
const configuredDefault = this.configurationService.getValue<string>(ChatConfiguration.DefaultPermissionLevel);
86+
const initialLevel = isChatPermissionLevel(configuredDefault) ? configuredDefault : ChatPermissionLevel.Default;
87+
this._currentLevel = policyRestricted ? ChatPermissionLevel.Default : initialLevel;
88+
8089
const slot = dom.append(container, dom.$('.sessions-chat-picker-slot'));
8190
this._renderDisposables.add({ dispose: () => slot.remove() });
8291

@@ -220,7 +229,10 @@ export class PermissionPicker extends Disposable {
220229
custom: {
221230
icon: Codicon.warning,
222231
markdownDetails: [{
223-
markdown: new MarkdownString(localize('permissions.autoApprove.warning.detail', "Bypass Approvals will auto-approve all tool calls without asking for confirmation. This includes file edits, terminal commands, and external tool calls.")),
232+
markdown: new MarkdownString(
233+
localize('permissions.autoApprove.warning.detail', "Bypass Approvals will auto-approve all tool calls without asking for confirmation. This includes file edits, terminal commands, and external tool calls.\n\nTo make this the starting permission level for new chat sessions, change the [{0}](command:workbench.action.openSettings?%5B%22{0}%22%5D) setting.", ChatConfiguration.DefaultPermissionLevel),
234+
{ isTrusted: { enabledCommands: ['workbench.action.openSettings'] } },
235+
),
224236
}],
225237
},
226238
});
@@ -247,7 +259,10 @@ export class PermissionPicker extends Disposable {
247259
custom: {
248260
icon: Codicon.rocket,
249261
markdownDetails: [{
250-
markdown: new MarkdownString(localize('permissions.autopilot.warning.detail', "Autopilot will auto-approve all tool calls and continue working autonomously until the task is complete. The agent will make decisions on your behalf without asking for confirmation.\n\nYou can stop the agent at any time by clicking the stop button. This applies to the current session only.")),
262+
markdown: new MarkdownString(
263+
localize('permissions.autopilot.warning.detail', "Autopilot will auto-approve all tool calls and continue working autonomously until the task is complete. The agent will make decisions on your behalf without asking for confirmation.\n\nYou can stop the agent at any time by clicking the stop button. This applies to the current session only.\n\nTo make this the starting permission level for new chat sessions, change the [{0}](command:workbench.action.openSettings?%5B%22{0}%22%5D) setting.", ChatConfiguration.DefaultPermissionLevel),
264+
{ isTrusted: { enabledCommands: ['workbench.action.openSettings'] } },
265+
),
251266
}],
252267
},
253268
});

src/vs/workbench/contrib/chat/browser/widget/input/permissionPickerActionItem.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,10 @@ export class PermissionPickerActionItem extends ChatInputPickerActionViewItem {
115115
custom: {
116116
icon: Codicon.warning,
117117
markdownDetails: [{
118-
markdown: new MarkdownString(localize('permissions.autoApprove.warning.detail', "Bypass Approvals will auto-approve all tool calls without asking for confirmation. This includes file edits, terminal commands, and external tool calls.")),
118+
markdown: new MarkdownString(
119+
localize('permissions.autoApprove.warning.detail', "Bypass Approvals will auto-approve all tool calls without asking for confirmation. This includes file edits, terminal commands, and external tool calls.\n\nTo make this the starting permission level for new chat sessions, change the [{0}](command:workbench.action.openSettings?%5B%22{0}%22%5D) setting.", ChatConfiguration.DefaultPermissionLevel),
120+
{ isTrusted: { enabledCommands: ['workbench.action.openSettings'] } },
121+
),
119122
}],
120123
},
121124
});
@@ -164,7 +167,10 @@ export class PermissionPickerActionItem extends ChatInputPickerActionViewItem {
164167
custom: {
165168
icon: Codicon.rocket,
166169
markdownDetails: [{
167-
markdown: new MarkdownString(localize('permissions.autopilot.warning.detail', "Autopilot will auto-approve all tool calls and continue working autonomously until the task is complete. This includes terminal commands, file edits, and external tool calls. The agent will make decisions on your behalf without asking for confirmation.\n\nYou can stop the agent at any time by clicking the stop button. This applies to the current session only.")),
170+
markdown: new MarkdownString(
171+
localize('permissions.autopilot.warning.detail', "Autopilot will auto-approve all tool calls and continue working autonomously until the task is complete. This includes terminal commands, file edits, and external tool calls. The agent will make decisions on your behalf without asking for confirmation.\n\nYou can stop the agent at any time by clicking the stop button. This applies to the current session only.\n\nTo make this the starting permission level for new chat sessions, change the [{0}](command:workbench.action.openSettings?%5B%22{0}%22%5D) setting.", ChatConfiguration.DefaultPermissionLevel),
172+
{ isTrusted: { enabledCommands: ['workbench.action.openSettings'] } },
173+
),
168174
}],
169175
},
170176
});

0 commit comments

Comments
 (0)