Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/src/vs/workbench/contrib/inlineChat/common/inlineChat.ts
3296 views
1
/*---------------------------------------------------------------------------------------------
2
* Copyright (c) Microsoft Corporation. All rights reserved.
3
* Licensed under the MIT License. See License.txt in the project root for license information.
4
*--------------------------------------------------------------------------------------------*/
5
6
import { localize } from '../../../../nls.js';
7
import { MenuId } from '../../../../platform/actions/common/actions.js';
8
import { Extensions, IConfigurationRegistry } from '../../../../platform/configuration/common/configurationRegistry.js';
9
import { RawContextKey } from '../../../../platform/contextkey/common/contextkey.js';
10
import { Registry } from '../../../../platform/registry/common/platform.js';
11
import { diffInserted, diffRemoved, editorWidgetBackground, editorWidgetBorder, editorWidgetForeground, focusBorder, inputBackground, inputPlaceholderForeground, registerColor, transparent, widgetShadow } from '../../../../platform/theme/common/colorRegistry.js';
12
13
// settings
14
15
export const enum InlineChatConfigKeys {
16
FinishOnType = 'inlineChat.finishOnType',
17
StartWithOverlayWidget = 'inlineChat.startWithOverlayWidget',
18
HoldToSpeech = 'inlineChat.holdToSpeech',
19
AccessibleDiffView = 'inlineChat.accessibleDiffView',
20
LineEmptyHint = 'inlineChat.lineEmptyHint',
21
LineNLHint = 'inlineChat.lineNaturalLanguageHint',
22
EnableV2 = 'inlineChat.enableV2',
23
notebookAgent = 'inlineChat.notebookAgent',
24
HideOnRequest = 'inlineChat.hideOnRequest'
25
}
26
27
Registry.as<IConfigurationRegistry>(Extensions.Configuration).registerConfiguration({
28
id: 'editor',
29
properties: {
30
[InlineChatConfigKeys.FinishOnType]: {
31
description: localize('finishOnType', "Whether to finish an inline chat session when typing outside of changed regions."),
32
default: false,
33
type: 'boolean'
34
},
35
[InlineChatConfigKeys.HoldToSpeech]: {
36
description: localize('holdToSpeech', "Whether holding the inline chat keybinding will automatically enable speech recognition."),
37
default: true,
38
type: 'boolean'
39
},
40
[InlineChatConfigKeys.AccessibleDiffView]: {
41
description: localize('accessibleDiffView', "Whether the inline chat also renders an accessible diff viewer for its changes."),
42
default: 'auto',
43
type: 'string',
44
enum: ['auto', 'on', 'off'],
45
markdownEnumDescriptions: [
46
localize('accessibleDiffView.auto', "The accessible diff viewer is based on screen reader mode being enabled."),
47
localize('accessibleDiffView.on', "The accessible diff viewer is always enabled."),
48
localize('accessibleDiffView.off', "The accessible diff viewer is never enabled."),
49
],
50
},
51
[InlineChatConfigKeys.LineEmptyHint]: {
52
description: localize('emptyLineHint', "Whether empty lines show a hint to generate code with inline chat."),
53
default: false,
54
type: 'boolean',
55
tags: ['experimental'],
56
},
57
[InlineChatConfigKeys.LineNLHint]: {
58
markdownDescription: localize('lineSuffixHint', "Whether lines that are dominated by natural language or pseudo code show a hint to continue with inline chat. For instance, `class Person with name and hobbies` would show a hint to continue with chat."),
59
default: true,
60
type: 'boolean',
61
tags: ['experimental'],
62
},
63
[InlineChatConfigKeys.EnableV2]: {
64
description: localize('enableV2', "Whether to use the next version of inline chat."),
65
default: false,
66
type: 'boolean',
67
tags: ['preview'],
68
experiment: {
69
mode: 'auto'
70
}
71
},
72
[InlineChatConfigKeys.HideOnRequest]: {
73
markdownDescription: localize('hideOnRequest', "Whether to hide the inline chat widget after making a request. When enabled, the widget hides after a request has been made and instead the chat overlay shows. When hidden, the widget can always be shown again with the inline chat keybinding or from the chat overlay widget. *Note* that this setting requires `#inlineChat.enableV2#` to be enabled."),
74
default: false,
75
type: 'boolean',
76
tags: ['preview'],
77
experiment: {
78
mode: 'auto'
79
}
80
},
81
[InlineChatConfigKeys.notebookAgent]: {
82
markdownDescription: localize('notebookAgent', "Enable agent-like behavior for inline chat widget in notebooks. Depends on the `#inlineChat.enableV2#` setting being enabled."),
83
default: false,
84
type: 'boolean',
85
tags: ['experimental'],
86
experiment: {
87
mode: 'auto'
88
}
89
}
90
}
91
});
92
93
94
export const INLINE_CHAT_ID = 'interactiveEditor';
95
export const INTERACTIVE_EDITOR_ACCESSIBILITY_HELP_ID = 'interactiveEditorAccessiblityHelp';
96
97
// --- CONTEXT
98
99
export const enum InlineChatResponseType {
100
None = 'none',
101
Messages = 'messages',
102
MessagesAndEdits = 'messagesAndEdits'
103
}
104
105
export const CTX_INLINE_CHAT_POSSIBLE = new RawContextKey<boolean>('inlineChatPossible', false, localize('inlineChatHasPossible', "Whether a provider for inline chat exists and whether an editor for inline chat is open"));
106
export const CTX_INLINE_CHAT_HAS_AGENT = new RawContextKey<boolean>('inlineChatHasProvider', false, localize('inlineChatHasProvider', "Whether a provider for interactive editors exists"));
107
export const CTX_INLINE_CHAT_HAS_AGENT2 = new RawContextKey<boolean>('inlineChatHasEditsAgent', false, localize('inlineChatHasEditsAgent', "Whether an agent for inliine for interactive editors exists"));
108
export const CTX_INLINE_CHAT_VISIBLE = new RawContextKey<boolean>('inlineChatVisible', false, localize('inlineChatVisible', "Whether the interactive editor input is visible"));
109
export const CTX_INLINE_CHAT_FOCUSED = new RawContextKey<boolean>('inlineChatFocused', false, localize('inlineChatFocused', "Whether the interactive editor input is focused"));
110
export const CTX_INLINE_CHAT_EDITING = new RawContextKey<boolean>('inlineChatEditing', true, localize('inlineChatEditing', "Whether the user is currently editing or generating code in the inline chat"));
111
export const CTX_INLINE_CHAT_RESPONSE_FOCUSED = new RawContextKey<boolean>('inlineChatResponseFocused', false, localize('inlineChatResponseFocused', "Whether the interactive widget's response is focused"));
112
export const CTX_INLINE_CHAT_EMPTY = new RawContextKey<boolean>('inlineChatEmpty', false, localize('inlineChatEmpty', "Whether the interactive editor input is empty"));
113
export const CTX_INLINE_CHAT_INNER_CURSOR_FIRST = new RawContextKey<boolean>('inlineChatInnerCursorFirst', false, localize('inlineChatInnerCursorFirst', "Whether the cursor of the iteractive editor input is on the first line"));
114
export const CTX_INLINE_CHAT_INNER_CURSOR_LAST = new RawContextKey<boolean>('inlineChatInnerCursorLast', false, localize('inlineChatInnerCursorLast', "Whether the cursor of the iteractive editor input is on the last line"));
115
export const CTX_INLINE_CHAT_OUTER_CURSOR_POSITION = new RawContextKey<'above' | 'below' | ''>('inlineChatOuterCursorPosition', '', localize('inlineChatOuterCursorPosition', "Whether the cursor of the outer editor is above or below the interactive editor input"));
116
export const CTX_INLINE_CHAT_HAS_STASHED_SESSION = new RawContextKey<boolean>('inlineChatHasStashedSession', false, localize('inlineChatHasStashedSession', "Whether interactive editor has kept a session for quick restore"));
117
export const CTX_INLINE_CHAT_CHANGE_HAS_DIFF = new RawContextKey<boolean>('inlineChatChangeHasDiff', false, localize('inlineChatChangeHasDiff', "Whether the current change supports showing a diff"));
118
export const CTX_INLINE_CHAT_CHANGE_SHOWS_DIFF = new RawContextKey<boolean>('inlineChatChangeShowsDiff', false, localize('inlineChatChangeShowsDiff', "Whether the current change showing a diff"));
119
export const CTX_INLINE_CHAT_REQUEST_IN_PROGRESS = new RawContextKey<boolean>('inlineChatRequestInProgress', false, localize('inlineChatRequestInProgress', "Whether an inline chat request is currently in progress"));
120
export const CTX_INLINE_CHAT_RESPONSE_TYPE = new RawContextKey<InlineChatResponseType>('inlineChatResponseType', InlineChatResponseType.None, localize('inlineChatResponseTypes', "What type was the responses have been receieved, nothing yet, just messages, or messaged and local edits"));
121
122
123
// --- (selected) action identifier
124
125
export const ACTION_START = 'inlineChat.start';
126
export const ACTION_ACCEPT_CHANGES = 'inlineChat.acceptChanges';
127
export const ACTION_DISCARD_CHANGES = 'inlineChat.discardHunkChange';
128
export const ACTION_REGENERATE_RESPONSE = 'inlineChat.regenerate';
129
export const ACTION_VIEW_IN_CHAT = 'inlineChat.viewInChat';
130
export const ACTION_TOGGLE_DIFF = 'inlineChat.toggleDiff';
131
export const ACTION_REPORT_ISSUE = 'inlineChat.reportIssue';
132
133
// --- menus
134
135
export const MENU_INLINE_CHAT_WIDGET_STATUS = MenuId.for('inlineChatWidget.status');
136
export const MENU_INLINE_CHAT_WIDGET_SECONDARY = MenuId.for('inlineChatWidget.secondary');
137
export const MENU_INLINE_CHAT_ZONE = MenuId.for('inlineChatWidget.changesZone');
138
139
export const MENU_INLINE_CHAT_SIDE = MenuId.for('inlineChatWidget.side');
140
141
// --- colors
142
143
144
export const inlineChatForeground = registerColor('inlineChat.foreground', editorWidgetForeground, localize('inlineChat.foreground', "Foreground color of the interactive editor widget"));
145
export const inlineChatBackground = registerColor('inlineChat.background', editorWidgetBackground, localize('inlineChat.background', "Background color of the interactive editor widget"));
146
export const inlineChatBorder = registerColor('inlineChat.border', editorWidgetBorder, localize('inlineChat.border', "Border color of the interactive editor widget"));
147
export const inlineChatShadow = registerColor('inlineChat.shadow', widgetShadow, localize('inlineChat.shadow', "Shadow color of the interactive editor widget"));
148
export const inlineChatInputBorder = registerColor('inlineChatInput.border', editorWidgetBorder, localize('inlineChatInput.border', "Border color of the interactive editor input"));
149
export const inlineChatInputFocusBorder = registerColor('inlineChatInput.focusBorder', focusBorder, localize('inlineChatInput.focusBorder', "Border color of the interactive editor input when focused"));
150
export const inlineChatInputPlaceholderForeground = registerColor('inlineChatInput.placeholderForeground', inputPlaceholderForeground, localize('inlineChatInput.placeholderForeground', "Foreground color of the interactive editor input placeholder"));
151
export const inlineChatInputBackground = registerColor('inlineChatInput.background', inputBackground, localize('inlineChatInput.background', "Background color of the interactive editor input"));
152
153
export const inlineChatDiffInserted = registerColor('inlineChatDiff.inserted', transparent(diffInserted, .5), localize('inlineChatDiff.inserted', "Background color of inserted text in the interactive editor input"));
154
export const overviewRulerInlineChatDiffInserted = registerColor('editorOverviewRuler.inlineChatInserted', { dark: transparent(diffInserted, 0.6), light: transparent(diffInserted, 0.8), hcDark: transparent(diffInserted, 0.6), hcLight: transparent(diffInserted, 0.8) }, localize('editorOverviewRuler.inlineChatInserted', 'Overview ruler marker color for inline chat inserted content.'));
155
export const minimapInlineChatDiffInserted = registerColor('editorMinimap.inlineChatInserted', { dark: transparent(diffInserted, 0.6), light: transparent(diffInserted, 0.8), hcDark: transparent(diffInserted, 0.6), hcLight: transparent(diffInserted, 0.8) }, localize('editorMinimap.inlineChatInserted', 'Minimap marker color for inline chat inserted content.'));
156
157
export const inlineChatDiffRemoved = registerColor('inlineChatDiff.removed', transparent(diffRemoved, .5), localize('inlineChatDiff.removed', "Background color of removed text in the interactive editor input"));
158
export const overviewRulerInlineChatDiffRemoved = registerColor('editorOverviewRuler.inlineChatRemoved', { dark: transparent(diffRemoved, 0.6), light: transparent(diffRemoved, 0.8), hcDark: transparent(diffRemoved, 0.6), hcLight: transparent(diffRemoved, 0.8) }, localize('editorOverviewRuler.inlineChatRemoved', 'Overview ruler marker color for inline chat removed content.'));
159
160