From 404f49959dcc821a1ded5cab015a16319f2fa105 Mon Sep 17 00:00:00 2001 From: rcourtman Date: Wed, 14 Jan 2026 23:38:28 +0000 Subject: [PATCH] fix(ui): preserve user preferences across logout sessions Previously, logout cleared all localStorage, wiping user preferences like column visibility, view modes, temperature units, and filters. Now only auth and session-specific caches are cleared. Fixes #1107 --- frontend-modern/src/App.tsx | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/frontend-modern/src/App.tsx b/frontend-modern/src/App.tsx index d9f3bb581..cd56202b7 100644 --- a/frontend-modern/src/App.tsx +++ b/frontend-modern/src/App.tsx @@ -753,15 +753,18 @@ function App() { logger.error('Logout error', error); } - // Clear all local storage EXCEPT theme preference and logout flag - const currentTheme = localStorage.getItem(STORAGE_KEYS.DARK_MODE); - localStorage.clear(); + // Clear only auth and session-specific storage, preserve user preferences + // Keys to clear on logout (auth and per-session caches) + const keysToRemove = [ + STORAGE_KEYS.AUTH, + STORAGE_KEYS.LEGACY_TOKEN, + STORAGE_KEYS.GUEST_METADATA, + STORAGE_KEYS.DOCKER_METADATA, + STORAGE_KEYS.DOCKER_METADATA + '_hosts', + ]; + keysToRemove.forEach((key) => localStorage.removeItem(key)); sessionStorage.clear(); localStorage.setItem('just_logged_out', 'true'); - // Preserve theme preference across logout - if (currentTheme) { - localStorage.setItem(STORAGE_KEYS.DARK_MODE, currentTheme); - } // Clear WebSocket connection if (wsStore()) {