Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/src/vs/workbench/contrib/chat/browser/aiCustomization/embeddedAgentPluginDetail.ts
13406 views
1
/*---------------------------------------------------------------------------------------------
2
* Copyright (c) Microsoft Corporation. All rights reserved.
3
* Licensed under the MIT License. See License.txt in the project root for license information.
4
*--------------------------------------------------------------------------------------------*/
5
6
import * as DOM from '../../../../../base/browser/dom.js';
7
import { Disposable } from '../../../../../base/common/lifecycle.js';
8
import { localize } from '../../../../../nls.js';
9
import { AgentPluginItemKind, IAgentPluginItem } from '../agentPluginEditor/agentPluginItems.js';
10
import { extensionIcon, pluginIcon } from './aiCustomizationIcons.js';
11
12
const $ = DOM.$;
13
14
/**
15
* Compact detail view for an agent plugin inside the AI Customizations management editor's
16
* split-pane host. Renders identity (icon + name + source) and description.
17
*
18
* Advanced actions (enable / disable / uninstall) remain accessible via the row's existing
19
* context menu, so this component intentionally stays small.
20
*/
21
export class EmbeddedAgentPluginDetail extends Disposable {
22
23
private readonly root: HTMLElement;
24
private readonly iconEl: HTMLElement;
25
private readonly nameEl: HTMLElement;
26
private readonly sourceEl: HTMLElement;
27
private readonly descriptionEl: HTMLElement;
28
private readonly emptyEl: HTMLElement;
29
30
private current: IAgentPluginItem | undefined;
31
32
constructor(
33
parent: HTMLElement,
34
) {
35
super();
36
37
this.root = DOM.append(parent, $('.ai-customization-embedded-detail.embedded-plugin-detail'));
38
39
const header = DOM.append(this.root, $('.embedded-detail-header'));
40
this.iconEl = DOM.append(header, $('.embedded-detail-icon'));
41
const headerText = DOM.append(header, $('.embedded-detail-header-text'));
42
this.nameEl = DOM.append(headerText, $('h2.embedded-detail-name'));
43
this.nameEl.setAttribute('role', 'heading');
44
this.sourceEl = DOM.append(headerText, $('.embedded-detail-scope'));
45
46
this.descriptionEl = DOM.append(this.root, $('.embedded-detail-description'));
47
48
this.emptyEl = DOM.append(this.root, $('.embedded-detail-empty'));
49
this.emptyEl.textContent = localize('pluginDetailEmpty', "No plugin selected.");
50
51
this.renderItem();
52
}
53
54
get element(): HTMLElement {
55
return this.root;
56
}
57
58
setInput(item: IAgentPluginItem): void {
59
this.current = item;
60
this.renderItem();
61
}
62
63
clearInput(): void {
64
this.current = undefined;
65
this.renderItem();
66
}
67
68
private renderItem(): void {
69
const item = this.current;
70
const hasItem = !!item;
71
this.emptyEl.style.display = hasItem ? 'none' : '';
72
this.root.classList.toggle('is-empty', !hasItem);
73
if (!item) {
74
this.nameEl.textContent = '';
75
this.sourceEl.textContent = '';
76
this.descriptionEl.textContent = '';
77
this.iconEl.className = 'embedded-detail-icon';
78
return;
79
}
80
81
this.nameEl.textContent = item.name;
82
83
const isMarketplace = item.kind === AgentPluginItemKind.Marketplace;
84
const iconId = isMarketplace ? extensionIcon.id : pluginIcon.id;
85
this.iconEl.className = `embedded-detail-icon codicon codicon-${iconId}`;
86
87
const sourceLabel = item.marketplace
88
? (isMarketplace
89
? localize('pluginSourceMarketplace', "From {0}", item.marketplace)
90
: localize('pluginSourceInstalled', "Installed from {0}", item.marketplace))
91
: (isMarketplace
92
? localize('pluginSourceMarketplaceUnknown', "Marketplace plugin")
93
: localize('pluginSourceLocal', "Installed plugin"));
94
const iconSpan = $(`span.codicon.codicon-${iconId}`);
95
this.sourceEl.replaceChildren(iconSpan, document.createTextNode(' ' + sourceLabel));
96
97
const description = (item.description || '').trim();
98
this.descriptionEl.textContent = description;
99
this.descriptionEl.style.display = description ? '' : 'none';
100
}
101
}
102
103