@@ -84,6 +84,11 @@ export class ChatRequestModel implements IChatRequestModel {
8484
8585interface ResponsePart { string : IMarkdownString ; resolving ?: boolean }
8686class Response {
87+ private _onDidChangeValue = new Emitter < void > ( ) ;
88+ public get onDidChangeValue ( ) {
89+ return this . _onDidChangeValue . event ;
90+ }
91+
8792 private _responseParts : ResponsePart [ ] ;
8893 private _responseRepr : IMarkdownString ;
8994
@@ -96,7 +101,7 @@ class Response {
96101 this . _responseParts = [ { string : value } ] ;
97102 }
98103
99- updateContent ( responsePart : string | { placeholder : string ; resolvedContent ?: Promise < string > } ) : void {
104+ updateContent ( responsePart : string | { placeholder : string ; resolvedContent ?: Promise < string > } , quiet ?: boolean ) : void {
100105 if ( typeof responsePart === 'string' ) {
101106 const responsePartLength = this . _responseParts . length - 1 ;
102107 const lastResponsePart = this . _responseParts [ responsePartLength ] ;
@@ -109,22 +114,25 @@ class Response {
109114 this . _responseParts [ responsePartLength ] = { string : new MarkdownString ( lastResponsePart . string . value + responsePart ) } ;
110115 }
111116
112- this . _updateRepr ( ) ;
117+ this . _updateRepr ( quiet ) ;
113118 } else {
114119 // Add a new resolving part
115120 const responsePosition = this . _responseParts . push ( { string : new MarkdownString ( responsePart . placeholder ) , resolving : true } ) ;
116- this . _updateRepr ( ) ;
121+ this . _updateRepr ( quiet ) ;
117122
118123 responsePart . resolvedContent ?. then ( ( content ) => {
119124 // Replace the resolving part's content with the resolved response
120125 this . _responseParts [ responsePosition ] = { string : new MarkdownString ( content ) } ;
121- this . _updateRepr ( ) ;
126+ this . _updateRepr ( quiet ) ;
122127 } ) ;
123128 }
124129 }
125130
126- private _updateRepr ( ) {
131+ private _updateRepr ( quiet ?: boolean ) {
127132 this . _responseRepr = new MarkdownString ( this . _responseParts . map ( r => r . string . value ) . join ( '\n' ) ) ;
133+ if ( ! quiet ) {
134+ this . _onDidChangeValue . fire ( ) ;
135+ }
128136 }
129137}
130138
@@ -192,17 +200,12 @@ export class ChatResponseModel extends Disposable implements IChatResponseModel
192200 ) {
193201 super ( ) ;
194202 this . _response = new Response ( _response ) ;
203+ this . _register ( this . _response . onDidChangeValue ( ( ) => this . _onDidChange . fire ( ) ) ) ;
195204 this . _id = 'response_' + ChatResponseModel . nextId ++ ;
196205 }
197206
198207 updateContent ( responsePart : string | { placeholder : string ; resolvedContent ?: Promise < string > } , quiet ?: boolean ) {
199- try {
200- this . _response . updateContent ( responsePart ) ;
201- } finally {
202- if ( ! quiet ) {
203- this . _onDidChange . fire ( ) ;
204- }
205- }
208+ this . _response . updateContent ( responsePart , quiet ) ;
206209 }
207210
208211 setProviderResponseId ( providerResponseId : string ) {
0 commit comments