renaming the content inside of inlineChat folder from IE to IC

This commit is contained in:
Aiday Marlen Kyzy 2023-06-07 16:02:34 +02:00
parent 30092f40a3
commit c529638000
No known key found for this signature in database
GPG Key ID: 24A8B53DBD26FF4E
19 changed files with 390 additions and 390 deletions

View File

@ -312,15 +312,15 @@
"--vscode-inputValidation-warningBackground",
"--vscode-inputValidation-warningBorder",
"--vscode-inputValidation-warningForeground",
"--vscode-interactiveEditor-border",
"--vscode-interactiveEditor-regionHighlight",
"--vscode-interactiveEditor-shadow",
"--vscode-interactiveEditorDiff-inserted",
"--vscode-interactiveEditorDiff-removed",
"--vscode-interactiveEditorInput-background",
"--vscode-interactiveEditorInput-border",
"--vscode-interactiveEditorInput-focusBorder",
"--vscode-interactiveEditorInput-placeholderForeground",
"--vscode-inlineChat-border",
"--vscode-inlineChat-regionHighlight",
"--vscode-inlineChat-shadow",
"--vscode-inlineChatDiff-inserted",
"--vscode-inlineChatDiff-removed",
"--vscode-inlineChatInput-background",
"--vscode-inlineChatInput-border",
"--vscode-inlineChatInput-focusBorder",
"--vscode-inlineChatInput-placeholderForeground",
"--vscode-keybindingLabel-background",
"--vscode-keybindingLabel-border",
"--vscode-keybindingLabel-bottomBorder",

View File

