Skip to content

Commit 9e71c8e

Browse files
authored
tools: implement 'skip' for tool calls in place of cancel (microsoft#263314)
Closes microsoft#259534
1 parent 7a46ac4 commit 9e71c8e

File tree

4 files changed

+28
-30
lines changed

4 files changed

+28
-30
lines changed

src/vs/workbench/contrib/chat/browser/chatContentParts/toolInvocationParts/chatTerminalToolProgressPart.ts

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,14 @@
33
* Licensed under the MIT License. See License.txt in the project root for license information.
44
*--------------------------------------------------------------------------------------------*/
55

6-
import { Codicon } from '../../../../../../base/common/codicons.js';
76
import { MarkdownString } from '../../../../../../base/common/htmlContent.js';
8-
import { ThemeIcon } from '../../../../../../base/common/themables.js';
97
import { MarkdownRenderer } from '../../../../../../editor/browser/widget/markdownRenderer/browser/markdownRenderer.js';
108
import { ConfigurationTarget } from '../../../../../../platform/configuration/common/configuration.js';
119
import { IInstantiationService } from '../../../../../../platform/instantiation/common/instantiation.js';
1210
import { IPreferencesService, type IOpenSettingsOptions } from '../../../../../services/preferences/common/preferences.js';
1311
import { TerminalContribSettingId } from '../../../../terminal/terminalContribExports.js';
1412
import { migrateLegacyTerminalToolSpecificData } from '../../../common/chat.js';
15-
import { IChatMarkdownContent, IChatToolInvocation, IChatToolInvocationSerialized, ToolConfirmKind, type IChatTerminalToolInvocationData, type ILegacyChatTerminalToolInvocationData } from '../../../common/chatService.js';
13+
import { IChatMarkdownContent, IChatToolInvocation, IChatToolInvocationSerialized, type IChatTerminalToolInvocationData, type ILegacyChatTerminalToolInvocationData } from '../../../common/chatService.js';
1614
import { CodeBlockModelCollection } from '../../../common/codeBlockModelCollection.js';
1715
import { IChatCodeBlockInfo } from '../../chat.js';
1816
import { ICodeBlockRenderOptions } from '../../codeBlockPart.js';
@@ -106,17 +104,7 @@ export class ChatTerminalToolProgressPart extends BaseChatToolInvocationSubPart
106104
},
107105
}, currentWidthDelegate(), codeBlockModelCollection, { codeBlockRenderOptions }));
108106
this._register(this.markdownPart.onDidChangeHeight(() => this._onDidChangeHeight.fire()));
109-
const isConfirmed = typeof toolInvocation.isConfirmed === 'boolean'
110-
? toolInvocation.isConfirmed
111-
: toolInvocation.isConfirmed?.type === ToolConfirmKind.UserAction || toolInvocation.isConfirmed?.type === ToolConfirmKind.ConfirmationNotNeeded;
112-
const isSkipped = typeof toolInvocation.isConfirmed !== 'boolean' && toolInvocation.isConfirmed?.type === ToolConfirmKind.Skipped;
113-
const icon = isSkipped ?
114-
Codicon.circleSlash :
115-
(!isConfirmed ?
116-
Codicon.error :
117-
toolInvocation.isComplete ?
118-
Codicon.check : ThemeIcon.modify(Codicon.loading, 'spin'));
119-
const progressPart = instantiationService.createInstance(ChatCustomProgressPart, this.markdownPart.domNode, icon);
107+
const progressPart = instantiationService.createInstance(ChatCustomProgressPart, this.markdownPart.domNode, this.getIcon());
120108
this.domNode = progressPart.domNode;
121109
}
122110
}

src/vs/workbench/contrib/chat/browser/chatContentParts/toolInvocationParts/chatToolConfirmationSubPart.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,10 @@ export class ToolConfirmationSubPart extends BaseChatToolInvocationSubPart {
8080

8181
const enum ConfirmationOutcome {
8282
Allow,
83-
Disallow,
83+
Skip,
8484
AllowWorkspace,
8585
AllowGlobally,
8686
AllowSession,
87-
CustomAction,
8887
}
8988

9089
const buttons: IChatConfirmationButton<ConfirmationOutcome>[] = [
@@ -99,8 +98,8 @@ export class ToolConfirmationSubPart extends BaseChatToolInvocationSubPart {
9998
],
10099
},
101100
{
102-
label: localize('cancel', "Cancel"),
103-
data: ConfirmationOutcome.Disallow,
101+
label: localize('skip', "Skip"),
102+
data: ConfirmationOutcome.Skip,
104103
isSecondary: true,
105104
tooltip: cancelTooltip
106105
}];
@@ -327,8 +326,8 @@ export class ToolConfirmationSubPart extends BaseChatToolInvocationSubPart {
327326
case ConfirmationOutcome.Allow:
328327
toolInvocation.confirmed.complete({ type: ToolConfirmKind.UserAction });
329328
break;
330-
case ConfirmationOutcome.Disallow:
331-
toolInvocation.confirmed.complete({ type: ToolConfirmKind.Denied });
329+
case ConfirmationOutcome.Skip:
330+
toolInvocation.confirmed.complete({ type: ToolConfirmKind.Skipped });
332331
break;
333332
}
334333

