Skip to content

Commit 198cd6e

Browse files
authored
use modal to align with other voice action (microsoft#269598)
1 parent f8b61d4 commit 198cd6e

1 file changed

Lines changed: 15 additions & 32 deletions

File tree

src/vs/workbench/contrib/terminalContrib/voice/browser/terminalVoiceActions.ts

Lines changed: 15 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,13 @@
33
* Licensed under the MIT License. See License.txt in the project root for license information.
44
*--------------------------------------------------------------------------------------------*/
55

6-
import { IAction } from '../../../../../base/common/actions.js';
76
import { localize, localize2 } from '../../../../../nls.js';
87
import { MenuId } from '../../../../../platform/actions/common/actions.js';
98
import { ICommandService } from '../../../../../platform/commands/common/commands.js';
109
import { ContextKeyExpr, IContextKeyService } from '../../../../../platform/contextkey/common/contextkey.js';
10+
import { IDialogService } from '../../../../../platform/dialogs/common/dialogs.js';
1111
import { IExtensionManagementService } from '../../../../../platform/extensionManagement/common/extensionManagement.js';
1212
import { IInstantiationService } from '../../../../../platform/instantiation/common/instantiation.js';
13-
import { INotificationService, Severity } from '../../../../../platform/notification/common/notification.js';
1413
import { EnablementState, IWorkbenchExtensionEnablementService } from '../../../../services/extensionManagement/common/extensionManagement.js';
1514
import { HasSpeechProvider, SpeechToTextInProgress } from '../../../speech/common/speechService.js';
1615
import { registerActiveInstanceAction, sharedWhenClause } from '../../../terminal/browser/terminalActions.js';
@@ -30,7 +29,7 @@ export function registerTerminalVoiceActions() {
3029
run: async (activeInstance, c, accessor) => {
3130
const contextKeyService = accessor.get(IContextKeyService);
3231
const commandService = accessor.get(ICommandService);
33-
const notificationService = accessor.get(INotificationService);
32+
const dialogService = accessor.get(IDialogService);
3433
const workbenchExtensionEnablementService = accessor.get(IWorkbenchExtensionEnablementService);
3534
const extensionManagementService = accessor.get(IExtensionManagementService);
3635
if (HasSpeechProvider.getValue(contextKeyService)) {
@@ -41,39 +40,23 @@ export function registerTerminalVoiceActions() {
4140
const extensions = await extensionManagementService.getInstalled();
4241
const extension = extensions.find(extension => extension.identifier.id === 'ms-vscode.vscode-speech');
4342
const extensionIsDisabled = extension && !workbenchExtensionEnablementService.isEnabled(extension);
44-
const learnMoreAction = {
45-
label: localize('viewExtension', "View Extension"),
46-
run: () => commandService.executeCommand('workbench.extensions.search', '@id:ms-vscode.vscode-speech'),
47-
id: '',
48-
tooltip: '',
49-
class: undefined,
50-
enabled: true
51-
};
52-
53-
const actions: IAction[] = [];
43+
let run: () => Promise<unknown>;
5444
let message: string;
45+
let primaryButton: string;
5546
if (extensionIsDisabled) {
56-
message = localize('terminal.voice.enableSpeechExtension', "You must enable the Speech extension to use Dictation in the Terminal.");
57-
actions.push({
58-
id: 'enableSpeechExtension',
59-
tooltip: '',
60-
class: undefined,
61-
enabled: true,
62-
label: localize('enableSpeechExtension', "Enable for Workspace"),
63-
run: () => workbenchExtensionEnablementService.setEnablement([extension], EnablementState.EnabledWorkspace),
64-
}, learnMoreAction);
47+
message = localize('terminal.voice.enableSpeechExtension', "Would you like to enable the speech extension?");
48+
primaryButton = localize('enableExtension', "Enable Extension");
49+
run = () => workbenchExtensionEnablementService.setEnablement([extension], EnablementState.EnabledWorkspace);
6550
} else {
66-
message = localize('terminal.voice.installSpeechExtension', "You must install the Speech extension to use Dictation in the Terminal.");
67-
actions.push({
68-
id: 'installSpeechExtension',
69-
label: localize('installSpeechExtension', "Install Speech Extension"),
70-
run: () => commandService.executeCommand('workbench.extensions.installExtension', 'ms-vscode.vscode-speech'),
71-
tooltip: '',
72-
class: undefined,
73-
enabled: true
74-
}, learnMoreAction);
51+
message = localize('terminal.voice.installSpeechExtension', "Would you like to install 'VS Code Speech' extension from 'Microsoft'?");
52+
run = () => commandService.executeCommand('workbench.extensions.installExtension', 'ms-vscode.vscode-speech');
53+
primaryButton = localize('installExtension', "Install Extension");
54+
}
55+
const detail = localize('terminal.voice.detail', "Microphone support requires this extension.");
56+
const confirmed = await dialogService.confirm({ message, primaryButton, type: 'info', detail });
57+
if (confirmed.confirmed) {
58+
await run();
7559
}
76-
notificationService.notify({ severity: Severity.Info, message, actions: { primary: actions } });
7760
},
7861
menu: [
7962
{

0 commit comments

Comments
 (0)