Skip to content

Commit 275faf6

Browse files
authored
slash command pill: use btn for rerun, better hover (#234854)
1 parent 025439d commit 275faf6

File tree

2 files changed

+29
-13
lines changed

2 files changed

+29
-13
lines changed

src/vs/workbench/contrib/chat/browser/chatContentParts/chatAgentCommandContentPart.ts

+14-7
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,17 @@
44
*--------------------------------------------------------------------------------------------*/
55

66

7-
import { getDefaultHoverDelegate } from '../../../../../base/browser/ui/hover/hoverDelegateFactory.js';
87
import { Disposable } from '../../../../../base/common/lifecycle.js';
98
import { IHoverService } from '../../../../../platform/hover/browser/hover.js';
109
import { IChatAgentCommand } from '../../common/chatAgents.js';
1110
import { chatSubcommandLeader } from '../../common/chatParserTypes.js';
1211
import { IChatRendererContent } from '../../common/chatViewModel.js';
1312
import { ChatTreeItem } from '../chat.js';
1413
import { IChatContentPart } from './chatContentParts.js';
15-
import { renderIcon } from '../../../../../base/browser/ui/iconLabel/iconLabels.js';
1614
import { Codicon } from '../../../../../base/common/codicons.js';
17-
import { addDisposableListener } from '../../../../../base/browser/dom.js';
1815
import { localize } from '../../../../../nls.js';
16+
import { Button } from '../../../../../base/browser/ui/button/button.js';
17+
import { generateUuid } from '../../../../../base/common/uuid.js';
1918

2019

2120
export class ChatAgentCommandContentPart extends Disposable implements IChatContentPart {
@@ -28,15 +27,23 @@ export class ChatAgentCommandContentPart extends Disposable implements IChatCont
2827
@IHoverService private readonly _hoverService: IHoverService,
2928
) {
3029
super();
31-
this._store.add(this._hoverService.setupManagedHover(getDefaultHoverDelegate('element'), this.domNode, localize('rerun', "Detected command. Select to rerun without {0}{1}", chatSubcommandLeader, cmd.name)));
3230
this.domNode.classList.add('chat-agent-command');
33-
this.domNode.innerText = chatSubcommandLeader + cmd.name;
3431
this.domNode.setAttribute('aria-label', cmd.name);
3532
this.domNode.setAttribute('role', 'button');
3633

37-
this.domNode.appendChild(renderIcon(Codicon.close));
34+
const groupId = generateUuid();
3835

39-
this._store.add(addDisposableListener(this.domNode, 'click', onClick));
36+
const commandSpan = document.createElement('span');
37+
this.domNode.appendChild(commandSpan);
38+
commandSpan.innerText = chatSubcommandLeader + cmd.name;
39+
this._store.add(this._hoverService.setupDelayedHover(commandSpan, { content: cmd.description, appearance: { showPointer: true } }, { groupId }));
40+
41+
const rerun = localize('rerun', "Rerun without {0}{1}", chatSubcommandLeader, cmd.name);
42+
const btn = new Button(this.domNode, { ariaLabel: rerun });
43+
btn.icon = Codicon.close;
44+
btn.onDidClick(() => onClick());
45+
this._store.add(btn);
46+
this._store.add(this._hoverService.setupDelayedHover(btn.element, { content: rerun, appearance: { showPointer: true } }, { groupId }));
4047
}
4148

4249
hasSameContent(other: IChatRendererContent, followingContent: IChatRendererContent[], element: ChatTreeItem): boolean {

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

+15-6
Original file line numberDiff line numberDiff line change
@@ -1124,7 +1124,6 @@ have to be updated for changes to the rules above, or to support more deeply nes
11241124
}
11251125

11261126

1127-
.interactive-item-container .chat-agent-command,
11281127
.interactive-item-container .chat-resource-widget,
11291128
.interactive-item-container .chat-agent-widget .monaco-button {
11301129
border-radius: 4px;
@@ -1134,16 +1133,26 @@ have to be updated for changes to the rules above, or to support more deeply nes
11341133
.interactive-item-container .chat-agent-command {
11351134
background-color: var(--vscode-chat-slashCommandBackground);
11361135
color: var(--vscode-chat-slashCommandForeground);
1137-
cursor: pointer;
11381136
display: inline-flex;
11391137
align-items: center;
11401138
margin-right: 0.5ch;
1141-
padding: 1px 1px 1px 3px;
1139+
border-radius: 4px;
1140+
padding: 0 0 0 3px;
11421141
}
11431142

1144-
.interactive-item-container .chat-agent-command > .codicon[class*='codicon-'] {
1145-
color: var(--vscode-chat-slashCommandForeground);
1146-
font-size: 14px;
1143+
.interactive-item-container .chat-agent-command > .monaco-button {
1144+
display: flex;
1145+
align-self: stretch;
1146+
align-items: center;
1147+
cursor: pointer;
1148+
padding: 0 2px;
1149+
margin-left: 2px;
1150+
border-top-right-radius: 4px;
1151+
border-bottom-right-radius: 4px;
1152+
}
1153+
1154+
.interactive-item-container .chat-agent-command > .monaco-button:hover {
1155+
background: var(--vscode-toolbar-hoverBackground);
11471156
}
11481157

11491158
.interactive-item-container .chat-agent-widget .monaco-text-button {

0 commit comments

Comments
 (0)