Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions src/vs/workbench/contrib/chat/browser/chatEditorInput.ts
Original file line number Diff line number Diff line change
Expand Up @@ -206,12 +206,6 @@ export class ChatEditorInput extends EditorInput implements IEditorCloseHandler
}

override getIcon(): ThemeIcon | URI | undefined {
// Return cached icon if available
if (this.cachedIcon) {
return this.cachedIcon;
}

// Try to resolve icon and cache it
const resolvedIcon = this.resolveIcon();
if (resolvedIcon) {
this.cachedIcon = resolvedIcon;
Expand Down
48 changes: 42 additions & 6 deletions src/vs/workbench/contrib/chat/browser/chatSessions.contribution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ import { ContextKeyExpr, IContextKeyService } from '../../../../platform/context
import { InstantiationType, registerSingleton } from '../../../../platform/instantiation/common/extensions.js';
import { ServicesAccessor } from '../../../../platform/instantiation/common/instantiation.js';
import { ILogService } from '../../../../platform/log/common/log.js';
import { isDark } from '../../../../platform/theme/common/theme.js';
import { IThemeService } from '../../../../platform/theme/common/themeService.js';
import { IEditableData } from '../../../common/views.js';
import { IEditorService } from '../../../services/editor/common/editorService.js';
import { IExtensionService, isProposedApiEnabled } from '../../../services/extensions/common/extensions.js';
Expand Down Expand Up @@ -64,7 +66,22 @@ const extensionPoint = ExtensionsRegistry.registerExtensionPoint<IChatSessionsEx
},
icon: {
description: localize('chatSessionsExtPoint.icon', 'Icon identifier (codicon ID) for the chat session editor tab. For example, "$(github)" or "$(cloud)".'),
type: 'string'
anyOf: [{
type: 'string'
},
{
type: 'object',
properties: {
light: {
description: localize('icon.light', 'Icon path when a light theme is used'),
type: 'string'
},
dark: {
description: localize('icon.dark', 'Icon path when a dark theme is used'),
type: 'string'
}
}
}]
},
order: {
description: localize('chatSessionsExtPoint.order', 'Order in which this item should be displayed.'),
Expand Down Expand Up @@ -234,7 +251,7 @@ export class ChatSessionsService extends Disposable implements IChatSessionsServ

private readonly inProgressMap: Map<string, number> = new Map();
private readonly _sessionTypeOptions: Map<string, IChatSessionProviderOptionGroup[]> = new Map();
private readonly _sessionTypeIcons: Map<string, ThemeIcon | URI> = new Map();
private readonly _sessionTypeIcons: Map<string, ThemeIcon | { light: URI; dark: URI }> = new Map();
private readonly _sessionTypeWelcomeTitles: Map<string, string> = new Map();
private readonly _sessionTypeWelcomeMessages: Map<string, string> = new Map();
private readonly _sessionTypeWelcomeTips: Map<string, string> = new Map();
Expand All @@ -250,6 +267,7 @@ export class ChatSessionsService extends Disposable implements IChatSessionsServ
@IContextKeyService private readonly _contextKeyService: IContextKeyService,
@IMenuService private readonly _menuService: IMenuService,
@IConfigurationService private readonly _configurationService: IConfigurationService,
@IThemeService private readonly _themeService: IThemeService
) {
super();
this._register(extensionPoint.setHandler(extensions => {
Expand Down Expand Up @@ -357,12 +375,20 @@ export class ChatSessionsService extends Disposable implements IChatSessionsServ
}

// Store icon mapping if provided
let icon: ThemeIcon | URI | undefined;
let icon: ThemeIcon | { dark: URI; light: URI } | undefined;

if (contribution.icon) {
// Parse icon string - support ThemeIcon format or file path from extension
const themeIcon = ThemeIcon.fromString(contribution.icon);
icon = themeIcon || resources.joinPath(contribution.extensionDescription.extensionLocation, contribution.icon);
if (typeof contribution.icon === 'string') {
icon = contribution.icon.startsWith('$(') && contribution.icon.endsWith(')')
? ThemeIcon.fromString(contribution.icon)
: ThemeIcon.fromId(contribution.icon);
} else {
icon = {
dark: resources.joinPath(contribution.extensionDescription.extensionLocation, contribution.icon.dark),
light: resources.joinPath(contribution.extensionDescription.extensionLocation, contribution.icon.light)
};
}
}

if (icon) {
Expand Down Expand Up @@ -880,7 +906,17 @@ export class ChatSessionsService extends Disposable implements IChatSessionsServ
* Get the icon for a specific session type
*/
public getIconForSessionType(chatSessionType: string): ThemeIcon | URI | undefined {
return this._sessionTypeIcons.get(chatSessionType);
const sessionTypeIcon = this._sessionTypeIcons.get(chatSessionType);

if (ThemeIcon.isThemeIcon(sessionTypeIcon)) {
return sessionTypeIcon;
}

if (isDark(this._themeService.getColorTheme().type)) {
return sessionTypeIcon?.dark;
} else {
return sessionTypeIcon?.light;
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export interface IChatSessionsExtensionPoint {
readonly description: string;
readonly extensionDescription: IRelaxedExtensionDescription;
readonly when?: string;
readonly icon?: string;
readonly icon?: string | { light: string; dark: string };
readonly order?: number;
readonly alternativeIds?: string[];
readonly welcomeTitle?: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export class MockChatSessionsService implements IChatSessionsService {

getIconForSessionType(chatSessionType: string): ThemeIcon | URI | undefined {
const contribution = this.contributions.find(c => c.type === chatSessionType);
return contribution?.icon ? ThemeIcon.fromId(contribution.icon) : undefined;
return contribution?.icon && typeof contribution.icon === 'string' ? ThemeIcon.fromId(contribution.icon) : undefined;
}

getWelcomeTitleForSessionType(chatSessionType: string): string | undefined {
Expand Down
Loading