Skip to content

Commit c7c2253

Browse files
committed
Provider API fixes
1 parent cc907b8 commit c7c2253

File tree

3 files changed

+41
-5
lines changed

3 files changed

+41
-5
lines changed

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

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
import { CancellationToken } from '../../../base/common/cancellation.js';
77
import { Disposable, DisposableMap } from '../../../base/common/lifecycle.js';
8+
import { URI, UriComponents } from '../../../base/common/uri.js';
89
import { ILogService } from '../../../platform/log/common/log.js';
910
import { IChatSessionContent, IChatSessionsProvider, IChatSessionsService } from '../../contrib/chat/common/chatSessionsService.js';
1011
import { extHostNamedCustomer, IExtHostContext } from '../../services/extensions/common/extHostCustomers.js';
@@ -35,7 +36,12 @@ export class MainThreadChatSessions extends Disposable implements MainThreadChat
3536

3637
try {
3738
// Get all results as an array from the RPC call
38-
return await proxy.$provideChatSessions(handle, token);
39+
const sessions = await proxy.$provideChatSessions(handle, token);
40+
return sessions.map(session => ({
41+
...session,
42+
uri: URI.revive(session.uri),
43+
iconPath: session.iconPath ? this._reviveIconPath(session.iconPath) : undefined
44+
}));
3945
} catch (error) {
4046
this._logService.error('Error providing chat sessions:', error);
4147
}
@@ -45,4 +51,27 @@ export class MainThreadChatSessions extends Disposable implements MainThreadChat
4551
$unregisterChatSessionsProvider(handle: number): void {
4652
this._registrations.deleteAndDispose(handle);
4753
}
54+
55+
56+
private _reviveIconPath(
57+
iconPath: UriComponents | { light: UriComponents; dark: UriComponents } | { id: string; color?: { id: string } | undefined })
58+
: IChatSessionContent['iconPath'] {
59+
if (!iconPath) {
60+
return undefined;
61+
}
62+
63+
// Handle ThemeIcon (has id property)
64+
if (typeof iconPath === 'object' && 'id' in iconPath) {
65+
return iconPath; // ThemeIcon doesn't need conversion
66+
}
67+
68+
// Handle light/dark theme icons
69+
if (typeof iconPath === 'object' && ('light' in iconPath && 'dark' in iconPath)) {
70+
return {
71+
light: URI.revive(iconPath.light),
72+
dark: URI.revive(iconPath.dark)
73+
};
74+
}
75+
return undefined;
76+
}
4877
}

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

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,16 @@ import { CancellationToken } from '../../../../base/common/cancellation.js';
88
import { ILogService } from '../../../../platform/log/common/log.js';
99
import { createDecorator } from '../../../../platform/instantiation/common/instantiation.js';
1010
import { InstantiationType, registerSingleton } from '../../../../platform/instantiation/common/extensions.js';
11-
import { IconPath } from '../../../../editor/common/languages.js';
12-
import { UriComponents } from '../../../../base/common/uri.js';
11+
import { URI } from '../../../../base/common/uri.js';
12+
import { ThemeIcon } from '../../../../base/common/themables.js';
1313

1414
export interface IChatSessionContent {
15-
uri: UriComponents;
15+
uri: URI;
1616
label: string;
17-
iconPath?: IconPath;
17+
iconPath?: URI | {
18+
light: URI;
19+
dark: URI;
20+
} | ThemeIcon;
1821
}
1922

2023
export interface IChatSessionsProvider {

src/vscode-dts/vscode.proposed.chatSessionsProvider.d.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ declare module 'vscode' {
88
* Provides a list of chat sessions
99
*/
1010
export interface ChatSessionsProvider extends Disposable {
11+
/**
12+
* Type to identify providers.
13+
*/
14+
readonly chatSessionType: string;
1115

1216
/**
1317
* Fired when chat sessions change.

0 commit comments

Comments
 (0)