Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename "InteractiveSession" to "Chat" #182567

Merged
merged 4 commits into from May 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion build/lib/i18n.resources.json
Expand Up @@ -163,7 +163,7 @@
"project": "vscode-workbench"
},
{
"name": "vs/workbench/contrib/interactiveSession",
"name": "vs/workbench/contrib/chat",
"project": "vscode-workbench"
},
{
Expand Down
8 changes: 4 additions & 4 deletions src/vs/platform/actions/common/actions.ts
Expand Up @@ -179,10 +179,10 @@ export class MenuId {
static readonly MergeBaseToolbar = new MenuId('MergeBaseToolbar');
static readonly MergeInputResultToolbar = new MenuId('MergeToolbarResultToolbar');
static readonly InlineSuggestionToolbar = new MenuId('InlineSuggestionToolbar');
static readonly InteractiveSessionContext = new MenuId('InteractiveSessionContext');
static readonly InteractiveSessionCodeBlock = new MenuId('InteractiveSessionCodeblock');
static readonly InteractiveSessionTitle = new MenuId('InteractiveSessionTitle');
static readonly InteractiveSessionExecute = new MenuId('InteractiveSessionExecute');
static readonly ChatContext = new MenuId('ChatContext');
static readonly ChatCodeBlock = new MenuId('ChatCodeblock');
static readonly ChatTitle = new MenuId('ChatTitle');
static readonly ChatExecute = new MenuId('ChatExecute');

/**
* Create or reuse a `MenuId` with the given identifier
Expand Down
2 changes: 1 addition & 1 deletion src/vs/workbench/api/browser/extensionHost.contribution.ts
Expand Up @@ -73,7 +73,7 @@ import './mainThreadNotebookRenderers';
import './mainThreadNotebookSaveParticipant';
import './mainThreadInteractive';
import './mainThreadInteractiveEditor';
import './mainThreadInteractiveSession';
import './mainThreadChat';
import './mainThreadTask';
import './mainThreadLabelService';
import './mainThreadTunnelService';
Expand Down
Expand Up @@ -8,33 +8,33 @@ import { Disposable, DisposableMap } from 'vs/base/common/lifecycle';
import { URI } from 'vs/base/common/uri';
import { ILogService } from 'vs/platform/log/common/log';
import { IProductService } from 'vs/platform/product/common/productService';
import { ExtHostContext, ExtHostInteractiveSessionShape, IInteractiveRequestDto, MainContext, MainThreadInteractiveSessionShape } from 'vs/workbench/api/common/extHost.protocol';
import { IInteractiveSessionWidgetService } from 'vs/workbench/contrib/interactiveSession/browser/interactiveSession';
import { IInteractiveSessionContributionService } from 'vs/workbench/contrib/interactiveSession/common/interactiveSessionContributionService';
import { IInteractiveProgress, IInteractiveRequest, IInteractiveResponse, IInteractiveSession, IInteractiveSessionDynamicRequest, IInteractiveSessionService } from 'vs/workbench/contrib/interactiveSession/common/interactiveSessionService';
import { ExtHostContext, ExtHostChatShape, IChatRequestDto, MainContext, MainThreadChatShape } from 'vs/workbench/api/common/extHost.protocol';
import { IChatWidgetService } from 'vs/workbench/contrib/chat/browser/chat';
import { IChatContributionService } from 'vs/workbench/contrib/chat/common/chatContributionService';
import { IChatProgress, IChatRequest, IChatResponse, IChat, IChatDynamicRequest, IChatService } from 'vs/workbench/contrib/chat/common/chatService';
import { IExtHostContext, extHostNamedCustomer } from 'vs/workbench/services/extensions/common/extHostCustomers';

@extHostNamedCustomer(MainContext.MainThreadInteractiveSession)
export class MainThreadInteractiveSession extends Disposable implements MainThreadInteractiveSessionShape {
@extHostNamedCustomer(MainContext.MainThreadChat)
export class MainThreadChat extends Disposable implements MainThreadChatShape {

private readonly _providerRegistrations = this._register(new DisposableMap<number>());
private readonly _activeRequestProgressCallbacks = new Map<string, (progress: IInteractiveProgress) => void>();
private readonly _activeRequestProgressCallbacks = new Map<string, (progress: IChatProgress) => void>();
private readonly _stateEmitters = new Map<number, Emitter<any>>();

private readonly _proxy: ExtHostInteractiveSessionShape;
private readonly _proxy: ExtHostChatShape;

constructor(
extHostContext: IExtHostContext,
@IInteractiveSessionService private readonly _interactiveSessionService: IInteractiveSessionService,
@IInteractiveSessionWidgetService private readonly _interactiveSessionWidgetService: IInteractiveSessionWidgetService,
@IInteractiveSessionContributionService private readonly interactiveSessionContribService: IInteractiveSessionContributionService,
@IChatService private readonly _chatService: IChatService,
@IChatWidgetService private readonly _chatWidgetService: IChatWidgetService,
@IChatContributionService private readonly chatContribService: IChatContributionService,
@IProductService private readonly productService: IProductService,
@ILogService private readonly logService: ILogService,
) {
super();
this._proxy = extHostContext.getProxy(ExtHostContext.ExtHostInteractiveSession);
this._proxy = extHostContext.getProxy(ExtHostContext.ExtHostChat);

this._register(this._interactiveSessionService.onDidPerformUserAction(e => {
this._register(this._chatService.onDidPerformUserAction(e => {
this._proxy.$onDidPerformUserAction(e);
}));
}
Expand All @@ -45,7 +45,7 @@ export class MainThreadInteractiveSession extends Disposable implements MainThre
return;
}

const unreg = this._interactiveSessionService.registerSlashCommandProvider({
const unreg = this._chatService.registerSlashCommandProvider({
chatProviderId,
provideSlashCommands: async token => {
return this._proxy.$provideProviderSlashCommands(handle, token);
Expand All @@ -62,22 +62,22 @@ export class MainThreadInteractiveSession extends Disposable implements MainThre
this._providerRegistrations.deleteAndDispose(handle);
}

async $registerInteractiveSessionProvider(handle: number, id: string): Promise<void> {
async $registerChatProvider(handle: number, id: string): Promise<void> {
if (this.productService.quality === 'stable') {
this.logService.trace(`The interactive session API is not supported in stable VS Code.`);
return;
}

const registration = this.interactiveSessionContribService.registeredProviders.find(staticProvider => staticProvider.id === id);
const registration = this.chatContribService.registeredProviders.find(staticProvider => staticProvider.id === id);
if (!registration) {
throw new Error(`Provider ${id} must be declared in the package.json.`);
}

const unreg = this._interactiveSessionService.registerProvider({
const unreg = this._chatService.registerProvider({
id,
displayName: registration.label,
prepareSession: async (initialState, token) => {
const session = await this._proxy.$prepareInteractiveSession(handle, initialState, token);
const session = await this._proxy.$prepareChat(handle, initialState, token);
if (!session) {
return undefined;
}
Expand All @@ -88,7 +88,7 @@ export class MainThreadInteractiveSession extends Disposable implements MainThre

const emitter = new Emitter<any>();
this._stateEmitters.set(session.id, emitter);
return <IInteractiveSession>{
return <IChat>{
id: session.id,
requesterUsername: session.requesterUsername,
requesterAvatarIconUri: URI.revive(session.requesterAvatarIconUri),
Expand All @@ -104,8 +104,8 @@ export class MainThreadInteractiveSession extends Disposable implements MainThre
};
},
resolveRequest: async (session, context, token) => {
const dto = await this._proxy.$resolveInteractiveRequest(handle, session.id, context, token);
return <IInteractiveRequest>{
const dto = await this._proxy.$resolveRequest(handle, session.id, context, token);
return <IChatRequest>{
session,
...dto
};
Expand All @@ -114,11 +114,11 @@ export class MainThreadInteractiveSession extends Disposable implements MainThre
const id = `${handle}_${request.session.id}`;
this._activeRequestProgressCallbacks.set(id, progress);
try {
const requestDto: IInteractiveRequestDto = {
const requestDto: IChatRequestDto = {
message: request.message,
};
const dto = await this._proxy.$provideInteractiveReply(handle, request.session.id, requestDto, token);
return <IInteractiveResponse>{
const dto = await this._proxy.$provideReply(handle, request.session.id, requestDto, token);
return <IChatResponse>{
session: request.session,
...dto
};
Expand All @@ -140,27 +140,27 @@ export class MainThreadInteractiveSession extends Disposable implements MainThre
this._providerRegistrations.set(handle, unreg);
}

$acceptInteractiveResponseProgress(handle: number, sessionId: number, progress: IInteractiveProgress): void {
$acceptResponseProgress(handle: number, sessionId: number, progress: IChatProgress): void {
const id = `${handle}_${sessionId}`;
this._activeRequestProgressCallbacks.get(id)?.(progress);
}

async $acceptInteractiveSessionState(sessionId: number, state: any): Promise<void> {
async $acceptChatState(sessionId: number, state: any): Promise<void> {
this._stateEmitters.get(sessionId)?.fire(state);
}

$addInteractiveSessionRequest(context: any): void {
this._interactiveSessionService.addInteractiveRequest(context);
$addRequest(context: any): void {
this._chatService.addRequest(context);
}

async $sendInteractiveRequestToProvider(providerId: string, message: IInteractiveSessionDynamicRequest): Promise<void> {
const widget = await this._interactiveSessionWidgetService.revealViewForProvider(providerId);
async $sendRequestToProvider(providerId: string, message: IChatDynamicRequest): Promise<void> {
const widget = await this._chatWidgetService.revealViewForProvider(providerId);
if (widget && widget.viewModel) {
this._interactiveSessionService.sendInteractiveRequestToProvider(widget.viewModel.sessionId, message);
this._chatService.sendRequestToProvider(widget.viewModel.sessionId, message);
}
}

async $unregisterInteractiveSessionProvider(handle: number): Promise<void> {
async $unregisterChatProvider(handle: number): Promise<void> {
this._providerRegistrations.deleteAndDispose(handle);
}
}
14 changes: 7 additions & 7 deletions src/vs/workbench/api/common/extHost.api.impl.ts
Expand Up @@ -97,7 +97,7 @@ import { IExtHostLocalizationService } from 'vs/workbench/api/common/extHostLoca
import { EditSessionIdentityMatch } from 'vs/platform/workspace/common/editSessions';
import { ExtHostProfileContentHandlers } from 'vs/workbench/api/common/extHostProfileContentHandler';
import { ExtHostQuickDiff } from 'vs/workbench/api/common/extHostQuickDiff';
import { ExtHostInteractiveSession } from 'vs/workbench/api/common/extHostInteractiveSession';
import { ExtHostChat } from 'vs/workbench/api/common/extHostChat';
import { ExtHostInteractiveEditor } from 'vs/workbench/api/common/extHostInteractiveEditor';
import { ExtHostNotebookDocumentSaveParticipant } from 'vs/workbench/api/common/extHostNotebookDocumentSaveParticipant';
import { ExtHostSemanticSimilarity } from 'vs/workbench/api/common/extHostSemanticSimilarity';
Expand Down Expand Up @@ -201,7 +201,7 @@ export function createApiFactoryAndRegisterActors(accessor: ServicesAccessor): I
const extHostProfileContentHandlers = rpcProtocol.set(ExtHostContext.ExtHostProfileContentHandlers, new ExtHostProfileContentHandlers(rpcProtocol));
rpcProtocol.set(ExtHostContext.ExtHostInteractive, new ExtHostInteractive(rpcProtocol, extHostNotebook, extHostDocumentsAndEditors, extHostCommands, extHostLogService));
const extHostInteractiveEditor = rpcProtocol.set(ExtHostContext.ExtHostInteractiveEditor, new ExtHostInteractiveEditor(rpcProtocol, extHostDocuments, extHostLogService));
const extHostInteractiveSession = rpcProtocol.set(ExtHostContext.ExtHostInteractiveSession, new ExtHostInteractiveSession(rpcProtocol, extHostLogService));
const extHostChat = rpcProtocol.set(ExtHostContext.ExtHostChat, new ExtHostChat(rpcProtocol, extHostLogService));
const extHostSemanticSimilarity = rpcProtocol.set(ExtHostContext.ExtHostSemanticSimilarity, new ExtHostSemanticSimilarity(rpcProtocol));
const extHostIssueReporter = rpcProtocol.set(ExtHostContext.ExtHostIssueReporter, new ExtHostIssueReporter(rpcProtocol));

Expand Down Expand Up @@ -1275,26 +1275,26 @@ export function createApiFactoryAndRegisterActors(accessor: ServicesAccessor): I
},
registerInteractiveSessionProvider(id: string, provider: vscode.InteractiveSessionProvider) {
checkProposedApiEnabled(extension, 'interactive');
return extHostInteractiveSession.registerInteractiveSessionProvider(extension, id, provider);
return extHostChat.registerChatProvider(extension, id, provider);
},
addInteractiveRequest(context: vscode.InteractiveSessionRequestArgs) {
checkProposedApiEnabled(extension, 'interactive');
return extHostInteractiveSession.addInteractiveSessionRequest(context);
return extHostChat.addChatRequest(context);
},
sendInteractiveRequestToProvider(providerId: string, message: vscode.InteractiveSessionDynamicRequest) {
checkProposedApiEnabled(extension, 'interactive');
return extHostInteractiveSession.sendInteractiveRequestToProvider(providerId, message);
return extHostChat.sendInteractiveRequestToProvider(providerId, message);
},
get onDidPerformUserAction() {
return extHostInteractiveSession.onDidPerformUserAction;
return extHostChat.onDidPerformUserAction;
}
};

// namespace: interactiveSlashCommands
const interactiveSlashCommands: typeof vscode.interactiveSlashCommands = {
registerSlashCommandProvider(chatProviderId: string, provider: vscode.InteractiveSlashCommandProvider) {
checkProposedApiEnabled(extension, 'interactiveSlashCommands');
return extHostInteractiveSession.registerSlashCommandProvider(extension, chatProviderId, provider);
return extHostChat.registerSlashCommandProvider(extension, chatProviderId, provider);
}
};

Expand Down