Skip to content

Commit f309aff

Browse files
committed
work on looping cue
1 parent ceb15e0 commit f309aff

File tree

3 files changed

+26
-1
lines changed

3 files changed

+26
-1
lines changed

src/vs/editor/standalone/browser/standaloneServices.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1055,6 +1055,9 @@ class StandaloneAudioService implements IAudioCueService {
10551055

10561056
async playSound(cue: Sound, allowManyInParallel?: boolean | undefined): Promise<void> {
10571057
}
1058+
playAudioCueLoop(cue: AudioCue): IDisposable {
1059+
return toDisposable(() => { });
1060+
}
10581061
}
10591062

10601063
export interface IEditorOverrideServices {

src/vs/platform/audioCues/browser/audioCueService.ts

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Licensed under the MIT License. See License.txt in the project root for license information.
44
*--------------------------------------------------------------------------------------------*/
55

6-
import { Disposable } from 'vs/base/common/lifecycle';
6+
import { Disposable, IDisposable, toDisposable } from 'vs/base/common/lifecycle';
77
import { FileAccess } from 'vs/base/common/network';
88
import { IAccessibilityService } from 'vs/platform/accessibility/common/accessibility';
99
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
@@ -22,6 +22,7 @@ export interface IAudioCueService {
2222
onEnabledChanged(cue: AudioCue): Event<void>;
2323

2424
playSound(cue: Sound, allowManyInParallel?: boolean): Promise<void>;
25+
playAudioCueLoop(cue: AudioCue): IDisposable;
2526
}
2627

2728
export class AudioCueService extends Disposable implements IAudioCueService {
@@ -87,6 +88,23 @@ export class AudioCueService extends Disposable implements IAudioCueService {
8788
}
8889
}
8990

91+
public playAudioCueLoop(cue: AudioCue): IDisposable {
92+
let playing = true;
93+
const playSound = () => {
94+
if (playing) {
95+
this.playSound(cue.sound, true).finally(() => {
96+
if (playing) {
97+
playSound();
98+
}
99+
});
100+
}
101+
};
102+
playSound();
103+
return toDisposable(() => {
104+
playing = false;
105+
});
106+
}
107+
90108
private readonly obsoleteAudioCuesEnabled = observableFromEvent(
91109
Event.filter(this.configurationService.onDidChangeConfiguration, (e) =>
92110
e.affectsConfiguration('audioCues.enabled')

src/vs/workbench/contrib/chat/browser/chatWidget.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import 'vs/css!./media/chat';
1616
import { ICodeEditor } from 'vs/editor/browser/editorBrowser';
1717
import { localize } from 'vs/nls';
1818
import { MenuId } from 'vs/platform/actions/common/actions';
19+
import { AudioCue, IAudioCueService } from 'vs/platform/audioCues/browser/audioCueService';
1920
import { IContextKey, IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
2021
import { IContextMenuService } from 'vs/platform/contextview/browser/contextView';
2122
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
@@ -115,6 +116,7 @@ export class ChatWidget extends Disposable implements IChatWidget {
115116
@IChatService private readonly chatService: IChatService,
116117
@IChatWidgetService chatWidgetService: IChatWidgetService,
117118
@IContextMenuService private readonly contextMenuService: IContextMenuService,
119+
@IAudioCueService private readonly audioCueService: IAudioCueService
118120
) {
119121
super();
120122
CONTEXT_IN_CHAT_SESSION.bindTo(contextKeyService).set(true);
@@ -390,8 +392,10 @@ export class ChatWidget extends Disposable implements IChatWidget {
390392
}
391393

392394
const input = query ?? editorValue;
395+
const cue = this.audioCueService.playAudioCueLoop(AudioCue.break);
393396
const result = await this.chatService.sendRequest(this.viewModel.sessionId, input);
394397
if (result) {
398+
cue.dispose();
395399
this.inputPart.acceptInput(query);
396400
result.responseCompletePromise.then(() => {
397401
const responses = this.viewModel?.getItems().filter(isResponseVM);

0 commit comments

Comments
 (0)