Skip to content

Commit ad7c7a0

Browse files
Copilotrebornix
andcommitted
Add IHoverService to SessionsRenderer and fix tooltip for two-row items
Co-authored-by: rebornix <876920+rebornix@users.noreply.github.com>
1 parent f01c838 commit ad7c7a0

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
@@ -883,6 +883,7 @@ class SessionsRenderer extends Disposable implements ITreeRenderer<IChatSessionI
883883
@IChatSessionsService private readonly chatSessionsService: IChatSessionsService,
884884
@IMenuService private readonly menuService: IMenuService,
885885
@IContextKeyService private readonly contextKeyService: IContextKeyService,
886+
@IHoverService private readonly hoverService: IHoverService,
886887
@IInstantiationService instantiationService: IInstantiationService,
887888
) {
888889
super();
@@ -1072,6 +1073,15 @@ class SessionsRenderer extends Disposable implements ITreeRenderer<IChatSessionI
10721073
templateData.container.classList.toggle('multiline', false);
10731074
}
10741075

1076+
// Prepare tooltip content
1077+
const tooltipContent = 'tooltip' in session && session.tooltip ?
1078+
(typeof session.tooltip === 'string' ? session.tooltip :
1079+
isMarkdownString(session.tooltip) ? {
1080+
markdown: session.tooltip,
1081+
markdownNotSupportedFallback: session.tooltip.value
1082+
} : undefined) :
1083+
undefined;
1084+
10751085
// Set the resource label
10761086
templateData.resourceLabel.setResource({
10771087
name: session.label,
@@ -1080,15 +1090,23 @@ class SessionsRenderer extends Disposable implements ITreeRenderer<IChatSessionI
10801090
}, {
10811091
fileKind: undefined,
10821092
icon: iconTheme,
1083-
title: 'tooltip' in session && session.tooltip ?
1084-
(typeof session.tooltip === 'string' ? session.tooltip :
1085-
isMarkdownString(session.tooltip) ? {
1086-
markdown: session.tooltip,
1087-
markdownNotSupportedFallback: session.tooltip.value
1088-
} : undefined) :
1089-
undefined
1093+
// Set tooltip on resourceLabel only for single-row items
1094+
title: !renderDescriptionOnSecondRow || !session.description ? tooltipContent : undefined
10901095
});
10911096

1097+
// For two-row items, set tooltip on the container instead
1098+
if (renderDescriptionOnSecondRow && session.description && tooltipContent) {
1099+
if (typeof tooltipContent === 'string') {
1100+
templateData.elementDisposable.add(
1101+
this.hoverService.setupDelayedHover(templateData.container, { content: tooltipContent })
1102+
);
1103+
} else if (tooltipContent && typeof tooltipContent === 'object' && 'markdown' in tooltipContent) {
1104+
templateData.elementDisposable.add(
1105+
this.hoverService.setupDelayedHover(templateData.container, { content: tooltipContent.markdown })
1106+
);
1107+
}
1108+
}
1109+
10921110
// Handle timestamp display and grouping
10931111
const hasTimestamp = sessionWithProvider.timing?.startTime !== undefined;
10941112
if (hasTimestamp) {

0 commit comments

Comments
 (0)