diff --git a/src/vs/workbench/api/common/extHost.api.impl.ts b/src/vs/workbench/api/common/extHost.api.impl.ts index 7d3fdc548ef..0682ec27509 100644 --- a/src/vs/workbench/api/common/extHost.api.impl.ts +++ b/src/vs/workbench/api/common/extHost.api.impl.ts @@ -1505,9 +1505,9 @@ export function createApiFactoryAndRegisterActors(accessor: ServicesAccessor): I checkProposedApiEnabled(extension, 'chatParticipantPrivate'); return _asExtensionEvent(extHostChatAgents2.onDidDisposeChatSession)(listeners, thisArgs, disposables); }, - registerChatSessionsProvider(provider: vscode.ChatSessionsProvider) { + registerChatSessionItemProvider(chatSessionType: string, provider: vscode.ChatSessionItemProvider) { checkProposedApiEnabled(extension, 'chatSessionsProvider'); - return extHostChatSessions.registerChatSessionsProvider(provider); + return extHostChatSessions.registerChatSessionItemProvider(chatSessionType, provider); }, }; diff --git a/src/vs/workbench/api/common/extHostChatSessions.ts b/src/vs/workbench/api/common/extHostChatSessions.ts index 50aa6c41b43..75404ae85dc 100644 --- a/src/vs/workbench/api/common/extHostChatSessions.ts +++ b/src/vs/workbench/api/common/extHostChatSessions.ts @@ -3,30 +3,23 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import { Disposable, DisposableStore } from '../../../base/common/lifecycle.js'; -import { createDecorator } from '../../../platform/instantiation/common/instantiation.js'; -import { IExtHostRpcService } from './extHostRpcService.js'; -import { ExtHostChatSessionsShape, MainContext, MainThreadChatSessionsShape } from './extHost.protocol.js'; import type * as vscode from 'vscode'; -import { ILogService } from '../../../platform/log/common/log.js'; -import { Proxied } from '../../services/extensions/common/proxyIdentifier.js'; -import { ExtHostCommands } from './extHostCommands.js'; +import { Disposable, DisposableStore } from '../../../base/common/lifecycle.js'; import { MarshalledId } from '../../../base/common/marshallingIds.js'; import { URI } from '../../../base/common/uri.js'; +import { ILogService } from '../../../platform/log/common/log.js'; +import { Proxied } from '../../services/extensions/common/proxyIdentifier.js'; +import { ExtHostChatSessionsShape, MainContext, MainThreadChatSessionsShape } from './extHost.protocol.js'; +import { ExtHostCommands } from './extHostCommands.js'; +import { IExtHostRpcService } from './extHostRpcService.js'; +import { IChatSessionContent } from '../../contrib/chat/common/chatSessionsService.js'; -export interface IExtHostChatSessions extends ExtHostChatSessionsShape { - registerChatSessionsProvider(provider: vscode.ChatSessionsProvider): vscode.Disposable; - $provideChatSessions(handle: number, token: vscode.CancellationToken): Promise; -} -export const IExtHostChatSessions = createDecorator('IExtHostChatSessions'); - -export class ExtHostChatSessions extends Disposable implements IExtHostChatSessions { - declare _serviceBrand: undefined; +export class ExtHostChatSessions extends Disposable implements ExtHostChatSessionsShape { private readonly _proxy: Proxied; - private readonly _statusProviders = new Map(); + private readonly _statusProviders = new Map(); private _nextHandle = 0; - private _sessionMap: Map = new Map(); + private _sessionMap: Map = new Map(); constructor( commands: ExtHostCommands, @@ -54,32 +47,35 @@ export class ExtHostChatSessions extends Disposable implements IExtHostChatSessi }); } - registerChatSessionsProvider(provider: vscode.ChatSessionsProvider): vscode.Disposable { + registerChatSessionItemProvider(chatSessionType: string, provider: vscode.ChatSessionItemProvider): vscode.Disposable { const handle = this._nextHandle++; const disposables = new DisposableStore(); this._statusProviders.set(handle, { provider, disposable: disposables }); - this._proxy.$registerChatSessionsProvider(handle, provider.chatSessionType); + this._proxy.$registerChatSessionsProvider(handle, chatSessionType); return { dispose: () => { this._statusProviders.delete(handle); disposables.dispose(); - provider.dispose(); this._proxy.$unregisterChatSessionsProvider(handle); } }; } - async $provideChatSessions(handle: number, token: vscode.CancellationToken): Promise { + async $provideChatSessions(handle: number, token: vscode.CancellationToken): Promise { const entry = this._statusProviders.get(handle); if (!entry) { this._logService.error(`No provider registered for handle ${handle}`); return []; } - const sessions = await entry.provider.provideChatSessions(token); - const response: vscode.ChatSessionContent[] = []; + const sessions = await entry.provider.provideChatSessionItems(token); + if (!sessions) { + return []; + } + + const response: IChatSessionContent[] = []; for (const sessionContent of sessions) { if (sessionContent.uri) { this._sessionMap.set( diff --git a/src/vscode-dts/vscode.proposed.chatSessionsProvider.d.ts b/src/vscode-dts/vscode.proposed.chatSessionsProvider.d.ts index 364d0c231f5..19d7f1800e8 100644 --- a/src/vscode-dts/vscode.proposed.chatSessionsProvider.d.ts +++ b/src/vscode-dts/vscode.proposed.chatSessionsProvider.d.ts @@ -5,30 +5,25 @@ declare module 'vscode' { /** - * Provides a list of chat sessions + * Provides a list of information about chat sessions. */ - export interface ChatSessionsProvider extends Disposable { + export interface ChatSessionItemProvider { /** - * Type to identify providers. + * Event that the provider can fire to signal that chat sessions have changed. */ - readonly chatSessionType: string; + readonly onDidChangeChatSessionItems: Event; /** - * Fired when chat sessions change. + * Provides a list of chat sessions. */ - readonly onDidChangeChatSessionContent: Event; - - /** - * Provide a list of chat sessions. - * */ - provideChatSessions(token: CancellationToken): Thenable; + provideChatSessionItems(token: CancellationToken): ProviderResult; } - export interface ChatSessionContent { + export interface ChatSessionItem { /** - * Identifies the session - * */ - uri: Uri; + * Unique identifier for the chat session. + */ + id: string; /** * Human readable name of the session shown in the UI @@ -42,6 +37,6 @@ declare module 'vscode' { } export namespace chat { - export function registerChatSessionsProvider(provider: ChatSessionsProvider): Disposable; + export function registerChatSessionItemProvider(chatSessionType: string, provider: ChatSessionItemProvider): Disposable; } }