@theia/ai-core-ui 1.75.0-next.8 → 1.75.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/browser/ai-configuration/ai-configuration-category-registry.d.ts +29 -0
- package/lib/browser/ai-configuration/ai-configuration-category-registry.d.ts.map +1 -0
- package/lib/browser/ai-configuration/ai-configuration-category-registry.js +83 -0
- package/lib/browser/ai-configuration/ai-configuration-category-registry.js.map +1 -0
- package/lib/browser/ai-configuration/ai-configuration-category-registry.spec.d.ts +2 -0
- package/lib/browser/ai-configuration/ai-configuration-category-registry.spec.d.ts.map +1 -0
- package/lib/browser/ai-configuration/ai-configuration-category-registry.spec.js +122 -0
- package/lib/browser/ai-configuration/ai-configuration-category-registry.spec.js.map +1 -0
- package/lib/browser/ai-configuration/ai-configuration-category.d.ts +204 -0
- package/lib/browser/ai-configuration/ai-configuration-category.d.ts.map +1 -0
- package/lib/browser/ai-configuration/ai-configuration-category.js +86 -0
- package/lib/browser/ai-configuration/ai-configuration-category.js.map +1 -0
- package/lib/browser/ai-configuration/ai-configuration-selection-model.d.ts +15 -0
- package/lib/browser/ai-configuration/ai-configuration-selection-model.d.ts.map +1 -0
- package/lib/browser/ai-configuration/ai-configuration-selection-model.js +44 -0
- package/lib/browser/ai-configuration/ai-configuration-selection-model.js.map +1 -0
- package/lib/browser/ai-configuration/ai-configuration-setting-commands.d.ts +48 -0
- package/lib/browser/ai-configuration/ai-configuration-setting-commands.d.ts.map +1 -0
- package/lib/browser/ai-configuration/ai-configuration-setting-commands.js +98 -0
- package/lib/browser/ai-configuration/ai-configuration-setting-commands.js.map +1 -0
- package/lib/browser/ai-configuration/ai-configuration-setting-commands.spec.d.ts +2 -0
- package/lib/browser/ai-configuration/ai-configuration-setting-commands.spec.d.ts.map +1 -0
- package/lib/browser/ai-configuration/ai-configuration-setting-commands.spec.js +70 -0
- package/lib/browser/ai-configuration/ai-configuration-setting-commands.spec.js.map +1 -0
- package/lib/browser/ai-configuration/components/ai-configuration-components.spec.d.ts +2 -0
- package/lib/browser/ai-configuration/components/ai-configuration-components.spec.d.ts.map +1 -0
- package/lib/browser/ai-configuration/components/ai-configuration-components.spec.js +596 -0
- package/lib/browser/ai-configuration/components/ai-configuration-components.spec.js.map +1 -0
- package/lib/browser/ai-configuration/components/ai-configuration-controls.d.ts +118 -0
- package/lib/browser/ai-configuration/components/ai-configuration-controls.d.ts.map +1 -0
- package/lib/browser/ai-configuration/components/ai-configuration-controls.js +191 -0
- package/lib/browser/ai-configuration/components/ai-configuration-controls.js.map +1 -0
- package/lib/browser/ai-configuration/components/ai-configuration-item-row.d.ts +57 -0
- package/lib/browser/ai-configuration/components/ai-configuration-item-row.d.ts.map +1 -0
- package/lib/browser/ai-configuration/components/ai-configuration-item-row.js +48 -0
- package/lib/browser/ai-configuration/components/ai-configuration-item-row.js.map +1 -0
- package/lib/browser/ai-configuration/components/ai-configuration-origin-badge.d.ts +49 -0
- package/lib/browser/ai-configuration/components/ai-configuration-origin-badge.d.ts.map +1 -0
- package/lib/browser/ai-configuration/components/ai-configuration-origin-badge.js +79 -0
- package/lib/browser/ai-configuration/components/ai-configuration-origin-badge.js.map +1 -0
- package/lib/browser/ai-configuration/components/ai-configuration-primitives.d.ts +161 -0
- package/lib/browser/ai-configuration/components/ai-configuration-primitives.d.ts.map +1 -0
- package/lib/browser/ai-configuration/components/ai-configuration-primitives.js +131 -0
- package/lib/browser/ai-configuration/components/ai-configuration-primitives.js.map +1 -0
- package/lib/browser/ai-configuration/components/ai-configuration-setting-row.d.ts +54 -0
- package/lib/browser/ai-configuration/components/ai-configuration-setting-row.d.ts.map +1 -0
- package/lib/browser/ai-configuration/components/ai-configuration-setting-row.js +77 -0
- package/lib/browser/ai-configuration/components/ai-configuration-setting-row.js.map +1 -0
- package/lib/browser/ai-configuration/components/ai-settings-row-service.d.ts +194 -0
- package/lib/browser/ai-configuration/components/ai-settings-row-service.d.ts.map +1 -0
- package/lib/browser/ai-configuration/components/ai-settings-row-service.js +352 -0
- package/lib/browser/ai-configuration/components/ai-settings-row-service.js.map +1 -0
- package/lib/browser/ai-configuration/components/ai-settings-row-service.spec.d.ts +2 -0
- package/lib/browser/ai-configuration/components/ai-settings-row-service.spec.d.ts.map +1 -0
- package/lib/browser/ai-configuration/components/ai-settings-row-service.spec.js +233 -0
- package/lib/browser/ai-configuration/components/ai-settings-row-service.spec.js.map +1 -0
- package/lib/browser/ai-configuration/components/ai-settings-row.d.ts +50 -0
- package/lib/browser/ai-configuration/components/ai-settings-row.d.ts.map +1 -0
- package/lib/browser/ai-configuration/components/ai-settings-row.js +85 -0
- package/lib/browser/ai-configuration/components/ai-settings-row.js.map +1 -0
- package/lib/browser/ai-configuration/components/collapsible-list.d.ts +65 -0
- package/lib/browser/ai-configuration/components/collapsible-list.d.ts.map +1 -0
- package/lib/browser/ai-configuration/components/collapsible-list.js +82 -0
- package/lib/browser/ai-configuration/components/collapsible-list.js.map +1 -0
- package/lib/browser/ai-configuration/components/prompt-customization-dialogs.d.ts +35 -0
- package/lib/browser/ai-configuration/components/prompt-customization-dialogs.d.ts.map +1 -0
- package/lib/browser/ai-configuration/components/prompt-customization-dialogs.js +83 -0
- package/lib/browser/ai-configuration/components/prompt-customization-dialogs.js.map +1 -0
- package/lib/browser/ai-configuration/components/variant-set-card.d.ts +25 -0
- package/lib/browser/ai-configuration/components/variant-set-card.d.ts.map +1 -0
- package/lib/browser/ai-configuration/components/variant-set-card.js +133 -0
- package/lib/browser/ai-configuration/components/variant-set-card.js.map +1 -0
- package/lib/browser/ai-configuration/renderers/collection-category-renderer.d.ts +44 -0
- package/lib/browser/ai-configuration/renderers/collection-category-renderer.d.ts.map +1 -0
- package/lib/browser/ai-configuration/renderers/collection-category-renderer.js +106 -0
- package/lib/browser/ai-configuration/renderers/collection-category-renderer.js.map +1 -0
- package/lib/browser/ai-configuration/renderers/collection-category-renderer.spec.d.ts +2 -0
- package/lib/browser/ai-configuration/renderers/collection-category-renderer.spec.d.ts.map +1 -0
- package/lib/browser/ai-configuration/renderers/collection-category-renderer.spec.js +120 -0
- package/lib/browser/ai-configuration/renderers/collection-category-renderer.spec.js.map +1 -0
- package/lib/browser/ai-configuration/renderers/single-page-category-renderer.d.ts +15 -0
- package/lib/browser/ai-configuration/renderers/single-page-category-renderer.d.ts.map +1 -0
- package/lib/browser/ai-configuration/renderers/single-page-category-renderer.js +20 -0
- package/lib/browser/ai-configuration/renderers/single-page-category-renderer.js.map +1 -0
- package/lib/browser/ai-core-ui-frontend-module.d.ts +1 -0
- package/lib/browser/ai-core-ui-frontend-module.d.ts.map +1 -1
- package/lib/browser/ai-core-ui-frontend-module.js +11 -0
- package/lib/browser/ai-core-ui-frontend-module.js.map +1 -1
- package/package.json +6 -5
- package/src/browser/ai-configuration/ai-configuration-category-registry.spec.ts +137 -0
- package/src/browser/ai-configuration/ai-configuration-category-registry.ts +79 -0
- package/src/browser/ai-configuration/ai-configuration-category.ts +246 -0
- package/src/browser/ai-configuration/ai-configuration-selection-model.ts +42 -0
- package/src/browser/ai-configuration/ai-configuration-setting-commands.spec.ts +82 -0
- package/src/browser/ai-configuration/ai-configuration-setting-commands.ts +104 -0
- package/src/browser/ai-configuration/components/ai-configuration-components.spec.ts +655 -0
- package/src/browser/ai-configuration/components/ai-configuration-controls.tsx +382 -0
- package/src/browser/ai-configuration/components/ai-configuration-item-row.tsx +127 -0
- package/src/browser/ai-configuration/components/ai-configuration-origin-badge.tsx +114 -0
- package/src/browser/ai-configuration/components/ai-configuration-primitives.tsx +359 -0
- package/src/browser/ai-configuration/components/ai-configuration-setting-row.tsx +154 -0
- package/src/browser/ai-configuration/components/ai-settings-row-service.spec.ts +275 -0
- package/src/browser/ai-configuration/components/ai-settings-row-service.ts +401 -0
- package/src/browser/ai-configuration/components/ai-settings-row.tsx +176 -0
- package/src/browser/ai-configuration/components/collapsible-list.tsx +205 -0
- package/src/browser/ai-configuration/components/prompt-customization-dialogs.ts +89 -0
- package/src/browser/ai-configuration/components/variant-set-card.tsx +200 -0
- package/src/browser/ai-configuration/renderers/collection-category-renderer.spec.ts +126 -0
- package/src/browser/ai-configuration/renderers/collection-category-renderer.tsx +164 -0
- package/src/browser/ai-configuration/renderers/single-page-category-renderer.tsx +41 -0
- package/src/browser/ai-core-ui-frontend-module.ts +14 -1
- package/src/browser/style/ai-configuration-components.css +1410 -0
- package/src/browser/style/index.css +17 -0
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// *****************************************************************************
|
|
3
|
+
// Copyright (C) 2026 EclipseSource and others.
|
|
4
|
+
//
|
|
5
|
+
// This program and the accompanying materials are made available under the
|
|
6
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
7
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
8
|
+
//
|
|
9
|
+
// This Source Code may also be made available under the following Secondary
|
|
10
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
11
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
12
|
+
// with the GNU Classpath Exception which is available at
|
|
13
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
14
|
+
//
|
|
15
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
16
|
+
// *****************************************************************************
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.PromptCustomizationDialogs = void 0;
|
|
19
|
+
const core_1 = require("@theia/core");
|
|
20
|
+
const browser_1 = require("@theia/core/lib/browser");
|
|
21
|
+
const prompt_service_1 = require("@theia/ai-core/lib/common/prompt-service");
|
|
22
|
+
/**
|
|
23
|
+
* The two ways to undo a customized prompt fragment, shared by every page that offers them (the agent
|
|
24
|
+
* detail's prompt variant sets and the Prompt Snippets list).
|
|
25
|
+
*
|
|
26
|
+
* Which one applies depends on whether a built-in exists: `resetToBuiltIn` deliberately does nothing for a
|
|
27
|
+
* fragment that has none — a user-authored file such as a custom prompt variant — so those must be deleted
|
|
28
|
+
* instead. Offering reset there is a dead button, which is exactly what this namespace exists to prevent.
|
|
29
|
+
*/
|
|
30
|
+
var PromptCustomizationDialogs;
|
|
31
|
+
(function (PromptCustomizationDialogs) {
|
|
32
|
+
/**
|
|
33
|
+
* Whether a built-in fragment stands behind `fragmentId`, i.e. whether resetting has anything to fall
|
|
34
|
+
* back to. `false` for a fragment that only exists as a user or workspace file.
|
|
35
|
+
*/
|
|
36
|
+
function hasBuiltIn(promptService, fragmentId) {
|
|
37
|
+
const fragments = promptService.getAllPromptFragments().get(fragmentId) ?? [];
|
|
38
|
+
return fragments.some(fragment => !(0, prompt_service_1.isCustomizedPromptFragment)(fragment));
|
|
39
|
+
}
|
|
40
|
+
PromptCustomizationDialogs.hasBuiltIn = hasBuiltIn;
|
|
41
|
+
/**
|
|
42
|
+
* Asks for confirmation — naming where the customization lives, so the user can see which file is about
|
|
43
|
+
* to go — and then deletes it. Resolves to `true` when it was removed.
|
|
44
|
+
*/
|
|
45
|
+
async function confirmAndRemove(promptService, fragmentId, options) {
|
|
46
|
+
const fragment = promptService.getRawPromptFragment(fragmentId);
|
|
47
|
+
if (!fragment || !(0, prompt_service_1.isCustomizedPromptFragment)(fragment)) {
|
|
48
|
+
return false;
|
|
49
|
+
}
|
|
50
|
+
const [type, description] = await Promise.all([
|
|
51
|
+
promptService.getCustomizationType(fragmentId, fragment.customizationId),
|
|
52
|
+
promptService.getCustomizationDescription(fragmentId, fragment.customizationId)
|
|
53
|
+
]);
|
|
54
|
+
const dialog = new browser_1.ConfirmDialog({
|
|
55
|
+
title: options.title,
|
|
56
|
+
msg: options.message({ type, description }),
|
|
57
|
+
ok: core_1.nls.localizeByDefault('Remove'),
|
|
58
|
+
cancel: core_1.nls.localizeByDefault('Cancel')
|
|
59
|
+
});
|
|
60
|
+
if (await dialog.open()) {
|
|
61
|
+
await promptService.removeCustomization(fragmentId, fragment.customizationId);
|
|
62
|
+
return true;
|
|
63
|
+
}
|
|
64
|
+
return false;
|
|
65
|
+
}
|
|
66
|
+
PromptCustomizationDialogs.confirmAndRemove = confirmAndRemove;
|
|
67
|
+
/** Asks for confirmation and then drops every customization, so the built-in text applies again. */
|
|
68
|
+
async function confirmAndReset(promptService, fragmentId, title, message) {
|
|
69
|
+
const dialog = new browser_1.ConfirmDialog({
|
|
70
|
+
title,
|
|
71
|
+
msg: message,
|
|
72
|
+
ok: core_1.nls.localizeByDefault('Reset'),
|
|
73
|
+
cancel: core_1.nls.localizeByDefault('Cancel')
|
|
74
|
+
});
|
|
75
|
+
if (await dialog.open()) {
|
|
76
|
+
await promptService.resetToBuiltIn(fragmentId);
|
|
77
|
+
return true;
|
|
78
|
+
}
|
|
79
|
+
return false;
|
|
80
|
+
}
|
|
81
|
+
PromptCustomizationDialogs.confirmAndReset = confirmAndReset;
|
|
82
|
+
})(PromptCustomizationDialogs || (exports.PromptCustomizationDialogs = PromptCustomizationDialogs = {}));
|
|
83
|
+
//# sourceMappingURL=prompt-customization-dialogs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompt-customization-dialogs.js","sourceRoot":"","sources":["../../../../src/browser/ai-configuration/components/prompt-customization-dialogs.ts"],"names":[],"mappings":";AAAA,gFAAgF;AAChF,+CAA+C;AAC/C,EAAE;AACF,2EAA2E;AAC3E,mEAAmE;AACnE,wCAAwC;AACxC,EAAE;AACF,4EAA4E;AAC5E,8EAA8E;AAC9E,6EAA6E;AAC7E,yDAAyD;AACzD,uDAAuD;AACvD,EAAE;AACF,gFAAgF;AAChF,gFAAgF;;;AAEhF,sCAAkC;AAClC,qDAAwD;AACxD,6EAAqG;AAErG;;;;;;;GAOG;AACH,IAAiB,0BAA0B,CA4D1C;AA5DD,WAAiB,0BAA0B;IAEvC;;;OAGG;IACH,SAAgB,UAAU,CAAC,aAA4B,EAAE,UAAkB;QACvE,MAAM,SAAS,GAAG,aAAa,CAAC,qBAAqB,EAAE,CAAC,GAAG,CAAC,UAAU,CAAC,IAAI,EAAE,CAA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CAAC,aAA4B,EAAE,UAAkB,EAAE,KAAa,EAAE,OAAe;QAClH,MAAM,MAAM,GAAG,IAAI,uBAAa,CAAC;YAC7B,KAAK;YACL,GAAG,EAAE,OAAO;YACZ,EAAE,EAAE,UAAG,CAAC,iBAAiB,CAAC,OAAO,CAAC;YAClC,MAAM,EAAE,UAAG,CAAC,iBAAiB,CAAC,QAAQ,CAAC;SAC1C,CAAC,CAAC;QACH,IAAI,MAAM,MAAM,CAAC,IAAI,EAAE,EAAE,CAAC;YACtB,MAAM,aAAa,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC;YAC/C,OAAO,IAAI,CAAC;QAChB,CAAC;QACD,OAAO,KAAK,CAAC;IACjB,CAAC;IAZqB,0CAAe,kBAYpC,CAAA;AACL,CAAC,EA5DgB,0BAA0B,0CAA1B,0BAA0B,QA4D1C"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import * as React from '@theia/core/shared/react';
|
|
2
|
+
import { PromptService } from '@theia/ai-core/lib/common/prompt-service';
|
|
3
|
+
import { AiSettingsRowService } from './ai-settings-row-service';
|
|
4
|
+
export interface VariantSetCardProps {
|
|
5
|
+
/** The agent that owns this prompt variant set; the selection is stored per agent. */
|
|
6
|
+
readonly agentId: string;
|
|
7
|
+
/** The prompt variant set id (e.g. `coder-system`). */
|
|
8
|
+
readonly promptVariantSetId: string;
|
|
9
|
+
readonly promptService: PromptService;
|
|
10
|
+
/** Backs the row's gear menu, whose "Reset Setting" reverts the selected variant to the default. */
|
|
11
|
+
readonly settingsRowService: AiSettingsRowService;
|
|
12
|
+
/**
|
|
13
|
+
* Optional display names per variant id, as shown in the chat mode switcher (an agent's
|
|
14
|
+
* `ChatMode` names). Falls back to the fragment name and then the variant id.
|
|
15
|
+
*/
|
|
16
|
+
readonly variantLabels?: Record<string, string>;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* The reusable prompt-variant-set component rendered inside an agent's detail page: a single list row per
|
|
20
|
+
* variant set, showing the set id, a select that picks the variant this agent uses (with `(default)` and
|
|
21
|
+
* `[edited]` markers), an edit action to customize the selected variant, and a reset action that reverts a
|
|
22
|
+
* customized variant to built-in. The agent detail is the single source of truth for prompt variant sets.
|
|
23
|
+
*/
|
|
24
|
+
export declare const VariantSetCard: React.FC<VariantSetCardProps>;
|
|
25
|
+
//# sourceMappingURL=variant-set-card.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"variant-set-card.d.ts","sourceRoot":"","sources":["../../../../src/browser/ai-configuration/components/variant-set-card.tsx"],"names":[],"mappings":"AAkBA,OAAO,KAAK,KAAK,MAAM,0BAA0B,CAAC;AAClD,OAAO,EAA8B,aAAa,EAAE,MAAM,0CAA0C,CAAC;AAGrG,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAGjE,MAAM,WAAW,mBAAmB;IAChC,sFAAsF;IACtF,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,uDAAuD;IACvD,QAAQ,CAAC,kBAAkB,EAAE,MAAM,CAAC;IACpC,QAAQ,CAAC,aAAa,EAAE,aAAa,CAAC;IACtC,oGAAoG;IACpG,QAAQ,CAAC,kBAAkB,EAAE,oBAAoB,CAAC;IAClD;;;OAGG;IACH,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACnD;AAED;;;;;GAKG;AACH,eAAO,MAAM,cAAc,EAAE,KAAK,CAAC,EAAE,CAAC,mBAAmB,CAyJxD,CAAC"}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.VariantSetCard = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("@theia/core/shared/react/jsx-runtime");
|
|
5
|
+
// *****************************************************************************
|
|
6
|
+
// Copyright (C) 2026 EclipseSource and others.
|
|
7
|
+
//
|
|
8
|
+
// This program and the accompanying materials are made available under the
|
|
9
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
10
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
11
|
+
//
|
|
12
|
+
// This Source Code may also be made available under the following Secondary
|
|
13
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
14
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
15
|
+
// with the GNU Classpath Exception which is available at
|
|
16
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
17
|
+
//
|
|
18
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
19
|
+
// *****************************************************************************
|
|
20
|
+
const core_1 = require("@theia/core");
|
|
21
|
+
const browser_1 = require("@theia/core/lib/browser");
|
|
22
|
+
const React = require("@theia/core/shared/react");
|
|
23
|
+
const prompt_service_1 = require("@theia/ai-core/lib/common/prompt-service");
|
|
24
|
+
const ai_configuration_item_row_1 = require("./ai-configuration-item-row");
|
|
25
|
+
const ai_configuration_controls_1 = require("./ai-configuration-controls");
|
|
26
|
+
const prompt_customization_dialogs_1 = require("./prompt-customization-dialogs");
|
|
27
|
+
/**
|
|
28
|
+
* The reusable prompt-variant-set component rendered inside an agent's detail page: a single list row per
|
|
29
|
+
* variant set, showing the set id, a select that picks the variant this agent uses (with `(default)` and
|
|
30
|
+
* `[edited]` markers), an edit action to customize the selected variant, and a reset action that reverts a
|
|
31
|
+
* customized variant to built-in. The agent detail is the single source of truth for prompt variant sets.
|
|
32
|
+
*/
|
|
33
|
+
const VariantSetCard = ({ agentId, promptVariantSetId, promptService, settingsRowService, variantLabels }) => {
|
|
34
|
+
const variantIds = promptService.getVariantIds(promptVariantSetId);
|
|
35
|
+
const defaultVariantId = promptService.getDefaultVariantId(promptVariantSetId);
|
|
36
|
+
const [selectedVariantId, setSelectedVariantId] = React.useState(promptService.getSelectedVariantId(promptVariantSetId) ?? defaultVariantId);
|
|
37
|
+
React.useEffect(() => {
|
|
38
|
+
setSelectedVariantId(promptService.getSelectedVariantId(promptVariantSetId) ?? defaultVariantId);
|
|
39
|
+
const disposable = promptService.onSelectedVariantChange(notification => {
|
|
40
|
+
if (notification.promptVariantSetId === promptVariantSetId) {
|
|
41
|
+
setSelectedVariantId(notification.variantId ?? defaultVariantId);
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
return () => disposable.dispose();
|
|
45
|
+
}, [promptVariantSetId, defaultVariantId, promptService]);
|
|
46
|
+
const selected = selectedVariantId && variantIds.includes(selectedVariantId)
|
|
47
|
+
? selectedVariantId
|
|
48
|
+
: defaultVariantId ?? variantIds[0];
|
|
49
|
+
if (!selected) {
|
|
50
|
+
return (0, jsx_runtime_1.jsx)(ai_configuration_item_row_1.AiConfigurationItemRow, { label: promptVariantSetId, description: core_1.nls.localize('theia/ai/core/promptFragmentsConfiguration/variantSetError', 'The selected variant does not exist and no default could be found. Please check your configuration.'), status: { kind: 'error', label: core_1.nls.localizeByDefault('Error') } });
|
|
51
|
+
}
|
|
52
|
+
const isVariantCustomized = (variantId) => {
|
|
53
|
+
const fragment = promptService.getRawPromptFragment(variantId);
|
|
54
|
+
return fragment ? (0, prompt_service_1.isCustomizedPromptFragment)(fragment) : false;
|
|
55
|
+
};
|
|
56
|
+
const variantName = (variantId) => variantLabels?.[variantId] ?? promptService.getRawPromptFragment(variantId)?.name ?? variantId;
|
|
57
|
+
const selectVariant = (variantId) => {
|
|
58
|
+
promptService.updateSelectedVariantId(agentId, promptVariantSetId, variantId);
|
|
59
|
+
};
|
|
60
|
+
const customize = (variantId) => {
|
|
61
|
+
const fragment = promptService.getRawPromptFragment(variantId);
|
|
62
|
+
if (fragment && (0, prompt_service_1.isCustomizedPromptFragment)(fragment)) {
|
|
63
|
+
promptService.editCustomization(fragment.id, fragment.customizationId);
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
promptService.createBuiltInCustomization(variantId);
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
const resetVariant = async (variantId) => {
|
|
70
|
+
await prompt_customization_dialogs_1.PromptCustomizationDialogs.confirmAndReset(promptService, variantId, core_1.nls.localize('theia/ai/core/promptFragmentsConfiguration/resetToBuiltInDialogTitle', 'Reset to Built-in'), core_1.nls.localize('theia/ai/core/promptFragmentsConfiguration/resetToBuiltInDialogMsg', 'Are you sure you want to reset the prompt fragment "{0}" to its built-in version? This will remove all customizations.', variantId));
|
|
71
|
+
};
|
|
72
|
+
/**
|
|
73
|
+
* A variant that exists only as a user file — a custom prompt template, which becomes a variant of this
|
|
74
|
+
* set through its id prefix — has no built-in to fall back to, so it is deleted rather than reset. The
|
|
75
|
+
* dialog names the file, since this removes it from disk.
|
|
76
|
+
*/
|
|
77
|
+
const removeVariant = async (variantId) => {
|
|
78
|
+
const removed = await prompt_customization_dialogs_1.PromptCustomizationDialogs.confirmAndRemove(promptService, variantId, {
|
|
79
|
+
title: core_1.nls.localize('theia/ai/core/promptFragmentsConfiguration/removePromptTemplateDialogTitle', 'Remove Prompt Template'),
|
|
80
|
+
message: ({ type, description }) => description
|
|
81
|
+
? core_1.nls.localize('theia/ai/core/promptFragmentsConfiguration/removePromptTemplateWithDescDialogMsg', 'Are you sure you want to remove the {0} customization for prompt template "{1}" ({2})? It has no built-in version, so it will be gone entirely.', type ?? '', variantId, description)
|
|
82
|
+
: core_1.nls.localize('theia/ai/core/promptFragmentsConfiguration/removePromptTemplateDialogMsg', 'Are you sure you want to remove the {0} customization for prompt template "{1}"? It has no built-in version, so it will be gone entirely.', type ?? '', variantId)
|
|
83
|
+
});
|
|
84
|
+
// The agent still points at the template we just deleted, which would show up as an unavailable
|
|
85
|
+
// selection. Selecting the default drops the stored selection, so the set is simply back to default.
|
|
86
|
+
if (removed && defaultVariantId && promptService.getSelectedVariantId(promptVariantSetId) === variantId) {
|
|
87
|
+
await promptService.updateSelectedVariantId(agentId, promptVariantSetId, defaultVariantId);
|
|
88
|
+
setSelectedVariantId(defaultVariantId);
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
const explicitSelection = promptService.getSelectedVariantId(promptVariantSetId);
|
|
92
|
+
const invalidSelection = explicitSelection !== undefined && !variantIds.includes(explicitSelection);
|
|
93
|
+
const selectedCustomized = isVariantCustomized(selected);
|
|
94
|
+
// Without a built-in, `PromptService.resetToBuiltIn` is a no-op by design, so the action must delete.
|
|
95
|
+
const selectedHasBuiltIn = prompt_customization_dialogs_1.PromptCustomizationDialogs.hasBuiltIn(promptService, selected);
|
|
96
|
+
// The agent's selection deviates from the built-in default; the gear "Reset Setting" reverts it. (A
|
|
97
|
+
// customized variant is a separate, global edit, surfaced by the `[edited]` marker and the reset icon.)
|
|
98
|
+
const modified = defaultVariantId !== undefined && selected !== defaultVariantId;
|
|
99
|
+
const variantCountLabel = variantIds.length === 1
|
|
100
|
+
? core_1.nls.localize('theia/ai/core/variantSet/variantCountSingular', '1 variant')
|
|
101
|
+
: core_1.nls.localize('theia/ai/core/variantSet/variantCount', '{0} variants', variantIds.length);
|
|
102
|
+
// Each option shows the variant name plus `(default)`/`[edited]` markers, so the collapsed select surfaces
|
|
103
|
+
// the selected variant's state and the dropdown reveals which variants are customized.
|
|
104
|
+
const options = variantIds.map(variantId => {
|
|
105
|
+
const markers = [variantName(variantId)];
|
|
106
|
+
if (variantId === defaultVariantId) {
|
|
107
|
+
markers.push(`(${core_1.nls.localizeByDefault('Default')})`);
|
|
108
|
+
}
|
|
109
|
+
if (isVariantCustomized(variantId)) {
|
|
110
|
+
markers.push(`[${core_1.nls.localize('theia/ai/chat-ui/edited', 'edited')}]`);
|
|
111
|
+
}
|
|
112
|
+
return { value: variantId, label: markers.join(' ') };
|
|
113
|
+
});
|
|
114
|
+
// A selection pointing at a template that no longer exists stays visible as a disabled, red "Unavailable"
|
|
115
|
+
// entry instead of quietly showing the default: the effective prompt *is* the default, but silently
|
|
116
|
+
// displaying it would hide that the agent's own selection is broken and needs a new pick.
|
|
117
|
+
if (invalidSelection) {
|
|
118
|
+
options.unshift({
|
|
119
|
+
value: explicitSelection,
|
|
120
|
+
label: core_1.nls.localize('theia/ai/core/variantSet/unavailableVariant', '{0} (unavailable)', explicitSelection),
|
|
121
|
+
disabled: true
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
const editLabel = core_1.nls.localize('theia/ai/core/promptFragmentsConfiguration/editPromptTemplate', 'Edit prompt template');
|
|
125
|
+
const resetLabel = selectedHasBuiltIn
|
|
126
|
+
? core_1.nls.localize('theia/ai/core/promptFragmentsConfiguration/resetPromptTemplate', 'Reset prompt template')
|
|
127
|
+
: core_1.nls.localize('theia/ai/core/promptFragmentsConfiguration/removePromptTemplate', 'Remove prompt template');
|
|
128
|
+
return (0, jsx_runtime_1.jsx)(ai_configuration_item_row_1.AiConfigurationItemRow, { label: promptVariantSetId, description: variantCountLabel, modified: modified, onOpenMenu: modified && defaultVariantId
|
|
129
|
+
? gear => settingsRowService.openResetMenu(gear, () => selectVariant(defaultVariantId))
|
|
130
|
+
: undefined, trailing: (0, jsx_runtime_1.jsxs)("div", { className: 'ai-variant-controls', children: [(0, jsx_runtime_1.jsx)(ai_configuration_controls_1.AiEnumSelect, { value: invalidSelection ? explicitSelection : selected, ariaLabel: core_1.nls.localize('theia/ai/core/variantSet/templateLabel', 'Template'), options: options, invalid: invalidSelection, onCommit: selectVariant }), (0, jsx_runtime_1.jsx)("button", { className: 'ai-variant-action-button', title: editLabel, "aria-label": editLabel, onClick: () => customize(selected), children: (0, jsx_runtime_1.jsx)("span", { className: (0, browser_1.codicon)('edit') }) }), selectedCustomized && (0, jsx_runtime_1.jsx)("button", { className: 'ai-variant-action-button', title: resetLabel, "aria-label": resetLabel, onClick: () => selectedHasBuiltIn ? resetVariant(selected) : removeVariant(selected), children: (0, jsx_runtime_1.jsx)("span", { className: (0, browser_1.codicon)(selectedHasBuiltIn ? 'discard' : 'trash') }) })] }) });
|
|
131
|
+
};
|
|
132
|
+
exports.VariantSetCard = VariantSetCard;
|
|
133
|
+
//# sourceMappingURL=variant-set-card.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"variant-set-card.js","sourceRoot":"","sources":["../../../../src/browser/ai-configuration/components/variant-set-card.tsx"],"names":[],"mappings":";;;;AAAA,gFAAgF;AAChF,+CAA+C;AAC/C,EAAE;AACF,2EAA2E;AAC3E,mEAAmE;AACnE,wCAAwC;AACxC,EAAE;AACF,4EAA4E;AAC5E,8EAA8E;AAC9E,6EAA6E;AAC7E,yDAAyD;AACzD,uDAAuD;AACvD,EAAE;AACF,gFAAgF;AAChF,gFAAgF;AAEhF,sCAAkC;AAClC,qDAAkD;AAClD,kDAAkD;AAClD,6EAAqG;AACrG,2EAAqE;AACrE,2EAAyE;AAEzE,iFAA4E;AAiB5E;;;;;GAKG;AACI,MAAM,cAAc,GAAkC,CAAC,EAAE,OAAO,EAAE,kBAAkB,EAAE,aAAa,EAAE,kBAAkB,EAAE,aAAa,EAAE,EAAE,EAAE;IAC/I,MAAM,UAAU,GAAG,aAAa,CAAC,aAAa,CAAC,kBAAkB,CAAC,CAAC;IACnE,MAAM,gBAAgB,GAAG,aAAa,CAAC,mBAAmB,CAAC,kBAAkB,CAAC,CAAC;IAE/E,MAAM,CAAC,iBAAiB,EAAE,oBAAoB,CAAC,GAAG,KAAK,CAAC,QAAQ,CAC5D,aAAa,CAAC,oBAAoB,CAAC,kBAAkB,CAAC,IAAI,gBAAgB,CAAC,CAAC;IAEhF,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE;QACjB,oBAAoB,CAAC,aAAa,CAAC,oBAAoB,CAAC,kBAAkB,CAAC,IAAI,gBAAgB,CAAC,CAAC;QACjG,MAAM,UAAU,GAAG,aAAa,CAAC,uBAAuB,CAAC,YAAY,CAAC,EAAE;YACpE,IAAI,YAAY,CAAC,kBAAkB,KAAK,kBAAkB,EAAE,CAAC;gBACzD,oBAAoB,CAAC,YAAY,CAAC,SAAS,IAAI,gBAAgB,CAAC,CAAC;YACrE,CAAC;QACL,CAAC,CAAC,CAAC;QACH,OAA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,EACtD,SAAS,EAAE,UAAG,CAAC,QAAQ,CAAC,wCAAwC,EAAE,UAAU,CAAC,EAC7E,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,gBAAgB,EACzB,QAAQ,EAAE,aAAa,GACzB,EACF,mCACI,SAAS,EAAC,0BAA0B,EACpC,KAAK,EAAE,SAAS,gBACJ,SAAS,EACrB,OAAO,EAAE,GAAG,EAAE,CAAC,SAAS,CAAC,QAAQ,CAAC,YAClC,iCAAM,SAAS,EAAE,IAAA,iBAAO,EAAC,MAAM,CAAC,GAAS,GACpC,EACR,kBAAkB,IAAI,mCACnB,SAAS,EAAC,0BAA0B,EACpC,KAAK,EAAE,UAAU,gBACL,UAAU,EACtB,OAAO,EAAE,GAAG,EAAE,CAAC,kBAAkB,CAAC,CAAC,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,QAAQ,CAAC,YACpF,iCAAM,SAAS,EAAE,IAAA,iBAAO,EAAC,kBAAkB,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,GAAS,GACtE,IACP,GACR,CAAC;AACP,CAAC,CAAC;AAzJW,QAAA,cAAc,kBAyJzB"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import * as React from '@theia/core/shared/react';
|
|
2
|
+
import { AiConfigurationAddDescriptor, AiConfigurationCategoryRenderer, AiConfigurationRenderContext, AiConfigurationTreeItem } from '../ai-configuration-category';
|
|
3
|
+
export { AiConfigurationAddDescriptor };
|
|
4
|
+
/** Describes the overview's "Add …" affordance. */
|
|
5
|
+
/**
|
|
6
|
+
* Convenience base for `collection` categories. Renders the overview (category
|
|
7
|
+
* settings slot + item card grid + add action + empty state) and the per-item
|
|
8
|
+
* detail frame (header + sections). Subclasses provide the items, the item
|
|
9
|
+
* sections, and optionally category-level settings and an add action.
|
|
10
|
+
*/
|
|
11
|
+
export declare abstract class CollectionCategoryRenderer implements AiConfigurationCategoryRenderer {
|
|
12
|
+
/** The owning category id, used to build navigation targets for the cards. */
|
|
13
|
+
protected abstract get categoryId(): string;
|
|
14
|
+
/** Ids already reported as duplicated, so the warning is logged once rather than on every render. */
|
|
15
|
+
protected readonly reportedDuplicateIds: Set<string>;
|
|
16
|
+
abstract getTreeChildren(): AiConfigurationTreeItem[];
|
|
17
|
+
renderOverview(ctx: AiConfigurationRenderContext): React.ReactNode;
|
|
18
|
+
/**
|
|
19
|
+
* The items this page can actually address, i.e. one per id. Everything downstream keys on the id — the
|
|
20
|
+
* tree node, the navigation target, the detail lookup and the per-item settings — so an item repeating an
|
|
21
|
+
* id could neither be opened nor configured on its own; it is dropped here and logged once. Representing
|
|
22
|
+
* such a clash properly is a separate concern from this view (it starts where the items are registered).
|
|
23
|
+
*/
|
|
24
|
+
protected addressableItems(items: AiConfigurationTreeItem[]): AiConfigurationTreeItem[];
|
|
25
|
+
/**
|
|
26
|
+
* Warns once per id, since the overview re-renders and would otherwise repeat itself indefinitely.
|
|
27
|
+
* `console` rather than an `ILogger`: this base class is not injectable, so it has no injection context
|
|
28
|
+
* of its own; subclasses that want their named logger can override this.
|
|
29
|
+
*/
|
|
30
|
+
protected warnAboutDuplicateId(id: string): void;
|
|
31
|
+
/** Optional heading shown above the item list (e.g. "Agents"), like the Providers page. None by default. */
|
|
32
|
+
protected get overviewListTitle(): string | undefined;
|
|
33
|
+
renderItemDetail(itemId: string, ctx: AiConfigurationRenderContext): React.ReactNode;
|
|
34
|
+
/** Category-level settings shown above the card grid; nothing by default. */
|
|
35
|
+
protected renderCategorySettings(ctx: AiConfigurationRenderContext): React.ReactNode;
|
|
36
|
+
/** Header of an item detail page; icon/title/subtitle/origins from the item by default. */
|
|
37
|
+
protected renderItemHeader(item: AiConfigurationTreeItem, ctx: AiConfigurationRenderContext): React.ReactNode;
|
|
38
|
+
/** Body of an item detail page: typically {@link AiConfigurationSection}s of rows. */
|
|
39
|
+
protected abstract renderItemSections(item: AiConfigurationTreeItem, ctx: AiConfigurationRenderContext): React.ReactNode;
|
|
40
|
+
/** The overview "Add …" affordance; none by default. */
|
|
41
|
+
getAddAction(ctx: AiConfigurationRenderContext): AiConfigurationAddDescriptor | undefined;
|
|
42
|
+
protected getEmptyMessage(): string;
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=collection-category-renderer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"collection-category-renderer.d.ts","sourceRoot":"","sources":["../../../../src/browser/ai-configuration/renderers/collection-category-renderer.tsx"],"names":[],"mappings":"AAiBA,OAAO,KAAK,KAAK,MAAM,0BAA0B,CAAC;AAClD,OAAO,EACH,4BAA4B,EAC5B,+BAA+B,EAC/B,4BAA4B,EAC5B,uBAAuB,EAC1B,MAAM,8BAA8B,CAAC;AAItC,OAAO,EAAE,4BAA4B,EAAE,CAAC;AASxC,mDAAmD;AACnD;;;;;GAKG;AACH,8BAAsB,0BAA2B,YAAW,+BAA+B;IAEvF,8EAA8E;IAC9E,SAAS,CAAC,QAAQ,KAAK,UAAU,IAAI,MAAM,CAAC;IAE5C,qGAAqG;IACrG,SAAS,CAAC,QAAQ,CAAC,oBAAoB,cAAqB;IAE5D,QAAQ,CAAC,eAAe,IAAI,uBAAuB,EAAE;IAErD,cAAc,CAAC,GAAG,EAAE,4BAA4B,GAAG,KAAK,CAAC,SAAS;IAmClE;;;;;OAKG;IACH,SAAS,CAAC,gBAAgB,CAAC,KAAK,EAAE,uBAAuB,EAAE,GAAG,uBAAuB,EAAE;IAYvF;;;;OAIG;IACH,SAAS,CAAC,oBAAoB,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI;IAShD,4GAA4G;IAC5G,SAAS,KAAK,iBAAiB,IAAI,MAAM,GAAG,SAAS,CAEpD;IAED,gBAAgB,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,4BAA4B,GAAG,KAAK,CAAC,SAAS;IAWpF,6EAA6E;IAC7E,SAAS,CAAC,sBAAsB,CAAC,GAAG,EAAE,4BAA4B,GAAG,KAAK,CAAC,SAAS;IAIpF,2FAA2F;IAC3F,SAAS,CAAC,gBAAgB,CAAC,IAAI,EAAE,uBAAuB,EAAE,GAAG,EAAE,4BAA4B,GAAG,KAAK,CAAC,SAAS;IAU7G,sFAAsF;IACtF,SAAS,CAAC,QAAQ,CAAC,kBAAkB,CAAC,IAAI,EAAE,uBAAuB,EAAE,GAAG,EAAE,4BAA4B,GAAG,KAAK,CAAC,SAAS;IAExH,wDAAwD;IACxD,YAAY,CAAC,GAAG,EAAE,4BAA4B,GAAG,4BAA4B,GAAG,SAAS;IAIzF,SAAS,CAAC,eAAe,IAAI,MAAM;CAGtC"}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CollectionCategoryRenderer = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("@theia/core/shared/react/jsx-runtime");
|
|
5
|
+
// *****************************************************************************
|
|
6
|
+
// Copyright (C) 2026 EclipseSource and others.
|
|
7
|
+
//
|
|
8
|
+
// This program and the accompanying materials are made available under the
|
|
9
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
10
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
11
|
+
//
|
|
12
|
+
// This Source Code may also be made available under the following Secondary
|
|
13
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
14
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
15
|
+
// with the GNU Classpath Exception which is available at
|
|
16
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
17
|
+
//
|
|
18
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
19
|
+
// *****************************************************************************
|
|
20
|
+
const core_1 = require("@theia/core");
|
|
21
|
+
const ai_configuration_primitives_1 = require("../components/ai-configuration-primitives");
|
|
22
|
+
const ai_configuration_item_row_1 = require("../components/ai-configuration-item-row");
|
|
23
|
+
/** Describes the overview's "Add …" affordance. */
|
|
24
|
+
/**
|
|
25
|
+
* Convenience base for `collection` categories. Renders the overview (category
|
|
26
|
+
* settings slot + item card grid + add action + empty state) and the per-item
|
|
27
|
+
* detail frame (header + sections). Subclasses provide the items, the item
|
|
28
|
+
* sections, and optionally category-level settings and an add action.
|
|
29
|
+
*/
|
|
30
|
+
class CollectionCategoryRenderer {
|
|
31
|
+
constructor() {
|
|
32
|
+
/** Ids already reported as duplicated, so the warning is logged once rather than on every render. */
|
|
33
|
+
this.reportedDuplicateIds = new Set();
|
|
34
|
+
}
|
|
35
|
+
renderOverview(ctx) {
|
|
36
|
+
const items = this.addressableItems(this.getTreeChildren());
|
|
37
|
+
const add = this.getAddAction(ctx);
|
|
38
|
+
const addAction = add && (0, jsx_runtime_1.jsx)(ai_configuration_primitives_1.AiConfigurationAddAction, { label: add.label, iconClass: add.iconClass, onClick: () => add.run() });
|
|
39
|
+
const body = items.length === 0
|
|
40
|
+
? (0, jsx_runtime_1.jsx)(ai_configuration_primitives_1.AiConfigurationEmptyState, { message: this.getEmptyMessage(), action: addAction })
|
|
41
|
+
: (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("div", { className: 'ai-configuration-item-list', children: items.map(item => (0, jsx_runtime_1.jsx)(ai_configuration_item_row_1.AiConfigurationItemRow, { label: item.label, iconClass: item.iconClass, description: item.description, tags: item.tags, origins: item.origins, status: item.status, onSelect: () => ctx.navigate({ categoryId: this.categoryId, itemId: item.id }) }, item.id)) }), addAction && (0, jsx_runtime_1.jsx)("div", { className: 'ai-configuration-overview-actions', children: addAction })] });
|
|
42
|
+
const listTitle = this.overviewListTitle;
|
|
43
|
+
return (0, jsx_runtime_1.jsxs)("div", { className: 'ai-configuration-page', children: [this.renderCategorySettings(ctx), listTitle !== undefined
|
|
44
|
+
// Foldable with its size on the header once there is a list to fold; an empty state stays plain.
|
|
45
|
+
? (0, jsx_runtime_1.jsx)(ai_configuration_primitives_1.AiConfigurationSection, { title: listTitle, count: items.length > 0 ? items.length : undefined, collapsible: items.length > 0, children: body })
|
|
46
|
+
: body] });
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* The items this page can actually address, i.e. one per id. Everything downstream keys on the id — the
|
|
50
|
+
* tree node, the navigation target, the detail lookup and the per-item settings — so an item repeating an
|
|
51
|
+
* id could neither be opened nor configured on its own; it is dropped here and logged once. Representing
|
|
52
|
+
* such a clash properly is a separate concern from this view (it starts where the items are registered).
|
|
53
|
+
*/
|
|
54
|
+
addressableItems(items) {
|
|
55
|
+
const byId = new Map();
|
|
56
|
+
for (const item of items) {
|
|
57
|
+
if (byId.has(item.id)) {
|
|
58
|
+
this.warnAboutDuplicateId(item.id);
|
|
59
|
+
continue;
|
|
60
|
+
}
|
|
61
|
+
byId.set(item.id, item);
|
|
62
|
+
}
|
|
63
|
+
return [...byId.values()];
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Warns once per id, since the overview re-renders and would otherwise repeat itself indefinitely.
|
|
67
|
+
* `console` rather than an `ILogger`: this base class is not injectable, so it has no injection context
|
|
68
|
+
* of its own; subclasses that want their named logger can override this.
|
|
69
|
+
*/
|
|
70
|
+
warnAboutDuplicateId(id) {
|
|
71
|
+
if (this.reportedDuplicateIds.has(id)) {
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
this.reportedDuplicateIds.add(id);
|
|
75
|
+
console.warn(`More than one entry of the AI configuration category "${this.categoryId}" declares the id "${id}". `
|
|
76
|
+
+ 'Only the first is shown, since everything (navigation, settings) is keyed by that id. Give each entry a unique id.');
|
|
77
|
+
}
|
|
78
|
+
/** Optional heading shown above the item list (e.g. "Agents"), like the Providers page. None by default. */
|
|
79
|
+
get overviewListTitle() {
|
|
80
|
+
return undefined;
|
|
81
|
+
}
|
|
82
|
+
renderItemDetail(itemId, ctx) {
|
|
83
|
+
const item = this.getTreeChildren().find(child => child.id === itemId);
|
|
84
|
+
if (!item) {
|
|
85
|
+
return undefined;
|
|
86
|
+
}
|
|
87
|
+
return (0, jsx_runtime_1.jsxs)("div", { className: 'ai-configuration-page', children: [this.renderItemHeader(item, ctx), this.renderItemSections(item, ctx)] });
|
|
88
|
+
}
|
|
89
|
+
/** Category-level settings shown above the card grid; nothing by default. */
|
|
90
|
+
renderCategorySettings(ctx) {
|
|
91
|
+
return undefined;
|
|
92
|
+
}
|
|
93
|
+
/** Header of an item detail page; icon/title/subtitle/origins from the item by default. */
|
|
94
|
+
renderItemHeader(item, ctx) {
|
|
95
|
+
return (0, jsx_runtime_1.jsx)(ai_configuration_primitives_1.AiConfigurationItemDetailHeader, { title: item.label, iconClass: item.iconClass, subtitle: item.description, status: item.status, origins: item.origins });
|
|
96
|
+
}
|
|
97
|
+
/** The overview "Add …" affordance; none by default. */
|
|
98
|
+
getAddAction(ctx) {
|
|
99
|
+
return undefined;
|
|
100
|
+
}
|
|
101
|
+
getEmptyMessage() {
|
|
102
|
+
return core_1.nls.localize('theia/ai/core/aiConfiguration/collectionEmpty', 'No items to configure yet.');
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
exports.CollectionCategoryRenderer = CollectionCategoryRenderer;
|
|
106
|
+
//# sourceMappingURL=collection-category-renderer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"collection-category-renderer.js","sourceRoot":"","sources":["../../../../src/browser/ai-configuration/renderers/collection-category-renderer.tsx"],"names":[],"mappings":";;;;AAAA,gFAAgF;AAChF,+CAA+C;AAC/C,EAAE;AACF,2EAA2E;AAC3E,mEAAmE;AACnE,wCAAwC;AACxC,EAAE;AACF,4EAA4E;AAC5E,8EAA8E;AAC9E,6EAA6E;AAC7E,yDAAyD;AACzD,uDAAuD;AACvD,EAAE;AACF,gFAAgF;AAChF,gFAAgF;AAEhF,sCAAkC;AAYlC,2FAKmD;AACnD,uFAAiF;AAEjF,mDAAmD;AACnD;;;;;GAKG;AACH,MAAsB,0BAA0B;IAAhD;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IAAc,iBAAiB;QAC3B,OAAO,SAAS,CAAC;IACrB,CAAC;IAED,gBAAgB,CAAC,MAAc,EAAE,GAAiC;QAC9D,MAAM,IAAI,GAAG,IAAI,CAAC,eAAe,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,EAAE,KAAK,MAAM,CAAC,CAAC;QACvE,IAAI,CAAC,IAAI,EAAE,CAAC;YACR,OAAO,SAAS,CAAC;QACrB,CAAC;QACD,OAAO,iCAAK,SAAS,EAAC,uBAAuB,aACxC,IAAI,CAAC,gBAAgB,CAAC,IAAI,EAAE,GAAG,CAAC,EAChC,IAAI,CAAC,kBAAkB,CAAC,IAAI,EAAE,GAAG,CAAC,IACjC,CAAC;IACX,CAAC;IAED,6EAA6E;IACnE,sBAAsB,CAAC,GAAiC;QAC9D,OAAO,SAAS,CAAC;IACrB,CAAC;IAED,2FAA2F;IACjF,gBAAgB,CAAC,IAA6B,EAAE,GAAiC;QACvF,OAAO,uBAAC,6DAA+B,IACnC,KAAK,EAAE,IAAI,CAAC,KAAK,EACjB,SAAS,EAAE,IAAI,CAAC,SAAS,EACzB,QAAQ,EAAE,IAAI,CAAC,WAAW,EAC1B,MAAM,EAAE,IAAI,CAAC,MAAM,EACnB,OAAO,EAAE,IAAI,CAAC,OAAO,GACvB,CAAC;IACP,CAAC;IAKD,wDAAwD;IACxD,YAAY,CAAC,GAAiC;QAC1C,OAAO,SAAS,CAAC;IACrB,CAAC;IAES,eAAe;QACrB,OAAO,UAAG,CAAC,QAAQ,CAAC,+CAA+C,EAAE,4BAA4B,CAAC,CAAC;IACvG,CAAC;CACJ;AAxHD,gEAwHC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"collection-category-renderer.spec.d.ts","sourceRoot":"","sources":["../../../../src/browser/ai-configuration/renderers/collection-category-renderer.spec.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// *****************************************************************************
|
|
3
|
+
// Copyright (C) 2026 EclipseSource and others.
|
|
4
|
+
//
|
|
5
|
+
// This program and the accompanying materials are made available under the
|
|
6
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
7
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
8
|
+
//
|
|
9
|
+
// This Source Code may also be made available under the following Secondary
|
|
10
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
11
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
12
|
+
// with the GNU Classpath Exception which is available at
|
|
13
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
14
|
+
//
|
|
15
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
16
|
+
// *****************************************************************************
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
const jsdom_1 = require("@theia/core/lib/browser/test/jsdom");
|
|
19
|
+
let disableJSDOM = (0, jsdom_1.enableJSDOM)();
|
|
20
|
+
const frontend_application_config_provider_1 = require("@theia/core/lib/browser/frontend-application-config-provider");
|
|
21
|
+
frontend_application_config_provider_1.FrontendApplicationConfigProvider.set({});
|
|
22
|
+
const chai_1 = require("chai");
|
|
23
|
+
const react_dom_1 = require("@theia/core/shared/react-dom");
|
|
24
|
+
const client_1 = require("@theia/core/shared/react-dom/client");
|
|
25
|
+
const collection_category_renderer_1 = require("./collection-category-renderer");
|
|
26
|
+
disableJSDOM();
|
|
27
|
+
describe('CollectionCategoryRenderer', () => {
|
|
28
|
+
before(() => disableJSDOM = (0, jsdom_1.enableJSDOM)());
|
|
29
|
+
after(() => disableJSDOM());
|
|
30
|
+
class TestCollection extends collection_category_renderer_1.CollectionCategoryRenderer {
|
|
31
|
+
constructor(items) {
|
|
32
|
+
super();
|
|
33
|
+
this.items = items;
|
|
34
|
+
}
|
|
35
|
+
get categoryId() {
|
|
36
|
+
return 'agents';
|
|
37
|
+
}
|
|
38
|
+
getTreeChildren() {
|
|
39
|
+
return this.items;
|
|
40
|
+
}
|
|
41
|
+
renderItemSections() {
|
|
42
|
+
return undefined;
|
|
43
|
+
}
|
|
44
|
+
getEmptyMessage() {
|
|
45
|
+
return 'No agents';
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
function renderOverview(items) {
|
|
49
|
+
// React reports duplicate keys through console.error; capture it so the test can assert on it, and
|
|
50
|
+
// capture console.warn too so the renderer's expected duplicate-id warning stays out of the output.
|
|
51
|
+
const warnings = [];
|
|
52
|
+
const originalError = console.error;
|
|
53
|
+
const originalWarn = console.warn;
|
|
54
|
+
console.error = (...args) => { warnings.push(String(args[0])); };
|
|
55
|
+
console.warn = (...args) => { warnings.push(String(args[0])); };
|
|
56
|
+
const container = document.createElement('div');
|
|
57
|
+
document.body.appendChild(container);
|
|
58
|
+
const root = (0, client_1.createRoot)(container);
|
|
59
|
+
const ctx = { scope: 'user', navigate: () => { }, update: () => { } };
|
|
60
|
+
try {
|
|
61
|
+
(0, react_dom_1.flushSync)(() => root.render(new TestCollection(items).renderOverview(ctx)));
|
|
62
|
+
}
|
|
63
|
+
finally {
|
|
64
|
+
console.error = originalError;
|
|
65
|
+
console.warn = originalWarn;
|
|
66
|
+
}
|
|
67
|
+
return { container, warnings, dispose: () => { (0, react_dom_1.flushSync)(() => root.unmount()); container.remove(); } };
|
|
68
|
+
}
|
|
69
|
+
it('shows one row per id, dropping an entry that repeats one', () => {
|
|
70
|
+
const { container, warnings, dispose } = renderOverview([
|
|
71
|
+
{ id: 'code-reviewer', label: 'Code Reviewer' },
|
|
72
|
+
{ id: 'code-reviewer', label: 'Code Reviewer (copy)' },
|
|
73
|
+
{ id: 'coder', label: 'Coder' }
|
|
74
|
+
]);
|
|
75
|
+
try {
|
|
76
|
+
const labels = Array.from(container.querySelectorAll('.ai-configuration-item-row-label')).map(label => label.textContent);
|
|
77
|
+
// The first wins: a repeated id is not addressable, so showing it would be a row that opens another.
|
|
78
|
+
(0, chai_1.expect)(labels).to.deep.equal(['Code Reviewer', 'Coder']);
|
|
79
|
+
// And no React duplicate-key warnings, which is what a rendered duplicate produced.
|
|
80
|
+
(0, chai_1.expect)(warnings.filter(warning => warning.includes('same key'))).to.be.empty;
|
|
81
|
+
}
|
|
82
|
+
finally {
|
|
83
|
+
dispose();
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
it('logs the dropped id once, however often the overview re-renders', () => {
|
|
87
|
+
const items = [
|
|
88
|
+
{ id: 'code-reviewer', label: 'Code Reviewer' },
|
|
89
|
+
{ id: 'code-reviewer', label: 'Code Reviewer (copy)' }
|
|
90
|
+
];
|
|
91
|
+
const collection = new TestCollection(items);
|
|
92
|
+
const ctx = { scope: 'user', navigate: () => { }, update: () => { } };
|
|
93
|
+
const logged = [];
|
|
94
|
+
const originalWarn = console.warn;
|
|
95
|
+
console.warn = (...args) => { logged.push(String(args[0])); };
|
|
96
|
+
try {
|
|
97
|
+
collection.renderOverview(ctx);
|
|
98
|
+
collection.renderOverview(ctx);
|
|
99
|
+
}
|
|
100
|
+
finally {
|
|
101
|
+
console.warn = originalWarn;
|
|
102
|
+
}
|
|
103
|
+
(0, chai_1.expect)(logged).to.have.lengthOf(1);
|
|
104
|
+
(0, chai_1.expect)(logged[0]).to.include('code-reviewer').and.to.include('agents');
|
|
105
|
+
});
|
|
106
|
+
it('leaves items with unique ids untouched, reporting their own status', () => {
|
|
107
|
+
const { container, dispose } = renderOverview([
|
|
108
|
+
{ id: 'coder', label: 'Coder', status: { kind: 'on', label: 'Enabled' } },
|
|
109
|
+
{ id: 'architect', label: 'Architect', status: { kind: 'off', label: 'Disabled' } }
|
|
110
|
+
]);
|
|
111
|
+
try {
|
|
112
|
+
const badges = Array.from(container.querySelectorAll('.ai-configuration-status-badge-label')).map(badge => badge.textContent);
|
|
113
|
+
(0, chai_1.expect)(badges).to.deep.equal(['Enabled', 'Disabled']);
|
|
114
|
+
}
|
|
115
|
+
finally {
|
|
116
|
+
dispose();
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
});
|
|
120
|
+
//# sourceMappingURL=collection-category-renderer.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"collection-category-renderer.spec.js","sourceRoot":"","sources":["../../../../src/browser/ai-configuration/renderers/collection-category-renderer.spec.ts"],"names":[],"mappings":";AAAA,gFAAgF;AAChF,+CAA+C;AAC/C,EAAE;AACF,2EAA2E;AAC3E,mEAAmE;AACnE,wCAAwC;AACxC,EAAE;AACF,4EAA4E;AAC5E,8EAA8E;AAC9E,6EAA6E;AAC7E,yDAAyD;AACzD,uDAAuD;AACvD,EAAE;AACF,gFAAgF;AAChF,gFAAgF;;AAEhF,8DAAiE;AACjE,IAAI,YAAY,GAAG,IAAA,mBAAW,GAAE,CAAC;AAEjC,uHAAiH;AACjH,wEAAiC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;AAE1C,+BAA8B;AAE9B,4DAAyD;AACzD,gEAAiE;AAEjE,iFAA4E;AAE5E,YAAY,EAAE,CAAC;AAEf,QAAQ,CAAC,4BAA4B,EAAE,GAAG,EAAE;IAExC,MAAM,CAAC,GAAG,EAAE,CAAC,YAAY,GAAG,IAAA,mBAAW,GAAE,CAAC,CAAC;IAC3C,KAAK,CAAC,GAAG,EAAE,CAAC,YAAY,EAAE,CAAC,CAAC;IAE5B,MAAM,cAAe,SAAQ,yDAA0B;QACnD,YAA+B,KAAgC;YAC3D,KAAK,EAAE,CAAC;YADmB,UAAK,GAAL,KAAK,CAA2B;QAE/D,CAAC;QACD,IAAc,UAAU;YACpB,OAAO,QAAQ,CAAC;QACpB,CAAC;QACD,eAAe;YACX,OAAO,IAAI,CAAC,KAAK,CAAC;QACtB,CAAC;QACS,kBAAkB;YACxB,OAAO,SAAS,CAAC;QACrB,CAAC;QACkB,eAAe;YAC9B,OAAO,WAAW,CAAC;QACvB,CAAC;KACJ;IAED,SAAS,cAAc,CAAC,KAAgC;QACpD,mGAAmG;QACnG,oGAA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AU,EAAE,EAAE;SACtF,CAAC,CAAC;QACH,IAAI,CAAC;YACD,MAAM,MAAM,GAAG,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,gBAAgB,CAAC,sCAAsC,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;YAC9H,IAAA,aAAM,EAAC,MAAM,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC,CAAC;QAC1D,CAAC;gBAAS,CAAC;YACP,OAAO,EAAE,CAAC;QACd,CAAC;IACL,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import * as React from '@theia/core/shared/react';
|
|
2
|
+
import { AiConfigurationCategoryRenderer, AiConfigurationRenderContext } from '../ai-configuration-category';
|
|
3
|
+
/**
|
|
4
|
+
* Convenience base for `single-page` categories. Subclasses implement
|
|
5
|
+
* {@link renderSections} (and optionally {@link renderHeader}); the page frame
|
|
6
|
+
* and scrolling container are provided.
|
|
7
|
+
*/
|
|
8
|
+
export declare abstract class SinglePageCategoryRenderer implements AiConfigurationCategoryRenderer {
|
|
9
|
+
renderPage(ctx: AiConfigurationRenderContext): React.ReactNode;
|
|
10
|
+
/** Optional page header (title/description); nothing by default. */
|
|
11
|
+
protected renderHeader(ctx: AiConfigurationRenderContext): React.ReactNode;
|
|
12
|
+
/** The page body: typically one or more {@link AiConfigurationSection}s of rows. */
|
|
13
|
+
protected abstract renderSections(ctx: AiConfigurationRenderContext): React.ReactNode;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=single-page-category-renderer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"single-page-category-renderer.d.ts","sourceRoot":"","sources":["../../../../src/browser/ai-configuration/renderers/single-page-category-renderer.tsx"],"names":[],"mappings":"AAgBA,OAAO,KAAK,KAAK,MAAM,0BAA0B,CAAC;AAClD,OAAO,EAAE,+BAA+B,EAAE,4BAA4B,EAAE,MAAM,8BAA8B,CAAC;AAE7G;;;;GAIG;AACH,8BAAsB,0BAA2B,YAAW,+BAA+B;IAEvF,UAAU,CAAC,GAAG,EAAE,4BAA4B,GAAG,KAAK,CAAC,SAAS;IAO9D,oEAAoE;IACpE,SAAS,CAAC,YAAY,CAAC,GAAG,EAAE,4BAA4B,GAAG,KAAK,CAAC,SAAS;IAI1E,oFAAoF;IACpF,SAAS,CAAC,QAAQ,CAAC,cAAc,CAAC,GAAG,EAAE,4BAA4B,GAAG,KAAK,CAAC,SAAS;CACxF"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SinglePageCategoryRenderer = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("@theia/core/shared/react/jsx-runtime");
|
|
5
|
+
/**
|
|
6
|
+
* Convenience base for `single-page` categories. Subclasses implement
|
|
7
|
+
* {@link renderSections} (and optionally {@link renderHeader}); the page frame
|
|
8
|
+
* and scrolling container are provided.
|
|
9
|
+
*/
|
|
10
|
+
class SinglePageCategoryRenderer {
|
|
11
|
+
renderPage(ctx) {
|
|
12
|
+
return (0, jsx_runtime_1.jsxs)("div", { className: 'ai-configuration-page', children: [this.renderHeader(ctx), this.renderSections(ctx)] });
|
|
13
|
+
}
|
|
14
|
+
/** Optional page header (title/description); nothing by default. */
|
|
15
|
+
renderHeader(ctx) {
|
|
16
|
+
return undefined;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
exports.SinglePageCategoryRenderer = SinglePageCategoryRenderer;
|
|
20
|
+
//# sourceMappingURL=single-page-category-renderer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"single-page-category-renderer.js","sourceRoot":"","sources":["../../../../src/browser/ai-configuration/renderers/single-page-category-renderer.tsx"],"names":[],"mappings":";;;;AAmBA;;;;GAIG;AACH,MAAsB,0BAA0B;IAE5C,UAAU,CAAC,GAAiC;QACxC,OAAO,iCAAK,SAAS,EAAC,uBAAuB,aACxC,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,EACtB,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,IACvB,CAAC;IACX,CAAC;IAED,oEAAoE;IAC1D,YAAY,CAAC,GAAiC;QACpD,OAAO,SAAS,CAAC;IACrB,CAAC;CAIJ;AAhBD,gEAgBC"}
|