import { useEffect, useState } from "preact/hooks"; import { t, LANG, setLang } from "../../i18n"; import { getTheme, setTheme, type ThemeMode } from "../../features/theme/theme"; import { api } from "../../features/customize/api"; import { custTab } from "../../features/customize/actions"; import { getLayout, setLayout, type LayoutName } from "../../features/customize/layout"; import { useAlive } from "./use-timer-lease"; import { markCustomizeLoaded } from "../../features/customize/load"; import { DiagnosticsTab } from "./DiagnosticsTab"; import { CustRow, Hdr, Seg } from "./ui"; export function GeneralTab() { const alive = useAlive(); const [keyLine, setKeyLine] = useState(t("cust.models.key.missing")); const theme = getTheme(); const layout = getLayout(); useEffect(() => { void (async () => { let conf: Record = {}; try { conf = await api("/config/llm"); } catch { conf = {}; } if (!alive()) return; markCustomizeLoaded(); setKeyLine( conf.has_api_key ? t("cust.general.apiKeyConfigured") + (conf.model ? "(" + String(conf.model) + ")" : "") : t("cust.models.key.missing"), ); })(); }, [alive]); return (
{ setTheme(val as ThemeMode); custTab("general"); }} /> { setLayout(val as LayoutName); custTab("general"); }} /> { void setLang(val); }} />
); }