fix: preserve custom route display state

This commit is contained in:
Patrick Ribbsaeter 2026-08-11 18:54:21 +02:00
parent fe74cefba4
commit 485ceda428
2 changed files with 9 additions and 4 deletions

View file

@ -22,9 +22,8 @@ export const exactKeyTypePresetFromRoutes = (allowedRoutes: string[] | null | un
return KEY_TYPE_BY_PRESET_ROUTE[allowedRoutes[0]];
};
// Determine the key_type display value from allowed_routes
export const keyTypeFromRoutes = (allowedRoutes: string[] | null | undefined): string =>
exactKeyTypePresetFromRoutes(allowedRoutes) ?? "default";
export const keyTypeFromRoutes = (allowedRoutes: string[] | null | undefined): string | undefined =>
exactKeyTypePresetFromRoutes(allowedRoutes);
export const parseAllowedRoutes = (value: unknown): string[] =>
typeof value === "string" && value.trim() !== ""
@ -51,4 +50,3 @@ export const currentValuePlaceholder = (
if (!premiumUser) return premiumHint;
return Array.isArray(current) && current.length > 0 ? `Current: ${current.join(", ")}` : emptyHint;
};

View file

@ -11,6 +11,7 @@ import {
modelAvailableCall,
vectorStoreListCall,
} from "../networking";
import { keyTypeFromRoutes } from "./keyEditFieldNormalizers";
import { KeyEditView } from "./key_edit_view";
const can = vi.fn();
@ -135,6 +136,12 @@ vi.mock("../agent_management/AgentSelector", () => ({
),
}));
describe("keyTypeFromRoutes", () => {
it("does not label a mixed allowlist as Full Access", () => {
expect(keyTypeFromRoutes(["llm_api_routes", "/custom"])).toBeUndefined();
});
});
vi.mock("../common_components/AccessGroupSelector", () => ({
default: ({ value = [], onChange }: { value?: string[]; onChange?: (v: string[]) => void }) => (
<input