@codingame/monaco-vscode-chat-service-override 13.1.6 → 14.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/index.js +9 -9
- package/package.json +20 -20
- package/vscode/src/vs/base/common/objectCache.d.ts +13 -0
- package/vscode/src/vs/base/common/objectCache.js +39 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatAccessibilityHelp.d.ts +12 -5
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatAccessibilityHelp.js +95 -23
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatCodeblockActions.d.ts +10 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatCodeblockActions.js +81 -19
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatContextActions.js +144 -66
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatCopyActions.js +4 -4
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatDeveloperActions.js +1 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatFileTreeActions.js +4 -4
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatGettingStarted.d.ts +6 -3
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatGettingStarted.js +17 -11
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatImportExport.js +6 -6
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatMoveActions.js +8 -7
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatQuickInputActions.js +10 -10
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/codeBlockOperations.d.ts +11 -8
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/codeBlockOperations.js +168 -167
- package/vscode/src/vs/workbench/contrib/chat/browser/chat.contribution.js +116 -54
- package/vscode/src/vs/workbench/contrib/chat/browser/chatAccessibilityService.d.ts +1 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/chatContentParts/chatMarkdownAnchorService.d.ts +11 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatContentParts/chatMarkdownAnchorService.js +34 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingService.d.ts +11 -11
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingService.js +105 -70
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingSession.d.ts +17 -16
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingSession.js +154 -83
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditor.d.ts +3 -3
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditor.js +5 -5
- package/vscode/src/vs/workbench/contrib/chat/browser/chatParticipant.contribution.d.ts +0 -4
- package/vscode/src/vs/workbench/contrib/chat/browser/chatParticipant.contribution.js +150 -130
- package/vscode/src/vs/workbench/contrib/chat/browser/chatPasteProviders.js +13 -7
- package/vscode/src/vs/workbench/contrib/chat/browser/chatQuick.d.ts +1 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/chatQuick.js +1 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/chatResponseAccessibleView.d.ts +3 -3
- package/vscode/src/vs/workbench/contrib/chat/browser/chatResponseAccessibleView.js +1 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/chatSetup.d.ts +11 -6
- package/vscode/src/vs/workbench/contrib/chat/browser/chatSetup.js +449 -229
- package/vscode/src/vs/workbench/contrib/chat/browser/chatVariables.d.ts +2 -2
- package/vscode/src/vs/workbench/contrib/chat/browser/chatVariables.js +2 -2
- package/vscode/src/vs/workbench/contrib/chat/browser/chatViewPane.js +7 -6
- package/vscode/src/vs/workbench/contrib/chat/browser/codeBlockContextProviderService.d.ts +1 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/contrib/chatInputEditorContrib.js +1 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/contrib/chatInputEditorHover.js +2 -2
- package/vscode/src/vs/workbench/contrib/chat/browser/contrib/chatInputRelatedFilesContrib.js +11 -9
- package/vscode/src/vs/workbench/contrib/chat/browser/languageModelToolsService.d.ts +7 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/languageModelToolsService.js +76 -13
- package/vscode/src/vs/workbench/contrib/chat/browser/media/chatViewSetup.css.js +1 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/viewsWelcome/chatViewsWelcomeHandler.js +5 -5
- package/vscode/src/vs/workbench/contrib/chat/common/chatCodeMapperService.d.ts +5 -18
- package/vscode/src/vs/workbench/contrib/chat/common/chatCodeMapperService.js +4 -122
- package/vscode/src/vs/workbench/contrib/chat/common/chatProgressTypes/chatToolInvocation.d.ts +3 -1
- package/vscode/src/vs/workbench/contrib/chat/common/chatProgressTypes/chatToolInvocation.js +5 -4
- package/vscode/src/vs/workbench/contrib/chat/common/chatServiceImpl.d.ts +6 -3
- package/vscode/src/vs/workbench/contrib/chat/common/chatServiceImpl.js +42 -11
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/contentProviders/textModelContentsProvider.d.ts +13 -0
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/contentProviders/textModelContentsProvider.js +49 -0
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/languageFeatures/promptLinkProvider.d.ts +14 -0
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/languageFeatures/promptLinkProvider.js +69 -0
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/parsers/textModelPromptParser.d.ts +10 -0
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/parsers/textModelPromptParser.js +24 -0
- package/vscode/src/vs/workbench/contrib/chat/common/tools/languageModelToolsContribution.js +73 -17
- package/vscode/src/vs/workbench/contrib/chat/common/tools/tools.d.ts +11 -0
- package/vscode/src/vs/workbench/contrib/chat/common/tools/tools.js +22 -0
- package/vscode/src/vs/workbench/contrib/chat/common/voiceChatService.d.ts +1 -1
- package/vscode/src/vs/workbench/contrib/chat/common/voiceChatService.js +2 -2
- package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChat.contribution.js +9 -6
- package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatAccessibilityHelp.d.ts +2 -2
- package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatAccessibleView.d.ts +2 -2
- package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatController2.d.ts +39 -0
- package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatController2.js +314 -0
- package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatCurrentLine.js +34 -19
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatClearActions.d.ts +0 -3
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatClearActions.js +0 -334
- package/vscode/src/vs/workbench/contrib/chat/common/chatWidgetHistoryService.d.ts +0 -31
- package/vscode/src/vs/workbench/contrib/chat/common/chatWidgetHistoryService.js +0 -46
- package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatSavingServiceImpl.d.ts +0 -29
- package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatSavingServiceImpl.js +0 -168
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
|
|
2
|
+
import { __decorate, __param } from '@codingame/monaco-vscode-api/external/tslib/tslib.es6';
|
|
3
|
+
import { Disposable } from '@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle';
|
|
4
|
+
import { IInstantiationService } from '@codingame/monaco-vscode-api/vscode/vs/platform/instantiation/common/instantiation';
|
|
5
|
+
import { ILanguageModelToolsService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/languageModelToolsService.service';
|
|
6
|
+
import { EditTool, EditToolData } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/tools/editFileTool';
|
|
7
|
+
|
|
8
|
+
let BuiltinToolsContribution = class BuiltinToolsContribution extends Disposable {
|
|
9
|
+
static { this.ID = 'chat.builtinTools'; }
|
|
10
|
+
constructor(toolsService, instantiationService) {
|
|
11
|
+
super();
|
|
12
|
+
const editTool = instantiationService.createInstance(EditTool);
|
|
13
|
+
this._register(toolsService.registerToolData(EditToolData));
|
|
14
|
+
this._register(toolsService.registerToolImplementation(EditToolData.id, editTool));
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
BuiltinToolsContribution = ( __decorate([
|
|
18
|
+
( __param(0, ILanguageModelToolsService)),
|
|
19
|
+
( __param(1, IInstantiationService))
|
|
20
|
+
], BuiltinToolsContribution));
|
|
21
|
+
|
|
22
|
+
export { BuiltinToolsContribution };
|
|
@@ -4,7 +4,7 @@ import { Disposable } from "@codingame/monaco-vscode-api/vscode/vs/base/common/l
|
|
|
4
4
|
import { RawContextKey } from "@codingame/monaco-vscode-api/vscode/vs/platform/contextkey/common/contextkey";
|
|
5
5
|
import { IContextKeyService } from "@codingame/monaco-vscode-api/vscode/vs/platform/contextkey/common/contextkey.service";
|
|
6
6
|
import { IChatAgentService } from "@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/chatAgents.service";
|
|
7
|
-
import { IChatModel } from "@codingame/monaco-vscode-
|
|
7
|
+
import { IChatModel } from "@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/chatModel";
|
|
8
8
|
import { ISpeechToTextEvent } from "@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/speech/common/speechService";
|
|
9
9
|
import { ISpeechService } from "@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/speech/common/speechService.service";
|
|
10
10
|
import { IVoiceChatService } from "./voiceChatService.service.js";
|
|
@@ -7,7 +7,7 @@ import { rtrim } from '@codingame/monaco-vscode-api/vscode/vs/base/common/string
|
|
|
7
7
|
import { RawContextKey } from '@codingame/monaco-vscode-api/vscode/vs/platform/contextkey/common/contextkey';
|
|
8
8
|
import { IContextKeyService } from '@codingame/monaco-vscode-api/vscode/vs/platform/contextkey/common/contextkey.service';
|
|
9
9
|
import { IChatAgentService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/chatAgents.service';
|
|
10
|
-
import { chatAgentLeader, chatSubcommandLeader } from '@codingame/monaco-vscode-
|
|
10
|
+
import { chatAgentLeader, chatSubcommandLeader } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/chatParserTypes';
|
|
11
11
|
import { SpeechToTextStatus } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/speech/common/speechService';
|
|
12
12
|
import { ISpeechService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/speech/common/speechService.service';
|
|
13
13
|
|
|
@@ -21,7 +21,7 @@ var PhraseTextType;
|
|
|
21
21
|
const VoiceChatInProgress = ( new RawContextKey(
|
|
22
22
|
'voiceChatInProgress',
|
|
23
23
|
false,
|
|
24
|
-
{ type: 'boolean', description: ( localize(
|
|
24
|
+
{ type: 'boolean', description: ( localize(4790, "A speech-to-text session is in progress for chat.")) }
|
|
25
25
|
));
|
|
26
26
|
let VoiceChatService = class VoiceChatService extends Disposable {
|
|
27
27
|
static { VoiceChatService_1 = this; }
|
|
@@ -2,14 +2,13 @@
|
|
|
2
2
|
import { registerEditorContribution, EditorContributionInstantiation } from '@codingame/monaco-vscode-api/vscode/vs/editor/browser/editorExtensions';
|
|
3
3
|
import { registerAction2, MenuRegistry } from '@codingame/monaco-vscode-api/vscode/vs/platform/actions/common/actions';
|
|
4
4
|
import { InlineChatController } from '@codingame/monaco-vscode-c465110a-57c0-59d7-a6b2-be0a4db7e517-common/vscode/vs/workbench/contrib/inlineChat/browser/inlineChatController';
|
|
5
|
-
import { StartSessionAction, CloseAction, ConfigureInlineChatAction, UnstashSessionAction, DiscardHunkAction, RerunAction, MoveToNextHunk, MoveToPreviousHunk, ArrowOutUpAction, ArrowOutDownAction, FocusInlineChat, ViewInChatAction, ToggleDiffForChange, AcceptChanges } from '@codingame/monaco-vscode-
|
|
5
|
+
import { StartSessionAction, CloseAction, ConfigureInlineChatAction, UnstashSessionAction, DiscardHunkAction, RerunAction, MoveToNextHunk, MoveToPreviousHunk, ArrowOutUpAction, ArrowOutDownAction, FocusInlineChat, ViewInChatAction, ToggleDiffForChange, AcceptChanges } from '@codingame/monaco-vscode-9e30237f-37af-5bbd-8bc1-5c4f2c0714b3-common/vscode/vs/workbench/contrib/inlineChat/browser/inlineChatActions';
|
|
6
6
|
import { INLINE_CHAT_ID, CTX_INLINE_CHAT_REQUEST_IN_PROGRESS, CTX_INLINE_CHAT_EDITING, MENU_INLINE_CHAT_WIDGET_STATUS } from '@codingame/monaco-vscode-c465110a-57c0-59d7-a6b2-be0a4db7e517-common/vscode/vs/workbench/contrib/inlineChat/common/inlineChat';
|
|
7
7
|
import '@codingame/monaco-vscode-api/vscode/vs/platform/instantiation/common/extensions';
|
|
8
8
|
import { Registry } from '@codingame/monaco-vscode-api/vscode/vs/platform/registry/common/platform';
|
|
9
9
|
import { LifecyclePhase } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/lifecycle/common/lifecycle';
|
|
10
10
|
import { InlineChatNotebookContribution } from './inlineChatNotebook.js';
|
|
11
11
|
import { Extensions, registerWorkbenchContribution2, WorkbenchPhase } from '@codingame/monaco-vscode-api/vscode/vs/workbench/common/contributions';
|
|
12
|
-
import './inlineChatSavingServiceImpl.js';
|
|
13
12
|
import { InlineChatAccessibleView } from './inlineChatAccessibleView.js';
|
|
14
13
|
import '@codingame/monaco-vscode-api/vscode/vs/platform/instantiation/common/instantiation';
|
|
15
14
|
import { InlineChatEnabler } from '@codingame/monaco-vscode-c465110a-57c0-59d7-a6b2-be0a4db7e517-common/vscode/vs/workbench/contrib/inlineChat/browser/inlineChatSessionServiceImpl';
|
|
@@ -20,7 +19,11 @@ import { ChatContextKeys } from '@codingame/monaco-vscode-api/vscode/vs/workbenc
|
|
|
20
19
|
import { ContextKeyExpr } from '@codingame/monaco-vscode-api/vscode/vs/platform/contextkey/common/contextkey';
|
|
21
20
|
import { InlineChatAccessibilityHelp } from './inlineChatAccessibilityHelp.js';
|
|
22
21
|
import { InlineChatExpandLineAction, ShowInlineChatHintAction, HideInlineChatHintAction, InlineChatHintsController } from './inlineChatCurrentLine.js';
|
|
22
|
+
import { InlineChatController2, StartSessionAction2, StopSessionAction2 } from './inlineChatController2.js';
|
|
23
23
|
|
|
24
|
+
registerEditorContribution(InlineChatController2.ID, InlineChatController2, EditorContributionInstantiation.Eager);
|
|
25
|
+
registerAction2(StartSessionAction2);
|
|
26
|
+
registerAction2(StopSessionAction2);
|
|
24
27
|
registerEditorContribution(INLINE_CHAT_ID, InlineChatController, EditorContributionInstantiation.Eager);
|
|
25
28
|
registerAction2(InlineChatExpandLineAction);
|
|
26
29
|
registerAction2(ShowInlineChatHintAction);
|
|
@@ -31,7 +34,7 @@ const editActionMenuItem = {
|
|
|
31
34
|
order: 0,
|
|
32
35
|
command: {
|
|
33
36
|
id: ChatSubmitAction.ID,
|
|
34
|
-
title: ( localize(
|
|
37
|
+
title: ( localize(6904, "Edit Code")),
|
|
35
38
|
},
|
|
36
39
|
when: ( ContextKeyExpr.and(ChatContextKeys.inputHasText, ( CTX_INLINE_CHAT_REQUEST_IN_PROGRESS.toNegated()), CTX_INLINE_CHAT_EDITING)),
|
|
37
40
|
};
|
|
@@ -40,7 +43,7 @@ const generateActionMenuItem = {
|
|
|
40
43
|
order: 0,
|
|
41
44
|
command: {
|
|
42
45
|
id: ChatSubmitAction.ID,
|
|
43
|
-
title: ( localize(
|
|
46
|
+
title: ( localize(6905, "Generate")),
|
|
44
47
|
},
|
|
45
48
|
when: ( ContextKeyExpr.and(ChatContextKeys.inputHasText, ( CTX_INLINE_CHAT_REQUEST_IN_PROGRESS.toNegated()), ( CTX_INLINE_CHAT_EDITING.toNegated()))),
|
|
46
49
|
};
|
|
@@ -51,8 +54,8 @@ const cancelActionMenuItem = {
|
|
|
51
54
|
order: 0,
|
|
52
55
|
command: {
|
|
53
56
|
id: CancelAction.ID,
|
|
54
|
-
title: ( localize(
|
|
55
|
-
shortTitle: ( localize(
|
|
57
|
+
title: ( localize(6906, "Cancel Request")),
|
|
58
|
+
shortTitle: ( localize(6907, "Cancel")),
|
|
56
59
|
},
|
|
57
60
|
when: ( ContextKeyExpr.and(CTX_INLINE_CHAT_REQUEST_IN_PROGRESS)),
|
|
58
61
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ServicesAccessor } from "@codingame/monaco-vscode-api/vscode/vs/editor/browser/editorExtensions";
|
|
2
2
|
import { AccessibleViewType } from "@codingame/monaco-vscode-api/vscode/vs/platform/accessibility/browser/accessibleView";
|
|
3
|
-
import {
|
|
4
|
-
export declare class InlineChatAccessibilityHelp implements
|
|
3
|
+
import { IAccessibleViewImplementation } from "@codingame/monaco-vscode-api/vscode/vs/platform/accessibility/browser/accessibleViewRegistry";
|
|
4
|
+
export declare class InlineChatAccessibilityHelp implements IAccessibleViewImplementation {
|
|
5
5
|
readonly priority = 106;
|
|
6
6
|
readonly name = "inlineChat";
|
|
7
7
|
readonly type = AccessibleViewType.Help;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AccessibleViewType, AccessibleContentProvider } from "@codingame/monaco-vscode-api/vscode/vs/platform/accessibility/browser/accessibleView";
|
|
2
2
|
import { ServicesAccessor } from "@codingame/monaco-vscode-api/vscode/vs/platform/instantiation/common/instantiation";
|
|
3
|
-
import {
|
|
4
|
-
export declare class InlineChatAccessibleView implements
|
|
3
|
+
import { IAccessibleViewImplementation } from "@codingame/monaco-vscode-api/vscode/vs/platform/accessibility/browser/accessibleViewRegistry";
|
|
4
|
+
export declare class InlineChatAccessibleView implements IAccessibleViewImplementation {
|
|
5
5
|
readonly priority = 100;
|
|
6
6
|
readonly name = "inlineChat";
|
|
7
7
|
readonly when: import("@codingame/monaco-vscode-api/vscode/vs/platform/contextkey/common/contextkey").ContextKeyExpression | undefined;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { ICodeEditor } from "@codingame/monaco-vscode-api/vscode/vs/editor/browser/editorBrowser";
|
|
2
|
+
import { EditorAction2, ServicesAccessor } from "@codingame/monaco-vscode-api/vscode/vs/editor/browser/editorExtensions";
|
|
3
|
+
import { IEditorContribution } from "@codingame/monaco-vscode-api/vscode/vs/editor/common/editorCommon";
|
|
4
|
+
import { IAction2Options } from "@codingame/monaco-vscode-api/vscode/vs/platform/actions/common/actions";
|
|
5
|
+
import { RawContextKey } from "@codingame/monaco-vscode-api/vscode/vs/platform/contextkey/common/contextkey";
|
|
6
|
+
import { IContextKeyService } from "@codingame/monaco-vscode-api/vscode/vs/platform/contextkey/common/contextkey.service";
|
|
7
|
+
import { IInstantiationService } from "@codingame/monaco-vscode-api/vscode/vs/platform/instantiation/common/instantiation";
|
|
8
|
+
import { INotebookEditorService } from "@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/notebook/browser/services/notebookEditorService.service";
|
|
9
|
+
import { IInlineChatSessionService } from "@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/inlineChat/browser/inlineChatSessionService.service";
|
|
10
|
+
export declare const CTX_HAS_SESSION: RawContextKey<"active" | "empty" | undefined>;
|
|
11
|
+
export declare class InlineChatController2 implements IEditorContribution {
|
|
12
|
+
private readonly _editor;
|
|
13
|
+
private readonly _instaService;
|
|
14
|
+
private readonly _notebookEditorService;
|
|
15
|
+
static readonly ID = "editor.contrib.inlineChatController2";
|
|
16
|
+
static get(editor: ICodeEditor): InlineChatController2 | undefined;
|
|
17
|
+
private readonly _store;
|
|
18
|
+
private readonly _showWidgetOverrideObs;
|
|
19
|
+
private readonly _isActiveController;
|
|
20
|
+
constructor(_editor: ICodeEditor, _instaService: IInstantiationService, _notebookEditorService: INotebookEditorService, inlineChatSessions: IInlineChatSessionService, contextKeyService: IContextKeyService);
|
|
21
|
+
dispose(): void;
|
|
22
|
+
toggleWidgetUntilNextRequest(): void;
|
|
23
|
+
markActiveController(): void;
|
|
24
|
+
}
|
|
25
|
+
export declare class StartSessionAction2 extends EditorAction2 {
|
|
26
|
+
constructor();
|
|
27
|
+
runEditorCommand(accessor: ServicesAccessor, editor: ICodeEditor, ...args: any[]): Promise<void>;
|
|
28
|
+
}
|
|
29
|
+
declare abstract class AbstractInlineChatAction extends EditorAction2 {
|
|
30
|
+
static readonly category: import("@codingame/monaco-vscode-api/vscode/vs/nls").ILocalizedString;
|
|
31
|
+
constructor(desc: IAction2Options);
|
|
32
|
+
runEditorCommand(accessor: ServicesAccessor, editor: ICodeEditor, ..._args: any[]): void;
|
|
33
|
+
abstract runInlineChatCommand(accessor: ServicesAccessor, ctrl: InlineChatController2, editor: ICodeEditor, ...args: any[]): void;
|
|
34
|
+
}
|
|
35
|
+
export declare class StopSessionAction2 extends AbstractInlineChatAction {
|
|
36
|
+
constructor();
|
|
37
|
+
runInlineChatCommand(accessor: ServicesAccessor, _ctrl: InlineChatController2, editor: ICodeEditor, ...args: any[]): void;
|
|
38
|
+
}
|
|
39
|
+
export {};
|
|
@@ -0,0 +1,314 @@
|
|
|
1
|
+
|
|
2
|
+
import { __decorate, __param } from '@codingame/monaco-vscode-api/external/tslib/tslib.es6';
|
|
3
|
+
import { CancellationToken } from '@codingame/monaco-vscode-api/vscode/vs/base/common/cancellation';
|
|
4
|
+
import { Codicon } from '@codingame/monaco-vscode-api/vscode/vs/base/common/codicons';
|
|
5
|
+
import { KeyMod, KeyCode } from '@codingame/monaco-vscode-api/vscode/vs/base/common/keyCodes';
|
|
6
|
+
import { Lazy } from '@codingame/monaco-vscode-api/vscode/vs/base/common/lazy';
|
|
7
|
+
import { DisposableStore } from '@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle';
|
|
8
|
+
import { observableValue, transaction } from '@codingame/monaco-vscode-api/vscode/vs/base/common/observableInternal/base';
|
|
9
|
+
import '@codingame/monaco-vscode-api/vscode/vs/base/common/arrays';
|
|
10
|
+
import '@codingame/monaco-vscode-api/vscode/vs/base/common/event';
|
|
11
|
+
import { autorunWithStore, autorun } from '@codingame/monaco-vscode-api/vscode/vs/base/common/observableInternal/autorun';
|
|
12
|
+
import { derived } from '@codingame/monaco-vscode-api/vscode/vs/base/common/observableInternal/derived';
|
|
13
|
+
import { observableSignalFromEvent, observableFromEvent, constObservable } from '@codingame/monaco-vscode-api/vscode/vs/base/common/observableInternal/utils';
|
|
14
|
+
import { isEqual } from '@codingame/monaco-vscode-api/vscode/vs/base/common/resources';
|
|
15
|
+
import { assertType } from '@codingame/monaco-vscode-api/vscode/vs/base/common/types';
|
|
16
|
+
import { isCodeEditor, isDiffEditor } from '@codingame/monaco-vscode-api/vscode/vs/editor/browser/editorBrowser';
|
|
17
|
+
import { EditorAction2 } from '@codingame/monaco-vscode-api/vscode/vs/editor/browser/editorExtensions';
|
|
18
|
+
import { observableCodeEditor } from '@codingame/monaco-vscode-api/vscode/vs/editor/browser/observableCodeEditor';
|
|
19
|
+
import { ICodeEditorService } from '@codingame/monaco-vscode-api/vscode/vs/editor/browser/services/codeEditorService';
|
|
20
|
+
import { EmbeddedCodeEditorWidget } from '@codingame/monaco-vscode-api/vscode/vs/editor/browser/widget/codeEditor/embeddedCodeEditorWidget';
|
|
21
|
+
import { EmbeddedDiffEditorWidget } from '@codingame/monaco-vscode-api/vscode/vs/editor/browser/widget/diffEditor/embeddedDiffEditorWidget';
|
|
22
|
+
import { EditorContextKeys } from '@codingame/monaco-vscode-api/vscode/vs/editor/common/editorContextKeys';
|
|
23
|
+
import { localize, localize2 } from '@codingame/monaco-vscode-api/vscode/vs/nls';
|
|
24
|
+
import { MenuId, registerAction2 } from '@codingame/monaco-vscode-api/vscode/vs/platform/actions/common/actions';
|
|
25
|
+
import { RawContextKey, ContextKeyExpr } from '@codingame/monaco-vscode-api/vscode/vs/platform/contextkey/common/contextkey';
|
|
26
|
+
import { IContextKeyService } from '@codingame/monaco-vscode-api/vscode/vs/platform/contextkey/common/contextkey.service';
|
|
27
|
+
import { IInstantiationService } from '@codingame/monaco-vscode-api/vscode/vs/platform/instantiation/common/instantiation';
|
|
28
|
+
import { KeybindingWeight } from '@codingame/monaco-vscode-api/vscode/vs/platform/keybinding/common/keybindingsRegistry';
|
|
29
|
+
import { ILogService } from '@codingame/monaco-vscode-api/vscode/vs/platform/log/common/log.service';
|
|
30
|
+
import { IEditorService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/editor/common/editorService.service';
|
|
31
|
+
import { ctxIsGlobalEditingSession } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/browser/chatEditorController';
|
|
32
|
+
import { ChatEditorOverlayController } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/browser/chatEditorOverlay';
|
|
33
|
+
import { ChatAgentLocation } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/chatAgents';
|
|
34
|
+
import { WorkingSetEntryState } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/chatEditingService';
|
|
35
|
+
import { INotebookEditorService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/notebook/browser/services/notebookEditorService.service';
|
|
36
|
+
import { CTX_INLINE_CHAT_VISIBLE, CTX_INLINE_CHAT_HAS_AGENT2, CTX_INLINE_CHAT_POSSIBLE } from '@codingame/monaco-vscode-c465110a-57c0-59d7-a6b2-be0a4db7e517-common/vscode/vs/workbench/contrib/inlineChat/common/inlineChat';
|
|
37
|
+
import { IInlineChatSessionService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/inlineChat/browser/inlineChatSessionService.service';
|
|
38
|
+
import { InlineChatZoneWidget } from '@codingame/monaco-vscode-c465110a-57c0-59d7-a6b2-be0a4db7e517-common/vscode/vs/workbench/contrib/inlineChat/browser/inlineChatZoneWidget';
|
|
39
|
+
|
|
40
|
+
var InlineChatController2_1;
|
|
41
|
+
const CTX_HAS_SESSION = ( new RawContextKey('inlineChatHasSession', undefined, ( localize(6931, "The current editor has an active inline chat session"))));
|
|
42
|
+
let InlineChatController2 = class InlineChatController2 {
|
|
43
|
+
static { InlineChatController2_1 = this; }
|
|
44
|
+
static { this.ID = 'editor.contrib.inlineChatController2'; }
|
|
45
|
+
static get(editor) {
|
|
46
|
+
return editor.getContribution(InlineChatController2_1.ID) ?? undefined;
|
|
47
|
+
}
|
|
48
|
+
constructor(_editor, _instaService, _notebookEditorService, inlineChatSessions, contextKeyService) {
|
|
49
|
+
this._editor = _editor;
|
|
50
|
+
this._instaService = _instaService;
|
|
51
|
+
this._notebookEditorService = _notebookEditorService;
|
|
52
|
+
this._store = ( new DisposableStore());
|
|
53
|
+
this._showWidgetOverrideObs = observableValue(this, false);
|
|
54
|
+
this._isActiveController = observableValue(this, false);
|
|
55
|
+
const ctxHasSession = CTX_HAS_SESSION.bindTo(contextKeyService);
|
|
56
|
+
const ctxInlineChatVisible = CTX_INLINE_CHAT_VISIBLE.bindTo(contextKeyService);
|
|
57
|
+
const zone = ( new Lazy(() => {
|
|
58
|
+
const location = {
|
|
59
|
+
location: ChatAgentLocation.Editor,
|
|
60
|
+
resolveData: () => {
|
|
61
|
+
assertType(this._editor.hasModel());
|
|
62
|
+
return {
|
|
63
|
+
type: ChatAgentLocation.Editor,
|
|
64
|
+
selection: this._editor.getSelection(),
|
|
65
|
+
document: this._editor.getModel().uri,
|
|
66
|
+
wholeRange: this._editor.getSelection(),
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
for (const notebookEditor of this._notebookEditorService.listNotebookEditors()) {
|
|
71
|
+
for (const [, codeEditor] of notebookEditor.codeEditors) {
|
|
72
|
+
if (codeEditor === this._editor) {
|
|
73
|
+
location.location = ChatAgentLocation.Notebook;
|
|
74
|
+
break;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
const result = this._instaService.createInstance(InlineChatZoneWidget, location, {
|
|
79
|
+
enableWorkingSet: 'implicit',
|
|
80
|
+
rendererOptions: {
|
|
81
|
+
renderCodeBlockPills: true,
|
|
82
|
+
renderTextEditsAsSummary: uri => isEqual(uri, _editor.getModel()?.uri)
|
|
83
|
+
}
|
|
84
|
+
}, this._editor);
|
|
85
|
+
result.domNode.classList.add('inline-chat-2');
|
|
86
|
+
return result;
|
|
87
|
+
}));
|
|
88
|
+
const editorObs = observableCodeEditor(_editor);
|
|
89
|
+
const sessionsSignal = observableSignalFromEvent(this, inlineChatSessions.onDidChangeSessions);
|
|
90
|
+
const sessionObs = derived(r => {
|
|
91
|
+
sessionsSignal.read(r);
|
|
92
|
+
const model = editorObs.model.read(r);
|
|
93
|
+
const value = model && inlineChatSessions.getSession2(model.uri);
|
|
94
|
+
return value ?? undefined;
|
|
95
|
+
});
|
|
96
|
+
this._store.add(autorunWithStore((r, store) => {
|
|
97
|
+
const session = sessionObs.read(r);
|
|
98
|
+
if (!session) {
|
|
99
|
+
ctxHasSession.set(undefined);
|
|
100
|
+
this._isActiveController.set(false, undefined);
|
|
101
|
+
}
|
|
102
|
+
else {
|
|
103
|
+
const checkRequests = () => ctxHasSession.set(session.chatModel.getRequests().length === 0 ? 'empty' : 'active');
|
|
104
|
+
store.add(session.chatModel.onDidChange(checkRequests));
|
|
105
|
+
checkRequests();
|
|
106
|
+
}
|
|
107
|
+
}));
|
|
108
|
+
const visibleSessionObs = observableValue(this, undefined);
|
|
109
|
+
this._store.add(autorunWithStore((r, store) => {
|
|
110
|
+
const session = sessionObs.read(r);
|
|
111
|
+
const isActive = this._isActiveController.read(r);
|
|
112
|
+
if (!session || !isActive) {
|
|
113
|
+
visibleSessionObs.set(undefined, undefined);
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
const { chatModel } = session;
|
|
117
|
+
const showShowUntil = this._showWidgetOverrideObs.read(r);
|
|
118
|
+
const hasNoRequests = chatModel.getRequests().length === 0;
|
|
119
|
+
store.add(chatModel.onDidChange(e => {
|
|
120
|
+
if (e.kind === 'addRequest') {
|
|
121
|
+
transaction(tx => {
|
|
122
|
+
this._showWidgetOverrideObs.set(false, tx);
|
|
123
|
+
visibleSessionObs.set(undefined, tx);
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
}));
|
|
127
|
+
if (showShowUntil || hasNoRequests) {
|
|
128
|
+
visibleSessionObs.set(session, undefined);
|
|
129
|
+
}
|
|
130
|
+
else {
|
|
131
|
+
visibleSessionObs.set(undefined, undefined);
|
|
132
|
+
}
|
|
133
|
+
}));
|
|
134
|
+
this._store.add(autorun(r => {
|
|
135
|
+
const session = visibleSessionObs.read(r);
|
|
136
|
+
if (!session) {
|
|
137
|
+
zone.rawValue?.hide();
|
|
138
|
+
_editor.focus();
|
|
139
|
+
ctxInlineChatVisible.reset();
|
|
140
|
+
}
|
|
141
|
+
else {
|
|
142
|
+
ctxInlineChatVisible.set(true);
|
|
143
|
+
zone.value.widget.setChatModel(session.chatModel);
|
|
144
|
+
if (!zone.value.position) {
|
|
145
|
+
zone.value.show(session.initialPosition);
|
|
146
|
+
}
|
|
147
|
+
zone.value.reveal(zone.value.position);
|
|
148
|
+
zone.value.widget.focus();
|
|
149
|
+
session.editingSession.getEntry(session.uri)?.autoAcceptController.get()?.cancel();
|
|
150
|
+
}
|
|
151
|
+
}));
|
|
152
|
+
this._store.add(autorun(r => {
|
|
153
|
+
const overlay = ChatEditorOverlayController.get(_editor);
|
|
154
|
+
const session = sessionObs.read(r);
|
|
155
|
+
const model = editorObs.model.read(r);
|
|
156
|
+
if (!session || !model) {
|
|
157
|
+
overlay.hide();
|
|
158
|
+
return;
|
|
159
|
+
}
|
|
160
|
+
const lastResponse = observableFromEvent(this, session.chatModel.onDidChange, () => session.chatModel.getRequests().at(-1)?.response);
|
|
161
|
+
const response = lastResponse.read(r);
|
|
162
|
+
const isInProgress = response
|
|
163
|
+
? observableFromEvent(this, response.onDidChange, () => !response.isComplete)
|
|
164
|
+
: constObservable(false);
|
|
165
|
+
if (isInProgress.read(r)) {
|
|
166
|
+
overlay.showRequest(session.editingSession);
|
|
167
|
+
}
|
|
168
|
+
else if (session.editingSession.getEntry(session.uri)?.state.get() !== WorkingSetEntryState.Modified) {
|
|
169
|
+
overlay.hide();
|
|
170
|
+
}
|
|
171
|
+
}));
|
|
172
|
+
}
|
|
173
|
+
dispose() {
|
|
174
|
+
this._store.dispose();
|
|
175
|
+
}
|
|
176
|
+
toggleWidgetUntilNextRequest() {
|
|
177
|
+
const value = this._showWidgetOverrideObs.get();
|
|
178
|
+
this._showWidgetOverrideObs.set(!value, undefined);
|
|
179
|
+
}
|
|
180
|
+
markActiveController() {
|
|
181
|
+
this._isActiveController.set(true, undefined);
|
|
182
|
+
}
|
|
183
|
+
};
|
|
184
|
+
InlineChatController2 = InlineChatController2_1 = ( __decorate([
|
|
185
|
+
( __param(1, IInstantiationService)),
|
|
186
|
+
( __param(2, INotebookEditorService)),
|
|
187
|
+
( __param(3, IInlineChatSessionService)),
|
|
188
|
+
( __param(4, IContextKeyService))
|
|
189
|
+
], InlineChatController2));
|
|
190
|
+
class StartSessionAction2 extends EditorAction2 {
|
|
191
|
+
constructor() {
|
|
192
|
+
super({
|
|
193
|
+
id: 'inlineChat2.start',
|
|
194
|
+
title: ( localize2(6932, "Inline Chat")),
|
|
195
|
+
precondition: ( ContextKeyExpr.and(CTX_INLINE_CHAT_HAS_AGENT2, CTX_INLINE_CHAT_POSSIBLE, ( CTX_HAS_SESSION.negate()), EditorContextKeys.writable, ( EditorContextKeys.editorSimpleInput.negate()))),
|
|
196
|
+
f1: true,
|
|
197
|
+
category: AbstractInlineChatAction.category,
|
|
198
|
+
keybinding: {
|
|
199
|
+
when: EditorContextKeys.focus,
|
|
200
|
+
weight: KeybindingWeight.WorkbenchContrib,
|
|
201
|
+
primary: KeyMod.CtrlCmd | KeyCode.KeyI
|
|
202
|
+
},
|
|
203
|
+
menu: {
|
|
204
|
+
id: MenuId.ChatCommandCenter,
|
|
205
|
+
group: 'd_inlineChat',
|
|
206
|
+
order: 10,
|
|
207
|
+
when: CTX_INLINE_CHAT_HAS_AGENT2
|
|
208
|
+
}
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
async runEditorCommand(accessor, editor, ...args) {
|
|
212
|
+
const inlineChatSessions = accessor.get(IInlineChatSessionService);
|
|
213
|
+
if (!editor.hasModel()) {
|
|
214
|
+
return;
|
|
215
|
+
}
|
|
216
|
+
const textModel = editor.getModel();
|
|
217
|
+
await inlineChatSessions.createSession2(editor, textModel.uri, CancellationToken.None);
|
|
218
|
+
InlineChatController2.get(editor)?.markActiveController();
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
class AbstractInlineChatAction extends EditorAction2 {
|
|
222
|
+
static { this.category = ( localize2(6933, "Inline Chat")); }
|
|
223
|
+
constructor(desc) {
|
|
224
|
+
super({
|
|
225
|
+
...desc,
|
|
226
|
+
category: AbstractInlineChatAction.category,
|
|
227
|
+
precondition: ( ContextKeyExpr.and(CTX_INLINE_CHAT_HAS_AGENT2, desc.precondition))
|
|
228
|
+
});
|
|
229
|
+
}
|
|
230
|
+
runEditorCommand(accessor, editor, ..._args) {
|
|
231
|
+
const editorService = accessor.get(IEditorService);
|
|
232
|
+
const logService = accessor.get(ILogService);
|
|
233
|
+
let ctrl = InlineChatController2.get(editor);
|
|
234
|
+
if (!ctrl) {
|
|
235
|
+
const { activeTextEditorControl } = editorService;
|
|
236
|
+
if (isCodeEditor(activeTextEditorControl)) {
|
|
237
|
+
editor = activeTextEditorControl;
|
|
238
|
+
}
|
|
239
|
+
else if (isDiffEditor(activeTextEditorControl)) {
|
|
240
|
+
editor = activeTextEditorControl.getModifiedEditor();
|
|
241
|
+
}
|
|
242
|
+
ctrl = InlineChatController2.get(editor);
|
|
243
|
+
}
|
|
244
|
+
if (!ctrl) {
|
|
245
|
+
logService.warn('[IE] NO controller found for action', this.desc.id, editor.getModel()?.uri);
|
|
246
|
+
return;
|
|
247
|
+
}
|
|
248
|
+
if (editor instanceof EmbeddedCodeEditorWidget) {
|
|
249
|
+
editor = editor.getParentEditor();
|
|
250
|
+
}
|
|
251
|
+
if (!ctrl) {
|
|
252
|
+
for (const diffEditor of accessor.get(ICodeEditorService).listDiffEditors()) {
|
|
253
|
+
if (diffEditor.getOriginalEditor() === editor || diffEditor.getModifiedEditor() === editor) {
|
|
254
|
+
if (diffEditor instanceof EmbeddedDiffEditorWidget) {
|
|
255
|
+
this.runEditorCommand(accessor, diffEditor.getParentEditor(), ..._args);
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
return;
|
|
260
|
+
}
|
|
261
|
+
this.runInlineChatCommand(accessor, ctrl, editor, ..._args);
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
class StopSessionAction2 extends AbstractInlineChatAction {
|
|
265
|
+
constructor() {
|
|
266
|
+
super({
|
|
267
|
+
id: 'inlineChat2.stop',
|
|
268
|
+
title: ( localize2(6934, "Stop")),
|
|
269
|
+
f1: true,
|
|
270
|
+
precondition: ( ContextKeyExpr.and(( CTX_HAS_SESSION.isEqualTo('empty')), CTX_INLINE_CHAT_VISIBLE)),
|
|
271
|
+
keybinding: {
|
|
272
|
+
weight: KeybindingWeight.WorkbenchContrib,
|
|
273
|
+
primary: KeyCode.Escape,
|
|
274
|
+
secondary: [KeyMod.CtrlCmd | KeyCode.KeyI]
|
|
275
|
+
},
|
|
276
|
+
});
|
|
277
|
+
}
|
|
278
|
+
runInlineChatCommand(accessor, _ctrl, editor, ...args) {
|
|
279
|
+
const inlineChatSessions = accessor.get(IInlineChatSessionService);
|
|
280
|
+
if (!editor.hasModel()) {
|
|
281
|
+
return;
|
|
282
|
+
}
|
|
283
|
+
const textModel = editor.getModel();
|
|
284
|
+
inlineChatSessions.getSession2(textModel.uri)?.dispose();
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
class RevealWidget extends AbstractInlineChatAction {
|
|
288
|
+
constructor() {
|
|
289
|
+
super({
|
|
290
|
+
id: 'inlineChat2.reveal',
|
|
291
|
+
title: ( localize2(6935, "Toggle Inline Chat")),
|
|
292
|
+
f1: true,
|
|
293
|
+
icon: Codicon.copilot,
|
|
294
|
+
precondition: ( ContextKeyExpr.and(CTX_HAS_SESSION)),
|
|
295
|
+
keybinding: {
|
|
296
|
+
weight: KeybindingWeight.WorkbenchContrib,
|
|
297
|
+
primary: KeyMod.CtrlCmd | KeyCode.KeyI
|
|
298
|
+
},
|
|
299
|
+
menu: {
|
|
300
|
+
id: MenuId.ChatEditingEditorContent,
|
|
301
|
+
when: ( ContextKeyExpr.and(CTX_HAS_SESSION, ( ctxIsGlobalEditingSession.negate()))),
|
|
302
|
+
group: 'navigate',
|
|
303
|
+
order: 4,
|
|
304
|
+
}
|
|
305
|
+
});
|
|
306
|
+
}
|
|
307
|
+
runInlineChatCommand(_accessor, ctrl, _editor) {
|
|
308
|
+
ctrl.toggleWidgetUntilNextRequest();
|
|
309
|
+
ctrl.markActiveController();
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
registerAction2(RevealWidget);
|
|
313
|
+
|
|
314
|
+
export { CTX_HAS_SESSION, InlineChatController2, StartSessionAction2, StopSessionAction2 };
|
|
@@ -11,7 +11,7 @@ import { EditorAction2 } from '@codingame/monaco-vscode-api/vscode/vs/editor/bro
|
|
|
11
11
|
import { EditOperation } from '@codingame/monaco-vscode-api/vscode/vs/editor/common/core/editOperation';
|
|
12
12
|
import { Range } from '@codingame/monaco-vscode-api/vscode/vs/editor/common/core/range';
|
|
13
13
|
import { Position } from '@codingame/monaco-vscode-api/vscode/vs/editor/common/core/position';
|
|
14
|
-
import { AbstractInlineChatAction } from '@codingame/monaco-vscode-
|
|
14
|
+
import { AbstractInlineChatAction } from '@codingame/monaco-vscode-9e30237f-37af-5bbd-8bc1-5c4f2c0714b3-common/vscode/vs/workbench/contrib/inlineChat/browser/inlineChatActions';
|
|
15
15
|
import { EditorContextKeys } from '@codingame/monaco-vscode-api/vscode/vs/editor/common/editorContextKeys';
|
|
16
16
|
import { TrackedRangeStickiness } from '@codingame/monaco-vscode-api/vscode/vs/editor/common/model';
|
|
17
17
|
import { URI } from '@codingame/monaco-vscode-api/vscode/vs/base/common/uri';
|
|
@@ -19,7 +19,7 @@ import { isEqual } from '@codingame/monaco-vscode-api/vscode/vs/base/common/reso
|
|
|
19
19
|
import { StandardTokenType } from '@codingame/monaco-vscode-api/vscode/vs/editor/common/encodedTokenAttributes';
|
|
20
20
|
import { observableValue } from '@codingame/monaco-vscode-api/vscode/vs/base/common/observableInternal/base';
|
|
21
21
|
import '@codingame/monaco-vscode-api/vscode/vs/base/common/arrays';
|
|
22
|
-
import
|
|
22
|
+
import '@codingame/monaco-vscode-api/vscode/vs/base/common/event';
|
|
23
23
|
import { autorun } from '@codingame/monaco-vscode-api/vscode/vs/base/common/observableInternal/autorun';
|
|
24
24
|
import { derived } from '@codingame/monaco-vscode-api/vscode/vs/base/common/observableInternal/derived';
|
|
25
25
|
import '@codingame/monaco-vscode-api/vscode/vs/base/common/cancellation';
|
|
@@ -40,16 +40,17 @@ import { observableCodeEditor } from '@codingame/monaco-vscode-api/vscode/vs/edi
|
|
|
40
40
|
import { PLAINTEXT_LANGUAGE_ID } from '@codingame/monaco-vscode-api/vscode/vs/editor/common/languages/modesRegistry';
|
|
41
41
|
import { createStyleSheet2 } from '@codingame/monaco-vscode-api/vscode/vs/base/browser/domStylesheets';
|
|
42
42
|
import { stringValue } from '@codingame/monaco-vscode-api/vscode/vs/base/browser/cssValue';
|
|
43
|
+
import { observableConfigValue } from '@codingame/monaco-vscode-api/vscode/vs/platform/observable/common/platformObservableUtils';
|
|
43
44
|
|
|
44
45
|
var InlineChatHintsController_1;
|
|
45
|
-
const CTX_INLINE_CHAT_SHOWING_HINT = ( new RawContextKey('inlineChatShowingHint', false, ( localize(
|
|
46
|
+
const CTX_INLINE_CHAT_SHOWING_HINT = ( new RawContextKey('inlineChatShowingHint', false, ( localize(6936, "Whether inline chat shows a contextual hint"))));
|
|
46
47
|
const _inlineChatActionId = 'inlineChat.startWithCurrentLine';
|
|
47
48
|
class InlineChatExpandLineAction extends EditorAction2 {
|
|
48
49
|
constructor() {
|
|
49
50
|
super({
|
|
50
51
|
id: _inlineChatActionId,
|
|
51
52
|
category: AbstractInlineChatAction.category,
|
|
52
|
-
title: ( localize2(
|
|
53
|
+
title: ( localize2(6937, "Start in Editor with Current Line")),
|
|
53
54
|
f1: true,
|
|
54
55
|
precondition: ( ContextKeyExpr.and(( CTX_INLINE_CHAT_VISIBLE.negate()), CTX_INLINE_CHAT_HAS_AGENT, EditorContextKeys.writable)),
|
|
55
56
|
keybinding: [{
|
|
@@ -99,7 +100,7 @@ class ShowInlineChatHintAction extends EditorAction2 {
|
|
|
99
100
|
super({
|
|
100
101
|
id: 'inlineChat.showHint',
|
|
101
102
|
category: AbstractInlineChatAction.category,
|
|
102
|
-
title: ( localize2(
|
|
103
|
+
title: ( localize2(6938, "Show Inline Chat Hint")),
|
|
103
104
|
f1: false,
|
|
104
105
|
precondition: ( ContextKeyExpr.and(( CTX_INLINE_CHAT_VISIBLE.negate()), CTX_INLINE_CHAT_HAS_AGENT, EditorContextKeys.writable)),
|
|
105
106
|
});
|
|
@@ -124,14 +125,28 @@ class ShowInlineChatHintAction extends EditorAction2 {
|
|
|
124
125
|
}
|
|
125
126
|
model.tokenization.forceTokenization(position.lineNumber);
|
|
126
127
|
const tokens = model.tokenization.getLineTokens(position.lineNumber);
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
128
|
+
let totalLength = 0;
|
|
129
|
+
let specialLength = 0;
|
|
130
|
+
let lastTokenType;
|
|
131
|
+
tokens.forEach(idx => {
|
|
132
|
+
const tokenType = tokens.getStandardTokenType(idx);
|
|
133
|
+
const startOffset = tokens.getStartOffset(idx);
|
|
134
|
+
const endOffset = tokens.getEndOffset(idx);
|
|
135
|
+
totalLength += endOffset - startOffset;
|
|
136
|
+
if (tokenType !== StandardTokenType.Other) {
|
|
137
|
+
specialLength += endOffset - startOffset;
|
|
138
|
+
}
|
|
139
|
+
lastTokenType = tokenType;
|
|
140
|
+
});
|
|
141
|
+
if (specialLength / totalLength > 0.25) {
|
|
130
142
|
ctrl.hide();
|
|
143
|
+
return;
|
|
131
144
|
}
|
|
132
|
-
|
|
133
|
-
ctrl.
|
|
145
|
+
if (lastTokenType === StandardTokenType.Comment) {
|
|
146
|
+
ctrl.hide();
|
|
147
|
+
return;
|
|
134
148
|
}
|
|
149
|
+
ctrl.show();
|
|
135
150
|
}
|
|
136
151
|
}
|
|
137
152
|
let InlineChatHintsController = class InlineChatHintsController extends Disposable {
|
|
@@ -175,14 +190,14 @@ let InlineChatHintsController = class InlineChatHintsController extends Disposab
|
|
|
175
190
|
const decos = this._editor.createDecorationsCollection();
|
|
176
191
|
const editorObs = observableCodeEditor(editor);
|
|
177
192
|
const keyObs = observableFromEvent(keybindingService.onDidUpdateKeybindings, _ => keybindingService.lookupKeybinding(ACTION_START)?.getLabel());
|
|
178
|
-
const
|
|
193
|
+
const configHintEmpty = observableConfigValue(InlineChatConfigKeys.LineEmptyHint, false, this._configurationService);
|
|
194
|
+
const configHintNL = observableConfigValue(InlineChatConfigKeys.LineNLHint, false, this._configurationService);
|
|
179
195
|
const showDataObs = derived(r => {
|
|
180
196
|
const ghostState = ghostCtrl?.model.read(r)?.state.read(r);
|
|
181
197
|
const textFocus = editorObs.isTextFocused.read(r);
|
|
182
198
|
const position = editorObs.cursorPosition.read(r);
|
|
183
199
|
const model = editorObs.model.read(r);
|
|
184
200
|
const kb = keyObs.read(r);
|
|
185
|
-
configSignal.read(r);
|
|
186
201
|
if (ghostState !== undefined || !kb || !position || !model || !textFocus) {
|
|
187
202
|
return undefined;
|
|
188
203
|
}
|
|
@@ -193,11 +208,11 @@ let InlineChatHintsController = class InlineChatHintsController extends Disposab
|
|
|
193
208
|
const isEol = model.getLineMaxColumn(position.lineNumber) === position.column;
|
|
194
209
|
const isWhitespace = model.getLineLastNonWhitespaceColumn(position.lineNumber) === 0 && model.getValueLength() > 0 && position.column > 1;
|
|
195
210
|
if (isWhitespace) {
|
|
196
|
-
return
|
|
211
|
+
return configHintEmpty.read(r)
|
|
197
212
|
? { isEol, isWhitespace, kb, position, model }
|
|
198
213
|
: undefined;
|
|
199
214
|
}
|
|
200
|
-
if (visible && isEol &&
|
|
215
|
+
if (visible && isEol && configHintNL.read(r)) {
|
|
201
216
|
return { isEol, isWhitespace, kb, position, model };
|
|
202
217
|
}
|
|
203
218
|
return undefined;
|
|
@@ -212,15 +227,15 @@ let InlineChatHintsController = class InlineChatHintsController extends Disposab
|
|
|
212
227
|
this._ctxShowingHint.reset();
|
|
213
228
|
return;
|
|
214
229
|
}
|
|
215
|
-
const agentName = chatAgentService.getDefaultAgent(ChatAgentLocation.Editor)?.name ?? ( localize(
|
|
230
|
+
const agentName = chatAgentService.getDefaultAgent(ChatAgentLocation.Editor)?.name ?? ( localize(6939, "Chat"));
|
|
216
231
|
const { position, isEol, isWhitespace, kb, model } = showData;
|
|
217
232
|
const inlineClassName = ['a' , 'inline-chat-hint', 'inline-chat-hint-text'];
|
|
218
233
|
let content;
|
|
219
234
|
if (isWhitespace) {
|
|
220
|
-
content = '\u00a0' + ( localize(
|
|
235
|
+
content = '\u00a0' + ( localize(6940, "{0} to edit with {1}", kb, agentName));
|
|
221
236
|
}
|
|
222
237
|
else if (isEol) {
|
|
223
|
-
content = '\u00a0' + ( localize(
|
|
238
|
+
content = '\u00a0' + ( localize(6941, "{0} to continue with {1}", kb, agentName));
|
|
224
239
|
}
|
|
225
240
|
else {
|
|
226
241
|
content = '\u200a' + kb + '\u200a';
|
|
@@ -249,7 +264,7 @@ let InlineChatHintsController = class InlineChatHintsController extends Disposab
|
|
|
249
264
|
getActions: () => [
|
|
250
265
|
toAction({
|
|
251
266
|
id: 'inlineChat.disableHint',
|
|
252
|
-
label: ( localize(
|
|
267
|
+
label: ( localize(6942, "Disable Inline Chat Hint")),
|
|
253
268
|
run: async () => {
|
|
254
269
|
await this._configurationService.updateValue(setting, false);
|
|
255
270
|
}
|
|
@@ -277,7 +292,7 @@ class HideInlineChatHintAction extends EditorAction2 {
|
|
|
277
292
|
constructor() {
|
|
278
293
|
super({
|
|
279
294
|
id: 'inlineChat.hideHint',
|
|
280
|
-
title: ( localize2(
|
|
295
|
+
title: ( localize2(6943, "Hide Inline Chat Hint")),
|
|
281
296
|
precondition: CTX_INLINE_CHAT_SHOWING_HINT,
|
|
282
297
|
keybinding: {
|
|
283
298
|
weight: KeybindingWeight.EditorContrib - 10,
|