@codingame/monaco-vscode-chat-service-override 5.2.0 → 6.0.0
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/chat.js +5 -7
- package/package.json +2 -2
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatAccessibilityHelp.js +160 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatClearActions.js +17 -11
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatCodeblockActions.js +15 -13
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatContextActions.js +215 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatCopyActions.js +1 -9
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatFileTreeActions.js +6 -4
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatTitleActions.js +15 -93
- package/vscode/src/vs/workbench/contrib/chat/browser/chat.contribution.js +27 -106
- package/vscode/src/vs/workbench/contrib/chat/browser/chatAccessibilityService.js +5 -2
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditor.js +6 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/chatParticipantContributions.js +95 -51
- package/vscode/src/vs/workbench/contrib/chat/browser/chatQuick.js +4 -4
- package/vscode/src/vs/workbench/contrib/chat/browser/chatResponseAccessibleView.js +94 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatVariables.js +64 -8
- package/vscode/src/vs/workbench/contrib/chat/browser/chatViewPane.js +2 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/contrib/chatContextAttachments.js +50 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/contrib/chatInputCompletions.js +370 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/contrib/chatInputEditorContrib.js +19 -366
- package/vscode/src/vs/workbench/contrib/chat/common/chatServiceImpl.js +122 -63
- package/vscode/src/vs/workbench/contrib/chat/common/chatWidgetHistoryService.js +12 -5
- package/vscode/src/vs/workbench/contrib/chat/common/languageModelStats.js +6 -5
- package/vscode/src/vs/workbench/contrib/chat/common/{voiceChat.js → voiceChatService.js} +58 -21
- package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChat.contribution.js +15 -14
- package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatAccessibleView.js +33 -32
- package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatSavingServiceImpl.js +6 -3
- package/vscode/src/vs/workbench/contrib/chat/browser/contrib/chatHistoryVariables.js +0 -26
- package/vscode/src/vs/workbench/contrib/chat/common/languageModels.js +0 -50
- package/vscode/src/vs/workbench/contrib/inlineChat/common/inlineChatServiceImpl.js +0 -33
|
@@ -1,19 +1,28 @@
|
|
|
1
1
|
import { __decorate, __param } from 'vscode/external/tslib/tslib.es6.js';
|
|
2
|
+
import { localizeWithPath } from 'vscode/vscode/vs/nls';
|
|
2
3
|
import { Emitter } from 'vscode/vscode/vs/base/common/event';
|
|
3
4
|
import { Disposable, DisposableStore } from 'vscode/vscode/vs/base/common/lifecycle';
|
|
4
5
|
import { rtrim } from 'vscode/vscode/vs/base/common/strings';
|
|
6
|
+
import { RawContextKey } from 'vscode/vscode/vs/platform/contextkey/common/contextkey';
|
|
7
|
+
import { IContextKeyService } from 'vscode/vscode/vs/platform/contextkey/common/contextkey.service';
|
|
5
8
|
import { IChatAgentService } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatAgents.service';
|
|
6
9
|
import { chatAgentLeader, chatSubcommandLeader } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatParserTypes';
|
|
7
10
|
import { SpeechToTextStatus } from 'vscode/vscode/vs/workbench/contrib/speech/common/speechService';
|
|
8
11
|
import { ISpeechService } from 'vscode/vscode/vs/workbench/contrib/speech/common/speechService.service';
|
|
9
12
|
|
|
10
13
|
var VoiceChatService_1;
|
|
14
|
+
const _moduleId = "vs/workbench/contrib/chat/common/voiceChatService";
|
|
11
15
|
var PhraseTextType;
|
|
12
|
-
( (function(PhraseTextType) {
|
|
16
|
+
( ((function(PhraseTextType) {
|
|
13
17
|
PhraseTextType[PhraseTextType["AGENT"] = 1] = "AGENT";
|
|
14
18
|
PhraseTextType[PhraseTextType["COMMAND"] = 2] = "COMMAND";
|
|
15
19
|
PhraseTextType[PhraseTextType["AGENT_AND_COMMAND"] = 3] = "AGENT_AND_COMMAND";
|
|
16
|
-
})(PhraseTextType || (PhraseTextType = {})));
|
|
20
|
+
})(PhraseTextType || (PhraseTextType = {}))));
|
|
21
|
+
const VoiceChatInProgress = ( (new RawContextKey(
|
|
22
|
+
'voiceChatInProgress',
|
|
23
|
+
false,
|
|
24
|
+
{ type: 'boolean', description: ( localizeWithPath(_moduleId, 0, "A speech-to-text session is in progress for chat.")) }
|
|
25
|
+
)));
|
|
17
26
|
let VoiceChatService = class VoiceChatService extends Disposable {
|
|
18
27
|
static { VoiceChatService_1 = this; }
|
|
19
28
|
static { this.AGENT_PREFIX = chatAgentLeader; }
|
|
@@ -26,14 +35,17 @@ let VoiceChatService = class VoiceChatService extends Disposable {
|
|
|
26
35
|
[VoiceChatService_1.AGENT_PREFIX]: 'At',
|
|
27
36
|
[VoiceChatService_1.COMMAND_PREFIX]: 'Slash'
|
|
28
37
|
}; }
|
|
29
|
-
static { this.CHAT_AGENT_ALIAS = ( new Map([['vscode', 'code']])); }
|
|
30
|
-
constructor(speechService, chatAgentService) {
|
|
38
|
+
static { this.CHAT_AGENT_ALIAS = ( (new Map([['vscode', 'code']]))); }
|
|
39
|
+
constructor(speechService, chatAgentService, contextKeyService) {
|
|
31
40
|
super();
|
|
32
41
|
this.speechService = speechService;
|
|
33
42
|
this.chatAgentService = chatAgentService;
|
|
43
|
+
this.contextKeyService = contextKeyService;
|
|
44
|
+
this.voiceChatInProgress = VoiceChatInProgress.bindTo(this.contextKeyService);
|
|
45
|
+
this.activeVoiceChatSessions = 0;
|
|
34
46
|
}
|
|
35
47
|
createPhrases(model) {
|
|
36
|
-
const phrases = ( new Map());
|
|
48
|
+
const phrases = ( (new Map()));
|
|
37
49
|
for (const agent of this.chatAgentService.getActivatedAgents()) {
|
|
38
50
|
const agentPhrase = `${VoiceChatService_1.PHRASES_LOWER[VoiceChatService_1.AGENT_PREFIX]} ${VoiceChatService_1.CHAT_AGENT_ALIAS.get(agent.name) ?? agent.name}`.toLowerCase();
|
|
39
51
|
phrases.set(agentPhrase, { agent: agent.name });
|
|
@@ -57,17 +69,30 @@ let VoiceChatService = class VoiceChatService extends Disposable {
|
|
|
57
69
|
}
|
|
58
70
|
}
|
|
59
71
|
async createVoiceChatSession(token, options) {
|
|
60
|
-
const disposables = ( new DisposableStore());
|
|
61
|
-
|
|
72
|
+
const disposables = ( (new DisposableStore()));
|
|
73
|
+
const onSessionStoppedOrCanceled = (dispose) => {
|
|
74
|
+
this.activeVoiceChatSessions = Math.max(0, this.activeVoiceChatSessions - 1);
|
|
75
|
+
if (this.activeVoiceChatSessions === 0) {
|
|
76
|
+
this.voiceChatInProgress.reset();
|
|
77
|
+
}
|
|
78
|
+
if (dispose) {
|
|
79
|
+
disposables.dispose();
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
disposables.add(token.onCancellationRequested(() => onSessionStoppedOrCanceled(true)));
|
|
62
83
|
let detectedAgent = false;
|
|
63
84
|
let detectedSlashCommand = false;
|
|
64
|
-
const emitter = disposables.add(( new Emitter()));
|
|
85
|
+
const emitter = disposables.add(( (new Emitter())));
|
|
65
86
|
const session = await this.speechService.createSpeechToTextSession(token, 'chat');
|
|
87
|
+
if (token.isCancellationRequested) {
|
|
88
|
+
onSessionStoppedOrCanceled(true);
|
|
89
|
+
}
|
|
66
90
|
const phrases = this.createPhrases(options.model);
|
|
67
91
|
disposables.add(session.onDidChange(e => {
|
|
68
92
|
switch (e.status) {
|
|
69
93
|
case SpeechToTextStatus.Recognizing:
|
|
70
|
-
case SpeechToTextStatus.Recognized:
|
|
94
|
+
case SpeechToTextStatus.Recognized: {
|
|
95
|
+
let massagedEvent = e;
|
|
71
96
|
if (e.text) {
|
|
72
97
|
const startsWithAgent = e.text.startsWith(VoiceChatService_1.PHRASES_UPPER[VoiceChatService_1.AGENT_PREFIX]) || e.text.startsWith(VoiceChatService_1.PHRASES_LOWER[VoiceChatService_1.AGENT_PREFIX]);
|
|
73
98
|
const startsWithSlashCommand = e.text.startsWith(VoiceChatService_1.PHRASES_UPPER[VoiceChatService_1.COMMAND_PREFIX]) || e.text.startsWith(VoiceChatService_1.PHRASES_LOWER[VoiceChatService_1.COMMAND_PREFIX]);
|
|
@@ -76,7 +101,7 @@ let VoiceChatService = class VoiceChatService extends Disposable {
|
|
|
76
101
|
let transformedWords;
|
|
77
102
|
let waitingForInput = false;
|
|
78
103
|
if (options.usesAgents && startsWithAgent && !detectedAgent && !detectedSlashCommand && originalWords.length >= 4) {
|
|
79
|
-
const phrase = phrases.get(( originalWords.slice(0, 4).map(word => this.normalizeWord(word))).join(' '));
|
|
104
|
+
const phrase = phrases.get(( (originalWords.slice(0, 4).map(word => this.normalizeWord(word)))).join(' '));
|
|
80
105
|
if (phrase) {
|
|
81
106
|
transformedWords = [this.toText(phrase, PhraseTextType.AGENT_AND_COMMAND), ...originalWords.slice(4)];
|
|
82
107
|
waitingForInput = originalWords.length === 4;
|
|
@@ -87,7 +112,7 @@ let VoiceChatService = class VoiceChatService extends Disposable {
|
|
|
87
112
|
}
|
|
88
113
|
}
|
|
89
114
|
if (options.usesAgents && startsWithAgent && !detectedAgent && !transformedWords && originalWords.length >= 2) {
|
|
90
|
-
const phrase = phrases.get(( originalWords.slice(0, 2).map(word => this.normalizeWord(word))).join(' '));
|
|
115
|
+
const phrase = phrases.get(( (originalWords.slice(0, 2).map(word => this.normalizeWord(word)))).join(' '));
|
|
91
116
|
if (phrase) {
|
|
92
117
|
transformedWords = [this.toText(phrase, PhraseTextType.AGENT), ...originalWords.slice(2)];
|
|
93
118
|
waitingForInput = originalWords.length === 2;
|
|
@@ -97,7 +122,7 @@ let VoiceChatService = class VoiceChatService extends Disposable {
|
|
|
97
122
|
}
|
|
98
123
|
}
|
|
99
124
|
if (startsWithSlashCommand && !detectedSlashCommand && !transformedWords && originalWords.length >= 2) {
|
|
100
|
-
const phrase = phrases.get(( originalWords.slice(0, 2).map(word => this.normalizeWord(word))).join(' '));
|
|
125
|
+
const phrase = phrases.get(( (originalWords.slice(0, 2).map(word => this.normalizeWord(word)))).join(' '));
|
|
101
126
|
if (phrase) {
|
|
102
127
|
transformedWords = [this.toText(phrase, options.usesAgents && !detectedAgent ?
|
|
103
128
|
PhraseTextType.AGENT_AND_COMMAND :
|
|
@@ -109,15 +134,26 @@ let VoiceChatService = class VoiceChatService extends Disposable {
|
|
|
109
134
|
}
|
|
110
135
|
}
|
|
111
136
|
}
|
|
112
|
-
|
|
137
|
+
massagedEvent = {
|
|
113
138
|
status: e.status,
|
|
114
139
|
text: (transformedWords ?? originalWords).join(' '),
|
|
115
140
|
waitingForInput
|
|
116
|
-
}
|
|
117
|
-
break;
|
|
141
|
+
};
|
|
118
142
|
}
|
|
119
143
|
}
|
|
120
|
-
|
|
144
|
+
emitter.fire(massagedEvent);
|
|
145
|
+
break;
|
|
146
|
+
}
|
|
147
|
+
case SpeechToTextStatus.Started:
|
|
148
|
+
this.activeVoiceChatSessions++;
|
|
149
|
+
this.voiceChatInProgress.set(true);
|
|
150
|
+
emitter.fire(e);
|
|
151
|
+
break;
|
|
152
|
+
case SpeechToTextStatus.Stopped:
|
|
153
|
+
onSessionStoppedOrCanceled(false);
|
|
154
|
+
emitter.fire(e);
|
|
155
|
+
break;
|
|
156
|
+
case SpeechToTextStatus.Error:
|
|
121
157
|
emitter.fire(e);
|
|
122
158
|
break;
|
|
123
159
|
}
|
|
@@ -133,9 +169,10 @@ let VoiceChatService = class VoiceChatService extends Disposable {
|
|
|
133
169
|
return word.toLowerCase();
|
|
134
170
|
}
|
|
135
171
|
};
|
|
136
|
-
VoiceChatService = VoiceChatService_1 = ( __decorate([
|
|
137
|
-
( __param(0, ISpeechService)),
|
|
138
|
-
( __param(1, IChatAgentService))
|
|
139
|
-
|
|
172
|
+
VoiceChatService = VoiceChatService_1 = ( (__decorate([
|
|
173
|
+
( (__param(0, ISpeechService))),
|
|
174
|
+
( (__param(1, IChatAgentService))),
|
|
175
|
+
( (__param(2, IContextKeyService)))
|
|
176
|
+
], VoiceChatService)));
|
|
140
177
|
|
|
141
|
-
export { VoiceChatService };
|
|
178
|
+
export { VoiceChatInProgress, VoiceChatService };
|
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
import { registerEditorContribution } from 'vscode/vscode/vs/editor/browser/editorExtensions';
|
|
1
|
+
import { registerEditorContribution, EditorContributionInstantiation } from 'vscode/vscode/vs/editor/browser/editorExtensions';
|
|
2
2
|
import { registerAction2 } from 'vscode/vscode/vs/platform/actions/common/actions';
|
|
3
3
|
import { InlineChatController } from 'vscode/vscode/vs/workbench/contrib/inlineChat/browser/inlineChatController';
|
|
4
|
-
import {
|
|
5
|
-
import { INLINE_CHAT_ID
|
|
6
|
-
import 'vscode/vscode/vs/platform/instantiation/common/
|
|
7
|
-
import '../common/inlineChatServiceImpl.js';
|
|
4
|
+
import { StartSessionAction, CloseAction, ConfigureInlineChatAction, UnstashSessionAction, DiscardHunkAction, DiscardAction, RerunAction, CancelSessionAction, MoveToNextHunk, MoveToPreviousHunk, ArrowOutUpAction, ArrowOutDownAction, FocusInlineChat, ViewInChatAction, ToggleDiffForChange, AcceptChanges, CopyRecordings } from 'vscode/vscode/vs/workbench/contrib/inlineChat/browser/inlineChatActions';
|
|
5
|
+
import { INLINE_CHAT_ID } from 'vscode/vscode/vs/workbench/contrib/inlineChat/common/inlineChat';
|
|
6
|
+
import 'vscode/vscode/vs/platform/instantiation/common/extensions';
|
|
8
7
|
import { Registry } from 'vscode/vscode/vs/platform/registry/common/platform';
|
|
8
|
+
import { LifecyclePhase } from 'vscode/vscode/vs/workbench/services/lifecycle/common/lifecycle';
|
|
9
9
|
import { InlineChatNotebookContribution } from './inlineChatNotebook.js';
|
|
10
|
-
import { Extensions } from 'vscode/vscode/vs/workbench/common/contributions';
|
|
10
|
+
import { Extensions, registerWorkbenchContribution2, WorkbenchPhase } from 'vscode/vscode/vs/workbench/common/contributions';
|
|
11
11
|
import './inlineChatSavingServiceImpl.js';
|
|
12
|
-
import {
|
|
13
|
-
import 'vscode/vscode/vs/
|
|
12
|
+
import { InlineChatAccessibleView } from './inlineChatAccessibleView.js';
|
|
13
|
+
import 'vscode/vscode/vs/platform/instantiation/common/instantiation';
|
|
14
|
+
import { InlineChatEnabler } from 'vscode/vscode/vs/workbench/contrib/inlineChat/browser/inlineChatSessionServiceImpl';
|
|
15
|
+
import { AccessibleViewRegistry } from 'vscode/vscode/vs/platform/accessibility/browser/accessibleViewRegistry';
|
|
14
16
|
|
|
15
|
-
registerEditorContribution(INLINE_CHAT_ID, InlineChatController,
|
|
16
|
-
registerEditorContribution(INTERACTIVE_EDITOR_ACCESSIBILITY_HELP_ID, InlineAccessibilityHelpContribution, 3 );
|
|
17
|
+
registerEditorContribution(INLINE_CHAT_ID, InlineChatController, EditorContributionInstantiation.Eager);
|
|
17
18
|
registerAction2(StartSessionAction);
|
|
18
19
|
registerAction2(CloseAction);
|
|
19
20
|
registerAction2(ConfigureInlineChatAction);
|
|
20
21
|
registerAction2(UnstashSessionAction);
|
|
21
22
|
registerAction2(DiscardHunkAction);
|
|
22
23
|
registerAction2(DiscardAction);
|
|
23
|
-
registerAction2(
|
|
24
|
-
registerAction2(DiscardUndoToNewFileAction);
|
|
24
|
+
registerAction2(RerunAction);
|
|
25
25
|
registerAction2(CancelSessionAction);
|
|
26
26
|
registerAction2(MoveToNextHunk);
|
|
27
27
|
registerAction2(MoveToPreviousHunk);
|
|
@@ -33,5 +33,6 @@ registerAction2(ToggleDiffForChange);
|
|
|
33
33
|
registerAction2(AcceptChanges);
|
|
34
34
|
registerAction2(CopyRecordings);
|
|
35
35
|
const workbenchContributionsRegistry = ( Registry.as(Extensions.Workbench));
|
|
36
|
-
workbenchContributionsRegistry.registerWorkbenchContribution(InlineChatNotebookContribution,
|
|
37
|
-
|
|
36
|
+
workbenchContributionsRegistry.registerWorkbenchContribution(InlineChatNotebookContribution, LifecyclePhase.Restored);
|
|
37
|
+
registerWorkbenchContribution2(InlineChatEnabler.Id, InlineChatEnabler, WorkbenchPhase.AfterRestored);
|
|
38
|
+
AccessibleViewRegistry.register(( new InlineChatAccessibleView()));
|
|
@@ -1,41 +1,42 @@
|
|
|
1
1
|
import { InlineChatController } from 'vscode/vscode/vs/workbench/contrib/inlineChat/browser/inlineChatController';
|
|
2
2
|
import { CTX_INLINE_CHAT_FOCUSED, CTX_INLINE_CHAT_RESPONSE_FOCUSED } from 'vscode/vscode/vs/workbench/contrib/inlineChat/common/inlineChat';
|
|
3
|
-
import { IAccessibleViewService } from 'vscode/vscode/vs/workbench/contrib/accessibility/browser/accessibleView.service';
|
|
4
|
-
import { Disposable } from 'vscode/vscode/vs/base/common/lifecycle';
|
|
5
3
|
import { ICodeEditorService } from 'vscode/vscode/vs/editor/browser/services/codeEditorService';
|
|
6
4
|
import { ContextKeyExpr } from 'vscode/vscode/vs/platform/contextkey/common/contextkey';
|
|
7
|
-
import {
|
|
5
|
+
import { AccessibleViewType, AccessibleViewProviderId } from 'vscode/vscode/vs/platform/accessibility/browser/accessibleView';
|
|
6
|
+
import { AccessibilityVerbositySettingId } from 'vscode/vscode/vs/workbench/contrib/accessibility/browser/accessibilityConfiguration';
|
|
8
7
|
|
|
9
|
-
class
|
|
8
|
+
class InlineChatAccessibleView {
|
|
10
9
|
constructor() {
|
|
11
|
-
|
|
12
|
-
this.
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
const editor = (codeEditorService.getActiveCodeEditor() || codeEditorService.getFocusedCodeEditor());
|
|
16
|
-
if (!editor) {
|
|
17
|
-
return false;
|
|
18
|
-
}
|
|
19
|
-
const controller = InlineChatController.get(editor);
|
|
20
|
-
if (!controller) {
|
|
21
|
-
return false;
|
|
22
|
-
}
|
|
23
|
-
const responseContent = controller?.getMessage();
|
|
24
|
-
if (!responseContent) {
|
|
25
|
-
return false;
|
|
26
|
-
}
|
|
27
|
-
accessibleViewService.show({
|
|
28
|
-
id: "inlineChat" ,
|
|
29
|
-
verbositySettingKey: "accessibility.verbosity.inlineChat" ,
|
|
30
|
-
provideContent() { return responseContent; },
|
|
31
|
-
onClose() {
|
|
32
|
-
controller.focus();
|
|
33
|
-
},
|
|
34
|
-
options: { type: "view" }
|
|
35
|
-
});
|
|
36
|
-
return true;
|
|
37
|
-
}, ( ContextKeyExpr.or(CTX_INLINE_CHAT_FOCUSED, CTX_INLINE_CHAT_RESPONSE_FOCUSED))));
|
|
10
|
+
this.priority = 100;
|
|
11
|
+
this.name = 'inlineChat';
|
|
12
|
+
this.when = ( ContextKeyExpr.or(CTX_INLINE_CHAT_FOCUSED, CTX_INLINE_CHAT_RESPONSE_FOCUSED));
|
|
13
|
+
this.type = AccessibleViewType.View;
|
|
38
14
|
}
|
|
15
|
+
getProvider(accessor) {
|
|
16
|
+
const codeEditorService = accessor.get(ICodeEditorService);
|
|
17
|
+
const editor = (codeEditorService.getActiveCodeEditor() || codeEditorService.getFocusedCodeEditor());
|
|
18
|
+
if (!editor) {
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
const controller = InlineChatController.get(editor);
|
|
22
|
+
if (!controller) {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
const responseContent = controller?.getMessage();
|
|
26
|
+
if (!responseContent) {
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
return {
|
|
30
|
+
id: AccessibleViewProviderId.InlineChat,
|
|
31
|
+
verbositySettingKey: AccessibilityVerbositySettingId.InlineChat,
|
|
32
|
+
provideContent() { return responseContent; },
|
|
33
|
+
onClose() {
|
|
34
|
+
controller.focus();
|
|
35
|
+
},
|
|
36
|
+
options: { type: AccessibleViewType.View }
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
dispose() { }
|
|
39
40
|
}
|
|
40
41
|
|
|
41
|
-
export {
|
|
42
|
+
export { InlineChatAccessibleView };
|
|
@@ -4,7 +4,10 @@ import { DisposableStore, MutableDisposable, dispose, combinedDisposable } from
|
|
|
4
4
|
import { isCodeEditor } from 'vscode/vscode/vs/editor/browser/editorBrowser';
|
|
5
5
|
import { localizeWithPath } from 'vscode/vscode/vs/nls';
|
|
6
6
|
import { IConfigurationService } from 'vscode/vscode/vs/platform/configuration/common/configuration.service';
|
|
7
|
+
import { SaveReason } from 'vscode/vscode/vs/workbench/common/editor';
|
|
7
8
|
import { IInlineChatSessionService } from 'vscode/vscode/vs/workbench/contrib/inlineChat/browser/inlineChatSessionService.service';
|
|
9
|
+
import { InlineChatConfigKeys } from 'vscode/vscode/vs/workbench/contrib/inlineChat/common/inlineChat';
|
|
10
|
+
import { GroupsOrder } from 'vscode/vscode/vs/workbench/services/editor/common/editorGroupsService';
|
|
8
11
|
import { IEditorGroupsService } from 'vscode/vscode/vs/workbench/services/editor/common/editorGroupsService.service';
|
|
9
12
|
import { IEditorService } from 'vscode/vscode/vs/workbench/services/editor/common/editorService.service';
|
|
10
13
|
import { IFilesConfigurationService } from 'vscode/vscode/vs/workbench/services/filesConfiguration/common/filesConfigurationService.service';
|
|
@@ -84,10 +87,10 @@ let InlineChatSavingServiceImpl = class InlineChatSavingServiceImpl {
|
|
|
84
87
|
this._saveParticipant.value = combinedDisposable(d1, d2, queue);
|
|
85
88
|
}
|
|
86
89
|
async _participate(uri, reason, progress, token) {
|
|
87
|
-
if (reason !==
|
|
90
|
+
if (reason !== SaveReason.EXPLICIT) {
|
|
88
91
|
return;
|
|
89
92
|
}
|
|
90
|
-
if (!this._configService.getValue(
|
|
93
|
+
if (!this._configService.getValue(InlineChatConfigKeys.AcceptedOrDiscardBeforeSave)) {
|
|
91
94
|
return;
|
|
92
95
|
}
|
|
93
96
|
const sessions = ( (new Map()));
|
|
@@ -125,7 +128,7 @@ let InlineChatSavingServiceImpl = class InlineChatSavingServiceImpl {
|
|
|
125
128
|
}
|
|
126
129
|
_getGroupsAndOrphans(sessions) {
|
|
127
130
|
const groupByEditor = ( (new Map()));
|
|
128
|
-
for (const group of this._editorGroupService.getGroups(
|
|
131
|
+
for (const group of this._editorGroupService.getGroups(GroupsOrder.MOST_RECENTLY_ACTIVE)) {
|
|
129
132
|
const candidate = group.activeEditorPane?.getControl();
|
|
130
133
|
if (isCodeEditor(candidate)) {
|
|
131
134
|
groupByEditor.set(candidate, group);
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { __decorate, __param } from 'vscode/external/tslib/tslib.es6.js';
|
|
2
|
-
import { Disposable } from 'vscode/vscode/vs/base/common/lifecycle';
|
|
3
|
-
import { Registry } from 'vscode/vscode/vs/platform/registry/common/platform';
|
|
4
|
-
import { Extensions } from 'vscode/vscode/vs/workbench/common/contributions';
|
|
5
|
-
import { IChatVariablesService } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatVariables.service';
|
|
6
|
-
|
|
7
|
-
let ChatHistoryVariables = class ChatHistoryVariables extends Disposable {
|
|
8
|
-
constructor(chatVariablesService) {
|
|
9
|
-
super();
|
|
10
|
-
this._register(chatVariablesService.registerVariable({ name: 'response', description: '', canTakeArgument: true, hidden: true }, async (message, arg, model, progress, token) => {
|
|
11
|
-
if (!arg) {
|
|
12
|
-
return undefined;
|
|
13
|
-
}
|
|
14
|
-
const responseNum = parseInt(arg, 10);
|
|
15
|
-
const response = model.getRequests()[responseNum - 1].response;
|
|
16
|
-
if (!response) {
|
|
17
|
-
return undefined;
|
|
18
|
-
}
|
|
19
|
-
return [{ level: 'full', value: response.response.asString() }];
|
|
20
|
-
}));
|
|
21
|
-
}
|
|
22
|
-
};
|
|
23
|
-
ChatHistoryVariables = ( __decorate([
|
|
24
|
-
( __param(0, IChatVariablesService))
|
|
25
|
-
], ChatHistoryVariables));
|
|
26
|
-
( Registry.as(Extensions.Workbench)).registerWorkbenchContribution(ChatHistoryVariables, 4 );
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { Emitter } from 'vscode/vscode/vs/base/common/event';
|
|
2
|
-
import { toDisposable } from 'vscode/vscode/vs/base/common/lifecycle';
|
|
3
|
-
|
|
4
|
-
class LanguageModelsService {
|
|
5
|
-
constructor() {
|
|
6
|
-
this._providers = ( new Map());
|
|
7
|
-
this._onDidChangeProviders = ( new Emitter());
|
|
8
|
-
this.onDidChangeLanguageModels = this._onDidChangeProviders.event;
|
|
9
|
-
}
|
|
10
|
-
dispose() {
|
|
11
|
-
this._onDidChangeProviders.dispose();
|
|
12
|
-
this._providers.clear();
|
|
13
|
-
}
|
|
14
|
-
getLanguageModelIds() {
|
|
15
|
-
return Array.from(( this._providers.keys()));
|
|
16
|
-
}
|
|
17
|
-
lookupLanguageModel(identifier) {
|
|
18
|
-
return this._providers.get(identifier)?.metadata;
|
|
19
|
-
}
|
|
20
|
-
registerLanguageModelChat(identifier, provider) {
|
|
21
|
-
if (( this._providers.has(identifier))) {
|
|
22
|
-
throw ( new Error(
|
|
23
|
-
`Chat response provider with identifier ${identifier} is already registered.`
|
|
24
|
-
));
|
|
25
|
-
}
|
|
26
|
-
this._providers.set(identifier, provider);
|
|
27
|
-
this._onDidChangeProviders.fire({ added: [provider.metadata] });
|
|
28
|
-
return toDisposable(() => {
|
|
29
|
-
if (this._providers.delete(identifier)) {
|
|
30
|
-
this._onDidChangeProviders.fire({ removed: [identifier] });
|
|
31
|
-
}
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
makeLanguageModelChatRequest(identifier, from, messages, options, progress, token) {
|
|
35
|
-
const provider = this._providers.get(identifier);
|
|
36
|
-
if (!provider) {
|
|
37
|
-
throw ( new Error(`Chat response provider with identifier ${identifier} is not registered.`));
|
|
38
|
-
}
|
|
39
|
-
return provider.provideChatResponse(messages, from, options, progress, token);
|
|
40
|
-
}
|
|
41
|
-
computeTokenLength(identifier, message, token) {
|
|
42
|
-
const provider = this._providers.get(identifier);
|
|
43
|
-
if (!provider) {
|
|
44
|
-
throw ( new Error(`Chat response provider with identifier ${identifier} is not registered.`));
|
|
45
|
-
}
|
|
46
|
-
return provider.provideTokenCount(message, token);
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
export { LanguageModelsService };
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { __decorate, __param } from 'vscode/external/tslib/tslib.es6.js';
|
|
2
|
-
import { toDisposable } from 'vscode/vscode/vs/base/common/lifecycle';
|
|
3
|
-
import { Emitter } from 'vscode/vscode/vs/base/common/event';
|
|
4
|
-
import { LinkedList } from 'vscode/vscode/vs/base/common/linkedList';
|
|
5
|
-
import { IContextKeyService } from 'vscode/vscode/vs/platform/contextkey/common/contextkey.service';
|
|
6
|
-
import { CTX_INLINE_CHAT_HAS_PROVIDER } from 'vscode/vscode/vs/workbench/contrib/inlineChat/common/inlineChat';
|
|
7
|
-
|
|
8
|
-
let InlineChatServiceImpl = class InlineChatServiceImpl {
|
|
9
|
-
constructor(contextKeyService) {
|
|
10
|
-
this._onDidChangeProviders = ( new Emitter());
|
|
11
|
-
this._entries = ( new LinkedList());
|
|
12
|
-
this.onDidChangeProviders = this._onDidChangeProviders.event;
|
|
13
|
-
this._ctxHasProvider = CTX_INLINE_CHAT_HAS_PROVIDER.bindTo(contextKeyService);
|
|
14
|
-
}
|
|
15
|
-
addProvider(provider) {
|
|
16
|
-
const rm = this._entries.push(provider);
|
|
17
|
-
this._ctxHasProvider.set(true);
|
|
18
|
-
this._onDidChangeProviders.fire({ added: provider });
|
|
19
|
-
return toDisposable(() => {
|
|
20
|
-
rm();
|
|
21
|
-
this._ctxHasProvider.set(this._entries.size > 0);
|
|
22
|
-
this._onDidChangeProviders.fire({ removed: provider });
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
getAllProvider() {
|
|
26
|
-
return [...this._entries].reverse();
|
|
27
|
-
}
|
|
28
|
-
};
|
|
29
|
-
InlineChatServiceImpl = ( __decorate([
|
|
30
|
-
( __param(0, IContextKeyService))
|
|
31
|
-
], InlineChatServiceImpl));
|
|
32
|
-
|
|
33
|
-
export { InlineChatServiceImpl };
|