@ -4,7 +4,7 @@
*--------------------------------------------------------------------------------------------*/
import { DisposableMap } from 'vs/base/common/lifecycle';
import { IInteractiveEditorBulkEditResponse, IInteractiveEditorResponse, IInteractiveEditorService } from 'vs/workbench/contrib/inlineChat/common/inlineChat';
import { IInlineChatBulkEditResponse, IInlineChatResponse, IInlineChatService } from 'vs/workbench/contrib/inlineChat/common/inlineChat';
import { IUriIdentityService } from 'vs/platform/uriIdentity/common/uriIdentity';
import { reviveWorkspaceEditDto } from 'vs/workbench/api/browser/mainThreadBulkEdits';
import { ExtHostContext, ExtHostInteractiveEditorShape, MainContext, MainThreadInteractiveEditorShape } from 'vs/workbench/api/common/extHost.protocol';
@ -18,7 +18,7 @@ export class MainThreadInteractiveEditor implements MainThreadInteractiveEditorS
constructor(
extHostContext: IExtHostContext,
@IInteractiveEditorService private readonly _interactiveEditorService: IInteractiveEditorService,
@IInlineChatService private readonly _inlineChatService: IInlineChatService,
@IUriIdentityService private readonly _uriIdentService: IUriIdentityService,
) {
this._proxy = extHostContext.getProxy(ExtHostContext.ExtHostInteractiveEditor);
@ -29,9 +29,9 @@ export class MainThreadInteractiveEditor implements MainThreadInteractiveEditorS
}
async $registerInteractiveEditorProvider(handle: number, debugName: string, supportsFeedback: boolean): Promise<void> {
const unreg = this._interactiveEditorService.addProvider({
const unreg = this._inlineChatService.addProvider({
debugName,
prepareInteractiveEditorSession: async (model, range, token) => {
prepareInlineChatSession: async (model, range, token) => {
const session = await this._proxy.$prepareInteractiveSession(handle, model.uri, range, token);
if (!session) {
return undefined;
@ -46,11 +46,11 @@ export class MainThreadInteractiveEditor implements MainThreadInteractiveEditorS
provideResponse: async (item, request, token) => {
const result = await this._proxy.$provideResponse(handle, item, request, token);
if (result?.type === 'bulkEdit') {
(<IInteractiveEditorBulkEditResponse>result).edits = reviveWorkspaceEditDto(result.edits, this._uriIdentService);
(<IInlineChatBulkEditResponse>result).edits = reviveWorkspaceEditDto(result.edits, this._uriIdentService);
}
return <IInteractiveEditorResponse | undefined>result;
return <IInlineChatResponse | undefined>result;
},
handleInteractiveEditorResponseFeedback: !supportsFeedback ? undefined : async (session, response, kind) => {
handleInlineChatResponseFeedback: !supportsFeedback ? undefined : async (session, response, kind) => {
this._proxy.$handleFeedback(handle, session.id, response.id, kind);
}
});

View File

@ -26,7 +26,7 @@ import * as languages from 'vs/editor/common/languages';
import { CharacterPair, CommentRule, EnterAction } from 'vs/editor/common/languages/languageConfiguration';
import { EndOfLineSequence } from 'vs/editor/common/model';
import { IModelChangedEvent } from 'vs/editor/common/model/mirrorTextModel';
import { IInteractiveEditorRequest, IInteractiveEditorResponse, IInteractiveEditorSession, InteractiveEditorResponseFeedbackKind } from 'vs/workbench/contrib/inlineChat/common/inlineChat';
import { IInlineChatRequest, IInlineChatResponse, IInlineChatSession, InlineChatResponseFeedbackKind } from 'vs/workbench/contrib/inlineChat/common/inlineChat';
import { IAccessibilityInformation } from 'vs/platform/accessibility/common/accessibility';
import { ConfigurationTarget, IConfigurationChange, IConfigurationData, IConfigurationOverrides } from 'vs/platform/configuration/common/configuration';
import { ConfigurationScope } from 'vs/platform/configuration/common/configurationRegistry';
@ -1120,12 +1120,12 @@ export interface MainThreadInteractiveEditorShape extends IDisposable {
$unregisterInteractiveEditorProvider(handle: number): Promise<void>;
}
export type IInteractiveEditorResponseDto = Dto<IInteractiveEditorResponse>;
export type IInteractiveEditorResponseDto = Dto<IInlineChatResponse>;
export interface ExtHostInteractiveEditorShape {
$prepareInteractiveSession(handle: number, uri: UriComponents, range: ISelection, token: CancellationToken): Promise<IInteractiveEditorSession | undefined>;
$provideResponse(handle: number, session: IInteractiveEditorSession, request: IInteractiveEditorRequest, token: CancellationToken): Promise<IInteractiveEditorResponseDto | undefined>;
$handleFeedback(handle: number, sessionId: number, responseId: number, kind: InteractiveEditorResponseFeedbackKind): void;
$prepareInteractiveSession(handle: number, uri: UriComponents, range: ISelection, token: CancellationToken): Promise<IInlineChatSession | undefined>;
$provideResponse(handle: number, session: IInlineChatSession, request: IInlineChatRequest, token: CancellationToken): Promise<IInteractiveEditorResponseDto | undefined>;
$handleFeedback(handle: number, sessionId: number, responseId: number, kind: InlineChatResponseFeedbackKind): void;
$releaseSession(handle: number, sessionId: number): void;
}

View File

@ -7,7 +7,7 @@ import { CancellationToken } from 'vs/base/common/cancellation';
import { toDisposable } from 'vs/base/common/lifecycle';
import { URI, UriComponents } from 'vs/base/common/uri';
import { ISelection } from 'vs/editor/common/core/selection';
import { IInteractiveEditorSession, IInteractiveEditorRequest, InteractiveEditorResponseFeedbackKind, InteractiveEditorResponseType } from 'vs/workbench/contrib/inlineChat/common/inlineChat';
import { IInlineChatSession, IInlineChatRequest, InlineChatResponseFeedbackKind, InlineChatResponseType } from 'vs/workbench/contrib/inlineChat/common/inlineChat';
import { IRelaxedExtensionDescription } from 'vs/platform/extensions/common/extensions';
import { ILogService } from 'vs/platform/log/common/log';
import { ExtHostInteractiveEditorShape, IInteractiveEditorResponseDto, IMainContext, MainContext, MainThreadInteractiveEditorShape } from 'vs/workbench/api/common/extHost.protocol';
@ -95,7 +95,7 @@ export class ExtHostInteractiveEditor implements ExtHostInteractiveEditorShape {
});
}
async $prepareInteractiveSession(handle: number, uri: UriComponents, range: ISelection, token: CancellationToken): Promise<IInteractiveEditorSession | undefined> {
async $prepareInteractiveSession(handle: number, uri: UriComponents, range: ISelection, token: CancellationToken): Promise<IInlineChatSession | undefined> {
const entry = this._inputProvider.get(handle);
if (!entry) {
this._logService.warn('CANNOT prepare session because the PROVIDER IS GONE');
@ -125,7 +125,7 @@ export class ExtHostInteractiveEditor implements ExtHostInteractiveEditorShape {
};
}
async $provideResponse(handle: number, item: IInteractiveEditorSession, request: IInteractiveEditorRequest, token: CancellationToken): Promise<IInteractiveEditorResponseDto | undefined> {
async $provideResponse(handle: number, item: IInlineChatSession, request: IInlineChatRequest, token: CancellationToken): Promise<IInteractiveEditorResponseDto | undefined> {
const entry = this._inputProvider.get(handle);
if (!entry) {
return undefined;
@ -156,7 +156,7 @@ export class ExtHostInteractiveEditor implements ExtHostInteractiveEditorShape {
return {
...stub,
id,
type: InteractiveEditorResponseType.Message,
type: InlineChatResponseType.Message,
message: typeConvert.MarkdownString.from(res.contents),
};
}
@ -166,7 +166,7 @@ export class ExtHostInteractiveEditor implements ExtHostInteractiveEditorShape {
return {
...stub,
id,
type: InteractiveEditorResponseType.BulkEdit,
type: InlineChatResponseType.BulkEdit,
edits: typeConvert.WorkspaceEdit.from(edits),
};
@ -174,7 +174,7 @@ export class ExtHostInteractiveEditor implements ExtHostInteractiveEditorShape {
return {
...stub,
id,
type: InteractiveEditorResponseType.EditorEdit,
type: InlineChatResponseType.EditorEdit,
edits: edits.map(typeConvert.TextEdit.from),
};
}
@ -183,7 +183,7 @@ export class ExtHostInteractiveEditor implements ExtHostInteractiveEditorShape {
return undefined;
}
$handleFeedback(handle: number, sessionId: number, responseId: number, kind: InteractiveEditorResponseFeedbackKind): void {
$handleFeedback(handle: number, sessionId: number, responseId: number, kind: InlineChatResponseFeedbackKind): void {
const entry = this._inputProvider.get(handle);
const sessionData = this._inputSessions.get(sessionId);
const response = sessionData?.responses[responseId];
@ -192,13 +192,13 @@ export class ExtHostInteractiveEditor implements ExtHostInteractiveEditorShape {
// todo@jrieken move to type converter
let apiKind: extHostTypes.InteractiveEditorResponseFeedbackKind;
switch (kind) {
case InteractiveEditorResponseFeedbackKind.Helpful:
case InlineChatResponseFeedbackKind.Helpful:
apiKind = extHostTypes.InteractiveEditorResponseFeedbackKind.Helpful;
break;
case InteractiveEditorResponseFeedbackKind.Unhelpful:
case InlineChatResponseFeedbackKind.Unhelpful:
apiKind = extHostTypes.InteractiveEditorResponseFeedbackKind.Unhelpful;
break;
case InteractiveEditorResponseFeedbackKind.Undone:
case InlineChatResponseFeedbackKind.Undone:
apiKind = extHostTypes.InteractiveEditorResponseFeedbackKind.Undone;
break;
}

View File

@ -5,48 +5,48 @@
import { registerAction2 } from 'vs/platform/actions/common/actions';
import { EditorContributionInstantiation, registerEditorContribution } from 'vs/editor/browser/editorExtensions';
import { InteractiveEditorController } from 'vs/workbench/contrib/inlineChat/browser/inlineChatController';
import * as interactiveEditorActions from 'vs/workbench/contrib/inlineChat/browser/inlineChatActions';
import { IInteractiveEditorService, INTERACTIVE_EDITOR_ID } from 'vs/workbench/contrib/inlineChat/common/inlineChat';
import { InlineChatController } from 'vs/workbench/contrib/inlineChat/browser/inlineChatController';
import * as InlineChatActions from 'vs/workbench/contrib/inlineChat/browser/inlineChatActions';
import { IInlineChatService, INLINE_CHAT_ID } from 'vs/workbench/contrib/inlineChat/common/inlineChat';
import { InstantiationType, registerSingleton } from 'vs/platform/instantiation/common/extensions';
import { InteractiveEditorServiceImpl } from 'vs/workbench/contrib/inlineChat/common/inlineChatServiceImpl';
import { IInteractiveEditorSessionService, InteractiveEditorSessionService } from 'vs/workbench/contrib/inlineChat/browser/inlineChatSession';
import { InlineChatServiceImpl } from 'vs/workbench/contrib/inlineChat/common/inlineChatServiceImpl';
import { IInlineChatSessionService, InlineChatSessionService } from 'vs/workbench/contrib/inlineChat/browser/inlineChatSession';
import { Registry } from 'vs/platform/registry/common/platform';
import { IWorkbenchContributionsRegistry, Extensions } from 'vs/workbench/common/contributions';
import { LifecyclePhase } from 'vs/workbench/services/lifecycle/common/lifecycle';
import { InteractiveEditorNotebookContribution } from 'vs/workbench/contrib/inlineChat/browser/inlineChatNotebook';
import { InlineChatNotebookContribution } from 'vs/workbench/contrib/inlineChat/browser/inlineChatNotebook';
registerSingleton(IInteractiveEditorService, InteractiveEditorServiceImpl, InstantiationType.Delayed);
registerSingleton(IInteractiveEditorSessionService, InteractiveEditorSessionService, InstantiationType.Delayed);
registerSingleton(IInlineChatService, InlineChatServiceImpl, InstantiationType.Delayed);
registerSingleton(IInlineChatSessionService, InlineChatSessionService, InstantiationType.Delayed);
registerEditorContribution(INTERACTIVE_EDITOR_ID, InteractiveEditorController, EditorContributionInstantiation.Eager); // EAGER because of notebook dispose/create of editors
registerEditorContribution(INLINE_CHAT_ID, InlineChatController, EditorContributionInstantiation.Eager); // EAGER because of notebook dispose/create of editors
registerAction2(interactiveEditorActions.StartSessionAction);
registerAction2(interactiveEditorActions.UnstashSessionAction);
registerAction2(interactiveEditorActions.MakeRequestAction);
registerAction2(interactiveEditorActions.StopRequestAction);
registerAction2(interactiveEditorActions.DiscardAction);
registerAction2(interactiveEditorActions.DiscardToClipboardAction);
registerAction2(interactiveEditorActions.DiscardUndoToNewFileAction);
registerAction2(interactiveEditorActions.CancelSessionAction);
registerAction2(InlineChatActions.StartSessionAction);
registerAction2(InlineChatActions.UnstashSessionAction);
registerAction2(InlineChatActions.MakeRequestAction);
registerAction2(InlineChatActions.StopRequestAction);
registerAction2(InlineChatActions.DiscardAction);
registerAction2(InlineChatActions.DiscardToClipboardAction);
registerAction2(InlineChatActions.DiscardUndoToNewFileAction);
registerAction2(InlineChatActions.CancelSessionAction);
registerAction2(interactiveEditorActions.ArrowOutUpAction);
registerAction2(interactiveEditorActions.ArrowOutDownAction);
registerAction2(interactiveEditorActions.FocusInteractiveEditor);
registerAction2(interactiveEditorActions.PreviousFromHistory);
registerAction2(interactiveEditorActions.NextFromHistory);
registerAction2(interactiveEditorActions.ViewInChatAction);
registerAction2(interactiveEditorActions.ExpandMessageAction);
registerAction2(interactiveEditorActions.ContractMessageAction);
registerAction2(interactiveEditorActions.AccessibilityHelpEditorAction);
registerAction2(InlineChatActions.ArrowOutUpAction);
registerAction2(InlineChatActions.ArrowOutDownAction);
registerAction2(InlineChatActions.FocusInlineChat);
registerAction2(InlineChatActions.PreviousFromHistory);
registerAction2(InlineChatActions.NextFromHistory);
registerAction2(InlineChatActions.ViewInChatAction);
registerAction2(InlineChatActions.ExpandMessageAction);
registerAction2(InlineChatActions.ContractMessageAction);
registerAction2(InlineChatActions.AccessibilityHelpEditorAction);
registerAction2(interactiveEditorActions.ToggleInlineDiff);
registerAction2(interactiveEditorActions.FeebackHelpfulCommand);
registerAction2(interactiveEditorActions.FeebackUnhelpfulCommand);
registerAction2(interactiveEditorActions.ApplyPreviewEdits);
registerAction2(InlineChatActions.ToggleInlineDiff);
registerAction2(InlineChatActions.FeebackHelpfulCommand);
registerAction2(InlineChatActions.FeebackUnhelpfulCommand);
registerAction2(InlineChatActions.ApplyPreviewEdits);
registerAction2(interactiveEditorActions.CopyRecordings);
registerAction2(InlineChatActions.CopyRecordings);
Registry.as<IWorkbenchContributionsRegistry>(Extensions.Workbench)
.registerWorkbenchContribution(InteractiveEditorNotebookContribution, LifecyclePhase.Restored);
.registerWorkbenchContribution(InlineChatNotebookContribution, LifecyclePhase.Restored);

View File

@ -11,8 +11,8 @@
color: inherit;
padding: 6px;
border-radius: 6px;
border: 1px solid var(--vscode-interactiveEditor-border);
box-shadow: 0 4px 8px var(--vscode-interactiveEditor-shadow);
border: 1px solid var(--vscode-inlineChat-border);
box-shadow: 0 4px 8px var(--vscode-inlineChat-shadow);
}
/* body */
@ -25,30 +25,30 @@
display: flex;
box-sizing: border-box;
border-radius: 2px;
border: 1px solid var(--vscode-interactiveEditorInput-border);
border: 1px solid var(--vscode-inlineChatInput-border);
}
.monaco-editor .interactive-editor .body .content.synthetic-focus {
outline: 1px solid var(--vscode-interactiveEditorInput-focusBorder);
outline: 1px solid var(--vscode-inlineChatInput-focusBorder);
}
.monaco-editor .interactive-editor .body .content .input {
padding: 2px 2px 2px 4px;
border-top-left-radius: 2px;
border-bottom-left-radius: 2px;
background-color: var(--vscode-interactiveEditorInput-background);
background-color: var(--vscode-inlineChatInput-background);
cursor: text;
}
.monaco-editor .interactive-editor .body .content .input .monaco-editor-background {
background-color: var(--vscode-interactiveEditorInput-background);
background-color: var(--vscode-inlineChatInput-background);
}
.monaco-editor .interactive-editor .body .content .input .editor-placeholder {
position: absolute;
z-index: 1;
padding: 3px 0 0 0;
color: var(--vscode-interactiveEditorInput-placeholderForeground);
color: var(--vscode-inlineChatInput-placeholderForeground);
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
@ -68,7 +68,7 @@
padding-right: 4px;
border-top-right-radius: 2px;
border-bottom-right-radius: 2px;
background: var(--vscode-interactiveEditorInput-background);
background: var(--vscode-inlineChatInput-background);
}
.monaco-editor .interactive-editor .body .toolbar .actions-container {
@ -215,7 +215,7 @@
.monaco-editor .interactive-editor .previewDiff {
display: inherit;
padding: 6px;
border: 1px solid var(--vscode-interactiveEditor-border);
border: 1px solid var(--vscode-inlineChat-border);
border-top: none;
border-bottom-left-radius: 2px;
border-bottom-right-radius: 2px;
@ -229,7 +229,7 @@
.monaco-editor .interactive-editor .previewCreate {
display: inherit;
padding: 6px;
border: 1px solid var(--vscode-interactiveEditor-border);
border: 1px solid var(--vscode-inlineChat-border);
border-radius: 2px;
margin: 0 2px 6px 2px;
}
@ -252,7 +252,7 @@
}
.monaco-editor .interactive-editor-block-selection {
background-color: var(--vscode-interactiveEditor-regionHighlight);
background-color: var(--vscode-inlineChat-regionHighlight);
}
.monaco-editor .interactive-editor-slash-command {
@ -271,14 +271,14 @@
.monaco-editor .interactive-editor-diff-widget .monaco-diff-editor .monaco-editor-background,
.monaco-editor .interactive-editor-diff-widget .monaco-diff-editor .monaco-editor .margin-view-overlays {
background-color: var(--vscode-interactiveEditor-regionHighlight);
background-color: var(--vscode-inlineChat-regionHighlight);
}
/* create zone */
.monaco-editor .interactive-editor-newfile-widget {
padding: 3px 0 6px 0;
background-color: var(--vscode-interactiveEditor-regionHighlight);
background-color: var(--vscode-inlineChat-regionHighlight);
}
.monaco-editor .interactive-editor-newfile-widget .title {

View File

@ -9,8 +9,8 @@ import { ICodeEditor } from 'vs/editor/browser/editorBrowser';
import { EditorAction2 } from 'vs/editor/browser/editorExtensions';
import { EmbeddedCodeEditorWidget, EmbeddedDiffEditorWidget } from 'vs/editor/browser/widget/embeddedCodeEditorWidget';
import { EditorContextKeys } from 'vs/editor/common/editorContextKeys';
import { InteractiveEditorController, InteractiveEditorRunOptions } from 'vs/workbench/contrib/inlineChat/browser/inlineChatController';
import { CTX_INTERACTIVE_EDITOR_FOCUSED, CTX_INTERACTIVE_EDITOR_HAS_ACTIVE_REQUEST, CTX_INTERACTIVE_EDITOR_HAS_PROVIDER, CTX_INTERACTIVE_EDITOR_INNER_CURSOR_FIRST, CTX_INTERACTIVE_EDITOR_INNER_CURSOR_LAST, CTX_INTERACTIVE_EDITOR_EMPTY, CTX_INTERACTIVE_EDITOR_OUTER_CURSOR_POSITION, CTX_INTERACTIVE_EDITOR_VISIBLE, MENU_INTERACTIVE_EDITOR_WIDGET, MENU_INTERACTIVE_EDITOR_WIDGET_DISCARD, MENU_INTERACTIVE_EDITOR_WIDGET_STATUS, CTX_INTERACTIVE_EDITOR_LAST_FEEDBACK, CTX_INTERACTIVE_EDITOR_SHOWING_DIFF, CTX_INTERACTIVE_EDITOR_EDIT_MODE, EditMode, CTX_INTERACTIVE_EDITOR_LAST_RESPONSE_TYPE, MENU_INTERACTIVE_EDITOR_WIDGET_MARKDOWN_MESSAGE, CTX_INTERACTIVE_EDITOR_MESSAGE_CROP_STATE, CTX_INTERACTIVE_EDITOR_DOCUMENT_CHANGED, CTX_INTERACTIVE_EDITOR_DID_EDIT, CTX_INTERACTIVE_EDITOR_HAS_STASHED_SESSION, MENU_INTERACTIVE_EDITOR_WIDGET_FEEDBACK, ACTION_ACCEPT_CHANGES } from 'vs/workbench/contrib/inlineChat/common/inlineChat';
import { InlineChatController, InlineChatRunOptions } from 'vs/workbench/contrib/inlineChat/browser/inlineChatController';
import { CTX_INLINE_CHAT_FOCUSED, CTX_INLINE_CHAT_HAS_ACTIVE_REQUEST, CTX_INLINE_CHAT_HAS_PROVIDER, CTX_INLINE_CHAT_INNER_CURSOR_FIRST, CTX_INLINE_CHAT_INNER_CURSOR_LAST, CTX_INLINE_CHAT_EMPTY, CTX_INLINE_CHAT_OUTER_CURSOR_POSITION, CTX_INLINE_CHAT_VISIBLE, MENU_INLINE_CHAT_WIDGET, MENU_INLINE_CHAT_WIDGET_DISCARD, MENU_INLINE_CHAT_WIDGET_STATUS, CTX_INLINE_CHAT_LAST_FEEDBACK, CTX_INLINE_CHAT_SHOWING_DIFF, CTX_INLINE_CHAT_EDIT_MODE, EditMode, CTX_INLINE_CHAT_LAST_RESPONSE_TYPE, MENU_INLINE_CHAT_WIDGET_MARKDOWN_MESSAGE, CTX_INLINE_CHAT_MESSAGE_CROP_STATE, CTX_INLINE_CHAT_DOCUMENT_CHANGED, CTX_INLINE_CHAT_DID_EDIT, CTX_INLINE_CHAT_HAS_STASHED_SESSION, MENU_INLINE_CHAT_WIDGET_FEEDBACK, ACTION_ACCEPT_CHANGES } from 'vs/workbench/contrib/inlineChat/common/inlineChat';
import { localize } from 'vs/nls';
import { IAction2Options, MenuRegistry } from 'vs/platform/actions/common/actions';
import { IClipboardService } from 'vs/platform/clipboard/common/clipboardService';
@ -23,7 +23,7 @@ import { IUntitledTextResourceEditorInput } from 'vs/workbench/common/editor';
import { ICodeEditorService } from 'vs/editor/browser/services/codeEditorService';
import { Range } from 'vs/editor/common/core/range';
import { fromNow } from 'vs/base/common/date';
import { IInteractiveEditorSessionService, Recording } from 'vs/workbench/contrib/inlineChat/browser/inlineChatSession';
import { IInlineChatSessionService, Recording } from 'vs/workbench/contrib/inlineChat/browser/inlineChatSession';
import { runAccessibilityHelpAction } from 'vs/workbench/contrib/chat/browser/actions/chatAccessibilityHelp';
import { CONTEXT_ACCESSIBILITY_MODE_ENABLED } from 'vs/platform/accessibility/common/accessibility';
@ -34,9 +34,9 @@ export class StartSessionAction extends EditorAction2 {
super({
id: 'interactiveEditor.start',
title: { value: localize('run', 'Start Code Chat'), original: 'Start Code Chat' },
category: AbstractInteractiveEditorAction.category,
category: AbstractInlineChatAction.category,
f1: true,
precondition: ContextKeyExpr.and(CTX_INTERACTIVE_EDITOR_HAS_PROVIDER, EditorContextKeys.writable),
precondition: ContextKeyExpr.and(CTX_INLINE_CHAT_HAS_PROVIDER, EditorContextKeys.writable),
keybinding: {
weight: KeybindingWeight.WorkbenchContrib,
primary: KeyMod.CtrlCmd | KeyCode.KeyI,
@ -45,7 +45,7 @@ export class StartSessionAction extends EditorAction2 {
});
}
private _isInteractivEditorOptions(options: any): options is InteractiveEditorRunOptions {
private _isInteractivEditorOptions(options: any): options is InlineChatRunOptions {
const { initialRange, message, autoSend } = options;
if (
typeof message !== 'undefined' && typeof message !== 'string'
@ -57,12 +57,12 @@ export class StartSessionAction extends EditorAction2 {
}
override runEditorCommand(_accessor: ServicesAccessor, editor: ICodeEditor, ..._args: any[]) {
let options: InteractiveEditorRunOptions | undefined;
let options: InlineChatRunOptions | undefined;
const arg = _args[0];
if (arg && this._isInteractivEditorOptions(arg)) {
options = arg;
}
InteractiveEditorController.get(editor)?.run(options);
InlineChatController.get(editor)?.run(options);
}
}
@ -71,8 +71,8 @@ export class UnstashSessionAction extends EditorAction2 {
super({
id: 'interactiveEditor.unstash',
title: { value: localize('unstash', 'Resume Last Dismissed Code Chat'), original: 'Resume Last Dismissed Code Chat' },
category: AbstractInteractiveEditorAction.category,
precondition: ContextKeyExpr.and(CTX_INTERACTIVE_EDITOR_HAS_STASHED_SESSION, EditorContextKeys.writable),
category: AbstractInlineChatAction.category,
precondition: ContextKeyExpr.and(CTX_INLINE_CHAT_HAS_STASHED_SESSION, EditorContextKeys.writable),
keybinding: {
weight: KeybindingWeight.WorkbenchContrib,
primary: KeyMod.CtrlCmd | KeyCode.KeyZ,
@ -81,7 +81,7 @@ export class UnstashSessionAction extends EditorAction2 {
}
override runEditorCommand(_accessor: ServicesAccessor, editor: ICodeEditor, ..._args: any[]) {
const ctrl = InteractiveEditorController.get(editor);
const ctrl = InlineChatController.get(editor);
if (ctrl) {
const session = ctrl.unstashLastSession();
if (session) {
@ -94,15 +94,15 @@ export class UnstashSessionAction extends EditorAction2 {
}
}
abstract class AbstractInteractiveEditorAction extends EditorAction2 {
abstract class AbstractInlineChatAction extends EditorAction2 {
static readonly category = { value: localize('cat', 'Interactive Editor'), original: 'Interactive Editor' };
constructor(desc: IAction2Options) {
super({
...desc,
category: AbstractInteractiveEditorAction.category,
precondition: ContextKeyExpr.and(CTX_INTERACTIVE_EDITOR_HAS_PROVIDER, desc.precondition)
category: AbstractInlineChatAction.category,
precondition: ContextKeyExpr.and(CTX_INLINE_CHAT_HAS_PROVIDER, desc.precondition)
});
}
@ -110,7 +110,7 @@ abstract class AbstractInteractiveEditorAction extends EditorAction2 {
if (editor instanceof EmbeddedCodeEditorWidget) {
editor = editor.getParentEditor();
}
const ctrl = InteractiveEditorController.get(editor);
const ctrl = InlineChatController.get(editor);
if (!ctrl) {
for (const diffEditor of accessor.get(ICodeEditorService).listDiffEditors()) {
if (diffEditor.getOriginalEditor() === editor || diffEditor.getModifiedEditor() === editor) {
@ -121,53 +121,53 @@ abstract class AbstractInteractiveEditorAction extends EditorAction2 {
}
return;
}
this.runInteractiveEditorCommand(accessor, ctrl, editor, ..._args);
this.runInlineChatCommand(accessor, ctrl, editor, ..._args);
}
abstract runInteractiveEditorCommand(accessor: ServicesAccessor, ctrl: InteractiveEditorController, editor: ICodeEditor, ...args: any[]): void;
abstract runInlineChatCommand(accessor: ServicesAccessor, ctrl: InlineChatController, editor: ICodeEditor, ...args: any[]): void;
}
export class MakeRequestAction extends AbstractInteractiveEditorAction {
export class MakeRequestAction extends AbstractInlineChatAction {
constructor() {
super({
id: 'interactiveEditor.accept',
title: localize('accept', 'Make Request'),
icon: Codicon.send,
precondition: ContextKeyExpr.and(CTX_INTERACTIVE_EDITOR_VISIBLE, CTX_INTERACTIVE_EDITOR_EMPTY.negate()),
precondition: ContextKeyExpr.and(CTX_INLINE_CHAT_VISIBLE, CTX_INLINE_CHAT_EMPTY.negate()),
keybinding: {
when: CTX_INTERACTIVE_EDITOR_FOCUSED,
when: CTX_INLINE_CHAT_FOCUSED,
weight: KeybindingWeight.EditorCore + 7,
primary: KeyCode.Enter
},
menu: {
id: MENU_INTERACTIVE_EDITOR_WIDGET,
id: MENU_INLINE_CHAT_WIDGET,
group: 'main',
order: 1,
when: CTX_INTERACTIVE_EDITOR_HAS_ACTIVE_REQUEST.isEqualTo(false)
when: CTX_INLINE_CHAT_HAS_ACTIVE_REQUEST.isEqualTo(false)
}
});
}
runInteractiveEditorCommand(_accessor: ServicesAccessor, ctrl: InteractiveEditorController, _editor: ICodeEditor, ..._args: any[]): void {
runInlineChatCommand(_accessor: ServicesAccessor, ctrl: InlineChatController, _editor: ICodeEditor, ..._args: any[]): void {
ctrl.acceptInput();
}
}
export class StopRequestAction extends AbstractInteractiveEditorAction {
export class StopRequestAction extends AbstractInlineChatAction {
constructor() {
super({
id: 'interactiveEditor.stop',
title: localize('stop', 'Stop Request'),
icon: Codicon.debugStop,
precondition: ContextKeyExpr.and(CTX_INTERACTIVE_EDITOR_VISIBLE, CTX_INTERACTIVE_EDITOR_EMPTY.negate(), CTX_INTERACTIVE_EDITOR_HAS_ACTIVE_REQUEST),
precondition: ContextKeyExpr.and(CTX_INLINE_CHAT_VISIBLE, CTX_INLINE_CHAT_EMPTY.negate(), CTX_INLINE_CHAT_HAS_ACTIVE_REQUEST),
menu: {
id: MENU_INTERACTIVE_EDITOR_WIDGET,
id: MENU_INLINE_CHAT_WIDGET,
group: 'main',
order: 1,
when: CTX_INTERACTIVE_EDITOR_HAS_ACTIVE_REQUEST
when: CTX_INLINE_CHAT_HAS_ACTIVE_REQUEST
},
keybinding: {
weight: KeybindingWeight.EditorContrib,
@ -176,17 +176,17 @@ export class StopRequestAction extends AbstractInteractiveEditorAction {
});
}
runInteractiveEditorCommand(_accessor: ServicesAccessor, ctrl: InteractiveEditorController, _editor: ICodeEditor, ..._args: any[]): void {
runInlineChatCommand(_accessor: ServicesAccessor, ctrl: InlineChatController, _editor: ICodeEditor, ..._args: any[]): void {
ctrl.cancelCurrentRequest();
}
}
export class ArrowOutUpAction extends AbstractInteractiveEditorAction {
export class ArrowOutUpAction extends AbstractInlineChatAction {
constructor() {
super({
id: 'interactiveEditor.arrowOutUp',
title: localize('arrowUp', 'Cursor Up'),
precondition: ContextKeyExpr.and(CTX_INTERACTIVE_EDITOR_FOCUSED, CTX_INTERACTIVE_EDITOR_INNER_CURSOR_FIRST, EditorContextKeys.isEmbeddedDiffEditor.negate(), CONTEXT_ACCESSIBILITY_MODE_ENABLED.negate()),
precondition: ContextKeyExpr.and(CTX_INLINE_CHAT_FOCUSED, CTX_INLINE_CHAT_INNER_CURSOR_FIRST, EditorContextKeys.isEmbeddedDiffEditor.negate(), CONTEXT_ACCESSIBILITY_MODE_ENABLED.negate()),
keybinding: {
weight: KeybindingWeight.EditorCore,
primary: KeyCode.UpArrow
@ -194,17 +194,17 @@ export class ArrowOutUpAction extends AbstractInteractiveEditorAction {
});
}
runInteractiveEditorCommand(_accessor: ServicesAccessor, ctrl: InteractiveEditorController, _editor: ICodeEditor, ..._args: any[]): void {
runInlineChatCommand(_accessor: ServicesAccessor, ctrl: InlineChatController, _editor: ICodeEditor, ..._args: any[]): void {
ctrl.arrowOut(true);
}
}
export class ArrowOutDownAction extends AbstractInteractiveEditorAction {
export class ArrowOutDownAction extends AbstractInlineChatAction {
constructor() {
super({
id: 'interactiveEditor.arrowOutDown',
title: localize('arrowDown', 'Cursor Down'),
precondition: ContextKeyExpr.and(CTX_INTERACTIVE_EDITOR_FOCUSED, CTX_INTERACTIVE_EDITOR_INNER_CURSOR_LAST, EditorContextKeys.isEmbeddedDiffEditor.negate(), CONTEXT_ACCESSIBILITY_MODE_ENABLED.negate()),
precondition: ContextKeyExpr.and(CTX_INLINE_CHAT_FOCUSED, CTX_INLINE_CHAT_INNER_CURSOR_LAST, EditorContextKeys.isEmbeddedDiffEditor.negate(), CONTEXT_ACCESSIBILITY_MODE_ENABLED.negate()),
keybinding: {
weight: KeybindingWeight.EditorCore,
primary: KeyCode.DownArrow
@ -212,44 +212,44 @@ export class ArrowOutDownAction extends AbstractInteractiveEditorAction {
});
}
runInteractiveEditorCommand(_accessor: ServicesAccessor, ctrl: InteractiveEditorController, _editor: ICodeEditor, ..._args: any[]): void {
runInlineChatCommand(_accessor: ServicesAccessor, ctrl: InlineChatController, _editor: ICodeEditor, ..._args: any[]): void {
ctrl.arrowOut(false);
}
}
export class FocusInteractiveEditor extends EditorAction2 {
export class FocusInlineChat extends EditorAction2 {
constructor() {
super({
id: 'interactiveEditor.focus',
title: { value: localize('focus', 'Focus Input'), original: 'Focus Input' },
f1: true,
category: AbstractInteractiveEditorAction.category,
precondition: ContextKeyExpr.and(EditorContextKeys.editorTextFocus, CTX_INTERACTIVE_EDITOR_VISIBLE, CTX_INTERACTIVE_EDITOR_FOCUSED.negate(), CONTEXT_ACCESSIBILITY_MODE_ENABLED.negate()),
category: AbstractInlineChatAction.category,
precondition: ContextKeyExpr.and(EditorContextKeys.editorTextFocus, CTX_INLINE_CHAT_VISIBLE, CTX_INLINE_CHAT_FOCUSED.negate(), CONTEXT_ACCESSIBILITY_MODE_ENABLED.negate()),
keybinding: [{
weight: KeybindingWeight.EditorCore + 10, // win against core_command
when: ContextKeyExpr.and(CTX_INTERACTIVE_EDITOR_OUTER_CURSOR_POSITION.isEqualTo('above'), EditorContextKeys.isEmbeddedDiffEditor.negate()),
when: ContextKeyExpr.and(CTX_INLINE_CHAT_OUTER_CURSOR_POSITION.isEqualTo('above'), EditorContextKeys.isEmbeddedDiffEditor.negate()),
primary: KeyCode.DownArrow,
}, {
weight: KeybindingWeight.EditorCore + 10, // win against core_command
when: ContextKeyExpr.and(CTX_INTERACTIVE_EDITOR_OUTER_CURSOR_POSITION.isEqualTo('below'), EditorContextKeys.isEmbeddedDiffEditor.negate()),
when: ContextKeyExpr.and(CTX_INLINE_CHAT_OUTER_CURSOR_POSITION.isEqualTo('below'), EditorContextKeys.isEmbeddedDiffEditor.negate()),
primary: KeyCode.UpArrow,
}]
});
}
override runEditorCommand(_accessor: ServicesAccessor, editor: ICodeEditor, ..._args: any[]) {
InteractiveEditorController.get(editor)?.focus();
InlineChatController.get(editor)?.focus();
}
}
export class PreviousFromHistory extends AbstractInteractiveEditorAction {
export class PreviousFromHistory extends AbstractInlineChatAction {
constructor() {
super({
id: 'interactiveEditor.previousFromHistory',
title: localize('previousFromHistory', 'Previous From History'),
precondition: CTX_INTERACTIVE_EDITOR_FOCUSED,
precondition: CTX_INLINE_CHAT_FOCUSED,
keybinding: {
weight: KeybindingWeight.EditorCore + 10, // win against core_command
primary: KeyMod.CtrlCmd | KeyCode.UpArrow,
@ -257,18 +257,18 @@ export class PreviousFromHistory extends AbstractInteractiveEditorAction {
});
}
override runInteractiveEditorCommand(_accessor: ServicesAccessor, ctrl: InteractiveEditorController, _editor: ICodeEditor, ..._args: any[]): void {
override runInlineChatCommand(_accessor: ServicesAccessor, ctrl: InlineChatController, _editor: ICodeEditor, ..._args: any[]): void {
ctrl.populateHistory(true);
}
}
export class NextFromHistory extends AbstractInteractiveEditorAction {
export class NextFromHistory extends AbstractInlineChatAction {
constructor() {
super({
id: 'interactiveEditor.nextFromHistory',
title: localize('nextFromHistory', 'Next From History'),
precondition: CTX_INTERACTIVE_EDITOR_FOCUSED,
precondition: CTX_INLINE_CHAT_FOCUSED,
keybinding: {
weight: KeybindingWeight.EditorCore + 10, // win against core_command
primary: KeyMod.CtrlCmd | KeyCode.DownArrow,
@ -276,68 +276,68 @@ export class NextFromHistory extends AbstractInteractiveEditorAction {
});
}
override runInteractiveEditorCommand(_accessor: ServicesAccessor, ctrl: InteractiveEditorController, _editor: ICodeEditor, ..._args: any[]): void {
override runInlineChatCommand(_accessor: ServicesAccessor, ctrl: InlineChatController, _editor: ICodeEditor, ..._args: any[]): void {
ctrl.populateHistory(false);
}
}
MenuRegistry.appendMenuItem(MENU_INTERACTIVE_EDITOR_WIDGET_STATUS, {
submenu: MENU_INTERACTIVE_EDITOR_WIDGET_DISCARD,
MenuRegistry.appendMenuItem(MENU_INLINE_CHAT_WIDGET_STATUS, {
submenu: MENU_INLINE_CHAT_WIDGET_DISCARD,
title: localize('discardMenu', "Discard..."),
icon: Codicon.discard,
group: '0_main',
order: 2,
when: CTX_INTERACTIVE_EDITOR_EDIT_MODE.notEqualsTo(EditMode.Preview),
when: CTX_INLINE_CHAT_EDIT_MODE.notEqualsTo(EditMode.Preview),
rememberDefaultAction: true
});
export class DiscardAction extends AbstractInteractiveEditorAction {
export class DiscardAction extends AbstractInlineChatAction {
constructor() {
super({
id: 'interactiveEditor.discard',
title: localize('discard', 'Discard'),
icon: Codicon.discard,
precondition: CTX_INTERACTIVE_EDITOR_VISIBLE,
precondition: CTX_INLINE_CHAT_VISIBLE,
keybinding: {
weight: KeybindingWeight.EditorContrib,
primary: KeyCode.Escape
},
menu: {
id: MENU_INTERACTIVE_EDITOR_WIDGET_DISCARD,
id: MENU_INLINE_CHAT_WIDGET_DISCARD,
group: '0_main',
order: 0
}
});
}
async runInteractiveEditorCommand(_accessor: ServicesAccessor, ctrl: InteractiveEditorController, _editor: ICodeEditor, ..._args: any[]): Promise<void> {
async runInlineChatCommand(_accessor: ServicesAccessor, ctrl: InlineChatController, _editor: ICodeEditor, ..._args: any[]): Promise<void> {
ctrl.cancelSession();
}
}
export class DiscardToClipboardAction extends AbstractInteractiveEditorAction {
export class DiscardToClipboardAction extends AbstractInlineChatAction {
constructor() {
super({
id: 'interactiveEditor.discardToClipboard',
title: localize('undo.clipboard', 'Discard to Clipboard'),
precondition: ContextKeyExpr.and(CTX_INTERACTIVE_EDITOR_VISIBLE, CTX_INTERACTIVE_EDITOR_DID_EDIT),
precondition: ContextKeyExpr.and(CTX_INLINE_CHAT_VISIBLE, CTX_INLINE_CHAT_DID_EDIT),
// keybinding: {
// weight: KeybindingWeight.EditorContrib + 10,
// primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.KeyZ,
// mac: { primary: KeyMod.CtrlCmd | KeyMod.Alt | KeyCode.KeyZ },
// },
menu: {
id: MENU_INTERACTIVE_EDITOR_WIDGET_DISCARD,
id: MENU_INLINE_CHAT_WIDGET_DISCARD,
group: '0_main',
order: 1
}
});
}
override async runInteractiveEditorCommand(accessor: ServicesAccessor, ctrl: InteractiveEditorController): Promise<void> {
override async runInlineChatCommand(accessor: ServicesAccessor, ctrl: InlineChatController): Promise<void> {
const clipboardService = accessor.get(IClipboardService);
const changedText = ctrl.cancelSession();
if (changedText !== undefined) {
@ -346,22 +346,22 @@ export class DiscardToClipboardAction extends AbstractInteractiveEditorAction {
}
}
export class DiscardUndoToNewFileAction extends AbstractInteractiveEditorAction {
export class DiscardUndoToNewFileAction extends AbstractInlineChatAction {
constructor() {
super({
id: 'interactiveEditor.discardToFile',
title: localize('undo.newfile', 'Discard to New File'),
precondition: ContextKeyExpr.and(CTX_INTERACTIVE_EDITOR_VISIBLE, CTX_INTERACTIVE_EDITOR_DID_EDIT),
precondition: ContextKeyExpr.and(CTX_INLINE_CHAT_VISIBLE, CTX_INLINE_CHAT_DID_EDIT),
menu: {
id: MENU_INTERACTIVE_EDITOR_WIDGET_DISCARD,
id: MENU_INLINE_CHAT_WIDGET_DISCARD,
group: '0_main',
order: 2
}
});
}
override async runInteractiveEditorCommand(accessor: ServicesAccessor, ctrl: InteractiveEditorController, editor: ICodeEditor, ..._args: any[]): Promise<void> {
override async runInlineChatCommand(accessor: ServicesAccessor, ctrl: InlineChatController, editor: ICodeEditor, ..._args: any[]): Promise<void> {
const editorService = accessor.get(IEditorService);
const changedText = ctrl.cancelSession();
if (changedText !== undefined) {
@ -371,74 +371,74 @@ export class DiscardUndoToNewFileAction extends AbstractInteractiveEditorAction
}
}
export class FeebackHelpfulCommand extends AbstractInteractiveEditorAction {
export class FeebackHelpfulCommand extends AbstractInlineChatAction {
constructor() {
super({
id: 'interactiveEditor.feedbackHelpful',
title: localize('feedback.helpful', 'Helpful'),
icon: Codicon.thumbsup,
precondition: CTX_INTERACTIVE_EDITOR_VISIBLE,
toggled: CTX_INTERACTIVE_EDITOR_LAST_FEEDBACK.isEqualTo('helpful'),
precondition: CTX_INLINE_CHAT_VISIBLE,
toggled: CTX_INLINE_CHAT_LAST_FEEDBACK.isEqualTo('helpful'),
menu: {
id: MENU_INTERACTIVE_EDITOR_WIDGET_FEEDBACK,
when: CTX_INTERACTIVE_EDITOR_LAST_RESPONSE_TYPE.notEqualsTo(undefined),
id: MENU_INLINE_CHAT_WIDGET_FEEDBACK,
when: CTX_INLINE_CHAT_LAST_RESPONSE_TYPE.notEqualsTo(undefined),
group: '2_feedback',
order: 1
}
});
}
override runInteractiveEditorCommand(_accessor: ServicesAccessor, ctrl: InteractiveEditorController): void {
override runInlineChatCommand(_accessor: ServicesAccessor, ctrl: InlineChatController): void {
ctrl.feedbackLast(true);
}
}
export class FeebackUnhelpfulCommand extends AbstractInteractiveEditorAction {
export class FeebackUnhelpfulCommand extends AbstractInlineChatAction {
constructor() {
super({
id: 'interactiveEditor.feedbackunhelpful',
title: localize('feedback.unhelpful', 'Unhelpful'),
icon: Codicon.thumbsdown,
precondition: CTX_INTERACTIVE_EDITOR_VISIBLE,
toggled: CTX_INTERACTIVE_EDITOR_LAST_FEEDBACK.isEqualTo('unhelpful'),
precondition: CTX_INLINE_CHAT_VISIBLE,
toggled: CTX_INLINE_CHAT_LAST_FEEDBACK.isEqualTo('unhelpful'),
menu: {
id: MENU_INTERACTIVE_EDITOR_WIDGET_FEEDBACK,
when: CTX_INTERACTIVE_EDITOR_LAST_RESPONSE_TYPE.notEqualsTo(undefined),
id: MENU_INLINE_CHAT_WIDGET_FEEDBACK,
when: CTX_INLINE_CHAT_LAST_RESPONSE_TYPE.notEqualsTo(undefined),
group: '2_feedback',
order: 2
}
});
}
override runInteractiveEditorCommand(_accessor: ServicesAccessor, ctrl: InteractiveEditorController): void {
override runInlineChatCommand(_accessor: ServicesAccessor, ctrl: InlineChatController): void {
ctrl.feedbackLast(false);
}
}
export class ToggleInlineDiff extends AbstractInteractiveEditorAction {
export class ToggleInlineDiff extends AbstractInlineChatAction {
constructor() {
super({
id: 'interactiveEditor.toggleDiff',
title: localize('toggleDiff', 'Toggle Diff'),
icon: Codicon.diff,
precondition: ContextKeyExpr.and(CTX_INTERACTIVE_EDITOR_VISIBLE, CTX_INTERACTIVE_EDITOR_DID_EDIT),
toggled: { condition: CTX_INTERACTIVE_EDITOR_SHOWING_DIFF, title: localize('toggleDiff2', "Show Inline Diff") },
precondition: ContextKeyExpr.and(CTX_INLINE_CHAT_VISIBLE, CTX_INLINE_CHAT_DID_EDIT),
toggled: { condition: CTX_INLINE_CHAT_SHOWING_DIFF, title: localize('toggleDiff2', "Show Inline Diff") },
menu: {
id: MENU_INTERACTIVE_EDITOR_WIDGET_DISCARD,
when: CTX_INTERACTIVE_EDITOR_EDIT_MODE.notEqualsTo(EditMode.Preview),
id: MENU_INLINE_CHAT_WIDGET_DISCARD,
when: CTX_INLINE_CHAT_EDIT_MODE.notEqualsTo(EditMode.Preview),
group: '1_config',
order: 9
}
});
}
override runInteractiveEditorCommand(_accessor: ServicesAccessor, ctrl: InteractiveEditorController): void {
override runInlineChatCommand(_accessor: ServicesAccessor, ctrl: InlineChatController): void {
ctrl.toggleDiff();
}
}
export class ApplyPreviewEdits extends AbstractInteractiveEditorAction {
export class ApplyPreviewEdits extends AbstractInlineChatAction {
constructor() {
super({
@ -446,51 +446,51 @@ export class ApplyPreviewEdits extends AbstractInteractiveEditorAction {
title: localize('apply1', 'Accept Changes'),
shortTitle: localize('apply2', 'Accept'),
icon: Codicon.check,
precondition: ContextKeyExpr.and(CTX_INTERACTIVE_EDITOR_VISIBLE, ContextKeyExpr.or(CTX_INTERACTIVE_EDITOR_DOCUMENT_CHANGED.toNegated(), CTX_INTERACTIVE_EDITOR_EDIT_MODE.notEqualsTo(EditMode.Preview))),
precondition: ContextKeyExpr.and(CTX_INLINE_CHAT_VISIBLE, ContextKeyExpr.or(CTX_INLINE_CHAT_DOCUMENT_CHANGED.toNegated(), CTX_INLINE_CHAT_EDIT_MODE.notEqualsTo(EditMode.Preview))),
keybinding: [{
weight: KeybindingWeight.EditorContrib + 10,
primary: KeyMod.CtrlCmd | KeyCode.Enter,
}],
menu: {
id: MENU_INTERACTIVE_EDITOR_WIDGET_STATUS,
id: MENU_INLINE_CHAT_WIDGET_STATUS,
group: '0_main',
order: 0
}
});
}
override async runInteractiveEditorCommand(_accessor: ServicesAccessor, ctrl: InteractiveEditorController): Promise<void> {
override async runInlineChatCommand(_accessor: ServicesAccessor, ctrl: InlineChatController): Promise<void> {
ctrl.acceptSession();
}
}
export class CancelSessionAction extends AbstractInteractiveEditorAction {
export class CancelSessionAction extends AbstractInlineChatAction {
constructor() {
super({
id: 'interactiveEditor.cancel',
title: localize('cancel', 'Cancel'),
icon: Codicon.clearAll,
precondition: ContextKeyExpr.and(CTX_INTERACTIVE_EDITOR_VISIBLE, CTX_INTERACTIVE_EDITOR_EDIT_MODE.isEqualTo(EditMode.Preview)),
precondition: ContextKeyExpr.and(CTX_INLINE_CHAT_VISIBLE, CTX_INLINE_CHAT_EDIT_MODE.isEqualTo(EditMode.Preview)),
keybinding: {
weight: KeybindingWeight.EditorContrib - 1,
primary: KeyCode.Escape
},
menu: {
id: MENU_INTERACTIVE_EDITOR_WIDGET_STATUS,
when: CTX_INTERACTIVE_EDITOR_EDIT_MODE.isEqualTo(EditMode.Preview),
id: MENU_INLINE_CHAT_WIDGET_STATUS,
when: CTX_INLINE_CHAT_EDIT_MODE.isEqualTo(EditMode.Preview),
group: '0_main',
order: 1
}
});
}
async runInteractiveEditorCommand(_accessor: ServicesAccessor, ctrl: InteractiveEditorController, _editor: ICodeEditor, ..._args: any[]): Promise<void> {
async runInlineChatCommand(_accessor: ServicesAccessor, ctrl: InlineChatController, _editor: ICodeEditor, ..._args: any[]): Promise<void> {
ctrl.cancelSession();
}
}
export class CopyRecordings extends AbstractInteractiveEditorAction {
export class CopyRecordings extends AbstractInlineChatAction {
constructor() {
super({
@ -503,11 +503,11 @@ export class CopyRecordings extends AbstractInteractiveEditorAction {
});
}
override async runInteractiveEditorCommand(accessor: ServicesAccessor): Promise<void> {
override async runInlineChatCommand(accessor: ServicesAccessor): Promise<void> {
const clipboardService = accessor.get(IClipboardService);
const quickPickService = accessor.get(IQuickInputService);
const ieSessionService = accessor.get(IInteractiveEditorSessionService);
const ieSessionService = accessor.get(IInlineChatSessionService);
const recordings = ieSessionService.recordings().filter(r => r.exchanges.length > 0);
if (recordings.length === 0) {
@ -529,62 +529,62 @@ export class CopyRecordings extends AbstractInteractiveEditorAction {
}
}
export class ViewInChatAction extends AbstractInteractiveEditorAction {
export class ViewInChatAction extends AbstractInlineChatAction {
constructor() {
super({
id: 'interactiveEditor.viewInChat',
title: localize('viewInChat', 'View in Chat'),
icon: Codicon.commentDiscussion,
precondition: CTX_INTERACTIVE_EDITOR_VISIBLE,
precondition: CTX_INLINE_CHAT_VISIBLE,
menu: {
id: MENU_INTERACTIVE_EDITOR_WIDGET_MARKDOWN_MESSAGE,
when: CTX_INTERACTIVE_EDITOR_LAST_RESPONSE_TYPE.isEqualTo('message'),
id: MENU_INLINE_CHAT_WIDGET_MARKDOWN_MESSAGE,
when: CTX_INLINE_CHAT_LAST_RESPONSE_TYPE.isEqualTo('message'),
group: '1_viewInChat',
order: 1
}
});
}
override runInteractiveEditorCommand(_accessor: ServicesAccessor, ctrl: InteractiveEditorController, _editor: ICodeEditor, ..._args: any[]): void {
override runInlineChatCommand(_accessor: ServicesAccessor, ctrl: InlineChatController, _editor: ICodeEditor, ..._args: any[]): void {
ctrl.viewInChat();
}
}
export class ExpandMessageAction extends AbstractInteractiveEditorAction {
export class ExpandMessageAction extends AbstractInlineChatAction {
constructor() {
super({
id: 'interactiveEditor.expandMessageAction',
title: localize('expandMessage', 'Expand Message'),
icon: Codicon.chevronDown,
precondition: CTX_INTERACTIVE_EDITOR_VISIBLE,
precondition: CTX_INLINE_CHAT_VISIBLE,
menu: {
id: MENU_INTERACTIVE_EDITOR_WIDGET_MARKDOWN_MESSAGE,
when: ContextKeyExpr.and(CTX_INTERACTIVE_EDITOR_LAST_RESPONSE_TYPE.isEqualTo('message'), CTX_INTERACTIVE_EDITOR_MESSAGE_CROP_STATE.isEqualTo('cropped')),
id: MENU_INLINE_CHAT_WIDGET_MARKDOWN_MESSAGE,
when: ContextKeyExpr.and(CTX_INLINE_CHAT_LAST_RESPONSE_TYPE.isEqualTo('message'), CTX_INLINE_CHAT_MESSAGE_CROP_STATE.isEqualTo('cropped')),
group: '2_expandOrContract',
order: 1
}
});
}
override runInteractiveEditorCommand(_accessor: ServicesAccessor, ctrl: InteractiveEditorController, _editor: ICodeEditor, ..._args: any[]): void {
override runInlineChatCommand(_accessor: ServicesAccessor, ctrl: InlineChatController, _editor: ICodeEditor, ..._args: any[]): void {
ctrl.updateExpansionState(true);
}
}
export class ContractMessageAction extends AbstractInteractiveEditorAction {
export class ContractMessageAction extends AbstractInlineChatAction {
constructor() {
super({
id: 'interactiveEditor.contractMessageAction',
title: localize('contractMessage', 'Contract Message'),
icon: Codicon.chevronUp,
precondition: CTX_INTERACTIVE_EDITOR_VISIBLE,
precondition: CTX_INLINE_CHAT_VISIBLE,
menu: {
id: MENU_INTERACTIVE_EDITOR_WIDGET_MARKDOWN_MESSAGE,
when: ContextKeyExpr.and(CTX_INTERACTIVE_EDITOR_LAST_RESPONSE_TYPE.isEqualTo('message'), CTX_INTERACTIVE_EDITOR_MESSAGE_CROP_STATE.isEqualTo('expanded')),
id: MENU_INLINE_CHAT_WIDGET_MARKDOWN_MESSAGE,
when: ContextKeyExpr.and(CTX_INLINE_CHAT_LAST_RESPONSE_TYPE.isEqualTo('message'), CTX_INLINE_CHAT_MESSAGE_CROP_STATE.isEqualTo('expanded')),
group: '2_expandOrContract',
order: 1
}
});
}
override runInteractiveEditorCommand(_accessor: ServicesAccessor, ctrl: InteractiveEditorController, _editor: ICodeEditor, ..._args: any[]): void {
override runInlineChatCommand(_accessor: ServicesAccessor, ctrl: InlineChatController, _editor: ICodeEditor, ..._args: any[]): void {
ctrl.updateExpansionState(false);
}
}
@ -594,9 +594,9 @@ export class AccessibilityHelpEditorAction extends EditorAction2 {
super({
id: 'interactiveEditor.accessibilityHelp',
title: localize('actions.interactiveSession.accessibiltyHelpEditor', "Interactive Session Editor Accessibility Help"),
category: AbstractInteractiveEditorAction.category,
category: AbstractInlineChatAction.category,
keybinding: {
when: CTX_INTERACTIVE_EDITOR_FOCUSED,
when: CTX_INLINE_CHAT_FOCUSED,
primary: KeyMod.Alt | KeyCode.F1,
weight: KeybindingWeight.EditorContrib
}

View File

@ -28,10 +28,10 @@ import { IContextKey, IContextKeyService } from 'vs/platform/contextkey/common/c
import { IDialogService } from 'vs/platform/dialogs/common/dialogs';
import { IInstantiationService, ServicesAccessor } from 'vs/platform/instantiation/common/instantiation';
import { ILogService } from 'vs/platform/log/common/log';
import { EditResponse, EmptyResponse, ErrorResponse, ExpansionState, IInteractiveEditorSessionService, MarkdownResponse, Session, SessionExchange } from 'vs/workbench/contrib/inlineChat/browser/inlineChatSession';
import { EditResponse, EmptyResponse, ErrorResponse, ExpansionState, IInlineChatSessionService, MarkdownResponse, Session, SessionExchange } from 'vs/workbench/contrib/inlineChat/browser/inlineChatSession';
import { EditModeStrategy, LivePreviewStrategy, LiveStrategy, PreviewStrategy } from 'vs/workbench/contrib/inlineChat/browser/inlineChatStrategies';
import { InteractiveEditorZoneWidget } from 'vs/workbench/contrib/inlineChat/browser/inlineChatWidget';
import { CTX_INTERACTIVE_EDITOR_HAS_ACTIVE_REQUEST, CTX_INTERACTIVE_EDITOR_LAST_FEEDBACK, IInteractiveEditorRequest, IInteractiveEditorResponse, INTERACTIVE_EDITOR_ID, EditMode, InteractiveEditorResponseFeedbackKind, CTX_INTERACTIVE_EDITOR_LAST_RESPONSE_TYPE, InteractiveEditorResponseType, CTX_INTERACTIVE_EDITOR_DID_EDIT, CTX_INTERACTIVE_EDITOR_HAS_STASHED_SESSION } from 'vs/workbench/contrib/inlineChat/common/inlineChat';
import { InlineChatZoneWidget } from 'vs/workbench/contrib/inlineChat/browser/inlineChatWidget';
import { CTX_INLINE_CHAT_HAS_ACTIVE_REQUEST, CTX_INLINE_CHAT_LAST_FEEDBACK, IInlineChatRequest, IInlineChatResponse, INLINE_CHAT_ID, EditMode, InlineChatResponseFeedbackKind, CTX_INLINE_CHAT_LAST_RESPONSE_TYPE, InlineChatResponseType, CTX_INLINE_CHAT_DID_EDIT, CTX_INLINE_CHAT_HAS_STASHED_SESSION } from 'vs/workbench/contrib/inlineChat/common/inlineChat';
import { IChatWidgetService } from 'vs/workbench/contrib/chat/browser/chat';
import { IChatService } from 'vs/workbench/contrib/chat/common/chatService';
import { INotebookEditorService } from 'vs/workbench/contrib/notebook/browser/services/notebookEditorService';
@ -61,7 +61,7 @@ const enum Message {
ACCEPT_INPUT = 1 << 5
}
export interface InteractiveEditorRunOptions {
export interface InlineChatRunOptions {
initialRange?: IRange;
message?: string;
autoSend?: boolean;
@ -69,10 +69,10 @@ export interface InteractiveEditorRunOptions {
isUnstashed?: boolean;
}
export class InteractiveEditorController implements IEditorContribution {
export class InlineChatController implements IEditorContribution {
static get(editor: ICodeEditor) {
return editor.getContribution<InteractiveEditorController>(INTERACTIVE_EDITOR_ID);
return editor.getContribution<InlineChatController>(INLINE_CHAT_ID);
}
private static _decoBlock = ModelDecorationOptions.register({
@ -86,9 +86,9 @@ export class InteractiveEditorController implements IEditorContribution {
private _historyOffset: number = -1;
private readonly _store = new DisposableStore();
private readonly _zone: Lazy<InteractiveEditorZoneWidget>;
private readonly _zone: Lazy<InlineChatZoneWidget>;
private readonly _ctxHasActiveRequest: IContextKey<boolean>;
private readonly _ctxLastResponseType: IContextKey<undefined | InteractiveEditorResponseType>;
private readonly _ctxLastResponseType: IContextKey<undefined | InlineChatResponseType>;
private readonly _ctxDidEdit: IContextKey<boolean>;
private readonly _ctxLastFeedbackKind: IContextKey<'helpful' | 'unhelpful' | ''>;
@ -103,7 +103,7 @@ export class InteractiveEditorController implements IEditorContribution {
constructor(
private readonly _editor: ICodeEditor,
@IInstantiationService private readonly _instaService: IInstantiationService,
@IInteractiveEditorSessionService private readonly _interactiveEditorSessionService: IInteractiveEditorSessionService,
@IInlineChatSessionService private readonly _inlineChatSessionService: IInlineChatSessionService,
@IEditorWorkerService private readonly _editorWorkerService: IEditorWorkerService,
@ILogService private readonly _logService: ILogService,
@IConfigurationService private readonly _configurationService: IConfigurationService,
@ -114,18 +114,18 @@ export class InteractiveEditorController implements IEditorContribution {
@IAccessibilityService private readonly _accessibilityService: IAccessibilityService,
@IKeybindingService private readonly _keybindingService: IKeybindingService,
) {
this._ctxHasActiveRequest = CTX_INTERACTIVE_EDITOR_HAS_ACTIVE_REQUEST.bindTo(contextKeyService);
this._ctxDidEdit = CTX_INTERACTIVE_EDITOR_DID_EDIT.bindTo(contextKeyService);
this._ctxLastResponseType = CTX_INTERACTIVE_EDITOR_LAST_RESPONSE_TYPE.bindTo(contextKeyService);
this._ctxLastFeedbackKind = CTX_INTERACTIVE_EDITOR_LAST_FEEDBACK.bindTo(contextKeyService);
this._zone = new Lazy(() => this._store.add(_instaService.createInstance(InteractiveEditorZoneWidget, this._editor)));
this._ctxHasActiveRequest = CTX_INLINE_CHAT_HAS_ACTIVE_REQUEST.bindTo(contextKeyService);
this._ctxDidEdit = CTX_INLINE_CHAT_DID_EDIT.bindTo(contextKeyService);
this._ctxLastResponseType = CTX_INLINE_CHAT_LAST_RESPONSE_TYPE.bindTo(contextKeyService);
this._ctxLastFeedbackKind = CTX_INLINE_CHAT_LAST_FEEDBACK.bindTo(contextKeyService);
this._zone = new Lazy(() => this._store.add(_instaService.createInstance(InlineChatZoneWidget, this._editor)));
this._store.add(this._editor.onDidChangeModel(async e => {
if (this._activeSession || !e.newModelUrl) {
return;
}
const existingSession = this._interactiveEditorSessionService.getSession(this._editor, e.newModelUrl);
const existingSession = this._inlineChatSessionService.getSession(this._editor, e.newModelUrl);
if (!existingSession) {
return;
}
@ -153,7 +153,7 @@ export class InteractiveEditorController implements IEditorContribution {
}
getId(): string {
return INTERACTIVE_EDITOR_ID;
return INLINE_CHAT_ID;
}
private _getMode(): EditMode {
@ -170,7 +170,7 @@ export class InteractiveEditorController implements IEditorContribution {
return this._zone.value.position;
}
async run(options: InteractiveEditorRunOptions | undefined): Promise<void> {
async run(options: InlineChatRunOptions | undefined): Promise<void> {
this._log('session starting');
await this._finishExistingSession();
this._stashedSession.clear();
@ -193,7 +193,7 @@ export class InteractiveEditorController implements IEditorContribution {
// ---- state machine
protected async _nextState(state: State, options: InteractiveEditorRunOptions | undefined): Promise<void> {
protected async _nextState(state: State, options: InlineChatRunOptions | undefined): Promise<void> {
this._log('setState to ', state);
const nextState = await this[state](options);
if (nextState) {
@ -201,7 +201,7 @@ export class InteractiveEditorController implements IEditorContribution {
}
}
private async [State.CREATE_SESSION](options: InteractiveEditorRunOptions | undefined): Promise<State.CANCEL | State.INIT_UI> {
private async [State.CREATE_SESSION](options: InlineChatRunOptions | undefined): Promise<State.CANCEL | State.INIT_UI> {
assertType(this._activeSession === undefined);
assertType(this._editor.hasModel());
@ -214,7 +214,7 @@ export class InteractiveEditorController implements IEditorContribution {
createSessionCts.cancel();
});
session = await this._interactiveEditorSessionService.createSession(
session = await this._inlineChatSessionService.createSession(
this._editor,
{ editMode: this._getMode(), wholeRange: options?.initialRange },
createSessionCts.token
@ -249,7 +249,7 @@ export class InteractiveEditorController implements IEditorContribution {
return State.INIT_UI;
}
private async [State.INIT_UI](options: InteractiveEditorRunOptions | undefined): Promise<State.WAIT_FOR_INPUT | State.SHOW_RESPONSE | State.APPLY_RESPONSE> {
private async [State.INIT_UI](options: InlineChatRunOptions | undefined): Promise<State.WAIT_FOR_INPUT | State.SHOW_RESPONSE | State.APPLY_RESPONSE> {
assertType(this._activeSession);
// hide/cancel inline completions when invoking IE
@ -261,7 +261,7 @@ export class InteractiveEditorController implements IEditorContribution {
const wholeRangeDecoration = this._editor.createDecorationsCollection([{
range: this._activeSession.wholeRange.value,
options: InteractiveEditorController._decoBlock
options: InlineChatController._decoBlock
}]);
this._sessionStore.add(toDisposable(() => wholeRangeDecoration.clear()));
@ -314,7 +314,7 @@ export class InteractiveEditorController implements IEditorContribution {
return '';
}
let result = this._activeSession.session.placeholder ?? localize('default.placeholder', "Ask a question");
if (InteractiveEditorController._promptHistory.length > 0) {
if (InlineChatController._promptHistory.length > 0) {
const kb1 = this._keybindingService.lookupKeybinding('interactiveEditor.previousFromHistory')?.getLabel();
const kb2 = this._keybindingService.lookupKeybinding('interactiveEditor.nextFromHistory')?.getLabel();
@ -346,7 +346,7 @@ export class InteractiveEditorController implements IEditorContribution {
// cancel all sibling sessions
for (const editor of editors) {
if (editor !== this._editor) {
InteractiveEditorController.get(editor)?._finishExistingSession();
InlineChatController.get(editor)?._finishExistingSession();
}
}
break;
@ -355,7 +355,7 @@ export class InteractiveEditorController implements IEditorContribution {
}
}
private async [State.WAIT_FOR_INPUT](options: InteractiveEditorRunOptions | undefined): Promise<State.ACCEPT | State.CANCEL | State.PAUSE | State.WAIT_FOR_INPUT | State.MAKE_REQUEST> {
private async [State.WAIT_FOR_INPUT](options: InlineChatRunOptions | undefined): Promise<State.ACCEPT | State.CANCEL | State.PAUSE | State.WAIT_FOR_INPUT | State.MAKE_REQUEST> {
assertType(this._activeSession);
this._zone.value.widget.placeholder = this._getPlaceholderText();
@ -403,8 +403,8 @@ export class InteractiveEditorController implements IEditorContribution {
const input = this._zone.value.widget.value;
if (!InteractiveEditorController._promptHistory.includes(input)) {
InteractiveEditorController._promptHistory.unshift(input);
if (!InlineChatController._promptHistory.includes(input)) {
InlineChatController._promptHistory.unshift(input);
}
const refer = this._activeSession.session.slashCommands?.some(value => value.refer && input!.startsWith(`/${value.command}`));
@ -443,7 +443,7 @@ export class InteractiveEditorController implements IEditorContribution {
});
const sw = StopWatch.create();
const request: IInteractiveEditorRequest = {
const request: IInlineChatRequest = {
prompt: this._activeSession.lastInput,
selection: this._editor.getSelection(),
wholeRange: this._activeSession.wholeRange.value,
@ -453,7 +453,7 @@ export class InteractiveEditorController implements IEditorContribution {
this._log('request started', this._activeSession.provider.debugName, this._activeSession.session, request);
let response: EditResponse | MarkdownResponse | ErrorResponse | EmptyResponse;
let reply: IInteractiveEditorResponse | null | undefined;
let reply: IInlineChatResponse | null | undefined;
try {
this._zone.value.widget.updateProgress(true);
this._zone.value.widget.updateInfo(!this._activeSession.lastExchange ? localize('thinking', "Thinking\u2026") : '');
@ -610,7 +610,7 @@ export class InteractiveEditorController implements IEditorContribution {
this._log(err);
}
this._interactiveEditorSessionService.releaseSession(this._activeSession);
this._inlineChatSessionService.releaseSession(this._activeSession);
this[State.PAUSE]();
}
@ -636,7 +636,7 @@ export class InteractiveEditorController implements IEditorContribution {
// only stash sessions that had edits
this._stashedSession.value = this._instaService.createInstance(StashedSession, this._editor, mySession);
} else {
this._interactiveEditorSessionService.releaseSession(mySession);
this._inlineChatSessionService.releaseSession(mySession);
}
}
@ -669,12 +669,12 @@ export class InteractiveEditorController implements IEditorContribution {
}
populateHistory(up: boolean) {
const len = InteractiveEditorController._promptHistory.length;
const len = InlineChatController._promptHistory.length;
if (len === 0) {
return;
}
const pos = (len + this._historyOffset + (up ? 1 : -1)) % len;
const entry = InteractiveEditorController._promptHistory[pos];
const entry = InlineChatController._promptHistory[pos];
this._zone.value.widget.value = entry;
this._zone.value.widget.selectAll();
@ -697,8 +697,8 @@ export class InteractiveEditorController implements IEditorContribution {
feedbackLast(helpful: boolean) {
if (this._activeSession?.lastExchange?.response instanceof EditResponse || this._activeSession?.lastExchange?.response instanceof MarkdownResponse) {
const kind = helpful ? InteractiveEditorResponseFeedbackKind.Helpful : InteractiveEditorResponseFeedbackKind.Unhelpful;
this._activeSession.provider.handleInteractiveEditorResponseFeedback?.(this._activeSession.session, this._activeSession.lastExchange.response.raw, kind);
const kind = helpful ? InlineChatResponseFeedbackKind.Helpful : InlineChatResponseFeedbackKind.Unhelpful;
this._activeSession.provider.handleInlineChatResponseFeedback?.(this._activeSession.session, this._activeSession.lastExchange.response.raw, kind);
this._ctxLastFeedbackKind.set(helpful ? 'helpful' : 'unhelpful');
this._zone.value.widget.updateStatus('Thank you for your feedback!', { resetAfter: 1250 });
}
@ -741,10 +741,10 @@ class StashedSession {
editor: ICodeEditor,
session: Session,
@IContextKeyService contextKeyService: IContextKeyService,
@IInteractiveEditorSessionService private readonly _sessionService: IInteractiveEditorSessionService,
@IInlineChatSessionService private readonly _sessionService: IInlineChatSessionService,
@ILogService private readonly _logService: ILogService,
) {
this._ctxHasStashedSession = CTX_INTERACTIVE_EDITOR_HAS_STASHED_SESSION.bindTo(contextKeyService);
this._ctxHasStashedSession = CTX_INLINE_CHAT_HAS_STASHED_SESSION.bindTo(contextKeyService);
// keep session for a little bit, only release when user continues to work (type, move cursor, etc.)
this._session = session;

View File

@ -16,7 +16,7 @@ import { IInstantiationService } from 'vs/platform/instantiation/common/instanti
import * as colorRegistry from 'vs/platform/theme/common/colorRegistry';
import * as editorColorRegistry from 'vs/editor/common/core/editorColorRegistry';
import { IThemeService } from 'vs/platform/theme/common/themeService';
import { INTERACTIVE_EDITOR_ID, interactiveEditorDiffInserted, interactiveEditorDiffRemoved, interactiveEditorRegionHighlight } from 'vs/workbench/contrib/inlineChat/common/inlineChat';
import { INLINE_CHAT_ID, inlineChatDiffInserted, inlineChatDiffRemoved, inlineChatRegionHighlight } from 'vs/workbench/contrib/inlineChat/common/inlineChat';
import { LineRange } from 'vs/editor/common/core/lineRange';
import { LineRangeMapping } from 'vs/editor/common/diff/linesDiffComputer';
import { Position } from 'vs/editor/common/core/position';
@ -32,7 +32,7 @@ import { IModelService } from 'vs/editor/common/services/model';
import { EditOperation } from 'vs/editor/common/core/editOperation';
import { Session } from 'vs/workbench/contrib/inlineChat/browser/inlineChatSession';
export class InteractiveEditorLivePreviewWidget extends ZoneWidget {
export class InlineChatLivePreviewWidget extends ZoneWidget {
private static readonly _hideId = 'overlayDiff';
@ -59,7 +59,7 @@ export class InteractiveEditorLivePreviewWidget extends ZoneWidget {
const diffContributions = EditorExtensionsRegistry
.getEditorContributions()
.filter(c => c.id !== INTERACTIVE_EDITOR_ID);
.filter(c => c.id !== INLINE_CHAT_ID);
this._diffEditor = instantiationService.createInstance(EmbeddedDiffEditorWidget, this._elements.domNode, {
scrollbar: { useShadows: false, alwaysConsumeMouseWheel: false },
@ -88,12 +88,12 @@ export class InteractiveEditorLivePreviewWidget extends ZoneWidget {
const doStyle = () => {
const theme = themeService.getColorTheme();
const overrides: [target: string, source: string][] = [
[colorRegistry.editorBackground, interactiveEditorRegionHighlight],
[editorColorRegistry.editorGutter, interactiveEditorRegionHighlight],
[colorRegistry.diffInsertedLine, interactiveEditorDiffInserted],
[colorRegistry.diffInserted, interactiveEditorDiffInserted],
[colorRegistry.diffRemovedLine, interactiveEditorDiffRemoved],
[colorRegistry.diffRemoved, interactiveEditorDiffRemoved],
[colorRegistry.editorBackground, inlineChatRegionHighlight],
[editorColorRegistry.editorGutter, inlineChatRegionHighlight],
[colorRegistry.diffInsertedLine, inlineChatDiffInserted],
[colorRegistry.diffInserted, inlineChatDiffInserted],
[colorRegistry.diffRemovedLine, inlineChatDiffRemoved],
[colorRegistry.diffRemoved, inlineChatDiffRemoved],
];
for (const [target, source] of overrides) {
@ -244,9 +244,9 @@ export class InteractiveEditorLivePreviewWidget extends ZoneWidget {
}
private _cleanupFullDiff() {
this.editor.setHiddenAreas([], InteractiveEditorLivePreviewWidget._hideId);
this._diffEditor.getOriginalEditor().setHiddenAreas([], InteractiveEditorLivePreviewWidget._hideId);
this._diffEditor.getModifiedEditor().setHiddenAreas([], InteractiveEditorLivePreviewWidget._hideId);
this.editor.setHiddenAreas([], InlineChatLivePreviewWidget._hideId);
this._diffEditor.getOriginalEditor().setHiddenAreas([], InlineChatLivePreviewWidget._hideId);
this._diffEditor.getModifiedEditor().setHiddenAreas([], InlineChatLivePreviewWidget._hideId);
super.hide();
}
@ -292,7 +292,7 @@ export class InteractiveEditorLivePreviewWidget extends ZoneWidget {
return;
}
const ranges = lineRanges.map(lineRangeAsRange);
editor.setHiddenAreas(ranges, InteractiveEditorLivePreviewWidget._hideId);
editor.setHiddenAreas(ranges, InlineChatLivePreviewWidget._hideId);
this._logService.debug(`[IE] diff HIDING ${ranges} for ${editor.getId()} with ${String(editor.getModel()?.uri)}`);
}
@ -334,7 +334,7 @@ function isInlineDiffFriendly(mapping: LineRangeMapping): boolean {
}
export class InteractiveEditorFileCreatePreviewWidget extends ZoneWidget {
export class InlineChatFileCreatePreviewWidget extends ZoneWidget {
private readonly _elements = h('div.interactive-editor-newfile-widget@domNode', [
h('div.title.show-file-icons@title'),
@ -368,8 +368,8 @@ export class InteractiveEditorFileCreatePreviewWidget extends ZoneWidget {
const doStyle = () => {
const theme = themeService.getColorTheme();
const overrides: [target: string, source: string][] = [
[colorRegistry.editorBackground, interactiveEditorRegionHighlight],
[editorColorRegistry.editorGutter, interactiveEditorRegionHighlight],
[colorRegistry.editorBackground, inlineChatRegionHighlight],
[editorColorRegistry.editorGutter, inlineChatRegionHighlight],
];
for (const [target, source] of overrides) {

View File

@ -6,14 +6,14 @@
import { illegalState } from 'vs/base/common/errors';
import { Schemas } from 'vs/base/common/network';
import { isEqual } from 'vs/base/common/resources';
import { IInteractiveEditorSessionService } from 'vs/workbench/contrib/inlineChat/browser/inlineChatSession';
import { IInlineChatSessionService } from 'vs/workbench/contrib/inlineChat/browser/inlineChatSession';
import { INotebookEditorService } from 'vs/workbench/contrib/notebook/browser/services/notebookEditorService';
import { CellUri } from 'vs/workbench/contrib/notebook/common/notebookCommon';
export class InteractiveEditorNotebookContribution {
export class InlineChatNotebookContribution {
constructor(
@IInteractiveEditorSessionService sessionService: IInteractiveEditorSessionService,
@IInlineChatSessionService sessionService: IInlineChatSessionService,
@INotebookEditorService notebookEditorService: INotebookEditorService,
) {

View File

@ -9,7 +9,7 @@ import { Event } from 'vs/base/common/event';
import { ResourceEdit, ResourceFileEdit, ResourceTextEdit } from 'vs/editor/browser/services/bulkEditService';
import { TextEdit } from 'vs/editor/common/languages';
import { IModelDeltaDecoration, ITextModel } from 'vs/editor/common/model';
import { EditMode, IInteractiveEditorSessionProvider, IInteractiveEditorSession, IInteractiveEditorBulkEditResponse, IInteractiveEditorEditResponse, IInteractiveEditorMessageResponse, IInteractiveEditorResponse, IInteractiveEditorService } from 'vs/workbench/contrib/inlineChat/common/inlineChat';
import { EditMode, IInlineChatSessionProvider, IInlineChatSession, IInlineChatBulkEditResponse, IInlineChatEditResponse, IInlineChatMessageResponse, IInlineChatResponse, IInlineChatService } from 'vs/workbench/contrib/inlineChat/common/inlineChat';
import { IRange, Range } from 'vs/editor/common/core/range';
import { IActiveCodeEditor, ICodeEditor } from 'vs/editor/browser/editorBrowser';
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
@ -28,8 +28,8 @@ import { ISingleEditOperation } from 'vs/editor/common/core/editOperation';
export type Recording = {
when: Date;
session: IInteractiveEditorSession;
exchanges: { prompt: string; res: IInteractiveEditorResponse }[];
session: IInlineChatSession;
exchanges: { prompt: string; res: IInlineChatResponse }[];
};
type TelemetryData = {
@ -124,8 +124,8 @@ export class Session {
readonly editor: ICodeEditor,
readonly textModel0: ITextModel,
readonly textModelN: ITextModel,
readonly provider: IInteractiveEditorSessionProvider,
readonly session: IInteractiveEditorSession,
readonly provider: IInlineChatSessionProvider,
readonly session: IInlineChatSession,
readonly wholeRange: SessionWholeRange
) {
this.textModelNAltVersion = textModelN.getAlternativeVersionId();
@ -264,7 +264,7 @@ export class ErrorResponse {
export class MarkdownResponse {
constructor(
readonly localUri: URI,
readonly raw: IInteractiveEditorMessageResponse
readonly raw: IInlineChatMessageResponse
) { }
}
@ -275,7 +275,7 @@ export class EditResponse {
readonly workspaceEdits: ResourceEdit[] | undefined;
readonly workspaceEditsIncludeLocalEdits: boolean = false;
constructor(localUri: URI, readonly raw: IInteractiveEditorBulkEditResponse | IInteractiveEditorEditResponse) {
constructor(localUri: URI, readonly raw: IInlineChatBulkEditResponse | IInlineChatEditResponse) {
if (raw.type === 'editorEdit') {
//
this.localEdits = raw.edits;
@ -328,9 +328,9 @@ export interface ISessionKeyComputer {
getComparisonKey(editor: ICodeEditor, uri: URI): string;
}
export const IInteractiveEditorSessionService = createDecorator<IInteractiveEditorSessionService>('IInteractiveEditorSessionService');
export const IInlineChatSessionService = createDecorator<IInlineChatSessionService>('IInlineChatSessionService');
export interface IInteractiveEditorSessionService {
export interface IInlineChatSessionService {
_serviceBrand: undefined;
createSession(editor: IActiveCodeEditor, options: { editMode: EditMode; wholeRange?: IRange }, token: CancellationToken): Promise<Session | undefined>;
@ -351,7 +351,7 @@ type SessionData = {
store: IDisposable;
};
export class InteractiveEditorSessionService implements IInteractiveEditorSessionService {
export class InlineChatSessionService implements IInlineChatSessionService {
declare _serviceBrand: undefined;
@ -360,7 +360,7 @@ export class InteractiveEditorSessionService implements IInteractiveEditorSessio
private _recordings: Recording[] = [];
constructor(
@IInteractiveEditorService private readonly _interactiveEditorService: IInteractiveEditorService,
@IInlineChatService private readonly _inlineChatService: IInlineChatService,
@ITelemetryService private readonly _telemetryService: ITelemetryService,
@IModelService private readonly _modelService: IModelService,
@ITextModelService private readonly _textModelService: ITextModelService,
@ -370,7 +370,7 @@ export class InteractiveEditorSessionService implements IInteractiveEditorSessio
async createSession(editor: IActiveCodeEditor, options: { editMode: EditMode; wholeRange?: Range }, token: CancellationToken): Promise<Session | undefined> {
const provider = Iterable.first(this._interactiveEditorService.getAllProvider());
const provider = Iterable.first(this._inlineChatService.getAllProvider());
if (!provider) {
this._logService.trace('[IE] NO provider found');
return undefined;
@ -378,9 +378,9 @@ export class InteractiveEditorSessionService implements IInteractiveEditorSessio
const textModel = editor.getModel();
const selection = editor.getSelection();
let raw: IInteractiveEditorSession | undefined | null;
let raw: IInlineChatSession | undefined | null;
try {
raw = await provider.prepareInteractiveEditorSession(textModel, selection, token);
raw = await provider.prepareInlineChatSession(textModel, selection, token);
} catch (error) {
this._logService.error('[IE] FAILED to prepare session', provider.debugName);
this._logService.error(error);

View File

@ -19,10 +19,10 @@ import { localize } from 'vs/nls';
import { IContextKey, IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
import { IInstantiationService, ServicesAccessor } from 'vs/platform/instantiation/common/instantiation';
import { IStorageService, StorageScope, StorageTarget } from 'vs/platform/storage/common/storage';
import { InteractiveEditorFileCreatePreviewWidget, InteractiveEditorLivePreviewWidget } from 'vs/workbench/contrib/inlineChat/browser/inlineChatLivePreviewWidget';
import { InlineChatFileCreatePreviewWidget, InlineChatLivePreviewWidget } from 'vs/workbench/contrib/inlineChat/browser/inlineChatLivePreviewWidget';
import { EditResponse, Session } from 'vs/workbench/contrib/inlineChat/browser/inlineChatSession';
import { InteractiveEditorWidget } from 'vs/workbench/contrib/inlineChat/browser/inlineChatWidget';
import { CTX_INTERACTIVE_EDITOR_SHOWING_DIFF, CTX_INTERACTIVE_EDITOR_DOCUMENT_CHANGED } from 'vs/workbench/contrib/inlineChat/common/inlineChat';
import { InlineChatWidget } from 'vs/workbench/contrib/inlineChat/browser/inlineChatWidget';
import { CTX_INLINE_CHAT_SHOWING_DIFF, CTX_INLINE_CHAT_DOCUMENT_CHANGED } from 'vs/workbench/contrib/inlineChat/common/inlineChat';
import { IEditorService, SIDE_GROUP } from 'vs/workbench/services/editor/common/editorService';
export abstract class EditModeStrategy {
@ -49,14 +49,14 @@ export class PreviewStrategy extends EditModeStrategy {
constructor(
private readonly _session: Session,
private readonly _widget: InteractiveEditorWidget,
private readonly _widget: InlineChatWidget,
@IContextKeyService contextKeyService: IContextKeyService,
@IBulkEditService private readonly _bulkEditService: IBulkEditService,
@IInstantiationService private readonly _instaService: IInstantiationService,
) {
super();
this._ctxDocumentChanged = CTX_INTERACTIVE_EDITOR_DOCUMENT_CHANGED.bindTo(contextKeyService);
this._ctxDocumentChanged = CTX_INLINE_CHAT_DOCUMENT_CHANGED.bindTo(contextKeyService);
this._listener = Event.debounce(_session.textModelN.onDidChangeContent.bind(_session.textModelN), () => { }, 350)(_ => {
this._ctxDocumentChanged.set(!_session.textModelN.equalsTextBuffer(_session.textModel0.getTextBuffer()));
});
@ -208,7 +208,7 @@ export class LiveStrategy extends EditModeStrategy {
constructor(
protected readonly _session: Session,
protected readonly _editor: ICodeEditor,
protected readonly _widget: InteractiveEditorWidget,
protected readonly _widget: InlineChatWidget,
@IContextKeyService contextKeyService: IContextKeyService,
@IStorageService protected _storageService: IStorageService,
@IBulkEditService protected readonly _bulkEditService: IBulkEditService,
@ -219,7 +219,7 @@ export class LiveStrategy extends EditModeStrategy {
this._diffEnabled = _storageService.getBoolean(LiveStrategy._inlineDiffStorageKey, StorageScope.PROFILE, true);
this._inlineDiffDecorations = new InlineDiffDecorations(this._editor, this._diffEnabled);
this._ctxShowingDiff = CTX_INTERACTIVE_EDITOR_SHOWING_DIFF.bindTo(contextKeyService);
this._ctxShowingDiff = CTX_INLINE_CHAT_SHOWING_DIFF.bindTo(contextKeyService);
this._ctxShowingDiff.set(this._diffEnabled);
this._inlineDiffDecorations.visible = this._diffEnabled;
}
@ -322,13 +322,13 @@ export class LiveStrategy extends EditModeStrategy {
export class LivePreviewStrategy extends LiveStrategy {
private readonly _diffZone: InteractiveEditorLivePreviewWidget;
private readonly _previewZone: InteractiveEditorFileCreatePreviewWidget;
private readonly _diffZone: InlineChatLivePreviewWidget;
private readonly _previewZone: InlineChatFileCreatePreviewWidget;
constructor(
session: Session,
editor: ICodeEditor,
widget: InteractiveEditorWidget,
widget: InlineChatWidget,
@IContextKeyService contextKeyService: IContextKeyService,
@IStorageService storageService: IStorageService,
@IBulkEditService bulkEditService: IBulkEditService,
@ -337,8 +337,8 @@ export class LivePreviewStrategy extends LiveStrategy {
) {
super(session, editor, widget, contextKeyService, storageService, bulkEditService, editorWorkerService, instaService);
this._diffZone = instaService.createInstance(InteractiveEditorLivePreviewWidget, editor, session);
this._previewZone = instaService.createInstance(InteractiveEditorFileCreatePreviewWidget, editor);
this._diffZone = instaService.createInstance(InlineChatLivePreviewWidget, editor, session);
this._previewZone = instaService.createInstance(InlineChatFileCreatePreviewWidget, editor);
}
override dispose(): void {

View File

@ -12,7 +12,7 @@ import { localize } from 'vs/nls';
import { IContextKey, IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { ZoneWidget } from 'vs/editor/contrib/zoneWidget/browser/zoneWidget';
import { CTX_INTERACTIVE_EDITOR_FOCUSED, CTX_INTERACTIVE_EDITOR_INNER_CURSOR_FIRST, CTX_INTERACTIVE_EDITOR_INNER_CURSOR_LAST, CTX_INTERACTIVE_EDITOR_EMPTY, CTX_INTERACTIVE_EDITOR_OUTER_CURSOR_POSITION, CTX_INTERACTIVE_EDITOR_VISIBLE, MENU_INTERACTIVE_EDITOR_WIDGET, MENU_INTERACTIVE_EDITOR_WIDGET_STATUS, MENU_INTERACTIVE_EDITOR_WIDGET_MARKDOWN_MESSAGE, CTX_INTERACTIVE_EDITOR_MESSAGE_CROP_STATE, IInteractiveEditorSlashCommand, MENU_INTERACTIVE_EDITOR_WIDGET_FEEDBACK, ACTION_ACCEPT_CHANGES } from 'vs/workbench/contrib/inlineChat/common/inlineChat';
import { CTX_INLINE_CHAT_FOCUSED, CTX_INLINE_CHAT_INNER_CURSOR_FIRST, CTX_INLINE_CHAT_INNER_CURSOR_LAST, CTX_INLINE_CHAT_EMPTY, CTX_INLINE_CHAT_OUTER_CURSOR_POSITION, CTX_INLINE_CHAT_VISIBLE, MENU_INLINE_CHAT_WIDGET, MENU_INLINE_CHAT_WIDGET_STATUS, MENU_INLINE_CHAT_WIDGET_MARKDOWN_MESSAGE, CTX_INLINE_CHAT_MESSAGE_CROP_STATE, IInlineChatSlashCommand, MENU_INLINE_CHAT_WIDGET_FEEDBACK, ACTION_ACCEPT_CHANGES } from 'vs/workbench/contrib/inlineChat/common/inlineChat';
import { IModelDeltaDecoration, ITextModel } from 'vs/editor/common/model';
import { Dimension, addDisposableListener, getTotalHeight, getTotalWidth, h, reset } from 'vs/base/browser/dom';
import { Emitter, Event, MicrotaskEmitter } from 'vs/base/common/event';
@ -114,13 +114,13 @@ const _previewEditorEditorOptions: IDiffEditorConstructionOptions = {
isInEmbeddedEditor: true
};
export interface InteractiveEditorWidgetViewState {
export interface InlineChatWidgetViewState {
editorViewState: ICodeEditorViewState;
input: string;
placeholder: string;
}
export class InteractiveEditorWidget {
export class InlineChatWidget {
private static _modelPool: number = 1;
@ -217,18 +217,18 @@ export class InteractiveEditorWidget {
}
}));
const uri = URI.from({ scheme: 'vscode', authority: 'interactive-editor', path: `/interactive-editor/model${InteractiveEditorWidget._modelPool++}.txt` });
const uri = URI.from({ scheme: 'vscode', authority: 'interactive-editor', path: `/interactive-editor/model${InlineChatWidget._modelPool++}.txt` });
this._inputModel = this._modelService.getModel(uri) ?? this._modelService.createModel('', null, uri);
this._inputEditor.setModel(this._inputModel);
// --- context keys
this._ctxMessageCropState = CTX_INTERACTIVE_EDITOR_MESSAGE_CROP_STATE.bindTo(this._contextKeyService);
this._ctxInputEmpty = CTX_INTERACTIVE_EDITOR_EMPTY.bindTo(this._contextKeyService);
this._ctxMessageCropState = CTX_INLINE_CHAT_MESSAGE_CROP_STATE.bindTo(this._contextKeyService);
this._ctxInputEmpty = CTX_INLINE_CHAT_EMPTY.bindTo(this._contextKeyService);
this._ctxInnerCursorFirst = CTX_INTERACTIVE_EDITOR_INNER_CURSOR_FIRST.bindTo(this._contextKeyService);
this._ctxInnerCursorLast = CTX_INTERACTIVE_EDITOR_INNER_CURSOR_LAST.bindTo(this._contextKeyService);
this._ctxInputEditorFocused = CTX_INTERACTIVE_EDITOR_FOCUSED.bindTo(this._contextKeyService);
this._ctxInnerCursorFirst = CTX_INLINE_CHAT_INNER_CURSOR_FIRST.bindTo(this._contextKeyService);
this._ctxInnerCursorLast = CTX_INLINE_CHAT_INNER_CURSOR_LAST.bindTo(this._contextKeyService);
this._ctxInputEditorFocused = CTX_INLINE_CHAT_FOCUSED.bindTo(this._contextKeyService);
// (1) inner cursor position (last/first line selected)
const updateInnerCursorFirstLast = () => {
@ -284,7 +284,7 @@ export class InteractiveEditorWidget {
// toolbars
const toolbar = this._instantiationService.createInstance(MenuWorkbenchToolBar, this._elements.editorToolbar, MENU_INTERACTIVE_EDITOR_WIDGET, {
const toolbar = this._instantiationService.createInstance(MenuWorkbenchToolBar, this._elements.editorToolbar, MENU_INLINE_CHAT_WIDGET, {
telemetrySource: 'interactiveEditorWidget-toolbar',
toolbarOptions: { primaryGroup: 'main' }
});
@ -333,11 +333,11 @@ export class InteractiveEditorWidget {
return createActionViewItem(this._instantiationService, action, options);
}
};
const statusToolbar = this._instantiationService.createInstance(MenuWorkbenchToolBar, this._elements.statusToolbar, MENU_INTERACTIVE_EDITOR_WIDGET_STATUS, { ...workbenchToolbarOptions, hiddenItemStrategy: HiddenItemStrategy.Ignore });
const statusToolbar = this._instantiationService.createInstance(MenuWorkbenchToolBar, this._elements.statusToolbar, MENU_INLINE_CHAT_WIDGET_STATUS, { ...workbenchToolbarOptions, hiddenItemStrategy: HiddenItemStrategy.Ignore });
this._store.add(statusToolbar.onDidChangeMenuItems(() => this._onDidChangeHeight.fire()));
this._store.add(statusToolbar);
const feedbackToolbar = this._instantiationService.createInstance(MenuWorkbenchToolBar, this._elements.feedbackToolbar, MENU_INTERACTIVE_EDITOR_WIDGET_FEEDBACK, { ...workbenchToolbarOptions, hiddenItemStrategy: HiddenItemStrategy.Ignore });
const feedbackToolbar = this._instantiationService.createInstance(MenuWorkbenchToolBar, this._elements.feedbackToolbar, MENU_INLINE_CHAT_WIDGET_FEEDBACK, { ...workbenchToolbarOptions, hiddenItemStrategy: HiddenItemStrategy.Ignore });
this._store.add(feedbackToolbar.onDidChangeMenuItems(() => this._onDidChangeHeight.fire()));
this._store.add(feedbackToolbar);
@ -349,7 +349,7 @@ export class InteractiveEditorWidget {
this._elements.message.tabIndex = 0;
this._elements.statusLabel.tabIndex = 0;
const markdownMessageToolbar = this._instantiationService.createInstance(MenuWorkbenchToolBar, this._elements.messageActions, MENU_INTERACTIVE_EDITOR_WIDGET_MARKDOWN_MESSAGE, workbenchToolbarOptions);
const markdownMessageToolbar = this._instantiationService.createInstance(MenuWorkbenchToolBar, this._elements.messageActions, MENU_INLINE_CHAT_WIDGET_MARKDOWN_MESSAGE, workbenchToolbarOptions);
this._store.add(markdownMessageToolbar.onDidChangeMenuItems(() => this._onDidChangeHeight.fire()));
this._store.add(markdownMessageToolbar);
}
@ -632,7 +632,7 @@ export class InteractiveEditorWidget {
// --- slash commands
updateSlashCommands(commands: IInteractiveEditorSlashCommand[]) {
updateSlashCommands(commands: IInlineChatSlashCommand[]) {
this._slashCommands.clear();
@ -643,7 +643,7 @@ export class InteractiveEditorWidget {
const selector: LanguageSelector = { scheme: this._inputModel.uri.scheme, pattern: this._inputModel.uri.path, language: this._inputModel.getLanguageId() };
this._slashCommands.add(this._languageFeaturesService.completionProvider.register(selector, new class implements CompletionItemProvider {
_debugDisplayName?: string = 'InteractiveEditorSlashCommandProvider';
_debugDisplayName?: string = 'InlineChatSlashCommandProvider';
readonly triggerCharacters?: string[] = ['/'];
@ -709,9 +709,9 @@ export class InteractiveEditorWidget {
}
}
export class InteractiveEditorZoneWidget extends ZoneWidget {
export class InlineChatZoneWidget extends ZoneWidget {
readonly widget: InteractiveEditorWidget;
readonly widget: InlineChatWidget;
private readonly _ctxVisible: IContextKey<boolean>;
private readonly _ctxCursorPosition: IContextKey<'above' | 'below' | ''>;
@ -724,15 +724,15 @@ export class InteractiveEditorZoneWidget extends ZoneWidget {
) {
super(editor, { showFrame: false, showArrow: false, isAccessible: true, className: 'interactive-editor-widget', keepEditorSelection: true, showInHiddenAreas: true, ordinal: 10000 + 3 });
this._ctxVisible = CTX_INTERACTIVE_EDITOR_VISIBLE.bindTo(contextKeyService);
this._ctxCursorPosition = CTX_INTERACTIVE_EDITOR_OUTER_CURSOR_POSITION.bindTo(contextKeyService);
this._ctxVisible = CTX_INLINE_CHAT_VISIBLE.bindTo(contextKeyService);
this._ctxCursorPosition = CTX_INLINE_CHAT_OUTER_CURSOR_POSITION.bindTo(contextKeyService);
this._disposables.add(toDisposable(() => {
this._ctxVisible.reset();
this._ctxCursorPosition.reset();
}));
this.widget = this._instaService.createInstance(InteractiveEditorWidget, this.editor);
this.widget = this._instaService.createInstance(InlineChatWidget, this.editor);
this._disposables.add(this.widget.onDidChangeHeight(() => this._relayout()));
this._disposables.add(this.widget);
this.create();

View File

@ -18,104 +18,104 @@ import { createDecorator } from 'vs/platform/instantiation/common/instantiation'
import { Registry } from 'vs/platform/registry/common/platform';
import { diffInserted, diffRemoved, editorHoverHighlight, editorWidgetBorder, focusBorder, inputBackground, inputPlaceholderForeground, registerColor, transparent, widgetShadow } from 'vs/platform/theme/common/colorRegistry';
export interface IInteractiveEditorSlashCommand {
export interface IInlineChatSlashCommand {
command: string;
detail?: string;
refer?: boolean;
}
export interface IInteractiveEditorSession {
export interface IInlineChatSession {
id: number;
placeholder?: string;
message?: string;
slashCommands?: IInteractiveEditorSlashCommand[];
slashCommands?: IInlineChatSlashCommand[];
wholeRange?: IRange;
dispose?(): void;
}
export interface IInteractiveEditorRequest {
export interface IInlineChatRequest {
prompt: string;
selection: ISelection;
wholeRange: IRange;
attempt: number;
}
export type IInteractiveEditorResponse = IInteractiveEditorEditResponse | IInteractiveEditorBulkEditResponse | IInteractiveEditorMessageResponse;
export type IInlineChatResponse = IInlineChatEditResponse | IInlineChatBulkEditResponse | IInlineChatMessageResponse;
export const enum InteractiveEditorResponseType {
export const enum InlineChatResponseType {
EditorEdit = 'editorEdit',
BulkEdit = 'bulkEdit',
Message = 'message'
}
export interface IInteractiveEditorEditResponse {
export interface IInlineChatEditResponse {
id: number;
type: InteractiveEditorResponseType.EditorEdit;
type: InlineChatResponseType.EditorEdit;
edits: TextEdit[];
placeholder?: string;
wholeRange?: IRange;
}
export interface IInteractiveEditorBulkEditResponse {
export interface IInlineChatBulkEditResponse {
id: number;
type: InteractiveEditorResponseType.BulkEdit;
type: InlineChatResponseType.BulkEdit;
edits: WorkspaceEdit;
placeholder?: string;
wholeRange?: IRange;
}
export interface IInteractiveEditorMessageResponse {
export interface IInlineChatMessageResponse {
id: number;
type: InteractiveEditorResponseType.Message;
type: InlineChatResponseType.Message;
message: IMarkdownString;
placeholder?: string;
wholeRange?: IRange;
}
export const enum InteractiveEditorResponseFeedbackKind {
export const enum InlineChatResponseFeedbackKind {
Unhelpful = 0,
Helpful = 1,
Undone = 2
}
export interface IInteractiveEditorSessionProvider {
export interface IInlineChatSessionProvider {
debugName: string;
prepareInteractiveEditorSession(model: ITextModel, range: ISelection, token: CancellationToken): ProviderResult<IInteractiveEditorSession>;
prepareInlineChatSession(model: ITextModel, range: ISelection, token: CancellationToken): ProviderResult<IInlineChatSession>;
provideResponse(item: IInteractiveEditorSession, request: IInteractiveEditorRequest, token: CancellationToken): ProviderResult<IInteractiveEditorResponse>;
provideResponse(item: IInlineChatSession, request: IInlineChatRequest, token: CancellationToken): ProviderResult<IInlineChatResponse>;
handleInteractiveEditorResponseFeedback?(session: IInteractiveEditorSession, response: IInteractiveEditorResponse, kind: InteractiveEditorResponseFeedbackKind): void;
handleInlineChatResponseFeedback?(session: IInlineChatSession, response: IInlineChatResponse, kind: InlineChatResponseFeedbackKind): void;
}
export const IInteractiveEditorService = createDecorator<IInteractiveEditorService>('IInteractiveEditorService');
export const IInlineChatService = createDecorator<IInlineChatService>('IInlineChatService');
export interface IInteractiveEditorService {
export interface IInlineChatService {
_serviceBrand: undefined;
addProvider(provider: IInteractiveEditorSessionProvider): IDisposable;
getAllProvider(): Iterable<IInteractiveEditorSessionProvider>;
addProvider(provider: IInlineChatSessionProvider): IDisposable;
getAllProvider(): Iterable<IInlineChatSessionProvider>;
}
export const INTERACTIVE_EDITOR_ID = 'interactiveEditor';
export const INLINE_CHAT_ID = 'interactiveEDitor';
export const CTX_INTERACTIVE_EDITOR_HAS_PROVIDER = new RawContextKey<boolean>('interactiveEditorHasProvider', false, localize('interactiveEditorHasProvider', "Whether a provider for interactive editors exists"));
export const CTX_INTERACTIVE_EDITOR_VISIBLE = new RawContextKey<boolean>('interactiveEditorVisible', false, localize('interactiveEditorVisible', "Whether the interactive editor input is visible"));
export const CTX_INTERACTIVE_EDITOR_FOCUSED = new RawContextKey<boolean>('interactiveEditorFocused', false, localize('interactiveEditorFocused', "Whether the interactive editor input is focused"));
export const CTX_INTERACTIVE_EDITOR_EMPTY = new RawContextKey<boolean>('interactiveEditorEmpty', false, localize('interactiveEditorEmpty', "Whether the interactive editor input is empty"));
export const CTX_INTERACTIVE_EDITOR_INNER_CURSOR_FIRST = new RawContextKey<boolean>('interactiveEditorInnerCursorFirst', false, localize('interactiveEditorInnerCursorFirst', "Whether the cursor of the iteractive editor input is on the first line"));
export const CTX_INTERACTIVE_EDITOR_INNER_CURSOR_LAST = new RawContextKey<boolean>('interactiveEditorInnerCursorLast', false, localize('interactiveEditorInnerCursorLast', "Whether the cursor of the iteractive editor input is on the last line"));
export const CTX_INTERACTIVE_EDITOR_MESSAGE_CROP_STATE = new RawContextKey<'cropped' | 'not_cropped' | 'expanded'>('interactiveEditorMarkdownMessageCropState', 'not_cropped', localize('interactiveEditorMarkdownMessageCropState', "Whether the interactive editor message is cropped, not cropped or expanded"));
export const CTX_INTERACTIVE_EDITOR_OUTER_CURSOR_POSITION = new RawContextKey<'above' | 'below' | ''>('interactiveEditorOuterCursorPosition', '', localize('interactiveEditorOuterCursorPosition', "Whether the cursor of the outer editor is above or below the interactive editor input"));
export const CTX_INTERACTIVE_EDITOR_HAS_ACTIVE_REQUEST = new RawContextKey<boolean>('interactiveEditorHasActiveRequest', false, localize('interactiveEditorHasActiveRequest', "Whether interactive editor has an active request"));
export const CTX_INTERACTIVE_EDITOR_HAS_STASHED_SESSION = new RawContextKey<boolean>('interactiveEditorHasStashedSession', false, localize('interactiveEditorHasStashedSession', "Whether interactive editor has kept a session for quick restore"));
export const CTX_INTERACTIVE_EDITOR_SHOWING_DIFF = new RawContextKey<boolean>('interactiveEditorDiff', false, localize('interactiveEditorDiff', "Whether interactive editor show diffs for changes"));
export const CTX_INTERACTIVE_EDITOR_LAST_RESPONSE_TYPE = new RawContextKey<InteractiveEditorResponseType | undefined>('interactiveEditorLastResponseType', undefined, localize('interactiveEditorResponseType', "What type was the last response of the current interactive editor session"));
export const CTX_INTERACTIVE_EDITOR_DID_EDIT = new RawContextKey<boolean>('interactiveEditorDidEdit', false, localize('interactiveEditorDidEdit', "Whether interactive editor did change any code"));
export const CTX_INTERACTIVE_EDITOR_LAST_FEEDBACK = new RawContextKey<'unhelpful' | 'helpful' | ''>('interactiveEditorLastFeedbackKind', '', localize('interactiveEditorLastFeedbackKind', "The last kind of feedback that was provided"));
export const CTX_INTERACTIVE_EDITOR_DOCUMENT_CHANGED = new RawContextKey<boolean>('interactiveEditorDocumentChanged', false, localize('interactiveEditorDocumentChanged', "Whether the document has changed concurrently"));
export const CTX_INTERACTIVE_EDITOR_EDIT_MODE = new RawContextKey<EditMode>('config.interactiveEditor.editMode', EditMode.Live);
export const CTX_INLINE_CHAT_HAS_PROVIDER = new RawContextKey<boolean>('inlineChatHasProvider', false, localize('inlineChatHasProvider', "Whether a provider for interactive editors exists"));
export const CTX_INLINE_CHAT_VISIBLE = new RawContextKey<boolean>('inlineChatVisible', false, localize('inlineChatVisible', "Whether the interactive editor input is visible"));
export const CTX_INLINE_CHAT_FOCUSED = new RawContextKey<boolean>('inlineChatFocused', false, localize('inlineChatFocused', "Whether the interactive editor input is focused"));
export const CTX_INLINE_CHAT_EMPTY = new RawContextKey<boolean>('inlineChatEmpty', false, localize('inlineChatEmpty', "Whether the interactive editor input is empty"));
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"));
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"));
export const CTX_INLINE_CHAT_MESSAGE_CROP_STATE = new RawContextKey<'cropped' | 'not_cropped' | 'expanded'>('inlineChatMarkdownMessageCropState', 'not_cropped', localize('inlineChatMarkdownMessageCropState', "Whether the interactive editor message is cropped, not cropped or expanded"));
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"));
export const CTX_INLINE_CHAT_HAS_ACTIVE_REQUEST = new RawContextKey<boolean>('inlineChatHasActiveRequest', false, localize('inlineChatHasActiveRequest', "Whether interactive editor has an active request"));
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"));
export const CTX_INLINE_CHAT_SHOWING_DIFF = new RawContextKey<boolean>('inlineChatDiff', false, localize('inlineChatDiff', "Whether interactive editor show diffs for changes"));
export const CTX_INLINE_CHAT_LAST_RESPONSE_TYPE = new RawContextKey<InlineChatResponseType | undefined>('inlineChatLastResponseType', undefined, localize('inlineChatResponseType', "What type was the last response of the current interactive editor session"));
export const CTX_INLINE_CHAT_DID_EDIT = new RawContextKey<boolean>('inlineChatDidEdit', false, localize('inlineChatDidEdit', "Whether interactive editor did change any code"));
export const CTX_INLINE_CHAT_LAST_FEEDBACK = new RawContextKey<'unhelpful' | 'helpful' | ''>('inlineChatLastFeedbackKind', '', localize('inlineChatLastFeedbackKind', "The last kind of feedback that was provided"));
export const CTX_INLINE_CHAT_DOCUMENT_CHANGED = new RawContextKey<boolean>('inlineChatDocumentChanged', false, localize('inlineChatDocumentChanged', "Whether the document has changed concurrently"));
export const CTX_INLINE_CHAT_EDIT_MODE = new RawContextKey<EditMode>('config.inlineChat.editMode', EditMode.Live);
// --- (select) action identifier
@ -123,24 +123,24 @@ export const ACTION_ACCEPT_CHANGES = 'interactive.acceptChanges';
// --- menus
export const MENU_INTERACTIVE_EDITOR_WIDGET = MenuId.for('interactiveEditorWidget');
export const MENU_INTERACTIVE_EDITOR_WIDGET_MARKDOWN_MESSAGE = MenuId.for('interactiveEditorWidget.markdownMessage');
export const MENU_INTERACTIVE_EDITOR_WIDGET_STATUS = MenuId.for('interactiveEditorWidget.status');
export const MENU_INTERACTIVE_EDITOR_WIDGET_FEEDBACK = MenuId.for('interactiveEditorWidget.feedback');
export const MENU_INTERACTIVE_EDITOR_WIDGET_DISCARD = MenuId.for('interactiveEditorWidget.undo');
export const MENU_INLINE_CHAT_WIDGET = MenuId.for('inlineChatWidget');
export const MENU_INLINE_CHAT_WIDGET_MARKDOWN_MESSAGE = MenuId.for('inlineChatWidget.markdownMessage');
export const MENU_INLINE_CHAT_WIDGET_STATUS = MenuId.for('inlineChatWidget.status');
export const MENU_INLINE_CHAT_WIDGET_FEEDBACK = MenuId.for('inlineChatWidget.feedback');
export const MENU_INLINE_CHAT_WIDGET_DISCARD = MenuId.for('inlineChatWidget.undo');
// --- colors
export const interactiveEditorBorder = registerColor('interactiveEditor.border', { dark: editorWidgetBorder, light: editorWidgetBorder, hcDark: editorWidgetBorder, hcLight: editorWidgetBorder }, localize('interactiveEditor.border', "Border color of the interactive editor widget"));
export const interactiveEditorShadow = registerColor('interactiveEditor.shadow', { dark: widgetShadow, light: widgetShadow, hcDark: widgetShadow, hcLight: widgetShadow }, localize('interactiveEditor.shadow', "Shadow color of the interactive editor widget"));
export const interactiveEditorRegionHighlight = registerColor('interactiveEditor.regionHighlight', { dark: editorHoverHighlight, light: editorHoverHighlight, hcDark: editorHoverHighlight, hcLight: editorHoverHighlight }, localize('interactiveEditor.regionHighlight', "Background highlighting of the current interactive region. Must be transparent."), true);
export const interactiveEditorInputBorder = registerColor('interactiveEditorInput.border', { dark: editorWidgetBorder, light: editorWidgetBorder, hcDark: editorWidgetBorder, hcLight: editorWidgetBorder }, localize('interactiveEditorInput.border', "Border color of the interactive editor input"));
export const interactiveEditorInputFocusBorder = registerColor('interactiveEditorInput.focusBorder', { dark: focusBorder, light: focusBorder, hcDark: focusBorder, hcLight: focusBorder }, localize('interactiveEditorInput.focusBorder', "Border color of the interactive editor input when focused"));
export const interactiveEditorInputPlaceholderForeground = registerColor('interactiveEditorInput.placeholderForeground', { dark: inputPlaceholderForeground, light: inputPlaceholderForeground, hcDark: inputPlaceholderForeground, hcLight: inputPlaceholderForeground }, localize('interactiveEditorInput.placeholderForeground', "Foreground color of the interactive editor input placeholder"));
export const interactiveEditorInputBackground = registerColor('interactiveEditorInput.background', { dark: inputBackground, light: inputBackground, hcDark: inputBackground, hcLight: inputBackground }, localize('interactiveEditorInput.background', "Background color of the interactive editor input"));
export const inlineChatBorder = registerColor('inlineChat.border', { dark: editorWidgetBorder, light: editorWidgetBorder, hcDark: editorWidgetBorder, hcLight: editorWidgetBorder }, localize('inlineChat.border', "Border color of the interactive editor widget"));
export const inlineChatShadow = registerColor('inlineChat.shadow', { dark: widgetShadow, light: widgetShadow, hcDark: widgetShadow, hcLight: widgetShadow }, localize('inlineChat.shadow', "Shadow color of the interactive editor widget"));
export const inlineChatRegionHighlight = registerColor('inlineChat.regionHighlight', { dark: editorHoverHighlight, light: editorHoverHighlight, hcDark: editorHoverHighlight, hcLight: editorHoverHighlight }, localize('inlineChat.regionHighlight', "Background highlighting of the current interactive region. Must be transparent."), true);
export const inlineChatInputBorder = registerColor('inlineChatInput.border', { dark: editorWidgetBorder, light: editorWidgetBorder, hcDark: editorWidgetBorder, hcLight: editorWidgetBorder }, localize('inlineChatInput.border', "Border color of the interactive editor input"));
export const inlineChatInputFocusBorder = registerColor('inlineChatInput.focusBorder', { dark: focusBorder, light: focusBorder, hcDark: focusBorder, hcLight: focusBorder }, localize('inlineChatInput.focusBorder', "Border color of the interactive editor input when focused"));
export const inlineChatInputPlaceholderForeground = registerColor('inlineChatInput.placeholderForeground', { dark: inputPlaceholderForeground, light: inputPlaceholderForeground, hcDark: inputPlaceholderForeground, hcLight: inputPlaceholderForeground }, localize('inlineChatInput.placeholderForeground', "Foreground color of the interactive editor input placeholder"));
export const inlineChatInputBackground = registerColor('inlineChatInput.background', { dark: inputBackground, light: inputBackground, hcDark: inputBackground, hcLight: inputBackground }, localize('inlineChatInput.background', "Background color of the interactive editor input"));
export const interactiveEditorDiffInserted = registerColor('interactiveEditorDiff.inserted', { dark: transparent(diffInserted, .5), light: transparent(diffInserted, .5), hcDark: transparent(diffInserted, .5), hcLight: transparent(diffInserted, .5) }, localize('interactiveEditorDiff.inserted', "Background color of inserted text in the interactive editor input"));
export const interactiveEditorDiffRemoved = registerColor('interactiveEditorDiff.removed', { dark: transparent(diffRemoved, .5), light: transparent(diffRemoved, .5), hcDark: transparent(diffRemoved, .5), hcLight: transparent(diffRemoved, .5) }, localize('interactiveEditorDiff.removed', "Background color of removed text in the interactive editor input"));
export const inlineChatDiffInserted = registerColor('inlineChatDiff.inserted', { dark: transparent(diffInserted, .5), light: transparent(diffInserted, .5), hcDark: transparent(diffInserted, .5), hcLight: transparent(diffInserted, .5) }, localize('inlineChatDiff.inserted', "Background color of inserted text in the interactive editor input"));
export const inlineChatDiffRemoved = registerColor('inlineChatrDiff.removed', { dark: transparent(diffRemoved, .5), light: transparent(diffRemoved, .5), hcDark: transparent(diffRemoved, .5), hcLight: transparent(diffRemoved, .5) }, localize('inlineChatDiff.removed', "Background color of removed text in the interactive editor input"));
// settings

View File

@ -6,21 +6,21 @@
import { IDisposable, toDisposable } from 'vs/base/common/lifecycle';
import { LinkedList } from 'vs/base/common/linkedList';
import { IContextKey, IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
import { IInteractiveEditorService, IInteractiveEditorSessionProvider, CTX_INTERACTIVE_EDITOR_HAS_PROVIDER } from './inlineChat';
import { IInlineChatService, IInlineChatSessionProvider, CTX_INLINE_CHAT_HAS_PROVIDER } from './inlineChat';
export class InteractiveEditorServiceImpl implements IInteractiveEditorService {
export class InlineChatServiceImpl implements IInlineChatService {
declare _serviceBrand: undefined;
private readonly _entries = new LinkedList<IInteractiveEditorSessionProvider>();
private readonly _entries = new LinkedList<IInlineChatSessionProvider>();
private readonly _ctxHasProvider: IContextKey<boolean>;
constructor(@IContextKeyService contextKeyService: IContextKeyService) {
this._ctxHasProvider = CTX_INTERACTIVE_EDITOR_HAS_PROVIDER.bindTo(contextKeyService);
this._ctxHasProvider = CTX_INLINE_CHAT_HAS_PROVIDER.bindTo(contextKeyService);
}
addProvider(provider: IInteractiveEditorSessionProvider): IDisposable {
addProvider(provider: IInlineChatSessionProvider): IDisposable {
const rm = this._entries.push(provider);
this._ctxHasProvider.set(true);

View File

@ -10,10 +10,10 @@ import { Range } from 'vs/editor/common/core/range';
import { instantiateTestCodeEditor } from 'vs/editor/test/browser/testCodeEditor';
import { SyncDescriptor } from 'vs/platform/instantiation/common/descriptors';
import { ServiceCollection } from 'vs/platform/instantiation/common/serviceCollection';
import { InteractiveEditorController, InteractiveEditorRunOptions, State } from 'vs/workbench/contrib/inlineChat/browser/inlineChatController';
import { IInteractiveEditorSessionService, InteractiveEditorSessionService } from 'vs/workbench/contrib/inlineChat/browser/inlineChatSession';
import { IInteractiveEditorService, InteractiveEditorResponseType } from 'vs/workbench/contrib/inlineChat/common/inlineChat';
import { InteractiveEditorServiceImpl } from 'vs/workbench/contrib/inlineChat/common/inlineChatServiceImpl';
import { InlineChatController, InlineChatRunOptions, State } from 'vs/workbench/contrib/inlineChat/browser/inlineChatController';
import { IInlineChatSessionService, InlineChatSessionService } from 'vs/workbench/contrib/inlineChat/browser/inlineChatSession';
import { IInlineChatService, InlineChatResponseType } from 'vs/workbench/contrib/inlineChat/common/inlineChat';
import { InlineChatServiceImpl } from 'vs/workbench/contrib/inlineChat/common/inlineChatServiceImpl';
import { workbenchInstantiationService } from 'vs/workbench/test/browser/workbenchTestServices';
import { MockContextKeyService } from 'vs/platform/keybinding/test/common/mockKeybindingService';
import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
@ -26,9 +26,9 @@ import { Emitter, Event } from 'vs/base/common/event';
import { equals } from 'vs/base/common/arrays';
import { timeout } from 'vs/base/common/async';
suite('InteractiveEditorController', function () {
suite('InteractiveChatontroller', function () {
class TestController extends InteractiveEditorController {
class TestController extends InlineChatController {
static INIT_SEQUENCE: readonly State[] = [State.CREATE_SESSION, State.INIT_UI, State.WAIT_FOR_INPUT];
static INIT_SEQUENCE_AUTO_SEND: readonly State[] = [...this.INIT_SEQUENCE, State.MAKE_REQUEST, State.APPLY_RESPONSE, State.SHOW_RESPONSE, State.WAIT_FOR_INPUT];
@ -57,7 +57,7 @@ suite('InteractiveEditorController', function () {
});
}
protected override _nextState(state: State, options: InteractiveEditorRunOptions | undefined): Promise<void> {
protected override _nextState(state: State, options: InlineChatRunOptions | undefined): Promise<void> {
this._onDidChangeState.fire(state);
(<State[]>this.states).push(state);
return super._nextState(state, options);
@ -74,19 +74,19 @@ suite('InteractiveEditorController', function () {
let model: ITextModel;
let ctrl: TestController;
// let contextKeys: MockContextKeyService;
let interactiveEditorService: InteractiveEditorServiceImpl;
let interactiveEditorSessionService: IInteractiveEditorSessionService;
let inlineChatService: InlineChatServiceImpl;
let inlineChatSessionService: IInlineChatSessionService;
let instaService: TestInstantiationService;
setup(function () {
const contextKeyService = new MockContextKeyService();
interactiveEditorService = new InteractiveEditorServiceImpl(contextKeyService);
inlineChatService = new InlineChatServiceImpl(contextKeyService);
const serviceCollection = new ServiceCollection(
[IContextKeyService, contextKeyService],
[IInteractiveEditorService, interactiveEditorService],
[IInteractiveEditorSessionService, new SyncDescriptor(InteractiveEditorSessionService)],
[IInlineChatService, inlineChatService],
[IInlineChatSessionService, new SyncDescriptor(InlineChatSessionService)],
[IEditorProgressService, new class extends mock<IEditorProgressService>() {
override show(total: unknown, delay?: unknown): IProgressRunner {
return {
@ -99,21 +99,21 @@ suite('InteractiveEditorController', function () {
);
instaService = workbenchInstantiationService(undefined, store).createChild(serviceCollection);
interactiveEditorSessionService = instaService.get(IInteractiveEditorSessionService);
inlineChatSessionService = instaService.get(IInlineChatSessionService);
model = instaService.get(IModelService).createModel('Hello\nWorld\nHello Again\nHello World\n', null);
editor = instantiateTestCodeEditor(instaService, model);
store.add(interactiveEditorService.addProvider({
store.add(inlineChatService.addProvider({
debugName: 'Unit Test',
prepareInteractiveEditorSession() {
prepareInlineChatSession() {
return {
id: Math.random()
};
},
provideResponse(session, request) {
return {
type: InteractiveEditorResponseType.EditorEdit,
type: InlineChatResponseType.EditorEdit,
id: Math.random(),
edits: [{
range: new Range(1, 1, 1, 1),
@ -155,9 +155,9 @@ suite('InteractiveEditorController', function () {
editor.setSelection(new Range(1, 1, 1, 3));
ctrl = instaService.createInstance(TestController, editor);
const d = interactiveEditorService.addProvider({
const d = inlineChatService.addProvider({
debugName: 'Unit Test',
prepareInteractiveEditorSession() {
prepareInlineChatSession() {
return {
id: Math.random()
};
@ -170,7 +170,7 @@ suite('InteractiveEditorController', function () {
ctrl.run({});
await Event.toPromise(Event.filter(ctrl.onDidChangeState, e => e === State.WAIT_FOR_INPUT));
const session = interactiveEditorSessionService.getSession(editor, editor.getModel()!.uri);
const session = inlineChatSessionService.getSession(editor, editor.getModel()!.uri);
assert.ok(session);
assert.deepStrictEqual(session.wholeRange.value, new Range(1, 1, 1, 6));
@ -183,9 +183,9 @@ suite('InteractiveEditorController', function () {
editor.setSelection(new Range(1, 1, 1, 1));
ctrl = instaService.createInstance(TestController, editor);
const d = interactiveEditorService.addProvider({
const d = inlineChatService.addProvider({
debugName: 'Unit Test',
prepareInteractiveEditorSession() {
prepareInlineChatSession() {
return {
id: Math.random(),
wholeRange: new Range(1, 1, 1, 3)
@ -199,7 +199,7 @@ suite('InteractiveEditorController', function () {
ctrl.run({});
await Event.toPromise(Event.filter(ctrl.onDidChangeState, e => e === State.WAIT_FOR_INPUT));
const session = interactiveEditorSessionService.getSession(editor, editor.getModel()!.uri);
const session = inlineChatSessionService.getSession(editor, editor.getModel()!.uri);
assert.ok(session);
assert.deepStrictEqual(session.wholeRange.value, new Range(1, 1, 1, 6));
@ -213,7 +213,7 @@ suite('InteractiveEditorController', function () {
await ctrl.waitFor(TestController.INIT_SEQUENCE_AUTO_SEND);
const session = interactiveEditorSessionService.getSession(editor, editor.getModel()!.uri);
const session = inlineChatSessionService.getSession(editor, editor.getModel()!.uri);
assert.ok(session);
assert.deepStrictEqual(session.wholeRange.value, new Range(1, 1, 1, 11));
@ -227,9 +227,9 @@ suite('InteractiveEditorController', function () {
editor.setSelection(new Range(3, 1, 3, 1));
const d = interactiveEditorService.addProvider({
const d = inlineChatService.addProvider({
debugName: 'Unit Test',
prepareInteractiveEditorSession() {
prepareInlineChatSession() {
return {
id: Math.random(),
wholeRange: new Range(3, 1, 3, 3)
@ -237,7 +237,7 @@ suite('InteractiveEditorController', function () {
},
provideResponse(session, request) {
return {
type: InteractiveEditorResponseType.EditorEdit,
type: InlineChatResponseType.EditorEdit,
id: Math.random(),
edits: [{
range: new Range(1, 1, 1, 1), // EDIT happens outside of whole range
@ -252,7 +252,7 @@ suite('InteractiveEditorController', function () {
await ctrl.waitFor(TestController.INIT_SEQUENCE);
const session = interactiveEditorSessionService.getSession(editor, editor.getModel()!.uri);
const session = inlineChatSessionService.getSession(editor, editor.getModel()!.uri);
assert.ok(session);
assert.deepStrictEqual(session.wholeRange.value, new Range(3, 1, 3, 12));
@ -264,9 +264,9 @@ suite('InteractiveEditorController', function () {
});
test('Stuck inline chat widget #211', async function () {
const d = interactiveEditorService.addProvider({
const d = inlineChatService.addProvider({
debugName: 'Unit Test',
prepareInteractiveEditorSession() {
prepareInlineChatSession() {
return {
id: Math.random(),
wholeRange: new Range(3, 1, 3, 3)
@ -278,7 +278,7 @@ suite('InteractiveEditorController', function () {
await timeout(50000);
return {
type: InteractiveEditorResponseType.EditorEdit,
type: InlineChatResponseType.EditorEdit,
id: Math.random(),
edits: [{
range: new Range(1, 1, 1, 1), // EDIT happens outside of whole range

View File

@ -17,8 +17,8 @@ import { InputFocusedContextKey } from 'vs/platform/contextkey/common/contextkey
import { ServicesAccessor } from 'vs/platform/instantiation/common/instantiation';
import { KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry';
import { Registry } from 'vs/platform/registry/common/platform';
import { InteractiveEditorController } from 'vs/workbench/contrib/inlineChat/browser/inlineChatController';
import { CTX_INTERACTIVE_EDITOR_FOCUSED, CTX_INTERACTIVE_EDITOR_INNER_CURSOR_LAST } from 'vs/workbench/contrib/inlineChat/common/inlineChat';
import { InlineChatController } from 'vs/workbench/contrib/inlineChat/browser/inlineChatController';
import { CTX_INLINE_CHAT_FOCUSED, CTX_INLINE_CHAT_INNER_CURSOR_LAST } from 'vs/workbench/contrib/inlineChat/common/inlineChat';
import { INotebookActionContext, INotebookCellActionContext, NotebookAction, NotebookCellAction, NOTEBOOK_EDITOR_WIDGET_ACTION_WEIGHT, findTargetCellEditor } from 'vs/workbench/contrib/notebook/browser/controller/coreActions';
import { CellEditState } from 'vs/workbench/contrib/notebook/browser/notebookBrowser';
import { CellKind, NOTEBOOK_EDITOR_CURSOR_BOUNDARY } from 'vs/workbench/contrib/notebook/common/notebookCommon';
@ -88,8 +88,8 @@ registerAction2(class FocusNextCellAction extends NotebookCellAction {
NOTEBOOK_EDITOR_CURSOR_BOUNDARY.notEqualsTo('top'),
NOTEBOOK_EDITOR_CURSOR_BOUNDARY.notEqualsTo('none'),
),
CTX_INTERACTIVE_EDITOR_FOCUSED,
CTX_INTERACTIVE_EDITOR_INNER_CURSOR_LAST,
CTX_INLINE_CHAT_FOCUSED,
CTX_INLINE_CHAT_INNER_CURSOR_LAST,
EditorContextKeys.isEmbeddedDiffEditor.negate()
),
primary: KeyCode.DownArrow,
@ -104,8 +104,8 @@ registerAction2(class FocusNextCellAction extends NotebookCellAction {
NOTEBOOK_CELL_TYPE.isEqualTo('markup'),
NOTEBOOK_CELL_MARKDOWN_EDIT_MODE.isEqualTo(false),
NOTEBOOK_CURSOR_NAVIGATION_MODE),
CTX_INTERACTIVE_EDITOR_FOCUSED,
CTX_INTERACTIVE_EDITOR_INNER_CURSOR_LAST,
CTX_INLINE_CHAT_FOCUSED,
CTX_INLINE_CHAT_INNER_CURSOR_LAST,
EditorContextKeys.isEmbeddedDiffEditor.negate()
),
primary: KeyCode.DownArrow,
@ -133,8 +133,8 @@ registerAction2(class FocusNextCellAction extends NotebookCellAction {
const targetCell = (context.cell ?? context.selectedCells?.[0]);
const foundEditor: ICodeEditor | undefined = targetCell ? findTargetCellEditor(context, targetCell) : undefined;
if (foundEditor && foundEditor.hasTextFocus() && InteractiveEditorController.get(foundEditor)?.getWidgetPosition()?.lineNumber === focusEditorLine) {
InteractiveEditorController.get(foundEditor)?.focus();
if (foundEditor && foundEditor.hasTextFocus() && InlineChatController.get(foundEditor)?.getWidgetPosition()?.lineNumber === focusEditorLine) {
InlineChatController.get(foundEditor)?.focus();
} else {
const newCell = editor.cellAt(idx + 1);
const newFocusMode = newCell.cellKind === CellKind.Markup && newCell.getEditState() === CellEditState.Preview ? 'container' : 'editor';
@ -207,8 +207,8 @@ registerAction2(class FocusPreviousCellAction extends NotebookCellAction {
const foundEditor: ICodeEditor | undefined = findTargetCellEditor(context, newCell);
if (foundEditor && InteractiveEditorController.get(foundEditor)?.getWidgetPosition()?.lineNumber === focusEditorLine) {
InteractiveEditorController.get(foundEditor)?.focus();
if (foundEditor && InlineChatController.get(foundEditor)?.getWidgetPosition()?.lineNumber === focusEditorLine) {
InlineChatController.get(foundEditor)?.focus();
}
}
});

View File

@ -31,7 +31,7 @@ import { INotebookKernelService } from 'vs/workbench/contrib/notebook/common/not
import { IDialogService, IConfirmationResult } from 'vs/platform/dialogs/common/dialogs';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { ICodeEditor } from 'vs/editor/browser/editorBrowser';
import { InteractiveEditorController } from 'vs/workbench/contrib/inlineChat/browser/inlineChatController';
import { InlineChatController } from 'vs/workbench/contrib/inlineChat/browser/inlineChatController';
const CLEAR_ALL_CELLS_OUTPUTS_COMMAND_ID = 'notebook.clearAllCellsOutputs';
@ -76,8 +76,8 @@ registerAction2(class EditCellAction extends NotebookCellAction {
await context.notebookEditor.focusNotebookCell(context.cell, 'editor');
const foundEditor: ICodeEditor | undefined = context.cell ? findTargetCellEditor(context, context.cell) : undefined;
if (foundEditor && foundEditor.hasTextFocus() && InteractiveEditorController.get(foundEditor)?.getWidgetPosition()?.lineNumber === foundEditor.getPosition()?.lineNumber) {
InteractiveEditorController.get(foundEditor)?.focus();
if (foundEditor && foundEditor.hasTextFocus() && InlineChatController.get(foundEditor)?.getWidgetPosition()?.lineNumber === foundEditor.getPosition()?.lineNumber) {
InlineChatController.get(foundEditor)?.focus();
}
}
});

View File

@ -17,8 +17,8 @@ import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey';
import { ServicesAccessor } from 'vs/platform/instantiation/common/instantiation';
import { EditorsOrder } from 'vs/workbench/common/editor';
import { IDebugService } from 'vs/workbench/contrib/debug/common/debug';
import { InteractiveEditorController } from 'vs/workbench/contrib/inlineChat/browser/inlineChatController';
import { CTX_INTERACTIVE_EDITOR_FOCUSED } from 'vs/workbench/contrib/inlineChat/common/inlineChat';
import { InlineChatController } from 'vs/workbench/contrib/inlineChat/browser/inlineChatController';
import { CTX_INLINE_CHAT_FOCUSED } from 'vs/workbench/contrib/inlineChat/common/inlineChat';
import { insertCell } from 'vs/workbench/contrib/notebook/browser/controller/cellOperations';
import { CELL_TITLE_CELL_GROUP_ID, CellToolbarOrder, INotebookActionContext, INotebookCellActionContext, INotebookCellToolbarActionContext, INotebookCommandContext, NOTEBOOK_EDITOR_WIDGET_ACTION_WEIGHT, NotebookAction, NotebookCellAction, NotebookMultiCellAction, cellExecutionArgs, executeNotebookCondition, getContextFromActiveEditor, getContextFromUri, parseMultiCellExecutionArgs } from 'vs/workbench/contrib/notebook/browser/controller/coreActions';
import { CellEditState, CellFocusMode, EXECUTE_CELL_COMMAND_ID } from 'vs/workbench/contrib/notebook/browser/notebookBrowser';
@ -103,7 +103,7 @@ async function runCell(editorGroupsService: IEditorGroupsService, context: INote
return;
}
const controller = InteractiveEditorController.get(foundEditor);
const controller = InlineChatController.get(foundEditor);
if (!controller) {
return;
}
@ -436,7 +436,7 @@ registerAction2(class ExecuteCellSelectBelow extends NotebookCellAction {
keybinding: {
when: ContextKeyExpr.and(
NOTEBOOK_CELL_LIST_FOCUSED,
CTX_INTERACTIVE_EDITOR_FOCUSED.negate()
CTX_INLINE_CHAT_FOCUSED.negate()
),
primary: KeyMod.Shift | KeyCode.Enter,
weight: NOTEBOOK_EDITOR_WIDGET_ACTION_WEIGHT