From c8e41e437b2731cdbfcc7eaf040094597bc49865 Mon Sep 17 00:00:00 2001 From: Babak Bandpey Date: Tue, 17 Nov 2026 10:12:39 +0100 Subject: [PATCH] web(llm): keep password managers out of the API key field; add model search The profile drawer's API Key input is a masked field with no autocomplete hint, so browsers and password managers treat it as this site's login password: they fill it when the drawer opens and Save then persists the wrong secret over the key already stored in the profile. Mark the field new-password and add the 1Password/Bitwarden ignore hints, matching the setup page's convention. The loaded model list can hold several hundred entries (OpenRouter: 470), which is unusable without filtering. Add a search input above the list with a case-insensitive substring match, a "no model matches" state, and reset it whenever the list is reloaded or the popover closes. --- web/src/app/(main)/system/llm/page.tsx | 74 ++++++++++++++++++++------ 1 file changed, 59 insertions(+), 15 deletions(-) diff --git a/web/src/app/(main)/system/llm/page.tsx b/web/src/app/(main)/system/llm/page.tsx index 665214f..276a09b 100644 --- a/web/src/app/(main)/system/llm/page.tsx +++ b/web/src/app/(main)/system/llm/page.tsx @@ -343,6 +343,7 @@ function ProfileSheet({ const [models, setModels] = React.useState([]); const [loadingModels, setLoadingModels] = React.useState(false); const [modelsOpen, setModelsOpen] = React.useState(false); + const [modelQuery, setModelQuery] = React.useState(""); // filter text for the loaded model list; reset on open/close // Every time it opens, the form is re-filled from the passed-in profile (reset to defaults when creating). Closing and reopening // the drawer is a clean start, leaving no leftovers from the previous profile. @@ -374,14 +375,24 @@ function ProfileSheet({ setKeyHint(profile?.api_key_hint ?? ""); setModels([]); setModelsOpen(false); + setModelQuery(""); }, [open, profile]); const profileId = profile ? Number(profile.id) : undefined; + // Case-insensitive substring filter, so a provider prefix ("deepseek/") or a + // fragment ("flash") is enough to narrow a 400-entry list. + const filteredModels = React.useMemo(() => { + const q = modelQuery.trim().toLowerCase(); + if (!q) return models; + return models.filter((m) => m.toLowerCase().includes(q)); + }, [models, modelQuery]); + async function loadModels() { if (loadingModels) return; setLoadingModels(true); setModels([]); + setModelQuery(""); try { const r = await api.fetchLLMModels(format, baseUrl, apiKey, proxy, profileId); if (r.ok && r.models && r.models.length > 0) { @@ -541,7 +552,14 @@ function ProfileSheet({ /> {/* modal: this Popover's content is portaled to , outside the Sheet's scroll lock, so without modal the list renders but cannot scroll. modal lets it hold the topmost scroll lock itself. */} - + { + setModelsOpen(o); + if (!o) setModelQuery(""); + }} + modal + > - ))} + +
+ setModelQuery(e.target.value)} + spellCheck={false} + aria-label="Search models" + /> +
+
+ {filteredModels.length === 0 ? ( +

+ No model matches “{modelQuery.trim()}” +

+ ) : ( + filteredModels.map((m) => ( + + )) + )} +
)}
@@ -643,6 +680,13 @@ function ProfileSheet({ placeholder={keyPlaceholder} value={apiKey} onChange={(e) => setApiKey(e.target.value)} + // A masked field with no autocomplete hint looks like this site's + // login password: password managers fill it and Save persists the + // wrong secret over the stored key. new-password keeps them out. + autoComplete="new-password" + spellCheck={false} + data-1p-ignore="true" + data-lpignore="true" />