Use harness labels for current options

Signed-off-by: kenny lopez <klopez4212@gmail.com>
This commit is contained in:
kenny lopez
2026-07-27 13:29:51 +01:00
parent d3e74c33d8
commit 17329c4227
4 changed files with 37 additions and 3 deletions
@@ -37,6 +37,7 @@ import {
AUTO_PROVIDER_DROPDOWN_VALUE,
CUSTOM_PROVIDER_DROPDOWN_VALUE,
computeLocalModeGate,
formatCurrentRuntimeOptionLabel,
formatRuntimeOptionLabel,
getDefaultPersonaRuntime,
getPersonaHiddenProviderIds,
@@ -602,7 +603,7 @@ export function AgentDefinitionDialog({
!runtimeDropdownOptions.some((option) => option.value === runtime)
) {
runtimeDropdownOptions.push({
label: `${runtime.trim()} (current)`,
label: formatCurrentRuntimeOptionLabel(runtimes, runtime),
value: runtime.trim(),
});
}
@@ -28,6 +28,7 @@ import { EditAgentAdvancedFields } from "./EditAgentAdvancedFields";
import {
AUTO_PROVIDER_DROPDOWN_VALUE,
CUSTOM_PROVIDER_DROPDOWN_VALUE,
formatCurrentRuntimeOptionLabel,
formatRuntimeOptionLabel,
getDefaultLlmModelLabel,
getDefaultPersonaRuntime,
@@ -243,12 +244,12 @@ export function AgentInstanceEditDialog({
!options.some((o) => o.value === selectedRuntimeId)
) {
options.push({
label: `${selectedRuntimeId} (current)`,
label: formatCurrentRuntimeOptionLabel(runtimes, selectedRuntimeId),
value: selectedRuntimeId,
});
}
return options;
}, [sortedRuntimes, selectedRuntimeId]);
}, [runtimes, sortedRuntimes, selectedRuntimeId]);
// Resolve the dialog-opening command as the catalog loads. Edit-state runtime
// ids mutate during selection changes and cannot identify the original state.
@@ -2,6 +2,7 @@ import assert from "node:assert/strict";
import test from "node:test";
import {
formatCurrentRuntimeOptionLabel,
getDefaultPersonaRuntime,
getPersonaHiddenProviderIds,
getPersonaModelOptions,
@@ -34,6 +35,25 @@ function makeRuntime(
};
}
test("formatCurrentRuntimeOptionLabel uses the catalog display label", () => {
const runtime = {
...makeRuntime("goose"),
label: "Goose",
};
assert.equal(
formatCurrentRuntimeOptionLabel([runtime], "goose"),
"Goose (current)",
);
});
test("formatCurrentRuntimeOptionLabel falls back to an unknown runtime id", () => {
assert.equal(
formatCurrentRuntimeOptionLabel([], " custom-runtime "),
"custom-runtime (current)",
);
});
// ── getPersonaProviderOptions — hideProviderIds ───────────────────────────────
test("getPersonaProviderOptions returns databricks v1 and v2 when hideProviderIds is empty", () => {
@@ -489,6 +489,18 @@ export function formatRuntimeOptionLabel(runtime: AcpRuntimeCatalogEntry) {
return `${runtime.label}${suffix}`;
}
export function formatCurrentRuntimeOptionLabel(
runtimes: readonly AcpRuntimeCatalogEntry[],
runtimeId: string,
) {
const trimmedRuntimeId = runtimeId.trim();
const runtime = runtimes.find(
(candidate) => candidate.id === trimmedRuntimeId,
);
const label = runtime ? formatRuntimeOptionLabel(runtime) : trimmedRuntimeId;
return `${label} (current)`;
}
function runtimeAvailabilitySortRank(
availability: AcpRuntimeCatalogEntry["availability"],
) {