mirror of
https://github.com/microsoft/vscode.git
synced 2025-12-24 20:26:08 +00:00
Open a single chat editor for the right contribution (#279449)
This commit is contained in:
@@ -38,7 +38,6 @@ import { PROMPT_LANGUAGE_ID } from '../../common/promptSyntax/promptTypes.js';
|
||||
import { AgentSessionProviders, getAgentSessionProviderIcon, getAgentSessionProviderName } from '../agentSessions/agentSessions.js';
|
||||
import { IChatWidgetService } from '../chat.js';
|
||||
import { CHAT_SETUP_ACTION_ID } from './chatActions.js';
|
||||
import { CancellationToken } from '../../../../../base/common/cancellation.js';
|
||||
import { PromptFileVariableKind, toPromptFileVariableEntry } from '../../common/chatVariableEntries.js';
|
||||
import { NEW_CHAT_SESSION_ACTION_ID } from '../chatSessions/common.js';
|
||||
|
||||
@@ -298,11 +297,9 @@ class CreateRemoteAgentJobFromEditorAction {
|
||||
async run(accessor: ServicesAccessor, continuationTarget: IChatSessionsExtensionPoint) {
|
||||
|
||||
try {
|
||||
const chatService = accessor.get(IChatService);
|
||||
const continuationTargetType = continuationTarget.type;
|
||||
const editorService = accessor.get(IEditorService);
|
||||
const activeEditor = editorService.activeTextEditorControl;
|
||||
const editorService2 = accessor.get(IEditorService);
|
||||
const commandService = accessor.get(ICommandService);
|
||||
|
||||
if (!activeEditor) {
|
||||
return;
|
||||
@@ -312,17 +309,8 @@ class CreateRemoteAgentJobFromEditorAction {
|
||||
return;
|
||||
}
|
||||
const uri = model.uri;
|
||||
const chatModelReference = chatService.startSession(ChatAgentLocation.Chat, CancellationToken.None, {});
|
||||
const { sessionResource } = chatModelReference.object;
|
||||
if (!sessionResource) {
|
||||
return;
|
||||
}
|
||||
await editorService2.openEditor({ resource: sessionResource }, undefined);
|
||||
const attachedContext = [toPromptFileVariableEntry(uri, PromptFileVariableKind.PromptFile, undefined, false, [])];
|
||||
await chatService.sendRequest(sessionResource, `Implement this.`, {
|
||||
agentIdSilent: continuationTargetType,
|
||||
attachedContext
|
||||
});
|
||||
await commandService.executeCommand(`${NEW_CHAT_SESSION_ACTION_ID}.${continuationTarget.type}`, { prompt: `Implement this.`, attachedContext });
|
||||
} catch (e) {
|
||||
console.error('Error creating remote agent job from editor', e);
|
||||
throw e;
|
||||
|
||||
@@ -38,8 +38,9 @@ import { CHAT_CATEGORY } from './actions/chatActions.js';
|
||||
import { IChatEditorOptions } from './chatEditor.js';
|
||||
import { NEW_CHAT_SESSION_ACTION_ID } from './chatSessions/common.js';
|
||||
import { IChatModel, IChatProgressResponseContent, IChatRequestModel } from '../common/chatModel.js';
|
||||
import { IChatToolInvocation } from '../common/chatService.js';
|
||||
import { IChatService, IChatToolInvocation } from '../common/chatService.js';
|
||||
import { autorunSelfDisposable } from '../../../../base/common/observable.js';
|
||||
import { IChatRequestVariableEntry } from '../common/chatVariableEntries.js';
|
||||
|
||||
const extensionPoint = ExtensionsRegistry.registerExtensionPoint<IChatSessionsExtensionPoint[]>({
|
||||
extensionPoint: 'chatSessions',
|
||||
@@ -540,10 +541,10 @@ export class ChatSessionsService extends Disposable implements IChatSessionsServ
|
||||
});
|
||||
}
|
||||
|
||||
async run(accessor: ServicesAccessor) {
|
||||
async run(accessor: ServicesAccessor, chatOptions?: { prompt: string; attachedContext?: IChatRequestVariableEntry[] }): Promise<void> {
|
||||
const editorService = accessor.get(IEditorService);
|
||||
const logService = accessor.get(ILogService);
|
||||
|
||||
const chatService = accessor.get(IChatService);
|
||||
const { type } = contribution;
|
||||
|
||||
try {
|
||||
@@ -559,6 +560,9 @@ export class ChatSessionsService extends Disposable implements IChatSessionsServ
|
||||
path: `/untitled-${generateUuid()}`,
|
||||
});
|
||||
await editorService.openEditor({ resource, options });
|
||||
if (chatOptions?.prompt) {
|
||||
await chatService.sendRequest(resource, chatOptions.prompt, { attachedContext: chatOptions.attachedContext });
|
||||
}
|
||||
} catch (e) {
|
||||
logService.error(`Failed to open new '${type}' chat session editor`, e);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user