MCPcopy Create free account
hub / github.com/anus-dev/ANUS / generateSettingsItems

Function generateSettingsItems

packages/cli/src/ui/components/SettingsDialog.tsx:121–239  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

119 }, [selectedScope, modifiedSettings, modifiedValues, settings]);
120
121 const generateSettingsItems = () => {
122 const settingKeys = getDialogSettingKeys();
123
124 return settingKeys.map((key: string) => {
125 const currentValue = getSettingValue(key, pendingSettings, {});
126 const definition = getSettingDefinition(key);
127
128 return {
129 label: definition?.label || key,
130 value: key,
131 checked: currentValue,
132 toggle: () => {
133 const newValue = !currentValue;
134
135 setPendingSettings((prev) =>
136 setPendingSettingValue(key, newValue, prev),
137 );
138
139 if (!requiresRestart(key)) {
140 const immediateSettings = new Set([key]);
141 const immediateSettingsObject = setPendingSettingValue(
142 key,
143 newValue,
144 {},
145 );
146
147 console.log(
148 `[DEBUG SettingsDialog] Saving ${key} immediately with value:`,
149 newValue,
150 );
151 saveModifiedSettings(
152 immediateSettings,
153 immediateSettingsObject,
154 settings,
155 selectedScope,
156 );
157
158 // Special handling for vim mode to sync with VimModeContext
159 if (key === 'vimMode' && newValue !== vimEnabled) {
160 // Call toggleVimEnabled to sync the VimModeContext local state
161 toggleVimEnabled().catch((error) => {
162 console.error('Failed to toggle vim mode:', error);
163 });
164 }
165
166 // Capture the current modified settings before updating state
167 const currentModifiedSettings = new Set(modifiedSettings);
168
169 // Remove the saved setting from modifiedSettings since it's now saved
170 setModifiedSettings((prev) => {
171 const updated = new Set(prev);
172 updated.delete(key);
173 return updated;
174 });
175
176 // Remove from modifiedValues as well
177 setModifiedValues((prev) => {
178 const updated = new Map(prev);

Callers 1

SettingsDialogFunction · 0.85

Calls 11

getDialogSettingKeysFunction · 0.85
getSettingValueFunction · 0.85
getSettingDefinitionFunction · 0.85
setPendingSettingValueFunction · 0.85
requiresRestartFunction · 0.85
saveModifiedSettingsFunction · 0.85
forScopeMethod · 0.80
addMethod · 0.80
getMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected