Skip to content

Commit 4c0c00f

Browse files
authored
fix: preserve icon and full name for chat attachments (microsoft#223549)
* fix: preserve icon and full name for chat attachments * Small refactor
1 parent 04036ba commit 4c0c00f

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

src/vs/workbench/contrib/chat/browser/chatContentParts/chatReferencesContentPart.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ class CollapsibleListRenderer implements IListRenderer<IChatCollapsibleListItem,
250250

251251
renderTemplate(container: HTMLElement): ICollapsibleListTemplate {
252252
const templateDisposables = new DisposableStore();
253-
const label = templateDisposables.add(this.labels.create(container, { supportHighlights: true }));
253+
const label = templateDisposables.add(this.labels.create(container, { supportHighlights: true, supportIcons: true }));
254254
return { templateDisposables, label };
255255
}
256256

@@ -286,7 +286,11 @@ class CollapsibleListRenderer implements IListRenderer<IChatCollapsibleListItem,
286286
}, { icon, title: data.options?.status?.description ?? data.title });
287287
} else {
288288
const variable = this.chatVariablesService.getVariable(reference.variableName);
289-
templateData.label.setLabel(`#${reference.variableName}`, undefined, { title: data.options?.status?.description ?? variable?.description });
289+
// This is a hack to get chat attachment ThemeIcons to render for resource labels
290+
const asThemeIcon = variable?.icon ? `$(${variable.icon.id}) ` : '';
291+
const asVariableName = `#${reference.variableName}`; // Fallback, shouldn't really happen
292+
const label = `${asThemeIcon}${variable?.fullName ?? asVariableName}`;
293+
templateData.label.setLabel(label, asVariableName, { title: data.options?.status?.description ?? variable?.description });
290294
}
291295
} else {
292296
const uri = 'uri' in reference ? reference.uri : reference;

src/vs/workbench/contrib/chat/browser/chatVariables.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ export class ChatVariablesService implements IChatVariablesService {
8080
};
8181
jobs.push(data.resolver(prompt.text, '', model, variableProgressCallback, token).then(value => {
8282
if (value) {
83-
resolvedAttachedContext[i] = { id: data.data.id, modelDescription: data.data.modelDescription, name: attachment.name, range: attachment.range, value, references };
83+
resolvedAttachedContext[i] = { id: data.data.id, modelDescription: data.data.modelDescription, name: attachment.name, fullName: attachment.fullName, range: attachment.range, value, references, icon: attachment.icon };
8484
}
8585
}).catch(onUnexpectedExternalError));
8686
} else if (attachment.isDynamic || attachment.isTool) {

0 commit comments

Comments
 (0)