Skip to content

Commit 1e1bd82

Browse files
committed
pivot to element visibility approach
1 parent d8756ae commit 1e1bd82

File tree

2 files changed

+49
-30
lines changed

2 files changed

+49
-30
lines changed

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

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2824,6 +2824,7 @@ export class ChatWidget extends Disposable implements IChatWidget {
28242824
welcomeOffset = Math.max(welcomeOffset - this.input.attachmentsHeight, 0);
28252825
this.welcomeMessageContainer.style.height = `${contentHeight - welcomeOffset}px`;
28262826
this.welcomeMessageContainer.style.paddingBottom = `${welcomeOffset}px`;
2827+
this.updateWelcomeElementVisibility(contentHeight - welcomeOffset);
28272828

28282829
this.renderer.layout(width);
28292830

@@ -2836,6 +2837,54 @@ export class ChatWidget extends Disposable implements IChatWidget {
28362837
this._onDidChangeHeight.fire(height);
28372838
}
28382839

2840+
private updateWelcomeElementVisibility(availableHeight: number): void {
2841+
const container = this.welcomeMessageContainer;
2842+
if (!container || container.offsetHeight === 0) {
2843+
return;
2844+
}
2845+
2846+
const suggestedPrompts = container.querySelector<HTMLElement>('.chat-welcome-view-suggested-prompts');
2847+
if (!suggestedPrompts) {
2848+
return;
2849+
}
2850+
2851+
if (this.container.classList.contains('new-welcome-view')) {
2852+
return;
2853+
}
2854+
2855+
const selectors = [
2856+
'.chat-welcome-history-root',
2857+
'.chat-welcome-view-message',
2858+
'.chat-welcome-view-disclaimer',
2859+
'.chat-welcome-view-title',
2860+
'.chat-welcome-view-icon'
2861+
];
2862+
2863+
const elements = selectors
2864+
.map(sel => container.querySelector<HTMLElement>(sel))
2865+
.filter((el): el is HTMLElement => el !== null);
2866+
2867+
elements.forEach(el => {
2868+
if (el.style.display === 'none') {
2869+
el.style.display = '';
2870+
}
2871+
});
2872+
2873+
const suggestedPromptsHeight = suggestedPrompts.offsetHeight;
2874+
const adjustedAvailableHeight = availableHeight - suggestedPromptsHeight;
2875+
2876+
let totalHeight = 0;
2877+
for (const elem of elements) {
2878+
if (elem.style.display !== 'none') {
2879+
totalHeight += elem.offsetHeight;
2880+
if (totalHeight > adjustedAvailableHeight) {
2881+
elem.style.display = 'none';
2882+
totalHeight -= elem.offsetHeight;
2883+
}
2884+
}
2885+
}
2886+
}
2887+
28392888
private _dynamicMessageLayoutData?: { numOfMessages: number; maxHeight: number; enabled: boolean };
28402889

28412890
// An alternative to layout, this allows you to specify the number of ChatTreeItems

src/vs/workbench/contrib/chat/browser/media/chatViewWelcome.css

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -395,33 +395,3 @@ div.chat-welcome-view {
395395
word-wrap: break-word;
396396
}
397397

398-
/* Responsive fallbacks to avoid overlapping welcome content */
399-
400-
.interactive-session:not(.new-welcome-view):not(:has(.chat-welcome-view-icon .codicon-send-to-remote-agent)) {
401-
.chat-welcome-view-container:has(.chat-welcome-view-suggested-prompts > .chat-welcome-view-suggested-prompt:nth-of-type(2)) {
402-
@media (max-height: 760px), (max-width: 620px) {
403-
div.chat-welcome-view > .chat-welcome-view-title { display: none; }
404-
}
405-
406-
@media (max-height: 720px), (max-width: 580px) {
407-
div.chat-welcome-view > .chat-welcome-view-icon { display: none; }
408-
}
409-
410-
@media (max-height: 680px), (max-width: 540px) {
411-
div.chat-welcome-view > .chat-welcome-view-disclaimer { display: none; }
412-
}
413-
414-
@media (max-height: 640px), (max-width: 500px) {
415-
div.chat-welcome-view > :is(
416-
.chat-welcome-view-message,
417-
.chat-welcome-new-view-message,
418-
.chat-welcome-view-additional-message
419-
) { display: none; }
420-
}
421-
422-
@media (max-height: 520px), (max-width: 360px) {
423-
> .chat-welcome-history-root { display: none; }
424-
}
425-
}
426-
}
427-

0 commit comments

Comments
 (0)