mirror of
https://github.com/Microsoft/vscode
synced 2024-08-28 05:19:39 +00:00
chore - remove unused/dead code (#214009)
* remove dead `IInlineChatResponse` * remove `IInlineChatSession`
This commit is contained in:
parent
e258ea4d8f
commit
5c31068a22
|
@ -10,7 +10,6 @@ import { IDimension } from 'vs/editor/common/core/dimension';
|
|||
import { Emitter, Event } from 'vs/base/common/event';
|
||||
import { DisposableStore } from 'vs/base/common/lifecycle';
|
||||
import { IPosition, Position } from 'vs/editor/common/core/position';
|
||||
import { renderLabelWithIcons } from 'vs/base/browser/ui/iconLabel/iconLabels';
|
||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { inlineChatBackground } from 'vs/workbench/contrib/inlineChat/common/inlineChat';
|
||||
import { Session } from 'vs/workbench/contrib/inlineChat/browser/inlineChatSession';
|
||||
|
@ -192,16 +191,6 @@ export class InlineChatContentWidget implements IContentWidget {
|
|||
|
||||
setSession(session: Session): void {
|
||||
this._widget.setModel(session.chatModel, {});
|
||||
this._widget.setInputPlaceholder(session.session.placeholder ?? '');
|
||||
this._updateMessage(session.session.message ?? '');
|
||||
}
|
||||
|
||||
private _updateMessage(message: string) {
|
||||
if (message) {
|
||||
const renderedMessage = renderLabelWithIcons(message);
|
||||
dom.reset(this._messageContainer, ...renderedMessage);
|
||||
}
|
||||
this._messageContainer.style.display = message ? 'inherit' : 'none';
|
||||
this._editor.layoutContentWidget(this);
|
||||
this._widget.setInputPlaceholder(session.agent.description ?? '');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -384,10 +384,6 @@ export class InlineChatController implements IEditorContribution {
|
|||
this._ui.value.content.setSession(this._session);
|
||||
// this._ui.value.zone.widget.updateSlashCommands(this._session.session.slashCommands ?? []);
|
||||
this._updatePlaceholder();
|
||||
const message = this._session.session.message ?? localize('welcome.1', "AI-generated code may be incorrect");
|
||||
|
||||
|
||||
this._ui.value.zone.widget.updateInfo(message);
|
||||
|
||||
this._showWidget(!this._session.chatModel.hasRequests);
|
||||
|
||||
|
@ -470,7 +466,7 @@ export class InlineChatController implements IEditorContribution {
|
|||
if (position.lineNumber !== 1) {
|
||||
return undefined;
|
||||
}
|
||||
if (!this._session || !this._session.session.slashCommands) {
|
||||
if (!this._session || !this._session.agent.slashCommands) {
|
||||
return undefined;
|
||||
}
|
||||
const widget = this._chatWidgetService.getWidgetByInputUri(model.uri);
|
||||
|
@ -479,7 +475,7 @@ export class InlineChatController implements IEditorContribution {
|
|||
}
|
||||
|
||||
const result: CompletionList = { suggestions: [], incomplete: false };
|
||||
for (const command of this._session.session.slashCommands) {
|
||||
for (const command of this._session.agent.slashCommands) {
|
||||
const withSlash = `/${command.name}`;
|
||||
result.suggestions.push({
|
||||
label: { label: withSlash, description: command.description ?? '' },
|
||||
|
@ -496,7 +492,7 @@ 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.name.length - a.name.length)) {
|
||||
for (const command of (this._session?.agent.slashCommands ?? []).sort((a, b) => b.name.length - a.name.length)) {
|
||||
const withSlash = `/${command.name}`;
|
||||
const firstLine = model.getLineContent(1);
|
||||
if (firstLine.startsWith(withSlash)) {
|
||||
|
@ -977,7 +973,7 @@ export class InlineChatController implements IEditorContribution {
|
|||
}
|
||||
|
||||
private _getPlaceholderText(): string {
|
||||
return this._forcedPlaceholder ?? this._session?.session.placeholder ?? '';
|
||||
return this._forcedPlaceholder ?? this._session?.agent.description ?? '';
|
||||
}
|
||||
|
||||
// ---- controller API
|
||||
|
|
|
@ -5,10 +5,9 @@
|
|||
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import { Emitter, Event } from 'vs/base/common/event';
|
||||
import { ResourceEdit, ResourceFileEdit, ResourceTextEdit } from 'vs/editor/browser/services/bulkEditService';
|
||||
import { TextEdit } from 'vs/editor/common/languages';
|
||||
import { IIdentifiedSingleEditOperation, IModelDecorationOptions, IModelDeltaDecoration, ITextModel, IValidEditOperation, TrackedRangeStickiness } from 'vs/editor/common/model';
|
||||
import { EditMode, IInlineChatSession, CTX_INLINE_CHAT_HAS_STASHED_SESSION, IInlineChatResponse } from 'vs/workbench/contrib/inlineChat/common/inlineChat';
|
||||
import { EditMode, CTX_INLINE_CHAT_HAS_STASHED_SESSION } from 'vs/workbench/contrib/inlineChat/common/inlineChat';
|
||||
import { IRange, Range } from 'vs/editor/common/core/range';
|
||||
import { ModelDecorationOptions } from 'vs/editor/common/model/textModel';
|
||||
import { toErrorMessage } from 'vs/base/common/errorMessage';
|
||||
|
@ -160,7 +159,6 @@ export class Session {
|
|||
*/
|
||||
readonly textModelN: ITextModel,
|
||||
readonly agent: IChatAgent,
|
||||
readonly session: IInlineChatSession,
|
||||
readonly wholeRange: SessionWholeRange,
|
||||
readonly hunkData: HunkData,
|
||||
readonly chatModel: ChatModel,
|
||||
|
@ -257,14 +255,14 @@ export class Session {
|
|||
|
||||
asRecording(): Recording {
|
||||
const result: Recording = {
|
||||
session: this.session,
|
||||
session: this.chatModel.sessionId,
|
||||
when: this._startTime,
|
||||
exchanges: []
|
||||
};
|
||||
for (const exchange of this._exchange) {
|
||||
const response = exchange.response;
|
||||
if (response instanceof ReplyResponse) {
|
||||
result.exchanges.push({ prompt: exchange.prompt.value, res: response.raw });
|
||||
result.exchanges.push({ prompt: exchange.prompt.value, res: response.chatResponse });
|
||||
}
|
||||
}
|
||||
return result;
|
||||
|
@ -314,9 +312,7 @@ export class ReplyResponse {
|
|||
readonly untitledTextModel: IUntitledTextEditorModel | undefined;
|
||||
|
||||
constructor(
|
||||
readonly raw: IInlineChatResponse,
|
||||
localUri: URI,
|
||||
readonly modelAltVersionId: number,
|
||||
readonly chatRequest: IChatRequestModel,
|
||||
readonly chatResponse: IChatResponseModel,
|
||||
@ITextFileService private readonly _textFileService: ITextFileService,
|
||||
|
@ -324,28 +320,20 @@ export class ReplyResponse {
|
|||
) {
|
||||
|
||||
const editsMap = new ResourceMap<TextEdit[][]>();
|
||||
const edits = ResourceEdit.convert(raw.edits);
|
||||
|
||||
for (const edit of edits) {
|
||||
if (edit instanceof ResourceFileEdit) {
|
||||
if (edit.newResource && !edit.oldResource) {
|
||||
editsMap.set(edit.newResource, []);
|
||||
if (edit.options.contents) {
|
||||
console.warn('CONTENT not supported');
|
||||
for (const item of chatResponse.response.value) {
|
||||
if (item.kind === 'textEditGroup') {
|
||||
const array = editsMap.get(item.uri);
|
||||
for (const group of item.edits) {
|
||||
if (array) {
|
||||
array.push(group);
|
||||
} else {
|
||||
editsMap.set(item.uri, [group]);
|
||||
}
|
||||
}
|
||||
} else if (edit instanceof ResourceTextEdit) {
|
||||
//
|
||||
const array = editsMap.get(edit.resource);
|
||||
if (array) {
|
||||
array.push([edit.textEdit]);
|
||||
} else {
|
||||
editsMap.set(edit.resource, [[edit.textEdit]]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
for (const [uri, edits] of editsMap) {
|
||||
|
||||
const flatEdits = edits.flat();
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
*--------------------------------------------------------------------------------------------*/
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import { Event } from 'vs/base/common/event';
|
||||
import { EditMode, IInlineChatSession, IInlineChatResponse } from 'vs/workbench/contrib/inlineChat/common/inlineChat';
|
||||
import { EditMode } from 'vs/workbench/contrib/inlineChat/common/inlineChat';
|
||||
import { IRange } from 'vs/editor/common/core/range';
|
||||
import { IActiveCodeEditor, ICodeEditor } from 'vs/editor/browser/editorBrowser';
|
||||
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
|
||||
|
@ -12,12 +12,13 @@ import { IDisposable } from 'vs/base/common/lifecycle';
|
|||
import { CancellationToken } from 'vs/base/common/cancellation';
|
||||
import { Session, StashedSession } from './inlineChatSession';
|
||||
import { IValidEditOperation } from 'vs/editor/common/model';
|
||||
import { IChatResponseModel } from 'vs/workbench/contrib/chat/common/chatModel';
|
||||
|
||||
|
||||
export type Recording = {
|
||||
when: Date;
|
||||
session: IInlineChatSession;
|
||||
exchanges: { prompt: string; res: IInlineChatResponse }[];
|
||||
session: string;
|
||||
exchanges: { prompt: string; res: IChatResponseModel }[];
|
||||
};
|
||||
|
||||
export interface ISessionKeyComputer {
|
||||
|
|
|
@ -22,7 +22,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_AGENT, EditMode, IInlineChatResponse, IInlineChatSession } from 'vs/workbench/contrib/inlineChat/common/inlineChat';
|
||||
import { CTX_INLINE_CHAT_HAS_AGENT, EditMode } 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';
|
||||
|
@ -145,13 +145,6 @@ export class InlineChatSessionServiceImpl implements IInlineChatSessionService {
|
|||
const textModel = editor.getModel();
|
||||
const selection = editor.getSelection();
|
||||
|
||||
const rawSession: IInlineChatSession = {
|
||||
id: Math.random(),
|
||||
wholeRange: new Range(selection.selectionStartLineNumber, selection.selectionStartColumn, selection.positionLineNumber, selection.positionColumn),
|
||||
placeholder: agent.description,
|
||||
slashCommands: agent.slashCommands
|
||||
};
|
||||
|
||||
const store = new DisposableStore();
|
||||
this._logService.trace(`[IE] creating NEW session for ${editor.getId()}, ${agent.extensionId}`);
|
||||
|
||||
|
@ -172,8 +165,6 @@ export class InlineChatSessionServiceImpl implements IInlineChatSessionService {
|
|||
return;
|
||||
}
|
||||
|
||||
const modelAltVersionIdNow = textModel.getAlternativeVersionId();
|
||||
|
||||
const { response } = e.request;
|
||||
|
||||
lastResponseListener.value = response.onDidChange(() => {
|
||||
|
@ -197,29 +188,9 @@ export class InlineChatSessionServiceImpl implements IInlineChatSessionService {
|
|||
// epmty response
|
||||
inlineResponse = new EmptyResponse();
|
||||
} else {
|
||||
// replay response
|
||||
const raw: IInlineChatResponse = {
|
||||
edits: { edits: [] },
|
||||
};
|
||||
for (const item of response.response.value) {
|
||||
if (item.kind === 'textEditGroup') {
|
||||
for (const group of item.edits) {
|
||||
for (const edit of group) {
|
||||
raw.edits.edits.push({
|
||||
resource: item.uri,
|
||||
textEdit: edit,
|
||||
versionId: undefined
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
inlineResponse = this._instaService.createInstance(
|
||||
ReplyResponse,
|
||||
raw,
|
||||
session.textModelN.uri,
|
||||
modelAltVersionIdNow,
|
||||
e.request,
|
||||
response
|
||||
);
|
||||
|
@ -267,7 +238,7 @@ export class InlineChatSessionServiceImpl implements IInlineChatSessionService {
|
|||
|
||||
let wholeRange = options.wholeRange;
|
||||
if (!wholeRange) {
|
||||
wholeRange = rawSession.wholeRange ? Range.lift(rawSession.wholeRange) : editor.getSelection();
|
||||
wholeRange = new Range(selection.selectionStartLineNumber, selection.selectionStartColumn, selection.positionLineNumber, selection.positionColumn);
|
||||
}
|
||||
|
||||
if (token.isCancellationRequested) {
|
||||
|
@ -281,7 +252,6 @@ export class InlineChatSessionServiceImpl implements IInlineChatSessionService {
|
|||
textModel0,
|
||||
textModelN,
|
||||
agent,
|
||||
rawSession,
|
||||
store.add(new SessionWholeRange(textModelN, wholeRange)),
|
||||
store.add(new HunkData(this._editorWorkerService, textModel0, textModelN)),
|
||||
chatModel
|
||||
|
|
|
@ -3,9 +3,6 @@
|
|||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { IMarkdownString } from 'vs/base/common/htmlContent';
|
||||
import { IRange } from 'vs/editor/common/core/range';
|
||||
import { 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';
|
||||
|
@ -13,16 +10,7 @@ import { RawContextKey } from 'vs/platform/contextkey/common/contextkey';
|
|||
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 { IChatAgentCommand } from 'vs/workbench/contrib/chat/common/chatAgents';
|
||||
|
||||
export interface IInlineChatSession {
|
||||
id: number;
|
||||
placeholder?: string;
|
||||
input?: string;
|
||||
message?: string;
|
||||
slashCommands?: IChatAgentCommand[];
|
||||
wholeRange?: IRange;
|
||||
}
|
||||
|
||||
export const enum InlineChatResponseTypes {
|
||||
Empty = 'empty',
|
||||
|
@ -31,14 +19,6 @@ export const enum InlineChatResponseTypes {
|
|||
Mixed = 'mixed'
|
||||
}
|
||||
|
||||
export interface IInlineChatResponse {
|
||||
edits: WorkspaceEdit;
|
||||
message?: IMarkdownString;
|
||||
placeholder?: string;
|
||||
wholeRange?: IRange;
|
||||
}
|
||||
|
||||
|
||||
export const INLINE_CHAT_ID = 'interactiveEditor';
|
||||
export const INTERACTIVE_EDITOR_ACCESSIBILITY_HELP_ID = 'interactiveEditorAccessiblityHelp';
|
||||
|
||||
|
|
Loading…
Reference in a new issue