fix(plugins): mark ineligible saved profiles unavailable

This commit is contained in:
ayattara
2026-08-26 02:56:14 +00:00
parent 1f41ba57c4
commit 6dcf02bb75
2 changed files with 11 additions and 6 deletions
@@ -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,
@@ -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 (
<Select