File tree Expand file tree Collapse file tree 6 files changed +26
-32
lines changed
browser/chatContentParts/toolInvocationParts Expand file tree Collapse file tree 6 files changed +26
-32
lines changed Original file line number Diff line number Diff line change @@ -296,11 +296,11 @@ export class ChatAgentResponseStream {
296296 _report ( dto ) ;
297297 return this ;
298298 } ,
299- prepareToolInvocation ( toolName , streamData ) {
299+ prepareToolInvocation ( toolName , invocationMessage ) {
300300 throwIfDone ( this . prepareToolInvocation ) ;
301301 checkProposedApiEnabled ( that . _extension , 'chatParticipantAdditions' ) ;
302302
303- const part = new extHostTypes . ChatPrepareToolInvocationPart ( toolName , streamData ) ;
303+ const part = new extHostTypes . ChatPrepareToolInvocationPart ( toolName , invocationMessage ) ;
304304 const dto = typeConvert . ChatPrepareToolInvocationPart . from ( part ) ;
305305 _report ( dto ) ;
306306 return this ;
Original file line number Diff line number Diff line change @@ -2816,14 +2816,17 @@ export namespace ChatPrepareToolInvocationPart {
28162816 return {
28172817 kind : 'prepareToolInvocation' ,
28182818 toolName : part . toolName ,
2819- streamData : part . streamData ? {
2820- partialInput : part . streamData . partialInput
2821- } : undefined
2819+ invocationMessage : part . invocationMessage && typeof part . invocationMessage !== 'string'
2820+ ? MarkdownString . fromStrict ( part . invocationMessage )
2821+ : part . invocationMessage
28222822 } ;
28232823 }
28242824
28252825 export function to ( part : IChatPrepareToolInvocationPart ) : vscode . ChatPrepareToolInvocationPart {
2826- return new types . ChatPrepareToolInvocationPart ( part . toolName , part . streamData ) ;
2826+ const invocationMessage = part . invocationMessage && typeof part . invocationMessage !== 'string'
2827+ ? MarkdownString . to ( part . invocationMessage )
2828+ : part . invocationMessage ;
2829+ return new types . ChatPrepareToolInvocationPart ( part . toolName , invocationMessage ) ;
28272830 }
28282831}
28292832
Original file line number Diff line number Diff line change @@ -3339,16 +3339,14 @@ export class ChatResponseNotebookEditPart implements vscode.ChatResponseNotebook
33393339
33403340export class ChatPrepareToolInvocationPart {
33413341 toolName : string ;
3342- streamData ?: {
3343- readonly partialInput ?: unknown ;
3344- } ;
3342+ invocationMessage ?: string | vscode . MarkdownString ;
33453343 /**
33463344 * @param toolName The name of the tool being prepared for invocation.
3347- * @param streamData Optional streaming data with partial arguments .
3345+ * @param invocationMessage Optional message to display while preparing the invocation .
33483346 */
3349- constructor ( toolName : string , streamData ?: { readonly partialInput ?: unknown } ) {
3347+ constructor ( toolName : string , invocationMessage ?: string | vscode . MarkdownString ) {
33503348 this . toolName = toolName ;
3351- this . streamData = streamData ;
3349+ this . invocationMessage = invocationMessage ;
33523350 }
33533351}
33543352
Original file line number Diff line number Diff line change @@ -24,17 +24,15 @@ export class ChatPrepareToolInvocationPart extends ChatProgressContentPart imple
2424 @IConfigurationService configurationService : IConfigurationService
2525 ) {
2626 let messageContent : MarkdownString ;
27- if ( prepareToolPart . streamData ?. partialInput !== undefined ) {
28- // Show partial input if available
29- const partialInputStr = typeof prepareToolPart . streamData . partialInput === 'string'
30- ? prepareToolPart . streamData . partialInput
31- : JSON . stringify ( prepareToolPart . streamData . partialInput , null , 2 ) ;
32- messageContent = new MarkdownString ( ) . appendText ( `Preparing to call ${ prepareToolPart . toolName } ...` ) ;
33- if ( partialInputStr && partialInputStr . length > 0 && partialInputStr !== '{}' ) {
34- messageContent . appendMarkdown ( `\n\n\`\`\`json\n${ partialInputStr } \n\`\`\`` ) ;
27+ if ( prepareToolPart . invocationMessage ) {
28+ // Use custom invocation message if provided
29+ if ( typeof prepareToolPart . invocationMessage === 'string' ) {
30+ messageContent = new MarkdownString ( ) . appendText ( prepareToolPart . invocationMessage ) ;
31+ } else {
32+ messageContent = new MarkdownString ( prepareToolPart . invocationMessage . value , prepareToolPart . invocationMessage ) ;
3533 }
3634 } else {
37- // No streaming data yet, just show that we're preparing
35+ // Default message if no custom message provided
3836 messageContent = new MarkdownString ( ) . appendText ( `Preparing to call ${ prepareToolPart . toolName } ...` ) ;
3937 }
4038
Original file line number Diff line number Diff line change @@ -665,9 +665,7 @@ export class ChatMcpServersStarting implements IChatMcpServersStarting {
665665export interface IChatPrepareToolInvocationPart {
666666 readonly kind : 'prepareToolInvocation' ;
667667 readonly toolName : string ;
668- readonly streamData ?: {
669- readonly partialInput ?: unknown ;
670- } ;
668+ readonly invocationMessage ?: string | IMarkdownString ;
671669}
672670
673671export type IChatProgress =
Original file line number Diff line number Diff line change @@ -81,11 +81,8 @@ declare module 'vscode' {
8181
8282 export class ChatPrepareToolInvocationPart {
8383 toolName : string ;
84- /**
85- * Partial arguments that have streamed in for the tool invocation.
86- */
87- streamData ?: ChatToolInvocationStreamData ;
88- constructor ( toolName : string , streamData ?: ChatToolInvocationStreamData ) ;
84+ invocationMessage ?: string | MarkdownString ;
85+ constructor ( toolName : string , invocationMessage ?: string | MarkdownString ) ;
8986 }
9087
9188 export interface ChatToolInvocationStreamData {
@@ -360,10 +357,10 @@ declare module 'vscode' {
360357 codeCitation ( value : Uri , license : string , snippet : string ) : void ;
361358
362359 /**
363- * Notifies the UI that a tool invocation is being prepared. Optional streaming data can be
364- * provided to render partial arguments while the invocation input is still being generated.
360+ * Notifies the UI that a tool invocation is being prepared. Optional invocation message can be
361+ * provided to render a custom message while the invocation input is still being generated.
365362 */
366- prepareToolInvocation ( toolName : string , streamData ?: ChatToolInvocationStreamData ) : void ;
363+ prepareToolInvocation ( toolName : string , invocationMessage ?: string | MarkdownString ) : void ;
367364
368365 push ( part : ExtendedChatResponsePart ) : void ;
369366
You can’t perform that action at this time.
0 commit comments