MCPcopy
hub / github.com/opentrace/opentrace / SettingsDrawer

Function SettingsDrawer

ui/src/appComponents/SettingsDrawer.tsx:70–467  ·  view source on GitHub ↗
({
  onClose,
  onGraphCleared,
  onLimitsChanged,
  onAnimationSettingsChanged,
}: SettingsDrawerProps)

Source from the content-addressed store, hash-verified

68}
69
70export default function SettingsDrawer({
71 onClose,
72 onGraphCleared,
73 onLimitsChanged,
74 onAnimationSettingsChanged,
75}: SettingsDrawerProps) {
76 const { store } = useStore();
77 const panelRef = useRef<HTMLDivElement>(null);
78 const { width: panelWidth, handleMouseDown } = useResizablePanel({
79 storageKey: 'ot_settings_drawer_width',
80 defaultWidth: 420,
81 minWidth: 360,
82 maxWidth: 700,
83 side: 'left',
84 panelRef,
85 });
86 const [clearing, setClearing] = useState(false);
87 const [confirmOpen, setConfirmOpen] = useState(false);
88 const [error, setError] = useState<string | null>(null);
89 const [summaryStrategy, setSummaryStrategy] =
90 useState<SummarizationStrategyType>(loadSummarizerStrategy);
91 const [llmConfig, setLlmConfig] = useState(loadSummarizerLlmConfig);
92 const [llmModels, setLlmModels] = useState<string[] | null>(null);
93 const [llmModelsFetching, setLlmModelsFetching] = useState(false);
94 // String state so intermediate keystrokes (typing "4" before "000") are
95 // not clamped to `min` while still in flight. Parsed/clamped only when
96 // the user commits by clicking "Update".
97 const [maxNodesText, setMaxNodesText] = useState(() =>
98 String(loadLimit(LS_KEY_NODES, DEFAULT_MAX_NODES)),
99 );
100 const [maxEdgesText, setMaxEdgesText] = useState(() =>
101 String(loadLimit(LS_KEY_EDGES, DEFAULT_MAX_EDGES)),
102 );
103 const [animSettings, setAnimSettings] = useState(loadAnimationSettings);
104
105 const handleAnimToggle = (key: keyof AnimationSettings) => {
106 const next = { ...animSettings, [key]: !animSettings[key] };
107 setAnimSettings(next);
108 saveAnimationSetting(key, next[key]);
109 onAnimationSettingsChanged?.(next);
110 };
111
112 const handleClear = async () => {
113 setClearing(true);
114 setError(null);
115 try {
116 await store.clearGraph();
117 setConfirmOpen(false);
118 onGraphCleared();
119 } catch (err) {
120 setError(err instanceof Error ? err.message : 'Failed to clear graph');
121 } finally {
122 setClearing(false);
123 }
124 };
125
126 const handleStrategyChange = (strategy: SummarizationStrategyType) => {
127 setSummaryStrategy(strategy);

Callers

nothing calls this directly

Calls 7

useStoreFunction · 0.90
useResizablePanelFunction · 0.90
loadLimitFunction · 0.85
parseLimitFunction · 0.85
handleStrategyChangeFunction · 0.85
handleLlmConfigChangeFunction · 0.85
handleAnimToggleFunction · 0.85

Tested by

no test coverage detected