mirror of
https://github.com/Microsoft/vscode
synced 2024-08-27 13:00:58 +00:00
Merge interactiveUserActions proposal into chatAgents2Additions, and get rid of the old global event (#199916)
Towards #197687
This commit is contained in:
parent
f0d15e2878
commit
ada980d563
|
@ -53,8 +53,7 @@
|
|||
"workspaceTrust",
|
||||
"telemetry",
|
||||
"testingActiveProfile",
|
||||
"windowActivity",
|
||||
"interactiveUserActions"
|
||||
"windowActivity"
|
||||
],
|
||||
"private": true,
|
||||
"activationEvents": [],
|
||||
|
|
|
@ -28,12 +28,6 @@ export class MainThreadChat extends Disposable implements MainThreadChatShape {
|
|||
) {
|
||||
super();
|
||||
this._proxy = extHostContext.getProxy(ExtHostContext.ExtHostChat);
|
||||
|
||||
this._register(this._chatService.onDidPerformUserAction(e => {
|
||||
if (!e.agentId) {
|
||||
this._proxy.$onDidPerformUserAction(e);
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
$transferChatSession(sessionId: number, toWorkspace: UriComponents): void {
|
||||
|
|
|
@ -1334,10 +1334,6 @@ export function createApiFactoryAndRegisterActors(accessor: ServicesAccessor): I
|
|||
checkProposedApiEnabled(extension, 'interactive');
|
||||
return extHostChat.sendInteractiveRequestToProvider(providerId, message);
|
||||
},
|
||||
get onDidPerformUserAction() {
|
||||
checkProposedApiEnabled(extension, 'interactiveUserActions');
|
||||
return extHostChat.onDidPerformUserAction;
|
||||
},
|
||||
transferChatSession(session: vscode.InteractiveSession, toWorkspace: vscode.Uri) {
|
||||
checkProposedApiEnabled(extension, 'interactive');
|
||||
return extHostChat.transferChatSession(session, toWorkspace);
|
||||
|
@ -1609,7 +1605,7 @@ export function createApiFactoryAndRegisterActors(accessor: ServicesAccessor): I
|
|||
LogLevel: LogLevel,
|
||||
EditSessionIdentityMatch: EditSessionIdentityMatch,
|
||||
InteractiveSessionVoteDirection: extHostTypes.InteractiveSessionVoteDirection,
|
||||
InteractiveSessionCopyKind: extHostTypes.InteractiveSessionCopyKind,
|
||||
ChatAgentCopyKind: extHostTypes.ChatAgentCopyKind,
|
||||
InteractiveEditorResponseFeedbackKind: extHostTypes.InteractiveEditorResponseFeedbackKind,
|
||||
StackFrameFocus: extHostTypes.StackFrameFocus,
|
||||
ThreadFocus: extHostTypes.ThreadFocus,
|
||||
|
|
|
@ -1287,7 +1287,6 @@ export interface ExtHostChatShape {
|
|||
$provideWelcomeMessage(handle: number, token: CancellationToken): Promise<(string | IMarkdownString | IChatReplyFollowup[])[] | undefined>;
|
||||
$provideSampleQuestions(handle: number, token: CancellationToken): Promise<IChatReplyFollowup[] | undefined>;
|
||||
$releaseSession(sessionId: number): void;
|
||||
$onDidPerformUserAction(event: IChatUserActionEvent): Promise<void>;
|
||||
}
|
||||
|
||||
export interface ExtHostUrlsShape {
|
||||
|
|
|
@ -4,14 +4,13 @@
|
|||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { CancellationToken } from 'vs/base/common/cancellation';
|
||||
import { Emitter } from 'vs/base/common/event';
|
||||
import { IMarkdownString } from 'vs/base/common/htmlContent';
|
||||
import { Iterable } from 'vs/base/common/iterator';
|
||||
import { toDisposable } from 'vs/base/common/lifecycle';
|
||||
import { IRelaxedExtensionDescription } from 'vs/platform/extensions/common/extensions';
|
||||
import { ExtHostChatShape, IChatDto, IMainContext, MainContext, MainThreadChatShape } from 'vs/workbench/api/common/extHost.protocol';
|
||||
import * as typeConvert from 'vs/workbench/api/common/extHostTypeConverters';
|
||||
import { IChatReplyFollowup, IChatUserActionEvent } from 'vs/workbench/contrib/chat/common/chatService';
|
||||
import { IChatReplyFollowup } from 'vs/workbench/contrib/chat/common/chatService';
|
||||
import type * as vscode from 'vscode';
|
||||
|
||||
class ChatProviderWrapper<T> {
|
||||
|
@ -33,9 +32,6 @@ export class ExtHostChat implements ExtHostChatShape {
|
|||
|
||||
private readonly _chatSessions = new Map<number, vscode.InteractiveSession>();
|
||||
|
||||
private readonly _onDidPerformUserAction = new Emitter<vscode.InteractiveSessionUserActionEvent>();
|
||||
public readonly onDidPerformUserAction = this._onDidPerformUserAction.event;
|
||||
|
||||
private readonly _proxy: MainThreadChatShape;
|
||||
|
||||
constructor(
|
||||
|
@ -140,9 +136,5 @@ export class ExtHostChat implements ExtHostChatShape {
|
|||
this._chatSessions.delete(sessionId);
|
||||
}
|
||||
|
||||
async $onDidPerformUserAction(event: IChatUserActionEvent): Promise<void> {
|
||||
this._onDidPerformUserAction.fire(event as any);
|
||||
}
|
||||
|
||||
//#endregion
|
||||
}
|
||||
|
|
|
@ -4111,7 +4111,7 @@ export enum InteractiveSessionVoteDirection {
|
|||
Up = 1
|
||||
}
|
||||
|
||||
export enum InteractiveSessionCopyKind {
|
||||
export enum ChatAgentCopyKind {
|
||||
Action = 1,
|
||||
Toolbar = 2
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@ import { CHAT_CATEGORY } from 'vs/workbench/contrib/chat/browser/actions/chatAct
|
|||
import { IChatWidgetService } from 'vs/workbench/contrib/chat/browser/chat';
|
||||
import { ICodeBlockActionContext } from 'vs/workbench/contrib/chat/browser/codeBlockPart';
|
||||
import { CONTEXT_IN_CHAT_INPUT, CONTEXT_IN_CHAT_SESSION, CONTEXT_PROVIDER_EXISTS } from 'vs/workbench/contrib/chat/common/chatContextKeys';
|
||||
import { IChatService, IDocumentContext, InteractiveSessionCopyKind } from 'vs/workbench/contrib/chat/common/chatService';
|
||||
import { IChatService, IDocumentContext, ChatAgentCopyKind } from 'vs/workbench/contrib/chat/common/chatService';
|
||||
import { IChatResponseViewModel, isResponseVM } from 'vs/workbench/contrib/chat/common/chatViewModel';
|
||||
import { CTX_INLINE_CHAT_VISIBLE } from 'vs/workbench/contrib/inlineChat/common/inlineChat';
|
||||
import { insertCell } from 'vs/workbench/contrib/notebook/browser/controller/cellOperations';
|
||||
|
@ -114,7 +114,7 @@ export function registerChatCodeBlockActions() {
|
|||
action: {
|
||||
kind: 'copy',
|
||||
codeBlockIndex: context.codeBlockIndex,
|
||||
copyType: InteractiveSessionCopyKind.Toolbar,
|
||||
copyKind: ChatAgentCopyKind.Toolbar,
|
||||
copiedCharacters: context.code.length,
|
||||
totalCharacters: context.code.length,
|
||||
copiedText: context.code,
|
||||
|
@ -157,7 +157,7 @@ export function registerChatCodeBlockActions() {
|
|||
action: {
|
||||
kind: 'copy',
|
||||
codeBlockIndex: context.codeBlockIndex,
|
||||
copyType: InteractiveSessionCopyKind.Action,
|
||||
copyKind: ChatAgentCopyKind.Action,
|
||||
copiedText,
|
||||
copiedCharacters: copiedText.length,
|
||||
totalCharacters,
|
||||
|
|
|
@ -200,7 +200,7 @@ export interface IChatVoteAction {
|
|||
reportIssue?: boolean;
|
||||
}
|
||||
|
||||
export enum InteractiveSessionCopyKind {
|
||||
export enum ChatAgentCopyKind {
|
||||
// Keyboard shortcut or context menu
|
||||
Action = 1,
|
||||
Toolbar = 2
|
||||
|
@ -209,7 +209,7 @@ export enum InteractiveSessionCopyKind {
|
|||
export interface IChatCopyAction {
|
||||
kind: 'copy';
|
||||
codeBlockIndex: number;
|
||||
copyType: InteractiveSessionCopyKind;
|
||||
copyKind: ChatAgentCopyKind;
|
||||
copiedCharacters: number;
|
||||
totalCharacters: number;
|
||||
copiedText: string;
|
||||
|
|
|
@ -26,7 +26,7 @@ import { ChatModel, ChatModelInitState, ChatRequestModel, ChatWelcomeMessageMode
|
|||
import { ChatRequestAgentPart, ChatRequestAgentSubcommandPart, ChatRequestSlashCommandPart, IParsedChatRequest } from 'vs/workbench/contrib/chat/common/chatParserTypes';
|
||||
import { ChatMessageRole, IChatMessage } from 'vs/workbench/contrib/chat/common/chatProvider';
|
||||
import { ChatRequestParser } from 'vs/workbench/contrib/chat/common/chatRequestParser';
|
||||
import { IChat, IChatCompleteResponse, IChatDetail, IChatDynamicRequest, IChatFollowup, IChatProgress, IChatProvider, IChatProviderInfo, IChatResponse, IChatService, IChatTransferredSessionData, IChatUserActionEvent, InteractiveSessionCopyKind, InteractiveSessionVoteDirection } from 'vs/workbench/contrib/chat/common/chatService';
|
||||
import { IChat, IChatCompleteResponse, IChatDetail, IChatDynamicRequest, IChatFollowup, IChatProgress, IChatProvider, IChatProviderInfo, IChatResponse, IChatService, IChatTransferredSessionData, IChatUserActionEvent, ChatAgentCopyKind, InteractiveSessionVoteDirection } from 'vs/workbench/contrib/chat/common/chatService';
|
||||
import { IChatSlashCommandService } from 'vs/workbench/contrib/chat/common/chatSlashCommands';
|
||||
import { IChatVariablesService } from 'vs/workbench/contrib/chat/common/chatVariables';
|
||||
import { IExtensionService } from 'vs/workbench/services/extensions/common/extensions';
|
||||
|
@ -224,7 +224,7 @@ export class ChatService extends Disposable implements IChatService {
|
|||
} else if (action.action.kind === 'copy') {
|
||||
this.telemetryService.publicLog2<ChatCopyEvent, ChatCopyClassification>('interactiveSessionCopy', {
|
||||
providerId: action.providerId,
|
||||
copyKind: action.action.copyType === InteractiveSessionCopyKind.Action ? 'action' : 'toolbar'
|
||||
copyKind: action.action.copyKind === ChatAgentCopyKind.Action ? 'action' : 'toolbar'
|
||||
});
|
||||
} else if (action.action.kind === 'insert') {
|
||||
this.telemetryService.publicLog2<ChatInsertEvent, ChatInsertClassification>('interactiveSessionInsert', {
|
||||
|
|
|
@ -57,7 +57,6 @@ export const allApiProposals = Object.freeze({
|
|||
idToken: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.idToken.d.ts',
|
||||
inlineCompletionsAdditions: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.inlineCompletionsAdditions.d.ts',
|
||||
interactive: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.interactive.d.ts',
|
||||
interactiveUserActions: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.interactiveUserActions.d.ts',
|
||||
interactiveWindow: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.interactiveWindow.d.ts',
|
||||
ipc: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.ipc.d.ts',
|
||||
languageStatusText: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.languageStatusText.d.ts',
|
||||
|
|
|
@ -5,11 +5,6 @@
|
|||
|
||||
declare module 'vscode' {
|
||||
|
||||
export interface ChatAgentUserActionEvent {
|
||||
readonly result: ChatAgentResult2;
|
||||
readonly action: InteractiveSessionCopyAction | InteractiveSessionInsertAction | InteractiveSessionTerminalAction | InteractiveSessionCommandAction | InteractiveSessionFollowupAction | InteractiveSessionBugReportAction;
|
||||
}
|
||||
|
||||
export interface ChatAgent2 {
|
||||
onDidPerformAction: Event<ChatAgentUserActionEvent>;
|
||||
supportIssueReporting?: boolean;
|
||||
|
@ -77,4 +72,61 @@ declare module 'vscode' {
|
|||
*/
|
||||
export function createChatAgent(name: string, handler: ChatAgentExtendedHandler): ChatAgent2;
|
||||
}
|
||||
|
||||
/*
|
||||
* User action events
|
||||
*/
|
||||
|
||||
export enum ChatAgentCopyKind {
|
||||
// Keyboard shortcut or context menu
|
||||
Action = 1,
|
||||
Toolbar = 2
|
||||
}
|
||||
|
||||
export interface ChatAgentCopyAction {
|
||||
// eslint-disable-next-line local/vscode-dts-string-type-literals
|
||||
kind: 'copy';
|
||||
codeBlockIndex: number;
|
||||
copyKind: ChatAgentCopyKind;
|
||||
copiedCharacters: number;
|
||||
totalCharacters: number;
|
||||
copiedText: string;
|
||||
}
|
||||
|
||||
export interface ChatAgentInsertAction {
|
||||
// eslint-disable-next-line local/vscode-dts-string-type-literals
|
||||
kind: 'insert';
|
||||
codeBlockIndex: number;
|
||||
totalCharacters: number;
|
||||
newFile?: boolean;
|
||||
}
|
||||
|
||||
export interface ChatAgentTerminalAction {
|
||||
// eslint-disable-next-line local/vscode-dts-string-type-literals
|
||||
kind: 'runInTerminal';
|
||||
codeBlockIndex: number;
|
||||
languageId?: string;
|
||||
}
|
||||
|
||||
export interface ChatAgentCommandAction {
|
||||
// eslint-disable-next-line local/vscode-dts-string-type-literals
|
||||
kind: 'command';
|
||||
command: ChatAgentCommandFollowup;
|
||||
}
|
||||
|
||||
export interface ChatAgentSessionFollowupAction {
|
||||
// eslint-disable-next-line local/vscode-dts-string-type-literals
|
||||
kind: 'followUp';
|
||||
followup: ChatAgentReplyFollowup;
|
||||
}
|
||||
|
||||
export interface ChatAgentBugReportAction {
|
||||
// eslint-disable-next-line local/vscode-dts-string-type-literals
|
||||
kind: 'bug';
|
||||
}
|
||||
|
||||
export interface ChatAgentUserActionEvent {
|
||||
readonly result: ChatAgentResult2;
|
||||
readonly action: ChatAgentCopyAction | ChatAgentInsertAction | ChatAgentTerminalAction | ChatAgentCommandAction | ChatAgentSessionFollowupAction | ChatAgentBugReportAction;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,77 +0,0 @@
|
|||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
declare module 'vscode' {
|
||||
|
||||
export enum InteractiveSessionVoteDirection {
|
||||
Down = 0,
|
||||
Up = 1
|
||||
}
|
||||
|
||||
export interface InteractiveSessionVoteAction {
|
||||
// eslint-disable-next-line local/vscode-dts-string-type-literals
|
||||
kind: 'vote';
|
||||
direction: InteractiveSessionVoteDirection;
|
||||
}
|
||||
|
||||
export enum InteractiveSessionCopyKind {
|
||||
// Keyboard shortcut or context menu
|
||||
Action = 1,
|
||||
Toolbar = 2
|
||||
}
|
||||
|
||||
export interface InteractiveSessionCopyAction {
|
||||
// eslint-disable-next-line local/vscode-dts-string-type-literals
|
||||
kind: 'copy';
|
||||
codeBlockIndex: number;
|
||||
copyType: InteractiveSessionCopyKind;
|
||||
copiedCharacters: number;
|
||||
totalCharacters: number;
|
||||
copiedText: string;
|
||||
}
|
||||
|
||||
export interface InteractiveSessionInsertAction {
|
||||
// eslint-disable-next-line local/vscode-dts-string-type-literals
|
||||
kind: 'insert';
|
||||
codeBlockIndex: number;
|
||||
totalCharacters: number;
|
||||
newFile?: boolean;
|
||||
}
|
||||
|
||||
export interface InteractiveSessionTerminalAction {
|
||||
// eslint-disable-next-line local/vscode-dts-string-type-literals
|
||||
kind: 'runInTerminal';
|
||||
codeBlockIndex: number;
|
||||
languageId?: string;
|
||||
}
|
||||
|
||||
export interface InteractiveSessionCommandAction {
|
||||
// eslint-disable-next-line local/vscode-dts-string-type-literals
|
||||
kind: 'command';
|
||||
command: InteractiveResponseCommand;
|
||||
}
|
||||
|
||||
export interface InteractiveSessionFollowupAction {
|
||||
// eslint-disable-next-line local/vscode-dts-string-type-literals
|
||||
kind: 'followUp';
|
||||
followup: InteractiveSessionReplyFollowup;
|
||||
}
|
||||
|
||||
export interface InteractiveSessionBugReportAction {
|
||||
// eslint-disable-next-line local/vscode-dts-string-type-literals
|
||||
kind: 'bug';
|
||||
}
|
||||
|
||||
export type InteractiveSessionUserAction = InteractiveSessionVoteAction | InteractiveSessionCopyAction | InteractiveSessionInsertAction | InteractiveSessionTerminalAction | InteractiveSessionCommandAction | InteractiveSessionBugReportAction;
|
||||
|
||||
export interface InteractiveSessionUserActionEvent {
|
||||
action: InteractiveSessionUserAction;
|
||||
providerId: string;
|
||||
}
|
||||
|
||||
export namespace interactive {
|
||||
export const onDidPerformUserAction: Event<InteractiveSessionUserActionEvent>;
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue