mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-24 02:28:34 +01:00
WIP: move-able inline chat
This commit is contained in:
@@ -16,18 +16,19 @@ import { createTextBufferFactoryFromSnapshot } from 'vs/editor/common/model/text
|
||||
import { IEditorWorkerService } from 'vs/editor/common/services/editorWorker';
|
||||
import { IModelService } from 'vs/editor/common/services/model';
|
||||
import { ITextModelService } from 'vs/editor/common/services/resolverService';
|
||||
import { IContextKey, IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
|
||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { ILogService } from 'vs/platform/log/common/log';
|
||||
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 { ChatModel } from 'vs/workbench/contrib/chat/common/chatModel';
|
||||
import { IChatService } from 'vs/workbench/contrib/chat/common/chatService';
|
||||
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';
|
||||
import { IInlineChatSessionEndEvent, IInlineChatSessionEvent, IInlineChatSessionService, ISessionKeyComputer, Recording } from './inlineChatSessionService';
|
||||
import { IContextKey, IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
|
||||
|
||||
|
||||
type SessionData = {
|
||||
@@ -86,7 +87,7 @@ export class InlineChatSessionServiceImpl implements IInlineChatSessionService {
|
||||
this._sessions.clear();
|
||||
}
|
||||
|
||||
async createSession(editor: IActiveCodeEditor, options: { editMode: EditMode; wholeRange?: Range }, token: CancellationToken): Promise<Session | undefined> {
|
||||
async createSession(editor: IActiveCodeEditor, options: { editMode: EditMode; wholeRange?: Range; chatModel?: ChatModel }, token: CancellationToken): Promise<Session | undefined> {
|
||||
|
||||
const agent = this._chatAgentService.getDefaultAgent(ChatAgentLocation.Editor);
|
||||
|
||||
@@ -104,15 +105,19 @@ export class InlineChatSessionServiceImpl implements IInlineChatSessionService {
|
||||
const store = new DisposableStore();
|
||||
this._logService.trace(`[IE] creating NEW session for ${editor.getId()}, ${agent.extensionId}`);
|
||||
|
||||
const chatModel = this._chatService.startSession(ChatAgentLocation.Editor, token);
|
||||
const chatModel = options.chatModel ?? this._chatService.startSession(ChatAgentLocation.Editor, token);
|
||||
if (!chatModel) {
|
||||
this._logService.trace('[IE] NO chatModel found');
|
||||
return undefined;
|
||||
}
|
||||
|
||||
store.add(toDisposable(() => {
|
||||
this._chatService.clearSession(chatModel.sessionId);
|
||||
chatModel.dispose();
|
||||
const doesOtherSessionUseChatModel = [...this._sessions.values()].some(data => data.session !== session && data.session.chatModel === chatModel);
|
||||
|
||||
if (!doesOtherSessionUseChatModel) {
|
||||
this._chatService.clearSession(chatModel.sessionId);
|
||||
chatModel.dispose();
|
||||
}
|
||||
}));
|
||||
|
||||
const lastResponseListener = store.add(new MutableDisposable());
|
||||
|
||||
Reference in New Issue
Block a user