Skip to content

Commit 1d7ab52

Browse files
committed
Implementation
1 parent eb082b9 commit 1d7ab52

File tree

5 files changed

+43
-48
lines changed

5 files changed

+43
-48
lines changed

src/vs/workbench/api/browser/mainThreadChatSessions.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { CancellationToken } from '../../../base/common/cancellation.js';
77
import { Disposable, DisposableMap } from '../../../base/common/lifecycle.js';
88
import { URI, UriComponents } from '../../../base/common/uri.js';
99
import { ILogService } from '../../../platform/log/common/log.js';
10-
import { IChatSessionContent, IChatSessionsProvider, IChatSessionsService } from '../../contrib/chat/common/chatSessionsService.js';
10+
import { IChatSessionDefinition, IChatSessionDefinitionProvider, IChatSessionsService } from '../../contrib/chat/common/chatSessionsService.js';
1111
import { extHostNamedCustomer, IExtHostContext } from '../../services/extensions/common/extHostCustomers.js';
1212
import { ExtHostContext, MainContext, MainThreadChatSessionsShape } from '../common/extHost.protocol.js';
1313

@@ -23,24 +23,24 @@ export class MainThreadChatSessions extends Disposable implements MainThreadChat
2323
super();
2424
}
2525

26-
$registerChatSessionsProvider(handle: number, chatSessionType: string): void {
26+
$registerChatSessionItemProvider(handle: number, chatSessionType: string): void {
2727
// Register the provider handle - this tracks that a provider exists
28-
const provider: IChatSessionsProvider = {
28+
const provider: IChatSessionDefinitionProvider = {
2929
chatSessionType,
30-
provideChatSessions: (token) => this._provideChatSessionsInformation(handle, token)
30+
provideChatSessionDefinitions: (token) => this._provideChatSessionsInformation(handle, token)
3131
};
32-
this._registrations.set(handle, this._chatSessionsService.registerChatSessionsProvider(handle, provider));
32+
this._registrations.set(handle, this._chatSessionsService.registerChatSessionDefinitionProvider(handle, provider));
3333
}
3434

35-
private async _provideChatSessionsInformation(handle: number, token: CancellationToken): Promise<IChatSessionContent[]> {
35+
private async _provideChatSessionsInformation(handle: number, token: CancellationToken): Promise<IChatSessionDefinition[]> {
3636
const proxy = this._extHostContext.getProxy(ExtHostContext.ExtHostChatSessions);
3737

3838
try {
3939
// Get all results as an array from the RPC call
40-
const sessions = await proxy.$provideChatSessions(handle, token);
40+
const sessions = await proxy.$provideChatSessionItems(handle, token);
4141
return sessions.map(session => ({
4242
...session,
43-
uri: URI.revive(session.uri),
43+
id: session.id,
4444
iconPath: session.iconPath ? this._reviveIconPath(session.iconPath) : undefined
4545
}));
4646
} catch (error) {
@@ -49,14 +49,14 @@ export class MainThreadChatSessions extends Disposable implements MainThreadChat
4949
return [];
5050
}
5151

52-
$unregisterChatSessionsProvider(handle: number): void {
52+
$unregisterChatSessionItemProvider(handle: number): void {
5353
this._registrations.deleteAndDispose(handle);
5454
}
5555

5656

5757
private _reviveIconPath(
5858
iconPath: UriComponents | { light: UriComponents; dark: UriComponents } | { id: string; color?: { id: string } | undefined })
59-
: IChatSessionContent['iconPath'] {
59+
: IChatSessionDefinition['iconPath'] {
6060
if (!iconPath) {
6161
return undefined;
6262
}

src/vs/workbench/api/common/extHost.protocol.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ import { ICodeMapperRequest, ICodeMapperResult } from '../../contrib/chat/common
5858
import { IChatRelatedFile, IChatRelatedFileProviderMetadata as IChatRelatedFilesProviderMetadata, IChatRequestDraft } from '../../contrib/chat/common/chatEditingService.js';
5959
import { IChatProgressHistoryResponseContent } from '../../contrib/chat/common/chatModel.js';
6060
import { IChatContentInlineReference, IChatFollowup, IChatNotebookEdit, IChatProgress, IChatTask, IChatTaskDto, IChatUserActionEvent, IChatVoteAction } from '../../contrib/chat/common/chatService.js';
61-
import { IChatSessionContent } from '../../contrib/chat/common/chatSessionsService.js';
61+
import { IChatSessionDefinition as IChatSessionDefinition } from '../../contrib/chat/common/chatSessionsService.js';
6262
import { IChatRequestVariableValue } from '../../contrib/chat/common/chatVariables.js';
6363
import { ChatAgentLocation } from '../../contrib/chat/common/constants.js';
6464
import { IChatMessage, IChatResponseFragment, ILanguageModelChatMetadataAndIdentifier, ILanguageModelChatSelector } from '../../contrib/chat/common/languageModels.js';
@@ -3102,12 +3102,12 @@ export interface MainThreadChatStatusShape {
31023102
}
31033103

31043104
export interface MainThreadChatSessionsShape extends IDisposable {
3105-
$registerChatSessionsProvider(handle: number, chatSessionType: string): void;
3106-
$unregisterChatSessionsProvider(handle: number): void;
3105+
$registerChatSessionItemProvider(handle: number, chatSessionType: string): void;
3106+
$unregisterChatSessionItemProvider(handle: number): void;
31073107
}
31083108

31093109
export interface ExtHostChatSessionsShape {
3110-
$provideChatSessions(handle: number, token: CancellationToken): Promise<IChatSessionContent[]>;
3110+
$provideChatSessionItems(handle: number, token: CancellationToken): Promise<IChatSessionDefinition[]>;
31113111
}
31123112

31133113
// --- proxy identifiers

src/vs/workbench/api/common/extHostChatSessions.ts

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,12 @@
66
import type * as vscode from 'vscode';
77
import { Disposable, DisposableStore } from '../../../base/common/lifecycle.js';
88
import { MarshalledId } from '../../../base/common/marshallingIds.js';
9-
import { URI } from '../../../base/common/uri.js';
109
import { ILogService } from '../../../platform/log/common/log.js';
1110
import { Proxied } from '../../services/extensions/common/proxyIdentifier.js';
1211
import { ExtHostChatSessionsShape, MainContext, MainThreadChatSessionsShape } from './extHost.protocol.js';
1312
import { ExtHostCommands } from './extHostCommands.js';
1413
import { IExtHostRpcService } from './extHostRpcService.js';
15-
import { IChatSessionContent } from '../../contrib/chat/common/chatSessionsService.js';
14+
import { IChatSessionDefinition as IChatSessionItem } from '../../contrib/chat/common/chatSessionsService.js';
1615

1716
export class ExtHostChatSessions extends Disposable implements ExtHostChatSessionsShape {
1817

@@ -32,12 +31,12 @@ export class ExtHostChatSessions extends Disposable implements ExtHostChatSessio
3231
commands.registerArgumentProcessor({
3332
processArgument: (arg) => {
3433
if (arg && arg.$mid === MarshalledId.ChatSessionContext) {
35-
const id = this.uriToId(arg.uri);
34+
const id = arg.id;
3635
const sessionContent = this._sessionMap.get(id);
3736
if (sessionContent) {
3837
return sessionContent;
3938
} else {
40-
this._logService.warn(`No chat session found for URI: ${id}`);
39+
this._logService.warn(`No chat session found for ID: ${id}`);
4140
return arg;
4241
}
4342
}
@@ -52,18 +51,18 @@ export class ExtHostChatSessions extends Disposable implements ExtHostChatSessio
5251
const disposables = new DisposableStore();
5352

5453
this._statusProviders.set(handle, { provider, disposable: disposables });
55-
this._proxy.$registerChatSessionsProvider(handle, chatSessionType);
54+
this._proxy.$registerChatSessionItemProvider(handle, chatSessionType);
5655

5756
return {
5857
dispose: () => {
5958
this._statusProviders.delete(handle);
6059
disposables.dispose();
61-
this._proxy.$unregisterChatSessionsProvider(handle);
60+
this._proxy.$unregisterChatSessionItemProvider(handle);
6261
}
6362
};
6463
}
6564

66-
async $provideChatSessions(handle: number, token: vscode.CancellationToken): Promise<IChatSessionContent[]> {
65+
async $provideChatSessionItems(handle: number, token: vscode.CancellationToken): Promise<IChatSessionItem[]> {
6766
const entry = this._statusProviders.get(handle);
6867
if (!entry) {
6968
this._logService.error(`No provider registered for handle ${handle}`);
@@ -75,24 +74,20 @@ export class ExtHostChatSessions extends Disposable implements ExtHostChatSessio
7574
return [];
7675
}
7776

78-
const response: IChatSessionContent[] = [];
77+
const response: IChatSessionItem[] = [];
7978
for (const sessionContent of sessions) {
80-
if (sessionContent.uri) {
79+
if (sessionContent.id) {
8180
this._sessionMap.set(
82-
this.uriToId(sessionContent.uri),
81+
sessionContent.id,
8382
sessionContent
8483
);
8584
response.push({
86-
uri: sessionContent.uri,
85+
id: sessionContent.id,
8786
label: sessionContent.label,
8887
iconPath: sessionContent.iconPath
8988
});
9089
}
9190
}
9291
return response;
9392
}
94-
95-
private uriToId(uri: URI): string {
96-
return `${uri.scheme}+${uri.authority}+${uri.path}`;
97-
}
9893
}

src/vs/workbench/contrib/chat/browser/actions/chatActions.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -565,7 +565,7 @@ export function registerChatActions() {
565565
const cancellationToken = new CancellationTokenSource();
566566

567567
try {
568-
const sessions = await chatSessionsService.provideChatSessions(cancellationToken.token);
568+
const sessions = await chatSessionsService.provideChatSessionDefinitions(cancellationToken.token);
569569

570570
for (const session of sessions) {
571571
const sessionContent = session.session;
@@ -588,17 +588,17 @@ export function registerChatActions() {
588588
label: sessionContent.label,
589589
description: '',
590590
chat: {
591-
sessionId: sessionContent.uri.toString(),
591+
sessionId: sessionContent.id,
592592
title: sessionContent.label,
593593
isActive: false,
594594
lastMessageDate: 0,
595595
},
596596
buttons,
597-
uri: sessionContent.uri
597+
id: sessionContent.id
598598
};
599599

600600
// Check if this agent already exists (update existing or add new)
601-
const existingIndex = agentPicks.findIndex(pick => pick.chat.sessionId === sessionContent.uri.path);
601+
const existingIndex = agentPicks.findIndex(pick => pick.chat.sessionId === sessionContent.id);
602602
if (existingIndex >= 0) {
603603
agentPicks[existingIndex] = agentPick;
604604
} else {
@@ -845,7 +845,7 @@ export function registerChatActions() {
845845
}
846846

847847
const showAgentSessionsMenuConfig = configurationService.getValue<string>(ChatConfiguration.AgentSessionsViewLocation);
848-
if (showAgentSessionsMenuConfig === 'showChatsMenu' && chatSessionsService.hasChatSessionsProviders) {
848+
if (showAgentSessionsMenuConfig === 'showChatsMenu' && chatSessionsService.hasChatSessionDefinitionProviders) {
849849
await this.showIntegratedPicker(
850850
chatService,
851851
quickInputService,

src/vs/workbench/contrib/chat/common/chatSessionsService.ts

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,47 +11,47 @@ import { InstantiationType, registerSingleton } from '../../../../platform/insta
1111
import { URI } from '../../../../base/common/uri.js';
1212
import { ThemeIcon } from '../../../../base/common/themables.js';
1313

14-
export interface IChatSessionContent {
15-
uri: URI;
14+
export interface IChatSessionDefinition {
15+
id: string;
1616
label: string;
1717
iconPath?: URI | {
1818
light: URI;
1919
dark: URI;
2020
} | ThemeIcon;
2121
}
2222

23-
export interface IChatSessionsProvider {
23+
export interface IChatSessionDefinitionProvider {
2424
readonly chatSessionType: string;
25-
provideChatSessions(token: CancellationToken): Promise<IChatSessionContent[]>;
25+
provideChatSessionDefinitions(token: CancellationToken): Promise<IChatSessionDefinition[]>;
2626
}
2727

2828
export interface IChatSessionsService {
2929
readonly _serviceBrand: undefined;
30-
registerChatSessionsProvider(handle: number, provider: IChatSessionsProvider): IDisposable;
31-
hasChatSessionsProviders: boolean;
32-
provideChatSessions(token: CancellationToken): Promise<{ provider: IChatSessionsProvider; session: IChatSessionContent }[]>;
30+
registerChatSessionDefinitionProvider(handle: number, provider: IChatSessionDefinitionProvider): IDisposable;
31+
hasChatSessionDefinitionProviders: boolean;
32+
provideChatSessionDefinitions(token: CancellationToken): Promise<{ provider: IChatSessionDefinitionProvider; session: IChatSessionDefinition }[]>;
3333
}
3434

3535
export const IChatSessionsService = createDecorator<IChatSessionsService>('chatSessionsService');
3636

3737
export class ChatSessionsService extends Disposable implements IChatSessionsService {
3838
readonly _serviceBrand: undefined;
39-
private _providers: Map<number, IChatSessionsProvider> = new Map();
39+
private _providers: Map<number, IChatSessionDefinitionProvider> = new Map();
4040

4141
constructor(
4242
@ILogService private readonly _logService: ILogService,
4343
) {
4444
super();
4545
}
4646

47-
public async provideChatSessions(token: CancellationToken): Promise<{ provider: IChatSessionsProvider; session: IChatSessionContent }[]> {
48-
const results: { provider: IChatSessionsProvider; session: IChatSessionContent }[] = [];
47+
public async provideChatSessionDefinitions(token: CancellationToken): Promise<{ provider: IChatSessionDefinitionProvider; session: IChatSessionDefinition }[]> {
48+
const results: { provider: IChatSessionDefinitionProvider; session: IChatSessionDefinition }[] = [];
4949

5050
// Iterate through all registered providers and collect their results
5151
for (const [handle, provider] of this._providers) {
5252
try {
53-
if (provider.provideChatSessions) {
54-
const sessions = await provider.provideChatSessions(token);
53+
if (provider.provideChatSessionDefinitions) {
54+
const sessions = await provider.provideChatSessionDefinitions(token);
5555
results.push(...sessions.map(session => ({ provider, session })));
5656
}
5757
} catch (error) {
@@ -65,7 +65,7 @@ export class ChatSessionsService extends Disposable implements IChatSessionsServ
6565
return results;
6666
}
6767

68-
public registerChatSessionsProvider(handle: number, provider: IChatSessionsProvider): IDisposable {
68+
public registerChatSessionDefinitionProvider(handle: number, provider: IChatSessionDefinitionProvider): IDisposable {
6969
this._providers.set(handle, provider);
7070
return {
7171
dispose: () => {
@@ -74,7 +74,7 @@ export class ChatSessionsService extends Disposable implements IChatSessionsServ
7474
};
7575
}
7676

77-
public get hasChatSessionsProviders(): boolean {
77+
public get hasChatSessionDefinitionProviders(): boolean {
7878
return this._providers.size > 0;
7979
}
8080
}

0 commit comments

Comments
 (0)