4
4
*--------------------------------------------------------------------------------------------*/
5
5
6
6
import * as dom from '../../../../../../base/browser/dom.js' ;
7
- import { MarkdownString } from '../../../../../../base/common/htmlContent.js' ;
7
+ import { MarkdownString , type IMarkdownString } from '../../../../../../base/common/htmlContent.js' ;
8
8
import { thenIfNotDisposed } from '../../../../../../base/common/lifecycle.js' ;
9
9
import { Schemas } from '../../../../../../base/common/network.js' ;
10
10
import { URI } from '../../../../../../base/common/uri.js' ;
@@ -18,13 +18,14 @@ import { IInstantiationService } from '../../../../../../platform/instantiation/
18
18
import { IKeybindingService } from '../../../../../../platform/keybinding/common/keybinding.js' ;
19
19
import { ChatContextKeys } from '../../../common/chatContextKeys.js' ;
20
20
import { IChatToolInvocation , type IChatTerminalToolInvocationData } from '../../../common/chatService.js' ;
21
+ import type { CodeBlockModelCollection } from '../../../common/codeBlockModelCollection.js' ;
21
22
import { CancelChatActionId } from '../../actions/chatExecuteActions.js' ;
22
23
import { AcceptToolConfirmationActionId } from '../../actions/chatToolActions.js' ;
23
24
import { IChatCodeBlockInfo , IChatWidgetService } from '../../chat.js' ;
24
25
import { ICodeBlockRenderOptions } from '../../codeBlockPart.js' ;
25
26
import { ChatCustomConfirmationWidget , IChatConfirmationButton } from '../chatConfirmationWidget.js' ;
26
27
import { IChatContentPartRenderContext } from '../chatContentParts.js' ;
27
- import { EditorPool } from '../chatMarkdownContentPart.js' ;
28
+ import { ChatMarkdownContentPart , EditorPool } from '../chatMarkdownContentPart.js' ;
28
29
import { BaseChatToolInvocationSubPart } from './chatToolInvocationSubPart.js' ;
29
30
30
31
export class TerminalConfirmationWidgetSubPart extends BaseChatToolInvocationSubPart {
@@ -38,6 +39,7 @@ export class TerminalConfirmationWidgetSubPart extends BaseChatToolInvocationSub
38
39
private readonly renderer : MarkdownRenderer ,
39
40
private readonly editorPool : EditorPool ,
40
41
private readonly currentWidthDelegate : ( ) => number ,
42
+ private readonly codeBlockModelCollection : CodeBlockModelCollection ,
41
43
private readonly codeBlockStartIndex : number ,
42
44
@IInstantiationService private readonly instantiationService : IInstantiationService ,
43
45
@IKeybindingService keybindingService : IKeybindingService ,
@@ -52,8 +54,7 @@ export class TerminalConfirmationWidgetSubPart extends BaseChatToolInvocationSub
52
54
throw new Error ( 'Confirmation messages are missing' ) ;
53
55
}
54
56
55
- const title = toolInvocation . confirmationMessages . title ;
56
- const message = toolInvocation . confirmationMessages . message ;
57
+ const { title, message, disclaimer } = toolInvocation . confirmationMessages ;
57
58
const continueLabel = localize ( 'continue' , "Continue" ) ;
58
59
const continueKeybinding = keybindingService . lookupKeybinding ( AcceptToolConfirmationActionId ) ?. getLabel ( ) ;
59
60
const continueTooltip = continueKeybinding ? `${ continueLabel } (${ continueKeybinding } )` : continueLabel ;
@@ -136,6 +137,10 @@ export class TerminalConfirmationWidgetSubPart extends BaseChatToolInvocationSub
136
137
this . context . container ,
137
138
) ) ;
138
139
140
+ if ( disclaimer ) {
141
+ this . _appendMarkdownPart ( element , disclaimer , codeBlockRenderOptions ) ;
142
+ }
143
+
139
144
ChatContextKeys . Editing . hasToolConfirmation . bindTo ( this . contextKeyService ) . set ( true ) ;
140
145
this . _register ( confirmWidget . onDidClick ( button => {
141
146
toolInvocation . confirmed . complete ( button . data ) ;
@@ -155,4 +160,22 @@ export class TerminalConfirmationWidgetSubPart extends BaseChatToolInvocationSub
155
160
path : generateUuid ( ) ,
156
161
} ) ;
157
162
}
163
+
164
+ private _appendMarkdownPart ( container : HTMLElement , message : string | IMarkdownString , codeBlockRenderOptions : ICodeBlockRenderOptions ) {
165
+ const part = this . _register ( this . instantiationService . createInstance ( ChatMarkdownContentPart , {
166
+ kind : 'markdownContent' ,
167
+ content : typeof message === 'string' ? new MarkdownString ( ) . appendText ( message ) : message
168
+ } ,
169
+ this . context ,
170
+ this . editorPool ,
171
+ false ,
172
+ this . codeBlockStartIndex ,
173
+ this . renderer ,
174
+ this . currentWidthDelegate ( ) ,
175
+ this . codeBlockModelCollection ,
176
+ { codeBlockRenderOptions }
177
+ ) ) ;
178
+ dom . append ( container , part . domNode ) ;
179
+ this . _register ( part . onDidChangeHeight ( ( ) => this . _onDidChangeHeight . fire ( ) ) ) ;
180
+ }
158
181
}
0 commit comments