Skip to content

Commit 5865df3

Browse files
Implement Audio cues on cell execution completed (microsoft#165442)
* Implement Audio cues on cell execution completed * Revert refactor and improve behaviour * Add audio cues for notebook execution * remove old setting Co-authored-by: Rob Lourens <[email protected]>
1 parent c3f40b9 commit 5865df3

File tree

3 files changed

+26
-0
lines changed

3 files changed

+26
-0
lines changed

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,18 @@ export class AudioCue {
249249
settingsKey: 'audioCues.terminalBell'
250250
});
251251

252+
public static readonly notebookCellCompleted = AudioCue.register({
253+
name: localize('audioCues.notebookCellCompleted', 'Notebook Cell Completed'),
254+
sound: Sound.taskCompleted,
255+
settingsKey: 'audioCues.notebookCellCompleted'
256+
});
257+
258+
public static readonly notebookCellFailed = AudioCue.register({
259+
name: localize('audioCues.notebookCellFailed', 'Notebook Cell Failed'),
260+
sound: Sound.taskFailed,
261+
settingsKey: 'audioCues.notebookCellFailed'
262+
});
263+
252264
public static readonly diffLineInserted = AudioCue.register({
253265
name: localize('audioCues.diffLineInserted', 'Diff Line Inserted'),
254266
sound: Sound.diffLineInserted,

src/vs/workbench/contrib/audioCues/browser/audioCues.contribution.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,14 @@ Registry.as<IConfigurationRegistry>(ConfigurationExtensions.Configuration).regis
9595
'description': localize('audioCues.diffLineDeleted', "Plays a sound when the focus moves to a deleted line in diff review mode"),
9696
...audioCueFeatureBase,
9797
},
98+
'audioCues.notebookCellCompleted': {
99+
'description': localize('audioCues.notebookCellCompleted', "Plays a sound when a notebook cell execution is successfully completed."),
100+
...audioCueFeatureBase,
101+
},
102+
'audioCues.notebookCellFailed': {
103+
'description': localize('audioCues.notebookCellFailed', "Plays a sound when a notebook cell execution fails."),
104+
...audioCueFeatureBase,
105+
},
98106
}
99107
});
100108

src/vs/workbench/contrib/notebook/browser/services/notebookExecutionStateServiceImpl.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { ResourceMap } from 'vs/base/common/map';
99
import { isEqual } from 'vs/base/common/resources';
1010
import { withNullAsUndefined } from 'vs/base/common/types';
1111
import { URI } from 'vs/base/common/uri';
12+
import { AudioCue, IAudioCueService } from 'vs/platform/audioCues/browser/audioCueService';
1213
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
1314
import { ILogService } from 'vs/platform/log/common/log';
1415
import { NotebookTextModel } from 'vs/workbench/contrib/notebook/common/model/notebookTextModel';
@@ -36,6 +37,7 @@ export class NotebookExecutionStateService extends Disposable implements INotebo
3637
@IInstantiationService private readonly _instantiationService: IInstantiationService,
3738
@ILogService private readonly _logService: ILogService,
3839
@INotebookService private readonly _notebookService: INotebookService,
40+
@IAudioCueService private readonly _audioCueService: IAudioCueService
3941
) {
4042
super();
4143
}
@@ -104,8 +106,12 @@ export class NotebookExecutionStateService extends Disposable implements INotebo
104106

105107
if (lastRunSuccess !== undefined) {
106108
if (lastRunSuccess) {
109+
if (this._executions.size === 0) {
110+
this._audioCueService.playAudioCue(AudioCue.notebookCellCompleted);
111+
}
107112
this._clearLastFailedCell(notebookUri);
108113
} else {
114+
this._audioCueService.playAudioCue(AudioCue.notebookCellFailed);
109115
this._setLastFailedCell(notebookUri, cellHandle);
110116
}
111117
}

0 commit comments

Comments
 (0)