From fea97766dd69d18252df0fef881ea4680a74b3c5 Mon Sep 17 00:00:00 2001 From: can1357 Date: Sun, 3 May 2026 06:13:24 +0200 Subject: [PATCH] fix(coding-agent/modes): applied setting visibility conditions to all setting variants - Refactored setting definitions so the optional visibility predicate now lives on the shared base interface. - Updated path-to-def mapping to pass the shared condition through every setting variant. - Adjusted SettingsSelectorComponent to evaluate condition for all setting types before rendering items. --- .../src/modes/components/settings-defs.ts | 13 ++++++++----- .../src/modes/components/settings-selector.ts | 4 ++-- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/packages/coding-agent/src/modes/components/settings-defs.ts b/packages/coding-agent/src/modes/components/settings-defs.ts index 638914190..da5e60a50 100644 --- a/packages/coding-agent/src/modes/components/settings-defs.ts +++ b/packages/coding-agent/src/modes/components/settings-defs.ts @@ -33,11 +33,16 @@ interface BaseSettingDef { label: string; description: string; tab: SettingTab; + /** + * Optional visibility predicate. When supplied and returning false, the + * setting is hidden from the UI. Applies to every variant — booleans, + * enums, submenus, and text inputs. + */ + condition?: () => boolean; } export interface BooleanSettingDef extends BaseSettingDef { type: "boolean"; - condition?: () => boolean; } export interface EnumSettingDef extends BaseSettingDef { @@ -512,13 +517,11 @@ function pathToSettingDef(path: SettingPath): SettingDef | null { if (!ui) return null; const schemaType = getType(path); - const base = { path, label: ui.label, description: ui.description, tab: ui.tab }; - - // Check for condition const condition = ui.condition ? CONDITIONS[ui.condition] : undefined; + const base = { path, label: ui.label, description: ui.description, tab: ui.tab, condition }; if (schemaType === "boolean") { - return { ...base, type: "boolean", condition }; + return { ...base, type: "boolean" }; } if (schemaType === "enum") { diff --git a/packages/coding-agent/src/modes/components/settings-selector.ts b/packages/coding-agent/src/modes/components/settings-selector.ts index 4344b399e..f61e44acc 100644 --- a/packages/coding-agent/src/modes/components/settings-selector.ts +++ b/packages/coding-agent/src/modes/components/settings-selector.ts @@ -288,8 +288,8 @@ export class SettingsSelectorComponent extends Container { * Convert a setting definition to a SettingItem for the UI. */ #defToItem(def: SettingDef): SettingItem | null { - // Check condition - if (def.type === "boolean" && def.condition && !def.condition()) { + // Check condition: applies to every variant — booleans, enums, submenus, text inputs. + if (def.condition && !def.condition()) { return null; }