Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement Audio cues on cell execution completed #165442

12 changes: 12 additions & 0 deletions src/vs/platform/audioCues/browser/audioCueService.ts
Expand Up @@ -249,6 +249,18 @@ export class AudioCue {
settingsKey: 'audioCues.terminalBell'
});

public static readonly notebookCellCompleted = AudioCue.register({
name: localize('audioCues.notebookCellCompleted', 'Notebook Cell Completed'),
sound: Sound.taskCompleted,
settingsKey: 'audioCues.notebookCellCompleted'
});

public static readonly notebookCellFailed = AudioCue.register({
name: localize('audioCues.notebookCellFailed', 'Notebook Cell Failed'),
sound: Sound.taskFailed,
settingsKey: 'audioCues.notebookCellFailed'
});

public static readonly diffLineInserted = AudioCue.register({
name: localize('audioCues.diffLineInserted', 'Diff Line Inserted'),
sound: Sound.diffLineInserted,
Expand Down
Expand Up @@ -95,6 +95,14 @@ Registry.as<IConfigurationRegistry>(ConfigurationExtensions.Configuration).regis
'description': localize('audioCues.diffLineDeleted', "Plays a sound when the focus moves to a deleted line in diff review mode"),
...audioCueFeatureBase,
},
'audioCues.notebookCellCompleted': {
'description': localize('audioCues.notebookCellCompleted', "Plays a sound when a notebook cell execution is successfully completed."),
...audioCueFeatureBase,
},
'audioCues.notebookCellFailed': {
'description': localize('audioCues.notebookCellFailed', "Plays a sound when a notebook cell execution fails."),
...audioCueFeatureBase,
},
}
});

Expand Down
Expand Up @@ -9,6 +9,7 @@ import { ResourceMap } from 'vs/base/common/map';
import { isEqual } from 'vs/base/common/resources';
import { withNullAsUndefined } from 'vs/base/common/types';
import { URI } from 'vs/base/common/uri';
import { AudioCue, IAudioCueService } from 'vs/platform/audioCues/browser/audioCueService';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { ILogService } from 'vs/platform/log/common/log';
import { NotebookTextModel } from 'vs/workbench/contrib/notebook/common/model/notebookTextModel';
Expand Down Expand Up @@ -36,6 +37,7 @@ export class NotebookExecutionStateService extends Disposable implements INotebo
@IInstantiationService private readonly _instantiationService: IInstantiationService,
@ILogService private readonly _logService: ILogService,
@INotebookService private readonly _notebookService: INotebookService,
@IAudioCueService private readonly _audioCueService: IAudioCueService
) {
super();
}
Expand Down Expand Up @@ -104,8 +106,12 @@ export class NotebookExecutionStateService extends Disposable implements INotebo

if (lastRunSuccess !== undefined) {
if (lastRunSuccess) {
if (this._executions.size === 0) {
this._audioCueService.playAudioCue(AudioCue.notebookCellCompleted);
}
this._clearLastFailedCell(notebookUri);
} else {
this._audioCueService.playAudioCue(AudioCue.notebookCellFailed);
this._setLastFailedCell(notebookUri, cellHandle);
}
}
Expand Down