From 17329c4227c47a2fc05a1d8f9256d627c92c8cea Mon Sep 17 00:00:00 2001 From: kenny lopez Date: Fri, 24 Jul 2026 08:54:11 -0700 Subject: [PATCH] Use harness labels for current options Signed-off-by: kenny lopez --- .../agents/ui/AgentDefinitionDialog.tsx | 3 ++- .../agents/ui/AgentInstanceEditDialog.tsx | 5 +++-- .../agents/ui/agentConfigOptions.test.mjs | 20 +++++++++++++++++++ .../features/agents/ui/agentConfigOptions.tsx | 12 +++++++++++ 4 files changed, 37 insertions(+), 3 deletions(-) diff --git a/desktop/src/features/agents/ui/AgentDefinitionDialog.tsx b/desktop/src/features/agents/ui/AgentDefinitionDialog.tsx index ee6177ce3..482bf5a3b 100644 --- a/desktop/src/features/agents/ui/AgentDefinitionDialog.tsx +++ b/desktop/src/features/agents/ui/AgentDefinitionDialog.tsx @@ -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(), }); } diff --git a/desktop/src/features/agents/ui/AgentInstanceEditDialog.tsx b/desktop/src/features/agents/ui/AgentInstanceEditDialog.tsx index 1d87bf058..b523a9d8b 100644 --- a/desktop/src/features/agents/ui/AgentInstanceEditDialog.tsx +++ b/desktop/src/features/agents/ui/AgentInstanceEditDialog.tsx @@ -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. diff --git a/desktop/src/features/agents/ui/agentConfigOptions.test.mjs b/desktop/src/features/agents/ui/agentConfigOptions.test.mjs index d2dc068f9..a93e862f9 100644 --- a/desktop/src/features/agents/ui/agentConfigOptions.test.mjs +++ b/desktop/src/features/agents/ui/agentConfigOptions.test.mjs @@ -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", () => { diff --git a/desktop/src/features/agents/ui/agentConfigOptions.tsx b/desktop/src/features/agents/ui/agentConfigOptions.tsx index d8ceb0144..f31a20441 100644 --- a/desktop/src/features/agents/ui/agentConfigOptions.tsx +++ b/desktop/src/features/agents/ui/agentConfigOptions.tsx @@ -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"], ) {