From 06cf00129fa6f8c41ceea15de26c2de69bb1328e Mon Sep 17 00:00:00 2001 From: "Cody (Radius Red)" Date: Tue, 31 Mar 2026 15:09:54 +0000 Subject: [PATCH] fix(ui): preserve env var when switching type from Plain to Secret MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When changing an env var's type from Plain to Secret in the agent config form, the row was silently dropped because emit() skipped secret rows without a secretId. This caused data loss — the variable disappeared from both the UI and the saved config. Fix: keep the row as a plain binding during the transition state until the user selects an actual secret. This preserves the key and value so nothing is lost. Co-Authored-By: Paperclip --- ui/src/components/AgentConfigForm.tsx | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/ui/src/components/AgentConfigForm.tsx b/ui/src/components/AgentConfigForm.tsx index 06c74e65..7d5c4f45 100644 --- a/ui/src/components/AgentConfigForm.tsx +++ b/ui/src/components/AgentConfigForm.tsx @@ -1170,8 +1170,12 @@ function EnvVarEditor({ const k = row.key.trim(); if (!k) continue; if (row.source === "secret") { - if (!row.secretId) continue; - rec[k] = { type: "secret_ref", secretId: row.secretId, version: "latest" }; + if (row.secretId) { + rec[k] = { type: "secret_ref", secretId: row.secretId, version: "latest" }; + } else { + // Preserve as plain during transition to avoid data loss + rec[k] = { type: "plain", value: row.plainValue }; + } } else { rec[k] = { type: "plain", value: row.plainValue }; }