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.
This commit is contained in:
@@ -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") {
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user