From a315ab29bc465858d3cf5dd162d920481003b919 Mon Sep 17 00:00:00 2001 From: oyi77 Date: Tue, 31 Mar 2026 04:27:40 +0700 Subject: [PATCH] fix(debug/sidebar): make debug toggle control debug section visibility and fix sidebar hidden items tracking - Sync debugMode with showDebug in Sidebar (was using enableRequestLogs env var) - Only render debug-section sidebar toggles in AppearanceTab when debugMode=true - Sidebar filters debug-section items based on debugMode (was already correct) - Debug toggle now triggers omniroute:settings-updated event for instant sidebar update EOF --- .../dashboard/settings/components/AppearanceTab.tsx | 5 ++++- src/shared/components/Sidebar.tsx | 6 +++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/app/(dashboard)/dashboard/settings/components/AppearanceTab.tsx b/src/app/(dashboard)/dashboard/settings/components/AppearanceTab.tsx index 3c5d685530..bf173b8b4b 100644 --- a/src/app/(dashboard)/dashboard/settings/components/AppearanceTab.tsx +++ b/src/app/(dashboard)/dashboard/settings/components/AppearanceTab.tsx @@ -106,7 +106,10 @@ export default function AppearanceTab() { { id: "cyan", color: COLOR_THEMES.cyan, label: t("themeCyan") }, ]; - const sidebarSections = SIDEBAR_SECTIONS.map((section) => ({ + const showDebug = settings.debugMode === true; + const sidebarSections = SIDEBAR_SECTIONS.filter( + (section) => section.visibility !== "debug" || showDebug + ).map((section) => ({ ...section, title: getSidebarLabel(section.titleKey, section.titleFallback), items: section.items.map((item) => ({ ...item, label: tSidebar(item.i18nKey) })), diff --git a/src/shared/components/Sidebar.tsx b/src/shared/components/Sidebar.tsx index fb77a3017a..2eeb5a3b65 100644 --- a/src/shared/components/Sidebar.tsx +++ b/src/shared/components/Sidebar.tsx @@ -40,7 +40,7 @@ export default function Sidebar({ useEffect(() => { const applySettings = (data) => { - setShowDebug(data?.enableRequestLogs === true); + setShowDebug(data?.debugMode === true); setHiddenSidebarItems(normalizeHiddenSidebarItems(data?.[HIDDEN_SIDEBAR_ITEMS_SETTING_KEY])); }; @@ -52,8 +52,8 @@ export default function Sidebar({ const handleSettingsUpdated = (event: Event) => { const detail = (event as CustomEvent>).detail || {}; - if ("enableRequestLogs" in detail) { - setShowDebug(detail.enableRequestLogs === true); + if ("debugMode" in detail) { + setShowDebug(detail.debugMode === true); } if (HIDDEN_SIDEBAR_ITEMS_SETTING_KEY in detail) {