mirror of
https://github.com/microsoft/vscode.git
synced 2025-12-20 10:19:02 +00:00
debt - remove InlineChatWidget#updateChatMessage because it is effectively unused (#230213)
fyi @meganrogge @Tyriar this update the terminal chat controller. It use of `updateChatMessage` would be a noop since terminal chat uses a real chat model
This commit is contained in:
@@ -10,7 +10,7 @@ import { renderLabelWithIcons } from '../../../../base/browser/ui/iconLabel/icon
|
||||
import { IAction } from '../../../../base/common/actions.js';
|
||||
import { isNonEmptyArray, tail } from '../../../../base/common/arrays.js';
|
||||
import { Emitter, Event } from '../../../../base/common/event.js';
|
||||
import { IMarkdownString, MarkdownString } from '../../../../base/common/htmlContent.js';
|
||||
import { IMarkdownString } from '../../../../base/common/htmlContent.js';
|
||||
import { DisposableStore, MutableDisposable, toDisposable } from '../../../../base/common/lifecycle.js';
|
||||
import { constObservable, derived, ISettableObservable, observableValue } from '../../../../base/common/observable.js';
|
||||
import './media/inlineChat.css';
|
||||
@@ -45,10 +45,9 @@ import { MarkUnhelpfulActionId } from '../../chat/browser/actions/chatTitleActio
|
||||
import { IChatWidgetViewOptions } from '../../chat/browser/chat.js';
|
||||
import { ChatVoteDownButton } from '../../chat/browser/chatListRenderer.js';
|
||||
import { ChatWidget, IChatWidgetLocationOptions } from '../../chat/browser/chatWidget.js';
|
||||
import { ChatAgentLocation } from '../../chat/common/chatAgents.js';
|
||||
import { chatRequestBackground } from '../../chat/common/chatColors.js';
|
||||
import { CONTEXT_CHAT_RESPONSE_SUPPORT_ISSUE_REPORTING, CONTEXT_RESPONSE, CONTEXT_RESPONSE_ERROR, CONTEXT_RESPONSE_FILTERED, CONTEXT_RESPONSE_VOTE } from '../../chat/common/chatContextKeys.js';
|
||||
import { ChatModel, IChatModel } from '../../chat/common/chatModel.js';
|
||||
import { IChatModel } from '../../chat/common/chatModel.js';
|
||||
import { ChatAgentVoteDirection, IChatService } from '../../chat/common/chatService.js';
|
||||
import { isResponseVM } from '../../chat/common/chatViewModel.js';
|
||||
import { HunkInformation, Session } from './inlineChatSession.js';
|
||||
@@ -107,7 +106,6 @@ export class InlineChatWidget {
|
||||
|
||||
protected readonly _store = new DisposableStore();
|
||||
|
||||
private readonly _defaultChatModel: ChatModel;
|
||||
private readonly _ctxInputEditorFocused: IContextKey<boolean>;
|
||||
private readonly _ctxResponseFocused: IContextKey<boolean>;
|
||||
|
||||
@@ -287,13 +285,6 @@ export class InlineChatWidget {
|
||||
this.updateStatus('Thank you for your feedback!', { resetAfter: 1250 });
|
||||
}
|
||||
}));
|
||||
|
||||
// LEGACY - default chat model
|
||||
// this is only here for as long as we offer updateChatMessage
|
||||
this._defaultChatModel = this._store.add(this._instantiationService.createInstance(ChatModel, undefined, ChatAgentLocation.Editor));
|
||||
this._defaultChatModel.startInitialize();
|
||||
this._defaultChatModel.initialize(undefined);
|
||||
this.setChatModel(this._defaultChatModel);
|
||||
}
|
||||
|
||||
private _updateAriaLabel(): void {
|
||||
@@ -452,57 +443,14 @@ export class InlineChatWidget {
|
||||
}
|
||||
|
||||
|
||||
getChatModel(): IChatModel {
|
||||
return this._chatWidget.viewModel?.model ?? this._defaultChatModel;
|
||||
getChatModel(): IChatModel | undefined {
|
||||
return this._chatWidget.viewModel?.model;
|
||||
}
|
||||
|
||||
setChatModel(chatModel: IChatModel) {
|
||||
this._chatWidget.setModel(chatModel, { inputValue: undefined });
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated use `setChatModel` instead
|
||||
*/
|
||||
updateChatMessage(message: IInlineChatMessage, isIncomplete: true): IInlineChatMessageAppender;
|
||||
updateChatMessage(message: IInlineChatMessage | undefined): void;
|
||||
updateChatMessage(message: IInlineChatMessage | undefined, isIncomplete?: boolean, isCodeBlockEditable?: boolean): IInlineChatMessageAppender | undefined;
|
||||
updateChatMessage(message: IInlineChatMessage | undefined, isIncomplete?: boolean, isCodeBlockEditable?: boolean): IInlineChatMessageAppender | undefined {
|
||||
|
||||
if (!this._chatWidget.viewModel || this._chatWidget.viewModel.model !== this._defaultChatModel) {
|
||||
// this can only be used with the default chat model
|
||||
return;
|
||||
}
|
||||
|
||||
const model = this._defaultChatModel;
|
||||
if (!message?.message.value) {
|
||||
for (const request of model.getRequests()) {
|
||||
model.removeRequest(request.id);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
const chatRequest = model.addRequest({ parts: [], text: '' }, { variables: [] }, 0);
|
||||
model.acceptResponseProgress(chatRequest, {
|
||||
kind: 'markdownContent',
|
||||
content: message.message
|
||||
});
|
||||
|
||||
if (!isIncomplete) {
|
||||
model.completeResponse(chatRequest);
|
||||
return;
|
||||
}
|
||||
return {
|
||||
cancel: () => model.cancelRequest(chatRequest),
|
||||
complete: () => model.completeResponse(chatRequest),
|
||||
appendContent: (fragment: string) => {
|
||||
model.acceptResponseProgress(chatRequest, {
|
||||
kind: 'markdownContent',
|
||||
content: new MarkdownString(fragment)
|
||||
});
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
updateInfo(message: string): void {
|
||||
this._elements.infoLabel.classList.toggle('hidden', !message);
|
||||
const renderedMessage = renderLabelWithIcons(message);
|
||||
@@ -541,7 +489,6 @@ export class InlineChatWidget {
|
||||
reset() {
|
||||
this._chatWidget.setContext(true);
|
||||
this._chatWidget.saveState();
|
||||
this.updateChatMessage(undefined);
|
||||
|
||||
reset(this._elements.statusLabel);
|
||||
this._elements.statusLabel.classList.toggle('hidden', true);
|
||||
@@ -549,8 +496,6 @@ export class InlineChatWidget {
|
||||
this._elements.toolbar2.classList.add('hidden');
|
||||
this.updateInfo('');
|
||||
|
||||
this.chatWidget.setModel(this._defaultChatModel, {});
|
||||
|
||||
this._elements.accessibleViewer.classList.toggle('hidden', true);
|
||||
this._onDidChangeHeight.fire();
|
||||
}
|
||||
|
||||
@@ -17,7 +17,6 @@ import { TerminalWidgetManager } from '../../../terminal/browser/widgets/widgetM
|
||||
import { ITerminalProcessManager } from '../../../terminal/common/terminal.js';
|
||||
import { TerminalChatWidget } from './terminalChatWidget.js';
|
||||
|
||||
import { MarkdownString } from '../../../../../base/common/htmlContent.js';
|
||||
import { ChatModel, IChatResponseModel } from '../../../chat/common/chatModel.js';
|
||||
import { TerminalChatContextKeys } from './terminalChat.js';
|
||||
import { IViewsService } from '../../../../services/views/common/viewsService.js';
|
||||
@@ -244,8 +243,6 @@ export class TerminalChatController extends Disposable implements ITerminalContr
|
||||
if (response.isComplete) {
|
||||
this._requestActiveContextKey.set(false);
|
||||
this._requestActiveContextKey.set(false);
|
||||
const containsCode = responseContent.includes('```');
|
||||
this._terminalChatWidget!.value.inlineChatWidget.updateChatMessage({ message: new MarkdownString(responseContent), requestId: response!.requestId }, false, containsCode);
|
||||
const firstCodeBlock = await this.terminalChatWidget?.inlineChatWidget.getCodeBlockInfo(0);
|
||||
const secondCodeBlock = await this.terminalChatWidget?.inlineChatWidget.getCodeBlockInfo(1);
|
||||
this._responseContainsCodeBlockContextKey.set(!!firstCodeBlock);
|
||||
|
||||
Reference in New Issue
Block a user