remove IInlineChatService and types around it (#213298)

This commit is contained in:
Johannes Rieken 2024-05-23 11:03:49 +02:00 committed by GitHub
parent 082435c697
commit 3683ed7151
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 15 additions and 198 deletions

View file

@ -8,22 +8,19 @@ import { Button, IButtonStyles } from 'vs/base/browser/ui/button/button';
import { MarkdownString } from 'vs/base/common/htmlContent';
import { Disposable } from 'vs/base/common/lifecycle';
import { localize } from 'vs/nls';
import { ContextKeyExpr, IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
import { ChatAgentLocation, IChatAgentService } from 'vs/workbench/contrib/chat/common/chatAgents';
import { chatAgentLeader, chatSubcommandLeader } from 'vs/workbench/contrib/chat/common/chatParserTypes';
import { IChatFollowup } from 'vs/workbench/contrib/chat/common/chatService';
import { IInlineChatFollowup } from 'vs/workbench/contrib/inlineChat/common/inlineChat';
const $ = dom.$;
export class ChatFollowups<T extends IChatFollowup | IInlineChatFollowup> extends Disposable {
export class ChatFollowups<T extends IChatFollowup> extends Disposable {
constructor(
container: HTMLElement,
followups: T[],
private readonly location: ChatAgentLocation,
private readonly options: IButtonStyles | undefined,
private readonly clickHandler: (followup: T) => void,
@IContextKeyService private readonly contextService: IContextKeyService,
@IChatAgentService private readonly chatAgentService: IChatAgentService
) {
super();
@ -33,9 +30,6 @@ export class ChatFollowups<T extends IChatFollowup | IInlineChatFollowup> extend
}
private renderFollowup(container: HTMLElement, followup: T): void {
if (followup.kind === 'command' && followup.when && !this.contextService.contextMatchesRules(ContextKeyExpr.deserialize(followup.when))) {
return;
}
if (!this.chatAgentService.getDefaultAgent(this.location)) {
// No default agent yet, which affects how followups are rendered, so can't render this yet

View file

@ -7,9 +7,8 @@ import { EditorContributionInstantiation, registerEditorContribution } from 'vs/
import { registerAction2 } from 'vs/platform/actions/common/actions';
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 { INLINE_CHAT_ID } from 'vs/workbench/contrib/inlineChat/common/inlineChat';
import { InstantiationType, registerSingleton } from 'vs/platform/instantiation/common/extensions';
import { InlineChatServiceImpl } from 'vs/workbench/contrib/inlineChat/common/inlineChatServiceImpl';
import { Registry } from 'vs/platform/registry/common/platform';
import { LifecyclePhase } from 'vs/workbench/services/lifecycle/common/lifecycle';
import { InlineChatNotebookContribution } from 'vs/workbench/contrib/inlineChat/browser/inlineChatNotebook';
@ -24,7 +23,6 @@ import { AccessibleViewRegistry } from 'vs/platform/accessibility/browser/access
// --- browser
registerSingleton(IInlineChatService, InlineChatServiceImpl, InstantiationType.Delayed);
registerSingleton(IInlineChatSessionService, InlineChatSessionServiceImpl, InstantiationType.Delayed);
registerSingleton(IInlineChatSavingService, InlineChatSavingServiceImpl, InstantiationType.Delayed);

View file

@ -457,9 +457,9 @@ export class InlineChatController implements IEditorContribution {
const result: CompletionList = { suggestions: [], incomplete: false };
for (const command of this._session.session.slashCommands) {
const withSlash = `/${command.command}`;
const withSlash = `/${command.name}`;
result.suggestions.push({
label: { label: withSlash, description: command.detail ?? '' },
label: { label: withSlash, description: command.description ?? '' },
kind: CompletionItemKind.Text,
insertText: withSlash,
range: Range.fromPositions(new Position(1, 1), position),
@ -473,8 +473,8 @@ export class InlineChatController implements IEditorContribution {
const updateSlashDecorations = (collection: IEditorDecorationsCollection, model: ITextModel) => {
const newDecorations: IModelDeltaDecoration[] = [];
for (const command of (this._session?.session.slashCommands ?? []).sort((a, b) => b.command.length - a.command.length)) {
const withSlash = `/${command.command}`;
for (const command of (this._session?.session.slashCommands ?? []).sort((a, b) => b.name.length - a.name.length)) {
const withSlash = `/${command.name}`;
const firstLine = model.getLineContent(1);
if (firstLine.startsWith(withSlash)) {
newDecorations.push({
@ -490,13 +490,13 @@ export class InlineChatController implements IEditorContribution {
});
// inject detail when otherwise empty
if (firstLine.trim() === `/${command.command}`) {
if (firstLine.trim() === `/${command.name}`) {
newDecorations.push({
range: new Range(1, withSlash.length, 1, withSlash.length),
options: {
description: 'inline-chat-slash-command-detail',
after: {
content: `${command.detail}`,
content: `${command.description}`,
inlineClassName: 'inline-chat-slash-command-detail'
}
}

View file

@ -23,7 +23,7 @@ import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { DEFAULT_EDITOR_ASSOCIATION } from 'vs/workbench/common/editor';
import { ChatAgentLocation, IChatAgentService } from 'vs/workbench/contrib/chat/common/chatAgents';
import { IChatService } from 'vs/workbench/contrib/chat/common/chatService';
import { CTX_INLINE_CHAT_HAS_PROVIDER, EditMode, IInlineChatBulkEditResponse, IInlineChatSession, IInlineChatSlashCommand, InlineChatResponseType } from 'vs/workbench/contrib/inlineChat/common/inlineChat';
import { CTX_INLINE_CHAT_HAS_PROVIDER, EditMode, IInlineChatBulkEditResponse, IInlineChatSession, InlineChatResponseType } from 'vs/workbench/contrib/inlineChat/common/inlineChat';
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
import { UntitledTextEditorInput } from 'vs/workbench/services/untitled/common/untitledTextEditorInput';
import { EmptyResponse, ErrorResponse, HunkData, ReplyResponse, Session, SessionExchange, SessionWholeRange, StashedSession, TelemetryData, TelemetryDataClassification } from './inlineChatSession';
@ -150,15 +150,9 @@ export class InlineChatSessionServiceImpl implements IInlineChatSessionService {
id: Math.random(),
wholeRange: new Range(selection.selectionStartLineNumber, selection.selectionStartColumn, selection.positionLineNumber, selection.positionColumn),
placeholder: agent.description,
slashCommands: agent.slashCommands.map(agentCommand => {
return {
command: agentCommand.name,
detail: agentCommand.description,
} satisfies IInlineChatSlashCommand;
})
slashCommands: agent.slashCommands
};
const store = new DisposableStore();
this._logService.trace(`[IE] creating NEW session for ${editor.getId()}, ${agent.extensionId}`);

View file

@ -34,11 +34,10 @@ import { asCssVariable, asCssVariableName, editorBackground, editorForeground, i
import { AccessibilityVerbositySettingId } from 'vs/workbench/contrib/accessibility/browser/accessibilityConfiguration';
import { IAccessibleViewService } from 'vs/platform/accessibility/browser/accessibleView';
import { AccessibilityCommandId } from 'vs/workbench/contrib/accessibility/common/accessibilityCommands';
import { ChatFollowups } from 'vs/workbench/contrib/chat/browser/chatFollowups';
import { ChatModel, IChatModel } from 'vs/workbench/contrib/chat/common/chatModel';
import { isRequestVM, isResponseVM, isWelcomeVM } from 'vs/workbench/contrib/chat/common/chatViewModel';
import { HunkInformation, Session } from 'vs/workbench/contrib/inlineChat/browser/inlineChatSession';
import { CTX_INLINE_CHAT_FOCUSED, CTX_INLINE_CHAT_RESPONSE_FOCUSED, IInlineChatFollowup, IInlineChatSlashCommand, inlineChatBackground } from 'vs/workbench/contrib/inlineChat/common/inlineChat';
import { CTX_INLINE_CHAT_FOCUSED, CTX_INLINE_CHAT_RESPONSE_FOCUSED, inlineChatBackground } from 'vs/workbench/contrib/inlineChat/common/inlineChat';
import { ChatWidget } from 'vs/workbench/contrib/chat/browser/chatWidget';
import { chatRequestBackground } from 'vs/workbench/contrib/chat/common/chatColors';
import { Selection } from 'vs/editor/common/core/selection';
@ -133,7 +132,6 @@ export class InlineChatWidget {
readonly scopedContextKeyService: IContextKeyService;
private readonly _followUpDisposables = this._store.add(new DisposableStore());
constructor(
location: ChatAgentLocation,
options: IInlineChatWidgetConstructionOptions,
@ -530,28 +528,6 @@ export class InlineChatWidget {
}
};
}
/**
* @deprecated use `setChatModel` instead
*/
updateFollowUps(items: IInlineChatFollowup[], onFollowup: (followup: IInlineChatFollowup) => void): void;
updateFollowUps(items: undefined): void;
updateFollowUps(items: IInlineChatFollowup[] | undefined, onFollowup?: ((followup: IInlineChatFollowup) => void)) {
this._followUpDisposables.clear();
this._elements.followUps.classList.toggle('hidden', !items || items.length === 0);
reset(this._elements.followUps);
if (items && items.length > 0 && onFollowup) {
this._followUpDisposables.add(
this._instantiationService.createInstance(ChatFollowups, this._elements.followUps, items, ChatAgentLocation.Editor, undefined, onFollowup));
}
this._onDidChangeHeight.fire();
}
/**
* @deprecated use `setChatModel` instead
*/
updateSlashCommands(commands: IInlineChatSlashCommand[]) {
}
updateInfo(message: string): void {
this._elements.infoLabel.classList.toggle('hidden', !message);
@ -591,7 +567,6 @@ export class InlineChatWidget {
reset() {
this._chatWidget.saveState();
this.updateChatMessage(undefined);
this.updateFollowUps(undefined);
reset(this._elements.statusLabel);
this._elements.statusLabel.classList.toggle('hidden', true);

View file

@ -3,48 +3,27 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { Event } from 'vs/base/common/event';
import { IMarkdownString } from 'vs/base/common/htmlContent';
import { IDisposable } from 'vs/base/common/lifecycle';
import { IRange } from 'vs/editor/common/core/range';
import { ISelection } from 'vs/editor/common/core/selection';
import { TextEdit, WorkspaceEdit } from 'vs/editor/common/languages';
import { localize } from 'vs/nls';
import { MenuId } from 'vs/platform/actions/common/actions';
import { Extensions, IConfigurationRegistry } from 'vs/platform/configuration/common/configurationRegistry';
import { RawContextKey } from 'vs/platform/contextkey/common/contextkey';
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
import { Registry } from 'vs/platform/registry/common/platform';
import { diffInserted, diffRemoved, editorHoverHighlight, editorWidgetBackground, editorWidgetBorder, focusBorder, inputBackground, inputPlaceholderForeground, registerColor, transparent, widgetShadow } from 'vs/platform/theme/common/colorRegistry';
import { Extensions as ExtensionsMigration, IConfigurationMigrationRegistry } from 'vs/workbench/common/configuration';
import { URI } from 'vs/base/common/uri';
import { ExtensionIdentifier } from 'vs/platform/extensions/common/extensions';
export interface IInlineChatSlashCommand {
command: string;
detail?: string;
}
import { IChatAgentCommand } from 'vs/workbench/contrib/chat/common/chatAgents';
export interface IInlineChatSession {
id: number;
placeholder?: string;
input?: string;
message?: string;
slashCommands?: IInlineChatSlashCommand[];
slashCommands?: IChatAgentCommand[];
wholeRange?: IRange;
}
export interface IInlineChatRequest {
prompt: string;
selection: ISelection;
wholeRange: IRange;
attempt: number;
requestId: string;
live: boolean;
previewDocument: URI;
withIntentDetection: boolean;
}
export type IInlineChatResponse = IInlineChatEditResponse | IInlineChatBulkEditResponse;
export const enum InlineChatResponseType {
@ -77,81 +56,6 @@ export interface IInlineChatBulkEditResponse {
wholeRange?: IRange;
}
export interface IInlineChatProgressItem {
markdownFragment?: string;
edits?: TextEdit[];
editsShouldBeInstant?: boolean;
message?: string;
slashCommand?: string;
}
export const enum InlineChatResponseFeedbackKind {
Unhelpful = 0,
Helpful = 1,
Undone = 2,
Accepted = 3,
Bug = 4
}
export interface IInlineChatReplyFollowup {
kind: 'reply';
message: string;
title?: string;
tooltip?: string;
}
export interface IInlineChatCommandFollowup {
kind: 'command';
commandId: string;
args?: any[];
title: string; // supports codicon strings
when?: string;
}
export type IInlineChatFollowup = IInlineChatReplyFollowup | IInlineChatCommandFollowup;
/**
* @deprecated
*/
export interface IInlineChatSessionProvider {
extensionId: ExtensionIdentifier;
label: string;
}
/**
* @deprecated
*/
export const IInlineChatService = createDecorator<IInlineChatService>('IInlineChatService');
/**
* @deprecated
*/
export interface InlineChatProviderChangeEvent {
readonly added?: IInlineChatSessionProvider;
readonly removed?: IInlineChatSessionProvider;
}
/**
* @deprecated
*/
export interface IInlineChatService {
_serviceBrand: undefined;
/**
* @deprecated
*/
onDidChangeProviders: Event<InlineChatProviderChangeEvent>;
/**
* @deprecated
*/
addProvider(provider: IInlineChatSessionProvider): IDisposable;
/**
* @deprecated
*/
getAllProvider(): Iterable<IInlineChatSessionProvider>;
}
export const INLINE_CHAT_ID = 'interactiveEditor';
export const INTERACTIVE_EDITOR_ACCESSIBILITY_HELP_ID = 'interactiveEditorAccessiblityHelp';

View file

@ -1,42 +0,0 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { IDisposable, toDisposable } from 'vs/base/common/lifecycle';
import { Emitter } from 'vs/base/common/event';
import { LinkedList } from 'vs/base/common/linkedList';
import { IContextKey, IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
import { IInlineChatService, IInlineChatSessionProvider, CTX_INLINE_CHAT_HAS_PROVIDER, InlineChatProviderChangeEvent } from './inlineChat';
export class InlineChatServiceImpl implements IInlineChatService {
declare _serviceBrand: undefined;
private readonly _onDidChangeProviders = new Emitter<InlineChatProviderChangeEvent>();
private readonly _entries = new LinkedList<IInlineChatSessionProvider>();
private readonly _ctxHasProvider: IContextKey<boolean>;
readonly onDidChangeProviders = this._onDidChangeProviders.event;
constructor(@IContextKeyService contextKeyService: IContextKeyService) {
this._ctxHasProvider = CTX_INLINE_CHAT_HAS_PROVIDER.bindTo(contextKeyService);
}
addProvider(provider: IInlineChatSessionProvider): IDisposable {
const rm = this._entries.push(provider);
this._ctxHasProvider.set(true);
this._onDidChangeProviders.fire({ added: provider });
return toDisposable(() => {
rm();
this._ctxHasProvider.set(this._entries.size > 0);
this._onDidChangeProviders.fire({ removed: provider });
});
}
getAllProvider() {
return [...this._entries].reverse();
}
}

View file

@ -35,8 +35,7 @@ import { ChatAgentLocation, ChatAgentService, IChatAgentService } from 'vs/workb
import { IChatResponseViewModel } from 'vs/workbench/contrib/chat/common/chatViewModel';
import { InlineChatController, InlineChatRunOptions, State } from 'vs/workbench/contrib/inlineChat/browser/inlineChatController';
import { Session } from 'vs/workbench/contrib/inlineChat/browser/inlineChatSession';
import { CTX_INLINE_CHAT_USER_DID_EDIT, EditMode, IInlineChatService, InlineChatConfigKeys } from 'vs/workbench/contrib/inlineChat/common/inlineChat';
import { InlineChatServiceImpl } from 'vs/workbench/contrib/inlineChat/common/inlineChatServiceImpl';
import { CTX_INLINE_CHAT_USER_DID_EDIT, EditMode, InlineChatConfigKeys } from 'vs/workbench/contrib/inlineChat/common/inlineChat';
import { workbenchInstantiationService } from 'vs/workbench/test/browser/workbenchTestServices';
import { IInlineChatSavingService } from '../../browser/inlineChatSavingService';
import { IInlineChatSessionService } from '../../browser/inlineChatSessionService';
@ -149,7 +148,6 @@ suite('InteractiveChatController', function () {
[IEditorWorkerService, new SyncDescriptor(TestWorkerService)],
[IContextKeyService, contextKeyService],
[IChatAgentService, new SyncDescriptor(ChatAgentService)],
[IInlineChatService, new SyncDescriptor(InlineChatServiceImpl)],
[IDiffProviderFactoryService, new SyncDescriptor(TestDiffProviderFactoryService)],
[IInlineChatSessionService, new SyncDescriptor(InlineChatSessionServiceImpl)],
[ICommandService, new SyncDescriptor(TestCommandService)],

View file

@ -30,11 +30,10 @@ import { IInlineChatSavingService } from 'vs/workbench/contrib/inlineChat/browse
import { HunkState, Session } from 'vs/workbench/contrib/inlineChat/browser/inlineChatSession';
import { IInlineChatSessionService } from 'vs/workbench/contrib/inlineChat/browser/inlineChatSessionService';
import { InlineChatSessionServiceImpl } from 'vs/workbench/contrib/inlineChat/browser/inlineChatSessionServiceImpl';
import { EditMode, IInlineChatService } from 'vs/workbench/contrib/inlineChat/common/inlineChat';
import { EditMode } from 'vs/workbench/contrib/inlineChat/common/inlineChat';
import { workbenchInstantiationService } from 'vs/workbench/test/browser/workbenchTestServices';
import { CancellationToken } from 'vs/base/common/cancellation';
import { assertType } from 'vs/base/common/types';
import { InlineChatServiceImpl } from 'vs/workbench/contrib/inlineChat/common/inlineChatServiceImpl';
import { EditOperation } from 'vs/editor/common/core/editOperation';
import { Position } from 'vs/editor/common/core/position';
import { IEditorWorkerService } from 'vs/editor/common/services/editorWorker';
@ -86,7 +85,6 @@ suite('InlineChatSession', function () {
[IChatService, new SyncDescriptor(ChatService)],
[IEditorWorkerService, new SyncDescriptor(TestWorkerService)],
[IChatAgentService, new SyncDescriptor(ChatAgentService)],
[IInlineChatService, new SyncDescriptor(InlineChatServiceImpl)],
[IContextKeyService, contextKeyService],
[IDiffProviderFactoryService, new SyncDescriptor(TestDiffProviderFactoryService)],
[IInlineChatSessionService, new SyncDescriptor(InlineChatSessionServiceImpl)],

View file

@ -314,7 +314,6 @@ export class TerminalChatController extends Disposable implements ITerminalContr
try {
const task = this._chatAgentService.invokeAgent(this._terminalAgentId!, requestProps, progressCallback, getHistoryEntriesFromModel(model, this._terminalAgentId!), cancellationToken);
this._chatWidget?.value.inlineChatWidget.updateChatMessage(undefined);
this._chatWidget?.value.inlineChatWidget.updateFollowUps(undefined);
this._chatWidget?.value.inlineChatWidget.updateProgress(true);
this._chatWidget?.value.inlineChatWidget.updateInfo(GeneratingPhrase + '\u2026');
await task;

View file

@ -170,7 +170,6 @@ export class TerminalChatWidget extends Disposable {
this._container.classList.add('hide');
this._reset();
this._inlineChatWidget.updateChatMessage(undefined);
this._inlineChatWidget.updateFollowUps(undefined);
this._inlineChatWidget.updateProgress(false);
this._inlineChatWidget.updateToolbar(false);
this._inlineChatWidget.reset();