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

Function SettingsDialog

packages/cli/src/ui/components/SettingsDialog.tsx:45–471  ·  view source on GitHub ↗
({
  settings,
  onSelect,
  onRestartRequest,
}: SettingsDialogProps)

Source from the content-addressed store, hash-verified

43const maxItemsToShow = 8;
44
45export function SettingsDialog({
46 settings,
47 onSelect,
48 onRestartRequest,
49}: SettingsDialogProps): React.JSX.Element {
50 // Get vim mode context to sync vim mode changes
51 const { vimEnabled, toggleVimEnabled } = useVimMode();
52
53 // Focus state: 'settings' or 'scope'
54 const [focusSection, setFocusSection] = useState<'settings' | 'scope'>(
55 'settings',
56 );
57 // Scope selector state (User by default)
58 const [selectedScope, setSelectedScope] = useState<SettingScope>(
59 SettingScope.User,
60 );
61 // Active indices
62 const [activeSettingIndex, setActiveSettingIndex] = useState(0);
63 // Scroll offset for settings
64 const [scrollOffset, setScrollOffset] = useState(0);
65 const [showRestartPrompt, setShowRestartPrompt] = useState(false);
66
67 // Local pending settings state for the selected scope
68 const [pendingSettings, setPendingSettings] = useState<Settings>(() =>
69 // Deep clone to avoid mutation
70 structuredClone(settings.forScope(selectedScope).settings),
71 );
72
73 // Track which settings have been modified by the user
74 const [modifiedSettings, setModifiedSettings] = useState<Set<string>>(
75 new Set(),
76 );
77
78 // Track the intended values for modified settings
79 const [modifiedValues, setModifiedValues] = useState<Map<string, boolean>>(
80 new Map(),
81 );
82
83 // Track restart-required settings across scope changes
84 const [restartRequiredSettings, setRestartRequiredSettings] = useState<
85 Set<string>
86 >(new Set());
87
88 useEffect(() => {
89 setPendingSettings(
90 structuredClone(settings.forScope(selectedScope).settings),
91 );
92 // Don't reset modifiedSettings when scope changes - preserve user's pending changes
93 if (restartRequiredSettings.size === 0) {
94 setShowRestartPrompt(false);
95 }
96 }, [selectedScope, settings, restartRequiredSettings]);
97
98 // Preserve pending changes when scope changes
99 useEffect(() => {
100 if (modifiedSettings.size > 0) {
101 setPendingSettings((prevPending) => {
102 let updatedPending = { ...prevPending };

Callers

nothing calls this directly

Calls 14

useVimModeFunction · 0.85
setPendingSettingValueFunction · 0.85
generateSettingsItemsFunction · 0.85
getScopeItemsFunction · 0.85
useKeypressFunction · 0.85
getDefaultValueFunction · 0.85
requiresRestartFunction · 0.85
saveModifiedSettingsFunction · 0.85
getDisplayValueFunction · 0.85
isDefaultValueFunction · 0.85

Tested by

no test coverage detected