mirror of
https://github.com/microsoft/vscode.git
synced 2025-12-24 20:26:08 +00:00
Support link rendering for description (#263912)
This commit is contained in:
@@ -149,7 +149,7 @@ export class ExtHostChatSessions extends Disposable implements ExtHostChatSessio
|
||||
return {
|
||||
id: sessionContent.id,
|
||||
label: sessionContent.label,
|
||||
description: sessionContent.description,
|
||||
description: sessionContent.description ? typeConvert.MarkdownString.from(sessionContent.description) : undefined,
|
||||
status: this.convertChatSessionStatus(sessionContent.status),
|
||||
tooltip: typeConvert.MarkdownString.fromStrict(sessionContent.tooltip),
|
||||
timing: {
|
||||
|
||||
@@ -78,6 +78,9 @@ import { IChatModel } from '../common/chatModel.js';
|
||||
import { IObservable } from '../../../../base/common/observable.js';
|
||||
import { ChatSessionItemWithProvider, getChatSessionType, isChatSession } from './chatSessions/common.js';
|
||||
import { ChatSessionTracker } from './chatSessions/chatSessionTracker.js';
|
||||
import { MarkdownRenderer } from '../../../../editor/browser/widget/markdownRenderer/browser/markdownRenderer.js';
|
||||
import { allowedChatMarkdownHtmlTags } from './chatMarkdownRenderer.js';
|
||||
import product from '../../../../platform/product/common/product.js';
|
||||
|
||||
export const VIEWLET_ID = 'workbench.view.chat.sessions';
|
||||
|
||||
@@ -868,6 +871,7 @@ interface ISessionTemplateData {
|
||||
class SessionsRenderer extends Disposable implements ITreeRenderer<IChatSessionItem, FuzzyScore, ISessionTemplateData> {
|
||||
static readonly TEMPLATE_ID = 'session';
|
||||
private appliedIconColorStyles = new Set<string>();
|
||||
private markdownRenderer: MarkdownRenderer;
|
||||
|
||||
constructor(
|
||||
private readonly labels: ResourceLabels,
|
||||
@@ -878,6 +882,7 @@ class SessionsRenderer extends Disposable implements ITreeRenderer<IChatSessionI
|
||||
@IChatSessionsService private readonly chatSessionsService: IChatSessionsService,
|
||||
@IMenuService private readonly menuService: IMenuService,
|
||||
@IContextKeyService private readonly contextKeyService: IContextKeyService,
|
||||
@IInstantiationService instantiationService: IInstantiationService,
|
||||
) {
|
||||
super();
|
||||
|
||||
@@ -885,6 +890,8 @@ class SessionsRenderer extends Disposable implements ITreeRenderer<IChatSessionI
|
||||
this._register(this.themeService.onDidColorThemeChange(() => {
|
||||
this.appliedIconColorStyles.clear();
|
||||
}));
|
||||
|
||||
this.markdownRenderer = instantiationService.createInstance(MarkdownRenderer, {});
|
||||
}
|
||||
|
||||
private applyIconColorStyle(iconId: string, colorId: string): void {
|
||||
@@ -1038,10 +1045,26 @@ class SessionsRenderer extends Disposable implements ITreeRenderer<IChatSessionI
|
||||
|
||||
const renderDescriptionOnSecondRow = this.configurationService.getValue(ChatConfiguration.ShowAgentSessionsViewDescription);
|
||||
|
||||
if (renderDescriptionOnSecondRow && typeof session.description === 'string') {
|
||||
if (renderDescriptionOnSecondRow && session.description) {
|
||||
templateData.container.classList.toggle('multiline', true);
|
||||
templateData.descriptionRow.style.display = 'flex';
|
||||
templateData.descriptionLabel.textContent = session.description;
|
||||
if (typeof session.description === 'string') {
|
||||
templateData.descriptionLabel.textContent = session.description;
|
||||
} else {
|
||||
templateData.elementDisposable.add(this.markdownRenderer.render(session.description, {
|
||||
sanitizerConfig: {
|
||||
replaceWithPlaintext: true,
|
||||
allowedTags: {
|
||||
override: allowedChatMarkdownHtmlTags,
|
||||
},
|
||||
allowedLinkSchemes: { augment: [product.urlProtocol] }
|
||||
},
|
||||
}, templateData.descriptionLabel));
|
||||
templateData.elementDisposable.add(DOM.addDisposableListener(templateData.descriptionLabel, 'mousedown', e => e.stopPropagation()));
|
||||
templateData.elementDisposable.add(DOM.addDisposableListener(templateData.descriptionLabel, 'click', e => e.stopPropagation()));
|
||||
templateData.elementDisposable.add(DOM.addDisposableListener(templateData.descriptionLabel, 'auxclick', e => e.stopPropagation()));
|
||||
}
|
||||
|
||||
DOM.clearNode(templateData.statisticsLabel);
|
||||
const insertionNode = append(templateData.statisticsLabel, $('span.insertions'));
|
||||
insertionNode.textContent = session.statistics ? `+${session.statistics.insertions}` : '';
|
||||
|
||||
@@ -79,6 +79,20 @@
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.chat-sessions-tree-container .chat-session-item .description-row p {
|
||||
padding: 2px;
|
||||
margin: 0px;
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
.chat-sessions-tree-container .chat-session-item .description-row a {
|
||||
color: var(--vscode-foreground);
|
||||
}
|
||||
|
||||
.chat-sessions-tree-container .chat-session-item .description-row .description:hover p {
|
||||
background: var(--vscode-toolbar-hoverBackground);
|
||||
}
|
||||
|
||||
.chat-sessions-tree-container .chat-session-item .description-row .description {
|
||||
opacity: 0.5;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user