diff --git a/apps/web/components/settings/plugins/plugin-config-form.agent-profile.test.tsx b/apps/web/components/settings/plugins/plugin-config-form.agent-profile.test.tsx index 72fc10f35f..97d17ee6c7 100644 --- a/apps/web/components/settings/plugins/plugin-config-form.agent-profile.test.tsx +++ b/apps/web/components/settings/plugins/plugin-config-form.agent-profile.test.tsx @@ -82,6 +82,12 @@ describe("PluginConfigForm agent profile field", () => { expect(screen.getByText("Unavailable: deleted-profile")).not.toBeNull(); }); + it("marks an ineligible saved profile as unavailable", () => { + renderField([profile({ id: "disabled", label: "Disabled", enabled: false })], "disabled"); + + expect(screen.getByText("Unavailable: Disabled")).not.toBeNull(); + }); + it("hides the Not set option for required fields", () => { renderField([profile({ id: "eligible", label: ELIGIBLE_PROFILE_LABEL })], "", { required: true, diff --git a/apps/web/components/settings/plugins/plugin-config-form.tsx b/apps/web/components/settings/plugins/plugin-config-form.tsx index f9a04d60ea..cc06e246bb 100644 --- a/apps/web/components/settings/plugins/plugin-config-form.tsx +++ b/apps/web/components/settings/plugins/plugin-config-form.tsx @@ -256,14 +256,13 @@ function AgentProfileSelect({ const selectedID = typeof value === "string" ? value : ""; const selectedProfile = profiles.find((profile) => profile.id === selectedID); const eligibleProfiles = profiles.filter((profile) => utilityProfileEligibility(profile)); - let selectedLabel: string | undefined; - if (selectedProfile) { - selectedLabel = selectedProfile.label || selectedProfile.agent_name || selectedProfile.id; - } else if (selectedID) { - selectedLabel = t("settings:utilityUnavailableProfile", { name: selectedID }); - } const isStale = selectedID !== "" && !eligibleProfiles.some((profile) => profile.id === selectedID); + const selectedProfileLabel = + selectedProfile?.label || selectedProfile?.agent_name || selectedProfile?.id || selectedID; + const selectedLabel = isStale + ? t("settings:utilityUnavailableProfile", { name: selectedProfileLabel }) + : selectedProfileLabel || undefined; return (