@codingame/monaco-vscode-chat-service-override 2.1.1 → 2.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@codingame/monaco-vscode-chat-service-override",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.3",
|
|
4
4
|
"keywords": [],
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "CodinGame",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"module": "index.js",
|
|
19
19
|
"types": "index.d.ts",
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"vscode": "npm:@codingame/monaco-vscode-api@2.1.
|
|
21
|
+
"vscode": "npm:@codingame/monaco-vscode-api@2.1.3",
|
|
22
22
|
"vscode-marked": "npm:marked@=3.0.2"
|
|
23
23
|
}
|
|
24
24
|
}
|
|
@@ -7,7 +7,10 @@ import { Registry } from 'vscode/vscode/vs/platform/registry/common/platform';
|
|
|
7
7
|
import { InlineChatNotebookContribution } from './inlineChatNotebook.js';
|
|
8
8
|
import { Extensions } from 'vscode/vscode/vs/workbench/common/contributions';
|
|
9
9
|
import { InlineChatAccessibleViewContribution } from './inlineChatAccessibleView.js';
|
|
10
|
+
import { StartSessionAction, HoldToSpeak } from './inlineChatActions2.js';
|
|
10
11
|
|
|
12
|
+
registerAction2(StartSessionAction);
|
|
13
|
+
registerAction2(HoldToSpeak);
|
|
11
14
|
registerEditorContribution(INLINE_CHAT_ID, InlineChatController, 0 );
|
|
12
15
|
registerEditorContribution(INTERACTIVE_EDITOR_ACCESSIBILITY_HELP_ID, InlineAccessibilityHelpContribution, 3 );
|
|
13
16
|
registerAction2(CloseAction);
|
|
@@ -23,7 +23,12 @@ import { IPreferencesService } from 'vscode/vscode/vs/workbench/services/prefere
|
|
|
23
23
|
|
|
24
24
|
CommandsRegistry.registerCommandAlias('interactiveEditor.start', 'inlineChat.start');
|
|
25
25
|
CommandsRegistry.registerCommandAlias('interactive.acceptChanges', ACTION_ACCEPT_CHANGES);
|
|
26
|
-
|
|
26
|
+
const LOCALIZED_START_INLINE_CHAT_STRING = ( localizeWithPath(
|
|
27
|
+
'vs/workbench/contrib/inlineChat/browser/inlineChatActions',
|
|
28
|
+
'run',
|
|
29
|
+
'Start Inline Chat'
|
|
30
|
+
));
|
|
31
|
+
const START_INLINE_CHAT = registerIcon('start-inline-chat', Codicon.sparkle, ( localizeWithPath(
|
|
27
32
|
'vs/workbench/contrib/inlineChat/browser/inlineChatActions',
|
|
28
33
|
'startInlineChat',
|
|
29
34
|
'Icon which spawns the inline chat from the editor toolbar.'
|
|
@@ -736,4 +741,4 @@ class InlineAccessibilityHelpContribution extends Disposable {
|
|
|
736
741
|
}
|
|
737
742
|
}
|
|
738
743
|
|
|
739
|
-
export { AbstractInlineChatAction, AcceptChanges, ArrowOutDownAction, ArrowOutUpAction, CancelSessionAction, CloseAction, ConfigureInlineChatAction, ContractMessageAction, CopyRecordings, DiscardAction, DiscardHunkAction, DiscardToClipboardAction, DiscardUndoToNewFileAction, ExpandMessageAction, FeebackHelpfulCommand, FeebackUnhelpfulCommand, FocusInlineChat, InlineAccessibilityHelpContribution, MakeRequestAction, NextFromHistory, PreviousFromHistory, ReRunRequestAction, ReportIssueForBugCommand, StopRequestAction, ToggleDiffForChange, UnstashSessionAction, ViewInChatAction };
|
|
744
|
+
export { AbstractInlineChatAction, AcceptChanges, ArrowOutDownAction, ArrowOutUpAction, CancelSessionAction, CloseAction, ConfigureInlineChatAction, ContractMessageAction, CopyRecordings, DiscardAction, DiscardHunkAction, DiscardToClipboardAction, DiscardUndoToNewFileAction, ExpandMessageAction, FeebackHelpfulCommand, FeebackUnhelpfulCommand, FocusInlineChat, InlineAccessibilityHelpContribution, LOCALIZED_START_INLINE_CHAT_STRING, MakeRequestAction, NextFromHistory, PreviousFromHistory, ReRunRequestAction, ReportIssueForBugCommand, START_INLINE_CHAT, StopRequestAction, ToggleDiffForChange, UnstashSessionAction, ViewInChatAction };
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { KeyChord } from 'vscode/vscode/vs/base/common/keyCodes';
|
|
2
|
+
import { EditorAction2 } from 'vscode/vscode/vs/editor/browser/editorExtensions';
|
|
3
|
+
import { ContextKeyExpr } from 'vscode/vscode/vs/platform/contextkey/common/contextkey';
|
|
4
|
+
import { InlineChatController, InlineChatRunOptions } from 'vscode/vscode/vs/workbench/contrib/inlineChat/browser/inlineChatController';
|
|
5
|
+
import { LOCALIZED_START_INLINE_CHAT_STRING, AbstractInlineChatAction, START_INLINE_CHAT } from './inlineChatActions.js';
|
|
6
|
+
import { disposableTimeout } from 'vscode/vscode/vs/base/common/async';
|
|
7
|
+
import { EditorContextKeys } from 'vscode/vscode/vs/editor/common/editorContextKeys';
|
|
8
|
+
import { ICommandService } from 'vscode/vscode/vs/platform/commands/common/commands';
|
|
9
|
+
import { IKeybindingService } from 'vscode/vscode/vs/platform/keybinding/common/keybinding';
|
|
10
|
+
import { CTX_INLINE_CHAT_HAS_PROVIDER, CTX_INLINE_CHAT_VISIBLE } from 'vscode/vscode/vs/workbench/contrib/inlineChat/common/inlineChat';
|
|
11
|
+
import { IConfigurationService } from 'vscode/vscode/vs/platform/configuration/common/configuration';
|
|
12
|
+
import { ISpeechService, HasSpeechProvider } from 'vscode/vscode/vs/workbench/contrib/speech/common/speechService';
|
|
13
|
+
import { localize2WithPath } from 'vscode/vscode/vs/nls';
|
|
14
|
+
|
|
15
|
+
class StartSessionAction extends EditorAction2 {
|
|
16
|
+
constructor() {
|
|
17
|
+
super({
|
|
18
|
+
id: 'inlineChat.start',
|
|
19
|
+
title: { value: LOCALIZED_START_INLINE_CHAT_STRING, original: 'Start Inline Chat' },
|
|
20
|
+
category: AbstractInlineChatAction.category,
|
|
21
|
+
f1: true,
|
|
22
|
+
precondition: ( ContextKeyExpr.and(CTX_INLINE_CHAT_HAS_PROVIDER, EditorContextKeys.writable)),
|
|
23
|
+
keybinding: {
|
|
24
|
+
when: EditorContextKeys.focus,
|
|
25
|
+
weight: 200 ,
|
|
26
|
+
primary: 2048 | 39 ,
|
|
27
|
+
secondary: [KeyChord(2048 | 41 , 39 )],
|
|
28
|
+
},
|
|
29
|
+
icon: START_INLINE_CHAT
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
runEditorCommand(accessor, editor, ..._args) {
|
|
33
|
+
const configService = accessor.get(IConfigurationService);
|
|
34
|
+
const speechService = accessor.get(ISpeechService);
|
|
35
|
+
if (configService.getValue("inlineChat.holdToSpeech" )
|
|
36
|
+
&& speechService.hasSpeechProvider
|
|
37
|
+
) {
|
|
38
|
+
holdForSpeech(accessor, InlineChatController.get(editor), this.desc.id);
|
|
39
|
+
}
|
|
40
|
+
let options;
|
|
41
|
+
const arg = _args[0];
|
|
42
|
+
if (arg && InlineChatRunOptions.isInteractiveEditorOptions(arg)) {
|
|
43
|
+
options = arg;
|
|
44
|
+
}
|
|
45
|
+
InlineChatController.get(editor)?.run({ ...options });
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
class HoldToSpeak extends AbstractInlineChatAction {
|
|
49
|
+
constructor() {
|
|
50
|
+
super({
|
|
51
|
+
id: 'inlineChat.holdForSpeech',
|
|
52
|
+
precondition: ( ContextKeyExpr.and(HasSpeechProvider, CTX_INLINE_CHAT_VISIBLE)),
|
|
53
|
+
title: ( localize2WithPath(
|
|
54
|
+
'vs/workbench/contrib/inlineChat/browser/inlineChatActions2',
|
|
55
|
+
'holdForSpeech',
|
|
56
|
+
"Hold for Speech"
|
|
57
|
+
)),
|
|
58
|
+
keybinding: {
|
|
59
|
+
when: EditorContextKeys.textInputFocus,
|
|
60
|
+
weight: 200 ,
|
|
61
|
+
primary: 2048 | 39 ,
|
|
62
|
+
},
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
runInlineChatCommand(accessor, ctrl, editor, ...args) {
|
|
66
|
+
holdForSpeech(accessor, ctrl, this.desc.id);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
function holdForSpeech(accessor, ctrl, commandId) {
|
|
70
|
+
const keybindingService = accessor.get(IKeybindingService);
|
|
71
|
+
const commandService = accessor.get(ICommandService);
|
|
72
|
+
if (!ctrl) {
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
const holdMode = keybindingService.enableKeybindingHoldMode(commandId);
|
|
76
|
+
if (!holdMode) {
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
let listening = false;
|
|
80
|
+
const handle = disposableTimeout(() => {
|
|
81
|
+
commandService.executeCommand('workbench.action.chat.startVoiceChat', { voice: { disableTimeout: true } });
|
|
82
|
+
listening = true;
|
|
83
|
+
}, 250);
|
|
84
|
+
holdMode.finally(() => {
|
|
85
|
+
if (listening) {
|
|
86
|
+
commandService.executeCommand('workbench.action.chat.stopListening').finally(() => {
|
|
87
|
+
ctrl.acceptInput();
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
handle.dispose();
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export { HoldToSpeak, StartSessionAction };
|