Skip to content

Commit

Permalink
Implement Audio cues on cell execution completed (#165442)
Browse files Browse the repository at this point in the history
* 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 <roblourens@gmail.com>
  • Loading branch information
MonadChains and roblourens authored Nov 17, 2022
1 parent c3f40b9 commit 5865df3
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/vs/platform/audioCues/browser/audioCueService.ts
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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

0 comments on commit 5865df3

Please sign in to comment.