From d208dc70a4b17f217feea7d2786078d1a0be7140 Mon Sep 17 00:00:00 2001
From: "dayuan.jiang"
Date: Fri, 12 Jun 2026 08:13:26 +0900
Subject: [PATCH] fix: address admin panel review findings
- Security: test-model no longer resolves a stored secret when the
request's baseUrl/provider differs from the stored entry, closing a
path where a tampered baseUrl could exfiltrate a saved key
- Save failures are now visible: the save bar shows the error in red
(was masked by the persistent 'Unsaved changes' text), and per-field
validation errors from the settings API are surfaced under each field
- The Observability/Quota enable switch is now real: toggling off stages
deletion of the group's saved values, and the toggle no longer snaps
back to Enabled after saving
- Env provider's default star is hidden when a panel provider is the
active default (no more double star)
- Clearing a credential field reverts to the stored value instead of
silently deleting it; an explicit X button removes a stored secret
- Form inputs are disabled during an in-flight save
---
app/[lang]/admin/page.tsx | 127 ++++++++++++++++++++++++------
app/api/admin/providers/route.ts | 10 ++-
app/api/admin/test-model/route.ts | 15 +++-
3 files changed, 123 insertions(+), 29 deletions(-)
diff --git a/app/[lang]/admin/page.tsx b/app/[lang]/admin/page.tsx
index 79c6e65..1dff9d4 100644
--- a/app/[lang]/admin/page.tsx
+++ b/app/[lang]/admin/page.tsx
@@ -146,23 +146,37 @@ function RestartBadge() {
)
}
-// Secret input: shows masked hint as placeholder, typing replaces
+// Secret input: shows masked hint as placeholder, typing replaces.
+// With keepOnEmpty, clearing the field reverts to the stored value
+// ("keep") instead of deleting it — explicit deletion is via the X button.
function SecretInput({
id,
value,
disabled,
+ keepOnEmpty,
onChange,
}: {
id: string
value: string | SecretValue | undefined
disabled?: boolean
- onChange: (value: string) => void
+ keepOnEmpty?: boolean
+ onChange: (value: string | SecretValue) => void
}) {
const [show, setShow] = useState(false)
+ // The stored marker as it was at mount, to revert to on empty
+ const [original] = useState(value)
+ const hadStored = isSecretValue(original)
const text = typeof value === "string" ? value : ""
const placeholder = isSecretValue(value)
? `Saved (${value.hint}) — type to replace`
: "Not set"
+ const handleText = (t: string) => {
+ if (t === "" && keepOnEmpty && hadStored && original) {
+ onChange(original)
+ } else {
+ onChange(t)
+ }
+ }
return (