src/vs/workbench/contrib/chat/browser/chatContentParts/toolInvocationParts/chatToolInvocationSubPart.ts

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@
33
* Licensed under the MIT License. See License.txt in the project root for license information.
44
*--------------------------------------------------------------------------------------------*/
55

6+
import { Codicon } from '../../../../../../base/common/codicons.js';
67
import { Emitter } from '../../../../../../base/common/event.js';
78
import { Disposable } from '../../../../../../base/common/lifecycle.js';
8-
import { IChatToolInvocation, IChatToolInvocationSerialized } from '../../../common/chatService.js';
9+
import { ThemeIcon } from '../../../../../../base/common/themables.js';
10+
import { IChatToolInvocation, IChatToolInvocationSerialized, ToolConfirmKind } from '../../../common/chatService.js';
911
import { IChatCodeBlockInfo } from '../../chat.js';
1012

1113
export abstract class BaseChatToolInvocationSubPart extends Disposable {
@@ -23,12 +25,26 @@ export abstract class BaseChatToolInvocationSubPart extends Disposable {
2325
public readonly codeblocksPartId = 'tool-' + (BaseChatToolInvocationSubPart.idPool++);
2426

2527
constructor(
26-
toolInvocation: IChatToolInvocation | IChatToolInvocationSerialized,
28+
protected readonly toolInvocation: IChatToolInvocation | IChatToolInvocationSerialized,
2729
) {
2830
super();
2931

3032
if (toolInvocation.kind === 'toolInvocation' && !toolInvocation.isComplete) {
3133
toolInvocation.isCompletePromise.then(() => this._onNeedsRerender.fire());
3234
}
3335
}
36+
37+
protected getIcon() {
38+
const toolInvocation = this.toolInvocation;
39+
const isConfirmed = typeof toolInvocation.isConfirmed === 'boolean'
40+
? toolInvocation.isConfirmed
41+
: toolInvocation.isConfirmed?.type === ToolConfirmKind.UserAction || toolInvocation.isConfirmed?.type === ToolConfirmKind.ConfirmationNotNeeded;
42+
const isSkipped = typeof toolInvocation.isConfirmed !== 'boolean' && toolInvocation.isConfirmed?.type === ToolConfirmKind.Skipped;
43+
return isSkipped ?
44+
Codicon.circleSlash :
45+
(!isConfirmed ?
46+
Codicon.error :
47+
toolInvocation.isComplete ?
48+
Codicon.check : ThemeIcon.modify(Codicon.loading, 'spin'));
49+
}
3450
}

src/vs/workbench/contrib/chat/browser/chatContentParts/toolInvocationParts/chatToolProgressPart.ts

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,11 @@
44
*--------------------------------------------------------------------------------------------*/
55

66
import * as dom from '../../../../../../base/browser/dom.js';
7-
import { Codicon } from '../../../../../../base/common/codicons.js';
87
import { IMarkdownString, MarkdownString } from '../../../../../../base/common/htmlContent.js';
98
import { autorun } from '../../../../../../base/common/observable.js';
109
import { MarkdownRenderer } from '../../../../../../editor/browser/widget/markdownRenderer/browser/markdownRenderer.js';
1110
import { IInstantiationService } from '../../../../../../platform/instantiation/common/instantiation.js';
12-
import { IChatToolInvocation, IChatToolInvocationSerialized, IChatProgressMessage, ToolConfirmKind } from '../../../common/chatService.js';
11+
import { IChatProgressMessage, IChatToolInvocation, IChatToolInvocationSerialized, ToolConfirmKind } from '../../../common/chatService.js';
1312
import { IChatCodeBlockInfo } from '../../chat.js';
1413
import { IChatContentPartRenderContext } from '../chatContentParts.js';
1514
import { ChatProgressContentPart } from '../chatProgressContentPart.js';
@@ -21,7 +20,7 @@ export class ChatToolProgressSubPart extends BaseChatToolInvocationSubPart {
2120
public override readonly codeblocks: IChatCodeBlockInfo[] = [];
2221

2322
constructor(
24-
private readonly toolInvocation: IChatToolInvocation | IChatToolInvocationSerialized,
23+
toolInvocation: IChatToolInvocation | IChatToolInvocationSerialized,
2524
private readonly context: IChatContentPartRenderContext,
2625
private readonly renderer: MarkdownRenderer,
2726
@IInstantiationService private readonly instantiationService: IInstantiationService,
@@ -68,10 +67,6 @@ export class ChatToolProgressSubPart extends BaseChatToolInvocationSubPart {
6867
content
6968
};
7069

71-
const iconOverride = !this.toolIsConfirmed ?
72-
Codicon.error :
73-
this.toolInvocation.isComplete ?
74-
Codicon.check : undefined;
75-
return this.instantiationService.createInstance(ChatProgressContentPart, progressMessage, this.renderer, this.context, undefined, true, iconOverride);
70+
return this.instantiationService.createInstance(ChatProgressContentPart, progressMessage, this.renderer, this.context, undefined, true, this.getIcon());
7671
}
7772
}

0 commit comments

Comments
 (0)