@@ -19,7 +19,7 @@ import { CHAT_CATEGORY } from 'vs/workbench/contrib/chat/browser/actions/chatAct
19
19
import { IChatWidget , IChatWidgetService , IQuickChatService } from 'vs/workbench/contrib/chat/browser/chat' ;
20
20
import { IChatService } from 'vs/workbench/contrib/chat/common/chatService' ;
21
21
import { MENU_INLINE_CHAT_WIDGET } from 'vs/workbench/contrib/inlineChat/common/inlineChat' ;
22
- import { CONTEXT_PROVIDER_EXISTS } from 'vs/workbench/contrib/chat/common/chatContextKeys' ;
22
+ import { CONTEXT_CHAT_REQUEST_IN_PROGRESS , CONTEXT_PROVIDER_EXISTS } from 'vs/workbench/contrib/chat/common/chatContextKeys' ;
23
23
import { InlineChatController } from 'vs/workbench/contrib/inlineChat/browser/inlineChatController' ;
24
24
import { IEditorService } from 'vs/workbench/services/editor/common/editorService' ;
25
25
import { getCodeEditor } from 'vs/editor/browser/editorBrowser' ;
@@ -59,6 +59,7 @@ interface IVoiceChatSessionController {
59
59
focusInput ( ) : void ;
60
60
acceptInput ( ) : void ;
61
61
updateInput ( text : string ) : void ;
62
+ getInput ( ) : string ;
62
63
63
64
setInputPlaceholder ( text : string ) : void ;
64
65
clearInputPlaceholder ( ) : void ;
@@ -166,6 +167,7 @@ class VoiceChatSessionControllerFactory {
166
167
focusInput : ( ) => chatView . focusInput ( ) ,
167
168
acceptInput : ( ) => chatView . acceptInput ( ) ,
168
169
updateInput : text => chatView . updateInput ( text ) ,
170
+ getInput : ( ) => chatView . getInput ( ) ,
169
171
setInputPlaceholder : text => chatView . setInputPlaceholder ( text ) ,
170
172
clearInputPlaceholder : ( ) => chatView . resetInputPlaceholder ( )
171
173
} ;
@@ -179,13 +181,14 @@ class VoiceChatSessionControllerFactory {
179
181
focusInput : ( ) => quickChat . focusInput ( ) ,
180
182
acceptInput : ( ) => quickChat . acceptInput ( ) ,
181
183
updateInput : text => quickChat . updateInput ( text ) ,
184
+ getInput : ( ) => quickChat . getInput ( ) ,
182
185
setInputPlaceholder : text => quickChat . setInputPlaceholder ( text ) ,
183
186
clearInputPlaceholder : ( ) => quickChat . resetInputPlaceholder ( )
184
187
} ;
185
188
}
186
189
187
- private static doCreateForInlineChat ( inlineChat : InlineChatController , ) : IVoiceChatSessionController {
188
- const inlineChatSession = inlineChat . run ( ) ;
190
+ private static doCreateForInlineChat ( inlineChat : InlineChatController ) : IVoiceChatSessionController {
191
+ const inlineChatSession = inlineChat . joinCurrentRun ( ) ?? inlineChat . run ( ) ;
189
192
190
193
return {
191
194
context : 'inline' ,
@@ -196,7 +199,8 @@ class VoiceChatSessionControllerFactory {
196
199
) ,
197
200
focusInput : ( ) => inlineChat . focus ( ) ,
198
201
acceptInput : ( ) => inlineChat . acceptInput ( ) ,
199
- updateInput : text => inlineChat . updateInput ( text ) ,
202
+ updateInput : text => inlineChat . updateInput ( text , false ) ,
203
+ getInput : ( ) => inlineChat . getInput ( ) ,
200
204
setInputPlaceholder : text => inlineChat . setPlaceholder ( text ) ,
201
205
clearInputPlaceholder : ( ) => inlineChat . resetPlaceholder ( )
202
206
} ;
@@ -252,14 +256,13 @@ class VoiceChatSessions {
252
256
session . disposables . add ( controller . onDidAcceptInput ( ( ) => this . stop ( sessionId , controller . context ) ) ) ;
253
257
session . disposables . add ( controller . onDidCancelInput ( ( ) => this . stop ( sessionId , controller . context ) ) ) ;
254
258
255
- controller . updateInput ( '' ) ;
256
259
controller . focusInput ( ) ;
257
260
258
261
this . voiceChatGettingReadyKey . set ( true ) ;
259
262
260
263
const speechToTextSession = session . disposables . add ( this . speechService . createSpeechToTextSession ( cts . token ) ) ;
261
264
262
- let transcription : string = '' ;
265
+ let inputValue = controller . getInput ( ) ;
263
266
const acceptTranscriptionScheduler = session . disposables . add ( new RunOnceScheduler ( ( ) => session . controller . acceptInput ( ) , 1200 ) ) ;
264
267
session . disposables . add ( speechToTextSession . onDidChange ( ( { status, text } ) => {
265
268
if ( cts . token . isCancellationRequested ) {
@@ -272,14 +275,14 @@ class VoiceChatSessions {
272
275
break ;
273
276
case SpeechToTextStatus . Recognizing :
274
277
if ( text ) {
275
- session . controller . updateInput ( [ transcription , text ] . join ( ' ' ) ) ;
278
+ session . controller . updateInput ( [ inputValue , text ] . join ( ' ' ) ) ;
276
279
acceptTranscriptionScheduler . cancel ( ) ;
277
280
}
278
281
break ;
279
282
case SpeechToTextStatus . Recognized :
280
283
if ( text ) {
281
- transcription = [ transcription , text ] . join ( ' ' ) ;
282
- session . controller . updateInput ( transcription ) ;
284
+ inputValue = [ inputValue , text ] . join ( ' ' ) ;
285
+ session . controller . updateInput ( inputValue ) ;
283
286
acceptTranscriptionScheduler . schedule ( ) ;
284
287
}
285
288
break ;
@@ -368,7 +371,7 @@ export class VoiceChatInChatViewAction extends Action2 {
368
371
original : 'Voice Chat in Chat View'
369
372
} ,
370
373
category : CHAT_CATEGORY ,
371
- precondition : ContextKeyExpr . and ( HasSpeechProvider , CONTEXT_PROVIDER_EXISTS ) ,
374
+ precondition : ContextKeyExpr . and ( HasSpeechProvider , CONTEXT_PROVIDER_EXISTS , CONTEXT_CHAT_REQUEST_IN_PROGRESS . negate ( ) ) ,
372
375
f1 : true
373
376
} ) ;
374
377
}
@@ -395,7 +398,7 @@ export class InlineVoiceChatAction extends Action2 {
395
398
original : 'Inline Voice Chat'
396
399
} ,
397
400
category : CHAT_CATEGORY ,
398
- precondition : ContextKeyExpr . and ( HasSpeechProvider , CONTEXT_PROVIDER_EXISTS , ActiveEditorContext ) ,
401
+ precondition : ContextKeyExpr . and ( HasSpeechProvider , CONTEXT_PROVIDER_EXISTS , ActiveEditorContext , CONTEXT_CHAT_REQUEST_IN_PROGRESS . negate ( ) ) ,
399
402
f1 : true
400
403
} ) ;
401
404
}
@@ -422,7 +425,7 @@ export class QuickVoiceChatAction extends Action2 {
422
425
original : 'Quick Voice Chat'
423
426
} ,
424
427
category : CHAT_CATEGORY ,
425
- precondition : ContextKeyExpr . and ( HasSpeechProvider , CONTEXT_PROVIDER_EXISTS ) ,
428
+ precondition : ContextKeyExpr . and ( HasSpeechProvider , CONTEXT_PROVIDER_EXISTS , CONTEXT_CHAT_REQUEST_IN_PROGRESS . negate ( ) ) ,
426
429
f1 : true
427
430
} ) ;
428
431
}
@@ -450,7 +453,7 @@ export class StartVoiceChatAction extends Action2 {
450
453
} ,
451
454
category : CHAT_CATEGORY ,
452
455
icon : Codicon . mic ,
453
- precondition : ContextKeyExpr . and ( HasSpeechProvider , CONTEXT_VOICE_CHAT_GETTING_READY . negate ( ) ) ,
456
+ precondition : ContextKeyExpr . and ( HasSpeechProvider , CONTEXT_VOICE_CHAT_GETTING_READY . negate ( ) , CONTEXT_CHAT_REQUEST_IN_PROGRESS . negate ( ) ) ,
454
457
menu : [ {
455
458
id : MenuId . ChatExecute ,
456
459
when : ContextKeyExpr . and ( HasSpeechProvider , CONTEXT_VOICE_CHAT_IN_VIEW_IN_PROGRESS . negate ( ) , CONTEXT_QUICK_VOICE_CHAT_IN_PROGRESS . negate ( ) , CONTEXT_VOICE_CHAT_IN_EDITOR_IN_PROGRESS . negate ( ) ) ,
0 commit comments