Path: blob/main/src/vs/workbench/contrib/inlineChat/common/inlineChat.ts
3296 views
/*---------------------------------------------------------------------------------------------1* Copyright (c) Microsoft Corporation. All rights reserved.2* Licensed under the MIT License. See License.txt in the project root for license information.3*--------------------------------------------------------------------------------------------*/45import { localize } from '../../../../nls.js';6import { MenuId } from '../../../../platform/actions/common/actions.js';7import { Extensions, IConfigurationRegistry } from '../../../../platform/configuration/common/configurationRegistry.js';8import { RawContextKey } from '../../../../platform/contextkey/common/contextkey.js';9import { Registry } from '../../../../platform/registry/common/platform.js';10import { diffInserted, diffRemoved, editorWidgetBackground, editorWidgetBorder, editorWidgetForeground, focusBorder, inputBackground, inputPlaceholderForeground, registerColor, transparent, widgetShadow } from '../../../../platform/theme/common/colorRegistry.js';1112// settings1314export const enum InlineChatConfigKeys {15FinishOnType = 'inlineChat.finishOnType',16StartWithOverlayWidget = 'inlineChat.startWithOverlayWidget',17HoldToSpeech = 'inlineChat.holdToSpeech',18AccessibleDiffView = 'inlineChat.accessibleDiffView',19LineEmptyHint = 'inlineChat.lineEmptyHint',20LineNLHint = 'inlineChat.lineNaturalLanguageHint',21EnableV2 = 'inlineChat.enableV2',22notebookAgent = 'inlineChat.notebookAgent',23HideOnRequest = 'inlineChat.hideOnRequest'24}2526Registry.as<IConfigurationRegistry>(Extensions.Configuration).registerConfiguration({27id: 'editor',28properties: {29[InlineChatConfigKeys.FinishOnType]: {30description: localize('finishOnType', "Whether to finish an inline chat session when typing outside of changed regions."),31default: false,32type: 'boolean'33},34[InlineChatConfigKeys.HoldToSpeech]: {35description: localize('holdToSpeech', "Whether holding the inline chat keybinding will automatically enable speech recognition."),36default: true,37type: 'boolean'38},39[InlineChatConfigKeys.AccessibleDiffView]: {40description: localize('accessibleDiffView', "Whether the inline chat also renders an accessible diff viewer for its changes."),41default: 'auto',42type: 'string',43enum: ['auto', 'on', 'off'],44markdownEnumDescriptions: [45localize('accessibleDiffView.auto', "The accessible diff viewer is based on screen reader mode being enabled."),46localize('accessibleDiffView.on', "The accessible diff viewer is always enabled."),47localize('accessibleDiffView.off', "The accessible diff viewer is never enabled."),48],49},50[InlineChatConfigKeys.LineEmptyHint]: {51description: localize('emptyLineHint', "Whether empty lines show a hint to generate code with inline chat."),52default: false,53type: 'boolean',54tags: ['experimental'],55},56[InlineChatConfigKeys.LineNLHint]: {57markdownDescription: 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."),58default: true,59type: 'boolean',60tags: ['experimental'],61},62[InlineChatConfigKeys.EnableV2]: {63description: localize('enableV2', "Whether to use the next version of inline chat."),64default: false,65type: 'boolean',66tags: ['preview'],67experiment: {68mode: 'auto'69}70},71[InlineChatConfigKeys.HideOnRequest]: {72markdownDescription: 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."),73default: false,74type: 'boolean',75tags: ['preview'],76experiment: {77mode: 'auto'78}79},80[InlineChatConfigKeys.notebookAgent]: {81markdownDescription: localize('notebookAgent', "Enable agent-like behavior for inline chat widget in notebooks. Depends on the `#inlineChat.enableV2#` setting being enabled."),82default: false,83type: 'boolean',84tags: ['experimental'],85experiment: {86mode: 'auto'87}88}89}90});919293export const INLINE_CHAT_ID = 'interactiveEditor';94export const INTERACTIVE_EDITOR_ACCESSIBILITY_HELP_ID = 'interactiveEditorAccessiblityHelp';9596// --- CONTEXT9798export const enum InlineChatResponseType {99None = 'none',100Messages = 'messages',101MessagesAndEdits = 'messagesAndEdits'102}103104export 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"));105export const CTX_INLINE_CHAT_HAS_AGENT = new RawContextKey<boolean>('inlineChatHasProvider', false, localize('inlineChatHasProvider', "Whether a provider for interactive editors exists"));106export const CTX_INLINE_CHAT_HAS_AGENT2 = new RawContextKey<boolean>('inlineChatHasEditsAgent', false, localize('inlineChatHasEditsAgent', "Whether an agent for inliine for interactive editors exists"));107export const CTX_INLINE_CHAT_VISIBLE = new RawContextKey<boolean>('inlineChatVisible', false, localize('inlineChatVisible', "Whether the interactive editor input is visible"));108export const CTX_INLINE_CHAT_FOCUSED = new RawContextKey<boolean>('inlineChatFocused', false, localize('inlineChatFocused', "Whether the interactive editor input is focused"));109export 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"));110export const CTX_INLINE_CHAT_RESPONSE_FOCUSED = new RawContextKey<boolean>('inlineChatResponseFocused', false, localize('inlineChatResponseFocused', "Whether the interactive widget's response is focused"));111export const CTX_INLINE_CHAT_EMPTY = new RawContextKey<boolean>('inlineChatEmpty', false, localize('inlineChatEmpty', "Whether the interactive editor input is empty"));112export 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"));113export 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"));114export 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"));115export const CTX_INLINE_CHAT_HAS_STASHED_SESSION = new RawContextKey<boolean>('inlineChatHasStashedSession', false, localize('inlineChatHasStashedSession', "Whether interactive editor has kept a session for quick restore"));116export const CTX_INLINE_CHAT_CHANGE_HAS_DIFF = new RawContextKey<boolean>('inlineChatChangeHasDiff', false, localize('inlineChatChangeHasDiff', "Whether the current change supports showing a diff"));117export const CTX_INLINE_CHAT_CHANGE_SHOWS_DIFF = new RawContextKey<boolean>('inlineChatChangeShowsDiff', false, localize('inlineChatChangeShowsDiff', "Whether the current change showing a diff"));118export const CTX_INLINE_CHAT_REQUEST_IN_PROGRESS = new RawContextKey<boolean>('inlineChatRequestInProgress', false, localize('inlineChatRequestInProgress', "Whether an inline chat request is currently in progress"));119export 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"));120121122// --- (selected) action identifier123124export const ACTION_START = 'inlineChat.start';125export const ACTION_ACCEPT_CHANGES = 'inlineChat.acceptChanges';126export const ACTION_DISCARD_CHANGES = 'inlineChat.discardHunkChange';127export const ACTION_REGENERATE_RESPONSE = 'inlineChat.regenerate';128export const ACTION_VIEW_IN_CHAT = 'inlineChat.viewInChat';129export const ACTION_TOGGLE_DIFF = 'inlineChat.toggleDiff';130export const ACTION_REPORT_ISSUE = 'inlineChat.reportIssue';131132// --- menus133134export const MENU_INLINE_CHAT_WIDGET_STATUS = MenuId.for('inlineChatWidget.status');135export const MENU_INLINE_CHAT_WIDGET_SECONDARY = MenuId.for('inlineChatWidget.secondary');136export const MENU_INLINE_CHAT_ZONE = MenuId.for('inlineChatWidget.changesZone');137138export const MENU_INLINE_CHAT_SIDE = MenuId.for('inlineChatWidget.side');139140// --- colors141142143export const inlineChatForeground = registerColor('inlineChat.foreground', editorWidgetForeground, localize('inlineChat.foreground', "Foreground color of the interactive editor widget"));144export const inlineChatBackground = registerColor('inlineChat.background', editorWidgetBackground, localize('inlineChat.background', "Background color of the interactive editor widget"));145export const inlineChatBorder = registerColor('inlineChat.border', editorWidgetBorder, localize('inlineChat.border', "Border color of the interactive editor widget"));146export const inlineChatShadow = registerColor('inlineChat.shadow', widgetShadow, localize('inlineChat.shadow', "Shadow color of the interactive editor widget"));147export const inlineChatInputBorder = registerColor('inlineChatInput.border', editorWidgetBorder, localize('inlineChatInput.border', "Border color of the interactive editor input"));148export const inlineChatInputFocusBorder = registerColor('inlineChatInput.focusBorder', focusBorder, localize('inlineChatInput.focusBorder', "Border color of the interactive editor input when focused"));149export const inlineChatInputPlaceholderForeground = registerColor('inlineChatInput.placeholderForeground', inputPlaceholderForeground, localize('inlineChatInput.placeholderForeground', "Foreground color of the interactive editor input placeholder"));150export const inlineChatInputBackground = registerColor('inlineChatInput.background', inputBackground, localize('inlineChatInput.background', "Background color of the interactive editor input"));151152export const inlineChatDiffInserted = registerColor('inlineChatDiff.inserted', transparent(diffInserted, .5), localize('inlineChatDiff.inserted', "Background color of inserted text in the interactive editor input"));153export 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.'));154export 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.'));155156export const inlineChatDiffRemoved = registerColor('inlineChatDiff.removed', transparent(diffRemoved, .5), localize('inlineChatDiff.removed', "Background color of removed text in the interactive editor input"));157export 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.'));158159160