Skip to content

Commit b756398

Browse files
authored
Merge pull request microsoft#264614 from microsoft/copilot/fix-a8c23d1f-2ff8-4ff6-9355-26cfe80c6713
Fix tooltip display for two-row chat session items
2 parents 8f7a63f + ad7c7a0 commit b756398

1 file changed

Lines changed: 25 additions & 7 deletions

File tree

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

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -921,6 +921,7 @@ class SessionsRenderer extends Disposable implements ITreeRenderer<IChatSessionI
921921
@IChatSessionsService private readonly chatSessionsService: IChatSessionsService,
922922
@IMenuService private readonly menuService: IMenuService,
923923
@IContextKeyService private readonly contextKeyService: IContextKeyService,
924+
@IHoverService private readonly hoverService: IHoverService,
924925
@IInstantiationService instantiationService: IInstantiationService,
925926
@IChatWidgetService private readonly chatWidgetService: IChatWidgetService,
926927
@IChatService private readonly chatService: IChatService,
@@ -1111,6 +1112,15 @@ class SessionsRenderer extends Disposable implements ITreeRenderer<IChatSessionI
11111112
templateData.container.classList.toggle('multiline', false);
11121113
}
11131114

1115+
// Prepare tooltip content
1116+
const tooltipContent = 'tooltip' in session && session.tooltip ?
1117+
(typeof session.tooltip === 'string' ? session.tooltip :
1118+
isMarkdownString(session.tooltip) ? {
1119+
markdown: session.tooltip,
1120+
markdownNotSupportedFallback: session.tooltip.value
1121+
} : undefined) :
1122+
undefined;
1123+
11141124
// Set the resource label
11151125
templateData.resourceLabel.setResource({
11161126
name: session.label,
@@ -1119,15 +1129,23 @@ class SessionsRenderer extends Disposable implements ITreeRenderer<IChatSessionI
11191129
}, {
11201130
fileKind: undefined,
11211131
icon: iconTheme,
1122-
title: 'tooltip' in session && session.tooltip ?
1123-
(typeof session.tooltip === 'string' ? session.tooltip :
1124-
isMarkdownString(session.tooltip) ? {
1125-
markdown: session.tooltip,
1126-
markdownNotSupportedFallback: session.tooltip.value
1127-
} : undefined) :
1128-
undefined
1132+
// Set tooltip on resourceLabel only for single-row items
1133+
title: !renderDescriptionOnSecondRow || !session.description ? tooltipContent : undefined
11291134
});
11301135

1136+
// For two-row items, set tooltip on the container instead
1137+
if (renderDescriptionOnSecondRow && session.description && tooltipContent) {
1138+
if (typeof tooltipContent === 'string') {
1139+
templateData.elementDisposable.add(
1140+
this.hoverService.setupDelayedHover(templateData.container, { content: tooltipContent })
1141+
);
1142+
} else if (tooltipContent && typeof tooltipContent === 'object' && 'markdown' in tooltipContent) {
1143+
templateData.elementDisposable.add(
1144+
this.hoverService.setupDelayedHover(templateData.container, { content: tooltipContent.markdown })
1145+
);
1146+
}
1147+
}
1148+
11311149
// Handle timestamp display and grouping
11321150
const hasTimestamp = sessionWithProvider.timing?.startTime !== undefined;
11331151
if (hasTimestamp) {

0 commit comments

Comments
 (0)