mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-27 20:13:32 +01:00
capture and restore partial view state
fixes https://github.com/microsoft/vscode-copilot/issues/9617
This commit is contained in:
@@ -34,7 +34,7 @@ import { IDialogService } from '../../../../platform/dialogs/common/dialogs.js';
|
||||
import { IInstantiationService, ServicesAccessor } from '../../../../platform/instantiation/common/instantiation.js';
|
||||
import { ILogService } from '../../../../platform/log/common/log.js';
|
||||
import { showChatView } from '../../chat/browser/chat.js';
|
||||
import { IChatWidgetLocationOptions } from '../../chat/browser/chatWidget.js';
|
||||
import { IChatViewState, IChatWidgetLocationOptions } from '../../chat/browser/chatWidget.js';
|
||||
import { ChatAgentLocation } from '../../chat/common/chatAgents.js';
|
||||
import { ChatModel, ChatRequestRemovalReason, IChatRequestModel, IChatTextEditGroup, IChatTextEditGroupState, IResponse } from '../../chat/common/chatModel.js';
|
||||
import { IChatService } from '../../chat/common/chatService.js';
|
||||
@@ -107,6 +107,7 @@ export class InlineChatController implements IEditorContribution {
|
||||
private readonly _store = new DisposableStore();
|
||||
|
||||
private readonly _ui: Lazy<InlineChatZoneWidget>;
|
||||
private _uiInitViewState: IChatViewState | undefined;
|
||||
|
||||
private readonly _ctxVisible: IContextKey<boolean>;
|
||||
private readonly _ctxEditing: IContextKey<boolean>;
|
||||
@@ -229,6 +230,19 @@ export class InlineChatController implements IEditorContribution {
|
||||
this._log('DISPOSED controller');
|
||||
}
|
||||
|
||||
saveViewState(): any {
|
||||
if (!this._ui.rawValue) {
|
||||
return undefined;
|
||||
}
|
||||
// only take select lm
|
||||
const { selectedLanguageModelId } = this._ui.rawValue.widget.chatWidget.getViewState();
|
||||
return { selectedLanguageModelId };
|
||||
}
|
||||
|
||||
restoreViewState(state: any): void {
|
||||
this._uiInitViewState = state;
|
||||
}
|
||||
|
||||
private _log(message: string | Error, ...more: any[]): void {
|
||||
if (message instanceof Error) {
|
||||
this._logService.error(message, ...more);
|
||||
@@ -398,7 +412,8 @@ export class InlineChatController implements IEditorContribution {
|
||||
this._sessionStore.add(this._session.wholeRange.onDidChange(handleWholeRangeChange));
|
||||
handleWholeRangeChange();
|
||||
|
||||
this._ui.value.widget.setChatModel(this._session.chatModel);
|
||||
this._ui.value.widget.setChatModel(this._session.chatModel, this._uiInitViewState);
|
||||
this._uiInitViewState = undefined;
|
||||
this._updatePlaceholder();
|
||||
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ import { AccessibilityCommandId } from '../../accessibility/common/accessibility
|
||||
import { MarkUnhelpfulActionId } from '../../chat/browser/actions/chatTitleActions.js';
|
||||
import { IChatWidgetViewOptions } from '../../chat/browser/chat.js';
|
||||
import { ChatVoteDownButton } from '../../chat/browser/chatListRenderer.js';
|
||||
import { ChatWidget, IChatWidgetLocationOptions } from '../../chat/browser/chatWidget.js';
|
||||
import { ChatWidget, IChatViewState, IChatWidgetLocationOptions } from '../../chat/browser/chatWidget.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 { IChatModel } from '../../chat/common/chatModel.js';
|
||||
@@ -451,8 +451,8 @@ export class InlineChatWidget {
|
||||
return this._chatWidget.viewModel?.model;
|
||||
}
|
||||
|
||||
setChatModel(chatModel: IChatModel) {
|
||||
this._chatWidget.setModel(chatModel, { inputValue: undefined });
|
||||
setChatModel(chatModel: IChatModel, state?: IChatViewState) {
|
||||
this._chatWidget.setModel(chatModel, { ...state, inputValue: undefined });
|
||||
}
|
||||
|
||||
updateInfo(message: string): void {
|
||||
|
||||
Reference in New Issue
Block a user