@@ -84,6 +84,11 @@ export class ChatRequestModel implements IChatRequestModel {
84
84
85
85
interface ResponsePart { string : IMarkdownString ; resolving ?: boolean }
86
86
class Response {
87
+ private _onDidChangeValue = new Emitter < void > ( ) ;
88
+ public get onDidChangeValue ( ) {
89
+ return this . _onDidChangeValue . event ;
90
+ }
91
+
87
92
private _responseParts : ResponsePart [ ] ;
88
93
private _responseRepr : IMarkdownString ;
89
94
@@ -96,7 +101,7 @@ class Response {
96
101
this . _responseParts = [ { string : value } ] ;
97
102
}
98
103
99
- updateContent ( responsePart : string | { placeholder : string ; resolvedContent ?: Promise < string > } ) : void {
104
+ updateContent ( responsePart : string | { placeholder : string ; resolvedContent ?: Promise < string > } , quiet ?: boolean ) : void {
100
105
if ( typeof responsePart === 'string' ) {
101
106
const responsePartLength = this . _responseParts . length - 1 ;
102
107
const lastResponsePart = this . _responseParts [ responsePartLength ] ;
@@ -109,22 +114,25 @@ class Response {
109
114
this . _responseParts [ responsePartLength ] = { string : new MarkdownString ( lastResponsePart . string . value + responsePart ) } ;
110
115
}
111
116
112
- this . _updateRepr ( ) ;
117
+ this . _updateRepr ( quiet ) ;
113
118
} else {
114
119
// Add a new resolving part
115
120
const responsePosition = this . _responseParts . push ( { string : new MarkdownString ( responsePart . placeholder ) , resolving : true } ) ;
116
- this . _updateRepr ( ) ;
121
+ this . _updateRepr ( quiet ) ;
117
122
118
123
responsePart . resolvedContent ?. then ( ( content ) => {
119
124
// Replace the resolving part's content with the resolved response
120
125
this . _responseParts [ responsePosition ] = { string : new MarkdownString ( content ) } ;
121
- this . _updateRepr ( ) ;
126
+ this . _updateRepr ( quiet ) ;
122
127
} ) ;
123
128
}
124
129
}
125
130
126
- private _updateRepr ( ) {
131
+ private _updateRepr ( quiet ?: boolean ) {
127
132
this . _responseRepr = new MarkdownString ( this . _responseParts . map ( r => r . string . value ) . join ( '\n' ) ) ;
133
+ if ( ! quiet ) {
134
+ this . _onDidChangeValue . fire ( ) ;
135
+ }
128
136
}
129
137
}
130
138
@@ -192,17 +200,12 @@ export class ChatResponseModel extends Disposable implements IChatResponseModel
192
200
) {
193
201
super ( ) ;
194
202
this . _response = new Response ( _response ) ;
203
+ this . _register ( this . _response . onDidChangeValue ( ( ) => this . _onDidChange . fire ( ) ) ) ;
195
204
this . _id = 'response_' + ChatResponseModel . nextId ++ ;
196
205
}
197
206
198
207
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 ) ;
206
209
}
207
210
208
211
setProviderResponseId ( providerResponseId : string ) {
0 commit comments