Skip to content

Commit 8fe04a7

Browse files
CopilotjoshspicerCopilot
authored
Add smart auto-suggest for chat.tools.eligibleForAutoApproval setting (microsoft#278254)
* Initial plan * Add smart auto suggest for chat.tools.eligibleForAutoApproval setting Co-authored-by: joshspicer <23246594+joshspicer@users.noreply.github.com> * Enhance tool reference name descriptions with source labels and tool descriptions Co-authored-by: joshspicer <23246594+joshspicer@users.noreply.github.com> * fix * Update src/vs/workbench/contrib/chat/browser/chat.contribution.ts Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: joshspicer <23246594+joshspicer@users.noreply.github.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent 3efda63 commit 8fe04a7

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

src/vs/workbench/contrib/chat/browser/chat.contribution.ts

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,9 @@ import { ConfigureToolSets, UserToolSetsContributions } from './tools/toolSetsCo
132132
import { ChatViewsWelcomeHandler } from './viewsWelcome/chatViewsWelcomeHandler.js';
133133
import { ChatWidgetService } from './chatWidgetService.js';
134134

135+
const toolReferenceNameEnumValues: string[] = [];
136+
const toolReferenceNameEnumDescriptions: string[] = [];
137+
135138
// Register configuration
136139
const configurationRegistry = Registry.as<IConfigurationRegistry>(ConfigurationExtensions.Configuration);
137140
configurationRegistry.registerConfiguration({
@@ -298,6 +301,10 @@ configurationRegistry.registerConfiguration({
298301
default: {},
299302
markdownDescription: nls.localize('chat.tools.eligibleForAutoApproval', 'Controls which tools are eligible for automatic approval. Tools set to \'false\' will always present a confirmation and will never offer the option to auto-approve. The default behavior (or setting a tool to \'true\') may result in the tool offering auto-approval options.'),
300303
type: 'object',
304+
propertyNames: {
305+
enum: toolReferenceNameEnumValues,
306+
enumDescriptions: toolReferenceNameEnumDescriptions,
307+
},
301308
additionalProperties: {
302309
type: 'boolean',
303310
},
@@ -921,6 +928,43 @@ class ChatAgentSettingContribution extends Disposable implements IWorkbenchContr
921928
}
922929
}
923930

931+
class ToolReferenceNamesContribution extends Disposable implements IWorkbenchContribution {
932+
933+
static readonly ID = 'workbench.contrib.toolReferenceNames';
934+
935+
constructor(
936+
@ILanguageModelToolsService private readonly _languageModelToolsService: ILanguageModelToolsService,
937+
) {
938+
super();
939+
this._updateToolReferenceNames();
940+
this._register(this._languageModelToolsService.onDidChangeTools(() => this._updateToolReferenceNames()));
941+
}
942+
943+
private _updateToolReferenceNames(): void {
944+
const tools =
945+
Array.from(this._languageModelToolsService.getTools())
946+
.filter((tool): tool is typeof tool & { toolReferenceName: string } => typeof tool.toolReferenceName === 'string')
947+
.sort((a, b) => a.toolReferenceName.localeCompare(b.toolReferenceName));
948+
toolReferenceNameEnumValues.length = 0;
949+
toolReferenceNameEnumDescriptions.length = 0;
950+
for (const tool of tools) {
951+
toolReferenceNameEnumValues.push(tool.toolReferenceName);
952+
toolReferenceNameEnumDescriptions.push(nls.localize(
953+
'chat.toolReferenceName.description',
954+
"{0} - {1}",
955+
tool.toolReferenceName,
956+
tool.userDescription || tool.displayName
957+
));
958+
}
959+
configurationRegistry.notifyConfigurationSchemaUpdated({
960+
id: 'chatSidebar',
961+
properties: {
962+
[ChatConfiguration.EligibleForAutoApproval]: {}
963+
}
964+
});
965+
}
966+
}
967+
924968
AccessibleViewRegistry.register(new ChatTerminalOutputAccessibleView());
925969
AccessibleViewRegistry.register(new ChatResponseAccessibleView());
926970
AccessibleViewRegistry.register(new PanelChatAccessibilityHelp());
@@ -1025,6 +1069,7 @@ registerWorkbenchContribution2(ChatTeardownContribution.ID, ChatTeardownContribu
10251069
registerWorkbenchContribution2(ChatStatusBarEntry.ID, ChatStatusBarEntry, WorkbenchPhase.BlockRestore);
10261070
registerWorkbenchContribution2(BuiltinToolsContribution.ID, BuiltinToolsContribution, WorkbenchPhase.Eventually);
10271071
registerWorkbenchContribution2(ChatAgentSettingContribution.ID, ChatAgentSettingContribution, WorkbenchPhase.AfterRestored);
1072+
registerWorkbenchContribution2(ToolReferenceNamesContribution.ID, ToolReferenceNamesContribution, WorkbenchPhase.AfterRestored);
10281073
registerWorkbenchContribution2(ChatEditingEditorAccessibility.ID, ChatEditingEditorAccessibility, WorkbenchPhase.AfterRestored);
10291074
registerWorkbenchContribution2(ChatEditingEditorOverlay.ID, ChatEditingEditorOverlay, WorkbenchPhase.AfterRestored);
10301075
registerWorkbenchContribution2(SimpleBrowserOverlay.ID, SimpleBrowserOverlay, WorkbenchPhase.AfterRestored);

0 commit comments

Comments
 (0)