|
3 | 3 | * Licensed under the MIT License. See License.txt in the project root for license information.
|
4 | 4 | *--------------------------------------------------------------------------------------------*/
|
5 | 5 |
|
6 |
| -import { Disposable, DisposableStore } from '../../../base/common/lifecycle.js'; |
7 |
| -import { createDecorator } from '../../../platform/instantiation/common/instantiation.js'; |
8 |
| -import { IExtHostRpcService } from './extHostRpcService.js'; |
9 |
| -import { ExtHostChatSessionsShape, MainContext, MainThreadChatSessionsShape } from './extHost.protocol.js'; |
10 | 6 | import type * as vscode from 'vscode';
|
| 7 | +import { Disposable, DisposableStore } from '../../../base/common/lifecycle.js'; |
| 8 | +import { MarshalledId } from '../../../base/common/marshallingIds.js'; |
| 9 | +import { URI } from '../../../base/common/uri.js'; |
11 | 10 | import { ILogService } from '../../../platform/log/common/log.js';
|
12 | 11 | import { Proxied } from '../../services/extensions/common/proxyIdentifier.js';
|
| 12 | +import { ExtHostChatSessionsShape, MainContext, MainThreadChatSessionsShape } from './extHost.protocol.js'; |
13 | 13 | import { ExtHostCommands } from './extHostCommands.js';
|
14 |
| -import { MarshalledId } from '../../../base/common/marshallingIds.js'; |
15 |
| -import { URI } from '../../../base/common/uri.js'; |
16 |
| - |
17 |
| -export interface IExtHostChatSessions extends ExtHostChatSessionsShape { |
18 |
| - registerChatSessionsProvider(provider: vscode.ChatSessionsProvider): vscode.Disposable; |
19 |
| - $provideChatSessions(handle: number, token: vscode.CancellationToken): Promise<vscode.ChatSessionContent[]>; |
20 |
| -} |
21 |
| -export const IExtHostChatSessions = createDecorator<IExtHostChatSessions>('IExtHostChatSessions'); |
| 14 | +import { IExtHostRpcService } from './extHostRpcService.js'; |
| 15 | +import { IChatSessionContent } from '../../contrib/chat/common/chatSessionsService.js'; |
22 | 16 |
|
23 |
| -export class ExtHostChatSessions extends Disposable implements IExtHostChatSessions { |
24 |
| - declare _serviceBrand: undefined; |
| 17 | +export class ExtHostChatSessions extends Disposable implements ExtHostChatSessionsShape { |
25 | 18 |
|
26 | 19 | private readonly _proxy: Proxied<MainThreadChatSessionsShape>;
|
27 |
| - private readonly _statusProviders = new Map<number, { provider: vscode.ChatSessionsProvider; disposable: DisposableStore }>(); |
| 20 | + private readonly _statusProviders = new Map<number, { provider: vscode.ChatSessionItemProvider; disposable: DisposableStore }>(); |
28 | 21 | private _nextHandle = 0;
|
29 |
| - private _sessionMap: Map<string, vscode.ChatSessionContent> = new Map(); |
| 22 | + private _sessionMap: Map<string, vscode.ChatSessionItem> = new Map(); |
30 | 23 |
|
31 | 24 | constructor(
|
32 | 25 | commands: ExtHostCommands,
|
@@ -54,32 +47,35 @@ export class ExtHostChatSessions extends Disposable implements IExtHostChatSessi
|
54 | 47 | });
|
55 | 48 | }
|
56 | 49 |
|
57 |
| - registerChatSessionsProvider(provider: vscode.ChatSessionsProvider): vscode.Disposable { |
| 50 | + registerChatSessionItemProvider(chatSessionType: string, provider: vscode.ChatSessionItemProvider): vscode.Disposable { |
58 | 51 | const handle = this._nextHandle++;
|
59 | 52 | const disposables = new DisposableStore();
|
60 | 53 |
|
61 | 54 | this._statusProviders.set(handle, { provider, disposable: disposables });
|
62 |
| - this._proxy.$registerChatSessionsProvider(handle, provider.chatSessionType); |
| 55 | + this._proxy.$registerChatSessionsProvider(handle, chatSessionType); |
63 | 56 |
|
64 | 57 | return {
|
65 | 58 | dispose: () => {
|
66 | 59 | this._statusProviders.delete(handle);
|
67 | 60 | disposables.dispose();
|
68 |
| - provider.dispose(); |
69 | 61 | this._proxy.$unregisterChatSessionsProvider(handle);
|
70 | 62 | }
|
71 | 63 | };
|
72 | 64 | }
|
73 | 65 |
|
74 |
| - async $provideChatSessions(handle: number, token: vscode.CancellationToken): Promise<vscode.ChatSessionContent[]> { |
| 66 | + async $provideChatSessions(handle: number, token: vscode.CancellationToken): Promise<IChatSessionContent[]> { |
75 | 67 | const entry = this._statusProviders.get(handle);
|
76 | 68 | if (!entry) {
|
77 | 69 | this._logService.error(`No provider registered for handle ${handle}`);
|
78 | 70 | return [];
|
79 | 71 | }
|
80 | 72 |
|
81 |
| - const sessions = await entry.provider.provideChatSessions(token); |
82 |
| - const response: vscode.ChatSessionContent[] = []; |
| 73 | + const sessions = await entry.provider.provideChatSessionItems(token); |
| 74 | + if (!sessions) { |
| 75 | + return []; |
| 76 | + } |
| 77 | + |
| 78 | + const response: IChatSessionContent[] = []; |
83 | 79 | for (const sessionContent of sessions) {
|
84 | 80 | if (sessionContent.uri) {
|
85 | 81 | this._sessionMap.set(
|
|
0 commit comments