Skip to content

Commit 6334cf0

Browse files
authored
chat: feat: allow rendering links as links (#288142)
1 parent 5ebbcae commit 6334cf0

File tree

4 files changed

+51
-0
lines changed

4 files changed

+51
-0
lines changed

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,16 @@ configurationRegistry.registerConfiguration({
262262
description: nls.localize('chat.renderRelatedFiles', "Controls whether related files should be rendered in the chat input."),
263263
default: false
264264
},
265+
[ChatConfiguration.InlineReferencesStyle]: {
266+
type: 'string',
267+
enum: ['box', 'link'],
268+
enumDescriptions: [
269+
nls.localize('chat.inlineReferences.style.box', "Display file and symbol references as boxed widgets with icons."),
270+
nls.localize('chat.inlineReferences.style.link', "Display file and symbol references as simple blue links without icons.")
271+
],
272+
description: nls.localize('chat.inlineReferences.style', "Controls how file and symbol references are displayed in chat messages."),
273+
default: 'box'
274+
},
265275
'chat.notifyWindowOnConfirmation': {
266276
type: 'boolean',
267277
description: nls.localize('chat.notifyWindowOnConfirmation', "Controls whether a chat session should present the user with an OS notification when a confirmation is needed while the window is not in focus. This includes a window badge as well as notification toast."),

src/vs/workbench/contrib/chat/browser/widget/chatContentParts/chatInlineAnchorWidget.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ import { IChatContentInlineReference } from '../../../common/chatService/chatSer
4444
import { IChatWidgetService } from '../../chat.js';
4545
import { chatAttachmentResourceContextKey, hookUpSymbolAttachmentDragAndContextMenu } from '../../attachments/chatAttachmentWidgets.js';
4646
import { IChatMarkdownAnchorService } from './chatMarkdownAnchorService.js';
47+
import { IConfigurationService } from '../../../../../../platform/configuration/common/configuration.js';
48+
import { ChatConfiguration } from '../../../common/constants.js';
4749

4850
type ContentRefData =
4951
| { readonly kind: 'symbol'; readonly symbol: IWorkspaceSymbol }
@@ -113,6 +115,7 @@ export class InlineAnchorWidget extends Disposable {
113115
private readonly element: HTMLAnchorElement | HTMLElement,
114116
public readonly inlineReference: IChatContentInlineReference,
115117
private readonly metadata: InlineAnchorWidgetMetadata | undefined,
118+
@IConfigurationService private readonly configurationService: IConfigurationService,
116119
@IContextKeyService originalContextKeyService: IContextKeyService,
117120
@IContextMenuService contextMenuService: IContextMenuService,
118121
@IFileService fileService: IFileService,
@@ -248,6 +251,14 @@ export class InlineAnchorWidget extends Disposable {
248251
const relativeLabel = labelService.getUriLabel(location.uri, { relative: true });
249252
this._register(hoverService.setupManagedHover(getDefaultHoverDelegate('element'), element, relativeLabel));
250253

254+
// Apply link-style if configured
255+
this.updateAppearance();
256+
this._register(this.configurationService.onDidChangeConfiguration(e => {
257+
if (e.affectsConfiguration(ChatConfiguration.InlineReferencesStyle)) {
258+
this.updateAppearance();
259+
}
260+
}));
261+
251262
// Drag and drop
252263
if (this.data.kind !== 'symbol') {
253264
element.draggable = true;
@@ -268,6 +279,12 @@ export class InlineAnchorWidget extends Disposable {
268279
return this.element;
269280
}
270281

282+
private updateAppearance(): void {
283+
const style = this.configurationService.getValue<string>(ChatConfiguration.InlineReferencesStyle);
284+
const useLinkStyle = style === 'link';
285+
this.element.classList.toggle('link-style', useLinkStyle);
286+
}
287+
271288
private getCellIndex(location: URI) {
272289
const notebook = this.notebookDocumentService.getNotebook(location);
273290
const index = notebook?.getCellIndex(location) ?? -1;

src/vs/workbench/contrib/chat/browser/widget/chatContentParts/media/chatInlineAnchorWidget.css

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,3 +59,26 @@
5959

6060
flex-shrink: 0;
6161
}
62+
63+
/* Link-style appearance - no box, no icon */
64+
.chat-inline-anchor-widget.link-style,
65+
.interactive-item-container .value .rendered-markdown .chat-inline-anchor-widget.link-style {
66+
border: none;
67+
background-color: transparent;
68+
padding: 0;
69+
margin: 0;
70+
color: var(--vscode-textLink-foreground);
71+
}
72+
73+
.chat-inline-anchor-widget.link-style:hover {
74+
background-color: transparent;
75+
text-decoration: underline;
76+
}
77+
78+
.chat-inline-anchor-widget.link-style .icon {
79+
display: none;
80+
}
81+
82+
.chat-inline-anchor-widget.link-style .icon-label {
83+
padding: 0;
84+
}

src/vs/workbench/contrib/chat/common/constants.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ export enum ChatConfiguration {
1616
ExtensionToolsEnabled = 'chat.extensionTools.enabled',
1717
RepoInfoEnabled = 'chat.repoInfo.enabled',
1818
EditRequests = 'chat.editRequests',
19+
InlineReferencesStyle = 'chat.inlineReferences.style',
1920
GlobalAutoApprove = 'chat.tools.global.autoApprove',
2021
AutoApproveEdits = 'chat.tools.edits.autoApprove',
2122
AutoApprovedUrls = 'chat.tools.urls.autoApprove',

0 commit comments

Comments
 (0)