Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove IInlineChatService and types around it #213298

Merged
merged 1 commit into from
May 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 1 addition & 7 deletions src/vs/workbench/contrib/chat/browser/chatFollowups.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -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({
Expand All @@ -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'
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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}`);

Expand Down
27 changes: 1 addition & 26 deletions src/vs/workbench/contrib/inlineChat/browser/inlineChatWidget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -133,7 +132,6 @@ export class InlineChatWidget {

readonly scopedContextKeyService: IContextKeyService;

private readonly _followUpDisposables = this._store.add(new DisposableStore());
constructor(
location: ChatAgentLocation,
options: IInlineChatWidgetConstructionOptions,
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
100 changes: 2 additions & 98 deletions src/vs/workbench/contrib/inlineChat/common/inlineChat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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';
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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)],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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)],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Loading
Loading