mirror of
https://github.com/microsoft/vscode.git
synced 2026-07-14 07:54:36 +01:00
chat - allow mode to be set from protocol link and command (#244911)
This commit is contained in:
@@ -50,7 +50,7 @@ import { extractAgentAndCommand } from '../../common/chatParserTypes.js';
|
||||
import { IChatDetail, IChatService } from '../../common/chatService.js';
|
||||
import { IChatRequestViewModel, IChatResponseViewModel, isRequestVM } from '../../common/chatViewModel.js';
|
||||
import { IChatWidgetHistoryService } from '../../common/chatWidgetHistoryService.js';
|
||||
import { ChatMode } from '../../common/constants.js';
|
||||
import { ChatMode, validateChatMode } from '../../common/constants.js';
|
||||
import { CopilotUsageExtensionFeatureId } from '../../common/languageModelStats.js';
|
||||
import { ILanguageModelToolsService } from '../../common/languageModelToolsService.js';
|
||||
import { ChatViewId, EditsViewId, IChatWidget, IChatWidgetService, showChatView, showCopilotView } from '../chat.js';
|
||||
@@ -68,7 +68,7 @@ const TOGGLE_CHAT_ACTION_ID = 'workbench.action.chat.toggle';
|
||||
|
||||
export interface IChatViewOpenOptions {
|
||||
/**
|
||||
* The query for quick chat.
|
||||
* The query for chat.
|
||||
*/
|
||||
query: string;
|
||||
/**
|
||||
@@ -83,11 +83,14 @@ export interface IChatViewOpenOptions {
|
||||
* Any previous chat requests and responses that should be shown in the chat view.
|
||||
*/
|
||||
previousRequests?: IChatViewOpenRequestEntry[];
|
||||
|
||||
/**
|
||||
* Whether a screenshot of the focused window should be taken and attached
|
||||
*/
|
||||
attachScreenshot?: boolean;
|
||||
/**
|
||||
* The mode to open the chat in.
|
||||
*/
|
||||
mode?: ChatMode;
|
||||
}
|
||||
|
||||
export interface IChatViewOpenRequestEntry {
|
||||
@@ -135,6 +138,9 @@ export function registerChatActions() {
|
||||
if (!chatWidget) {
|
||||
return;
|
||||
}
|
||||
if (opts?.mode && validateChatMode(opts.mode)) {
|
||||
chatWidget.input.setChatMode(opts.mode);
|
||||
}
|
||||
if (opts?.previousRequests?.length && chatWidget.viewModel) {
|
||||
for (const { request, response } of opts.previousRequests) {
|
||||
chatService.addCompleteRequest(chatWidget.viewModel.sessionId, request, undefined, 0, { message: response });
|
||||
|
||||
@@ -63,7 +63,7 @@ import { CHAT_CATEGORY, CHAT_OPEN_ACTION_ID, CHAT_SETUP_ACTION_ID } from './acti
|
||||
import { ChatViewId, EditsViewId, ensureSideBarChatViewSize, IChatWidgetService, preferCopilotEditsView, showCopilotView } from './chat.js';
|
||||
import { CHAT_EDITING_SIDEBAR_PANEL_ID, CHAT_SIDEBAR_PANEL_ID } from './chatViewPane.js';
|
||||
import { ChatViewsWelcomeExtensions, IChatViewsWelcomeContributionRegistry } from './viewsWelcome/chatViewsWelcome.js';
|
||||
import { ChatAgentLocation, ChatConfiguration } from '../common/constants.js';
|
||||
import { ChatAgentLocation, ChatConfiguration, ChatMode, validateChatMode } from '../common/constants.js';
|
||||
import { ILanguageModelsService } from '../common/languageModels.js';
|
||||
import { Dialog } from '../../../../base/browser/ui/dialog/dialog.js';
|
||||
import { ILayoutService } from '../../../../platform/layout/browser/layoutService.js';
|
||||
@@ -618,7 +618,7 @@ export class ChatSetupContribution extends Disposable implements IWorkbenchContr
|
||||
});
|
||||
}
|
||||
|
||||
override async run(accessor: ServicesAccessor): Promise<void> {
|
||||
override async run(accessor: ServicesAccessor, mode: ChatMode): Promise<void> {
|
||||
const viewsService = accessor.get(IViewsService);
|
||||
const viewDescriptorService = accessor.get(IViewDescriptorService);
|
||||
const configurationService = accessor.get(IConfigurationService);
|
||||
@@ -631,7 +631,11 @@ export class ChatSetupContribution extends Disposable implements IWorkbenchContr
|
||||
|
||||
await context.update({ hidden: false });
|
||||
|
||||
showCopilotView(viewsService, layoutService);
|
||||
const chatWidgetPromise = showCopilotView(viewsService, layoutService);
|
||||
if (mode) {
|
||||
const chatWidget = await chatWidgetPromise;
|
||||
chatWidget?.input.setChatMode(mode);
|
||||
}
|
||||
|
||||
const setupFromDialog = configurationService.getValue('chat.setupFromDialog');
|
||||
if (!setupFromDialog) {
|
||||
@@ -778,7 +782,7 @@ export class ChatSetupContribution extends Disposable implements IWorkbenchContr
|
||||
const params = new URLSearchParams(url.query);
|
||||
this.telemetryService.publicLog2<WorkbenchActionExecutedEvent, WorkbenchActionExecutedClassification>('workbenchActionExecuted', { id: CHAT_SETUP_ACTION_ID, from: 'url', detail: params.get('referrer') ?? undefined });
|
||||
|
||||
await this.commandService.executeCommand(CHAT_SETUP_ACTION_ID);
|
||||
await this.commandService.executeCommand(CHAT_SETUP_ACTION_ID, validateChatMode(params.get('mode')));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user