From 3e87e556049dc2d484fc4ca511fdee1ed6a1dfcc Mon Sep 17 00:00:00 2001 From: samzong Date: Wed, 6 May 2026 15:44:19 +0800 Subject: [PATCH] fix(ui): preserve empty plugin allowlists Signed-off-by: samzong --- ui/src/ui/controllers/config.test.ts | 42 ++++++++++++++++++++++++++++ ui/src/ui/controllers/config.ts | 4 +++ 2 files changed, 46 insertions(+) diff --git a/ui/src/ui/controllers/config.test.ts b/ui/src/ui/controllers/config.test.ts index 4f114f61f15..b44bdc6487d 100644 --- a/ui/src/ui/controllers/config.test.ts +++ b/ui/src/ui/controllers/config.test.ts @@ -324,6 +324,48 @@ describe("updateConfigFormValue", () => { }); expect(state.configFormDirty).toBe(true); }); + + it("preserves empty plugin allowlists when enabling a plugin", () => { + const state = createState(); + applyConfigSnapshot(state, { + hash: "hash-plugins", + config: { + plugins: { + allow: [], + entries: { + deepseek: { enabled: false }, + }, + }, + }, + valid: true, + issues: [], + raw: "{}", + }); + + updateConfigFormValue(state, ["plugins", "entries", "deepseek", "enabled"], true); + + expect(state.configForm).toEqual({ + plugins: { + allow: [], + entries: { + deepseek: { enabled: true }, + }, + }, + }); + expect(state.configFormDirty).toBe(true); + + updateConfigFormValue(state, ["plugins", "entries", "deepseek", "enabled"], false); + + expect(state.configForm).toEqual({ + plugins: { + allow: [], + entries: { + deepseek: { enabled: false }, + }, + }, + }); + expect(state.configFormDirty).toBe(false); + }); }); describe("stageConfigPreset", () => { diff --git a/ui/src/ui/controllers/config.ts b/ui/src/ui/controllers/config.ts index f7a4ed8e4dc..2be2702ad5c 100644 --- a/ui/src/ui/controllers/config.ts +++ b/ui/src/ui/controllers/config.ts @@ -332,6 +332,10 @@ function syncEnabledPluginAllowlist( if (allow.includes(pluginId)) { return; } + if (allow.length === 0) { + untrackAutoAllowlistedPluginId(state, pluginId); + return; + } setPathValue(draft, ["plugins", "allow"], [...allow, pluginId]); trackAutoAllowlistedPluginId(state, pluginId); return;