()
| 41 | ]; |
| 42 | |
| 43 | export default function CodeSettingsPage() { |
| 44 | const { config, saveConfig } = useApp(); |
| 45 | const [tools, setTools] = useState<SystemToolInfo[]>([]); |
| 46 | const [loading, setLoading] = useState(true); |
| 47 | const [backendUrl, setBackendUrl] = useState<string | null>(null); |
| 48 | const [paths, setPaths] = useState<PathsInfo | null>(null); |
| 49 | const [rules, setRules] = useState<RulesResponse | null>(null); |
| 50 | |
| 51 | useEffect(() => { |
| 52 | const loadDetails = async () => { |
| 53 | try { |
| 54 | const [apiBaseUrl, pathsData, rulesData, toolsData] = await Promise.all([ |
| 55 | getApiBaseUrl(), |
| 56 | getPaths(), |
| 57 | getProjectRules(), |
| 58 | getSystemTools(), |
| 59 | ]); |
| 60 | setBackendUrl(apiBaseUrl); |
| 61 | setPaths(pathsData); |
| 62 | setRules(rulesData); |
| 63 | setTools(toolsData); |
| 64 | } catch (err: any) { |
| 65 | toast.error(err?.message || "Failed to load code settings metadata"); |
| 66 | } finally { |
| 67 | setLoading(false); |
| 68 | } |
| 69 | }; |
| 70 | loadDetails(); |
| 71 | }, []); |
| 72 | |
| 73 | const toolMap = useMemo(() => { |
| 74 | const map = new Map<string, SystemToolInfo>(); |
| 75 | tools.forEach((tool) => map.set(tool.name, tool)); |
| 76 | return map; |
| 77 | }, [tools]); |
| 78 | |
| 79 | const updateLsp = (id: string, next: any) => { |
| 80 | if (!config) return; |
| 81 | saveConfig({ |
| 82 | ...config, |
| 83 | lsp: { |
| 84 | ...(config.lsp || {}), |
| 85 | [id]: { ...(config.lsp?.[id] || {}), ...next }, |
| 86 | }, |
| 87 | }); |
| 88 | }; |
| 89 | |
| 90 | const updateFormatter = (id: string, next: any) => { |
| 91 | if (!config) return; |
| 92 | saveConfig({ |
| 93 | ...config, |
| 94 | formatter: { |
| 95 | ...(config.formatter || {}), |
| 96 | [id]: { ...(config.formatter?.[id] || {}), ...next }, |
| 97 | }, |
| 98 | }); |
| 99 | }; |
| 100 |
nothing calls this directly
no test coverage detected