44 *--------------------------------------------------------------------------------------------*/
55
66import { ChatResponseReferencePartStatusKind } from '@vscode/prompt-tsx' ;
7- import type { ChatQuestion , ChatResponseFileTree , ChatResponseStream , ChatToolInvocationStreamData , ChatVulnerability , ChatWorkspaceFileEdit , Command , ExtendedChatResponsePart , Location , NotebookEdit , Progress , ThinkingDelta , Uri } from 'vscode' ;
7+ import type { ChatQuestion , ChatResponseFileTree , ChatResponseStream , ChatResultUsage , ChatToolInvocationStreamData , ChatVulnerability , ChatWorkspaceFileEdit , Command , ExtendedChatResponsePart , Location , NotebookEdit , Progress , ThinkingDelta , Uri } from 'vscode' ;
88import { ChatResponseAnchorPart , ChatResponseClearToPreviousToolInvocationReason , ChatResponseCodeblockUriPart , ChatResponseCodeCitationPart , ChatResponseCommandButtonPart , ChatResponseConfirmationPart , ChatResponseExternalEditPart , ChatResponseFileTreePart , ChatResponseMarkdownPart , ChatResponseMarkdownWithVulnerabilitiesPart , ChatResponseNotebookEditPart , ChatResponseProgressPart , ChatResponseProgressPart2 , ChatResponseReferencePart , ChatResponseReferencePart2 , ChatResponseTextEditPart , ChatResponseThinkingProgressPart , ChatResponseWarningPart , ChatResponseWorkspaceEditPart , MarkdownString , TextEdit } from '../../vscodeTypes' ;
99import type { ThemeIcon } from '../vs/base/common/themables' ;
1010
@@ -43,6 +43,9 @@ export class ChatResponseStreamImpl implements FinalizableChatResponseStream {
4343 } ,
4444 ( questions , allowSkip ) => {
4545 return stream . questionCarousel ( questions , allowSkip ) ;
46+ } ,
47+ ( usage ) => {
48+ stream . usage ( usage ) ;
4649 }
4750 ) ;
4851 }
@@ -66,6 +69,9 @@ export class ChatResponseStreamImpl implements FinalizableChatResponseStream {
6669 } ,
6770 ( questions , allowSkip ) => {
6871 return stream . questionCarousel ( questions , allowSkip ) ;
72+ } ,
73+ ( usage ) => {
74+ stream . usage ( usage ) ;
6975 } ) ;
7076 }
7177
@@ -89,6 +95,9 @@ export class ChatResponseStreamImpl implements FinalizableChatResponseStream {
8995 } ,
9096 ( questions , allowSkip ) => {
9197 return stream . questionCarousel ( questions , allowSkip ) ;
98+ } ,
99+ ( usage ) => {
100+ stream . usage ( usage ) ;
92101 } ) ;
93102 }
94103
@@ -99,6 +108,7 @@ export class ChatResponseStreamImpl implements FinalizableChatResponseStream {
99108 private readonly _beginToolInvocation ?: ( toolCallId : string , toolName : string , streamData ?: ChatToolInvocationStreamData ) => void ,
100109 private readonly _updateToolInvocation ?: ( toolCallId : string , streamData : ChatToolInvocationStreamData ) => void ,
101110 private readonly _questionCarousel ?: ( questions : ChatQuestion [ ] , allowSkip ?: boolean ) => Thenable < Record < string , unknown > | undefined > ,
111+ private readonly _usage ?: ( usage : ChatResultUsage ) => void ,
102112 ) { }
103113
104114 async finalize ( ) : Promise < void > {
@@ -219,4 +229,10 @@ export class ChatResponseStreamImpl implements FinalizableChatResponseStream {
219229 }
220230 return Promise . resolve ( undefined ) ;
221231 }
232+
233+ usage ( usage : ChatResultUsage ) : void {
234+ if ( this . _usage ) {
235+ this . _usage ( usage ) ;
236+ }
237+ }
222238}
0 commit comments