(null);
const locale = useLocale();
const t = useTranslations("settings");
@@ -54,6 +59,27 @@ export default function SystemStorageTab() {
}
};
+ const loadSettings = async () => {
+ setSettingsLoading(true);
+ try {
+ const res = await fetch("/api/settings");
+ if (!res.ok) return;
+ const data = await res.json();
+ const value =
+ typeof data.maxCallLogs === "number" &&
+ Number.isInteger(data.maxCallLogs) &&
+ data.maxCallLogs > 0
+ ? data.maxCallLogs
+ : 10000;
+ setMaxCallLogs(value);
+ setMaxCallLogsDraft(String(value));
+ } catch (err) {
+ console.error("Failed to fetch settings:", err);
+ } finally {
+ setSettingsLoading(false);
+ }
+ };
+
const handleManualBackup = async () => {
setManualBackupLoading(true);
setManualBackupStatus({ type: "", message: "" });
@@ -119,8 +145,47 @@ export default function SystemStorageTab() {
useEffect(() => {
loadStorageHealth();
+ loadSettings();
}, []);
+ const handleSaveMaxCallLogs = async () => {
+ const parsed = Number.parseInt(maxCallLogsDraft, 10);
+ if (!Number.isInteger(parsed) || parsed <= 0) {
+ setMaxCallLogsStatus({
+ type: "error",
+ message: "Enter a positive integer for the call log limit.",
+ });
+ return;
+ }
+
+ setMaxCallLogsSaving(true);
+ setMaxCallLogsStatus({ type: "", message: "" });
+ try {
+ const res = await fetch("/api/settings", {
+ method: "PATCH",
+ headers: { "Content-Type": "application/json" },
+ body: JSON.stringify({ maxCallLogs: parsed }),
+ });
+ const data = await res.json();
+ if (!res.ok) {
+ throw new Error(data.error || "Failed to save call log limit");
+ }
+ setMaxCallLogs(parsed);
+ setMaxCallLogsDraft(String(parsed));
+ setMaxCallLogsStatus({
+ type: "success",
+ message: "Call log retention limit saved.",
+ });
+ } catch (err) {
+ setMaxCallLogsStatus({
+ type: "error",
+ message: (err as Error).message || "Failed to save call log limit",
+ });
+ } finally {
+ setMaxCallLogsSaving(false);
+ }
+ };
+
const handleExport = async () => {
setExportLoading(true);
try {
@@ -276,6 +341,56 @@ export default function SystemStorageTab() {
+
+
+
+
Call log retention limit
+
+ Keep only the most recent call log entries in SQLite. Older entries are pruned
+ automatically after each new request log is saved.
+
+
+
+ {maxCallLogs.toLocaleString()}
+
+
+
+
+ setMaxCallLogsDraft(e.target.value)}
+ disabled={settingsLoading || maxCallLogsSaving}
+ className="w-40 rounded-lg border border-border bg-bg-secondary px-3 py-2 text-sm text-text-main focus:outline-none focus:ring-1 focus:ring-primary/40"
+ aria-label="Call log retention limit"
+ />
+
+
+
+ {maxCallLogsStatus.message && (
+
+ {maxCallLogsStatus.message}
+
+ )}
+
+
{/* Export / Import */}