4
4
*--------------------------------------------------------------------------------------------*/
5
5
6
6
import { status } from 'vs/base/browser/ui/aria/aria' ;
7
- import { disposableTimeout } from 'vs/base/common/async' ;
7
+ import { RunOnceScheduler } from 'vs/base/common/async' ;
8
8
import { Disposable , IDisposable } from 'vs/base/common/lifecycle' ;
9
9
import { AudioCue , AudioCueGroupId , IAudioCueService } from 'vs/platform/audioCues/browser/audioCueService' ;
10
10
import { IChatAccessibilityService } from 'vs/workbench/contrib/chat/browser/chat' ;
@@ -17,29 +17,31 @@ export class ChatAccessibilityService extends Disposable implements IChatAccessi
17
17
18
18
private _responsePendingAudioCue : IDisposable | undefined ;
19
19
private _hasReceivedRequest : boolean = false ;
20
+ private _runOnceScheduler : RunOnceScheduler | undefined ;
20
21
21
22
constructor ( @IAudioCueService private readonly _audioCueService : IAudioCueService ) {
22
23
super ( ) ;
23
24
}
24
25
acceptRequest ( ) : void {
25
26
this . _audioCueService . playAudioCue ( AudioCue . chatRequestSent , true ) ;
26
- this . _register ( disposableTimeout ( ( ) => {
27
+ this . _runOnceScheduler = new RunOnceScheduler ( ( ) => {
27
28
if ( ! this . _hasReceivedRequest ) {
28
29
this . _responsePendingAudioCue = this . _audioCueService . playAudioCueLoop ( AudioCue . chatResponsePending , CHAT_RESPONSE_PENDING_AUDIO_CUE_LOOP_MS ) ;
29
30
}
30
- } , CHAT_RESPONSE_PENDING_AUDIO_CUE_LOOP_MS ) ) ;
31
+ } , CHAT_RESPONSE_PENDING_AUDIO_CUE_LOOP_MS ) ;
31
32
}
32
33
acceptResponse ( response ?: IChatResponseViewModel | string ) : void {
33
34
this . _hasReceivedRequest = true ;
34
35
const isPanelChat = typeof response !== 'string' ;
35
36
this . _responsePendingAudioCue ?. dispose ( ) ;
37
+ this . _runOnceScheduler ?. cancel ( ) ;
36
38
this . _audioCueService . playRandomAudioCue ( AudioCueGroupId . chatResponseReceived , true ) ;
39
+ this . _hasReceivedRequest = false ;
37
40
if ( ! response ) {
38
41
return ;
39
42
}
40
43
const errorDetails = isPanelChat && response . errorDetails ? ` ${ response . errorDetails . message } ` : '' ;
41
44
const content = isPanelChat ? response . response . value : response ;
42
45
status ( content + errorDetails ) ;
43
- this . _hasReceivedRequest = false ;
44
46
}
45
47
}
0 commit comments