Skip to content

Commit 9f0d013

Browse files
authored
chat: improve tool truncation styling (microsoft#262177)
* chat: improve tool truncation styling Closes microsoft#261471 * refine
1 parent 715de88 commit 9f0d013

File tree

2 files changed

+24
-10
lines changed

2 files changed

+24
-10
lines changed

src/vs/workbench/contrib/chat/browser/chatContentParts/toolInvocationParts/chatToolConfirmationSubPart.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ import { IChatMarkdownAnchorService } from '../chatMarkdownAnchorService.js';
3636
import { ChatMarkdownContentPart, EditorPool } from '../chatMarkdownContentPart.js';
3737
import { BaseChatToolInvocationSubPart } from './chatToolInvocationSubPart.js';
3838

39-
const SHOW_MORE_MESSAGE_HEIGHT_TRIGGER = 30;
39+
const SHOW_MORE_MESSAGE_HEIGHT_TRIGGER = 45;
4040

4141
export class ToolConfirmationSubPart extends BaseChatToolInvocationSubPart {
4242
public readonly domNode: HTMLElement;
@@ -138,7 +138,9 @@ export class ToolConfirmationSubPart extends BaseChatToolInvocationSubPart {
138138
const elements = dom.h('div', [
139139
dom.h('.message@messageContainer', [
140140
dom.h('.message-wrapper@message'),
141-
dom.h('a.see-more@showMore'),
141+
dom.h('.see-more@showMore', [
142+
dom.h('a', [localize('showMore', "Show More")])
143+
]),
142144
]),
143145
dom.h('.editor@editor'),
144146
dom.h('.disclaimer@disclaimer'),
@@ -257,10 +259,9 @@ export class ToolConfirmationSubPart extends BaseChatToolInvocationSubPart {
257259
}
258260
}
259261

260-
this._makeMarkdownPart(elements.message, message, codeBlockRenderOptions);
261-
elements.showMore.textContent = localize('seeMore', "See more");
262+
const mdPart = this._makeMarkdownPart(elements.message, message, codeBlockRenderOptions);
262263

263-
const messageSeeMoreObserver = this._register(new ElementSizeObserver(elements.message, undefined));
264+
const messageSeeMoreObserver = this._register(new ElementSizeObserver(mdPart.domNode, undefined));
264265
const updateSeeMoreDisplayed = () => {
265266
const show = messageSeeMoreObserver.getHeight() > SHOW_MORE_MESSAGE_HEIGHT_TRIGGER;
266267
if (elements.messageContainer.classList.contains('can-see-more') !== show) {
@@ -360,5 +361,7 @@ export class ToolConfirmationSubPart extends BaseChatToolInvocationSubPart {
360361
container.append(part.domNode);
361362

362363
this._register(part.onDidChangeHeight(() => this._onDidChangeHeight.fire()));
364+
365+
return part;
363366
}
364367
}

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

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -439,16 +439,27 @@
439439

440440
.message .see-more {
441441
display: none;
442-
color: var(--vscode-textLink-foreground);
443-
text-decoration: underline;
444-
cursor: pointer;
442+
position: absolute;
443+
right: 0;
444+
top: 20px;
445+
446+
a {
447+
color: var(--vscode-textLink-foreground);
448+
text-decoration: underline;
449+
cursor: pointer;
450+
}
445451
}
446452

447453
.message.can-see-more {
454+
position: relative;
455+
448456
.message-wrapper {
449-
mask-image: linear-gradient(#000 0%, transparent 100%);
457+
/* This mask fades out the end of the second line of text so the "see more" message can be displayed over it. */
458+
mask-image:
459+
linear-gradient(to right, rgba(0,0,0,1) calc(100% - 95px), rgba(0,0,0,0) calc(100% - 72px)), linear-gradient(to top, rgba(0,0,0,0) 0%, rgba(0,0,0,0) 20px, rgba(0,0,0,1) 2px, rgba(0,0,0,1) 100%);
460+
mask-repeat: no-repeat, no-repeat;
450461
pointer-events: none;
451-
max-height: 2.5em;
462+
max-height: 40px;
452463
}
453464

454465
.see-more {

0 commit comments

Comments
 (0)