44 *--------------------------------------------------------------------------------------------*/
55
66import { status } from 'vs/base/browser/ui/aria/aria' ;
7- import { disposableTimeout } from 'vs/base/common/async' ;
7+ import { RunOnceScheduler } from 'vs/base/common/async' ;
88import { Disposable , IDisposable } from 'vs/base/common/lifecycle' ;
99import { AudioCue , AudioCueGroupId , IAudioCueService } from 'vs/platform/audioCues/browser/audioCueService' ;
1010import { IChatAccessibilityService } from 'vs/workbench/contrib/chat/browser/chat' ;
@@ -17,29 +17,31 @@ export class ChatAccessibilityService extends Disposable implements IChatAccessi
1717
1818 private _responsePendingAudioCue : IDisposable | undefined ;
1919 private _hasReceivedRequest : boolean = false ;
20+ private _runOnceScheduler : RunOnceScheduler | undefined ;
2021
2122 constructor ( @IAudioCueService private readonly _audioCueService : IAudioCueService ) {
2223 super ( ) ;
2324 }
2425 acceptRequest ( ) : void {
2526 this . _audioCueService . playAudioCue ( AudioCue . chatRequestSent , true ) ;
26- this . _register ( disposableTimeout ( ( ) => {
27+ this . _runOnceScheduler = new RunOnceScheduler ( ( ) => {
2728 if ( ! this . _hasReceivedRequest ) {
2829 this . _responsePendingAudioCue = this . _audioCueService . playAudioCueLoop ( AudioCue . chatResponsePending , CHAT_RESPONSE_PENDING_AUDIO_CUE_LOOP_MS ) ;
2930 }
30- } , CHAT_RESPONSE_PENDING_AUDIO_CUE_LOOP_MS ) ) ;
31+ } , CHAT_RESPONSE_PENDING_AUDIO_CUE_LOOP_MS ) ;
3132 }
3233 acceptResponse ( response ?: IChatResponseViewModel | string ) : void {
3334 this . _hasReceivedRequest = true ;
3435 const isPanelChat = typeof response !== 'string' ;
3536 this . _responsePendingAudioCue ?. dispose ( ) ;
37+ this . _runOnceScheduler ?. cancel ( ) ;
3638 this . _audioCueService . playRandomAudioCue ( AudioCueGroupId . chatResponseReceived , true ) ;
39+ this . _hasReceivedRequest = false ;
3740 if ( ! response ) {
3841 return ;
3942 }
4043 const errorDetails = isPanelChat && response . errorDetails ? ` ${ response . errorDetails . message } ` : '' ;
4144 const content = isPanelChat ? response . response . value : response ;
4245 status ( content + errorDetails ) ;
43- this . _hasReceivedRequest = false ;
4446 }
4547}
0 commit comments