From edee1141228c52f85f8c16ea352bb2e1fdb71dad Mon Sep 17 00:00:00 2001 From: Mark IJbema Date: Wed, 25 Mar 2026 14:40:18 +0100 Subject: [PATCH] fix(vscode): restrict export to custom modes and validate mode field on import Hide export button for native/built-in agents since their full definition is not available from config overrides alone. Validate the mode field on import against the allowed values (subagent, primary, all) instead of blindly casting. --- .../components/settings/AgentBehaviourTab.tsx | 3 ++- .../src/components/settings/ModeEditView.tsx | 22 +++++++++---------- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/packages/kilo-vscode/webview-ui/src/components/settings/AgentBehaviourTab.tsx b/packages/kilo-vscode/webview-ui/src/components/settings/AgentBehaviourTab.tsx index c63cbe922a5..ff55cc54392 100644 --- a/packages/kilo-vscode/webview-ui/src/components/settings/AgentBehaviourTab.tsx +++ b/packages/kilo-vscode/webview-ui/src/components/settings/AgentBehaviourTab.tsx @@ -248,7 +248,8 @@ const AgentBehaviourTab: Component = () => { if (typeof data.description === "string") partial.description = data.description if (typeof data.prompt === "string") partial.prompt = data.prompt if (typeof data.model === "string") partial.model = data.model - if (typeof data.mode === "string") partial.mode = data.mode as AgentConfig["mode"] + const modes = ["subagent", "primary", "all"] as const + if (typeof data.mode === "string" && modes.includes(data.mode)) partial.mode = data.mode if (typeof data.temperature === "number") partial.temperature = data.temperature if (typeof data.top_p === "number") partial.top_p = data.top_p if (typeof data.steps === "number") partial.steps = data.steps diff --git a/packages/kilo-vscode/webview-ui/src/components/settings/ModeEditView.tsx b/packages/kilo-vscode/webview-ui/src/components/settings/ModeEditView.tsx index d8c47b1f279..88a12774b5f 100644 --- a/packages/kilo-vscode/webview-ui/src/components/settings/ModeEditView.tsx +++ b/packages/kilo-vscode/webview-ui/src/components/settings/ModeEditView.tsx @@ -68,15 +68,15 @@ const ModeEditView: Component = (props) => { {language.t("settings.agentBehaviour.editMode")} — {props.name} -
- - + +
+ = (props) => { if (a) props.onRemove(a) }} /> - -
+
+