Skip to content

armgit / Pulse

Public Imported from GitHub
0

Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.

fix(frontend): persist kiosk mode in sessionStorage across navigation

rcourtman802ce68e0cf8
diff --git a/frontend-modern/src/App.tsx b/frontend-modern/src/App.tsx
index 5e57eed5f3..d9f3bb5815 100644
--- a/frontend-modern/src/App.tsx
+++ b/frontend-modern/src/App.tsx
@@ -53,6 +53,7 @@ import { AIStatusIndicator } from './components/AI/AIStatusIndicator';
import { aiChatStore } from './stores/aiChat';
import { useResourcesAsLegacy } from './hooks/useResources';
import { updateSystemSettingsFromResponse } from './stores/systemSettings';
+import { initKioskMode } from './utils/url';
const Dashboard = lazy(() =>
@@ -219,6 +220,10 @@ function GlobalUpdateProgressWatcher() {
}
function App() {
+ // Initialize kiosk mode from URL params immediately (persists to sessionStorage)
+ // This must happen before any renders so kiosk state is available everywhere
+ initKioskMode();
+
const TooltipRoot = createTooltipSystem();
const owner = getOwner();
const acquireWsStore = (): EnhancedStore => {
diff --git a/frontend-modern/src/components/Dashboard/Dashboard.tsx b/frontend-modern/src/components/Dashboard/Dashboard.tsx
index 250a460bf6..ab2d13384b 100644
--- a/frontend-modern/src/components/Dashboard/Dashboard.tsx
+++ b/frontend-modern/src/components/Dashboard/Dashboard.tsx
@@ -24,6 +24,7 @@ import { useBreakpoint } from '@/hooks/useBreakpoint';
import { STORAGE_KEYS } from '@/utils/localStorage';
import { getBackupInfo } from '@/utils/format';
import { aiChatStore } from '@/stores/aiChat';
+import { isKioskMode } from '@/utils/url';
type GuestMetadataRecord = Record<string, GuestMetadata>;
type IdleCallbackHandle = number;
@@ -212,12 +213,8 @@ export function Dashboard(props: DashboardProps) {
const alertsEnabled = createMemo(() => alertsActivation.activationState() === 'active');
// Kiosk mode - hide filter panel for clean dashboard display
- // Usage: Add ?kiosk=1 to URL
- const kioskMode = createMemo(() => {
- if (typeof window === 'undefined') return false;
- const params = new URLSearchParams(window.location.search);
- return params.get('kiosk') === '1' || params.get('kiosk') === 'true';
- });
+ // Usage: Add ?kiosk=1 to URL (persists across navigation via sessionStorage)
+ const kioskMode = createMemo(() => isKioskMode());
const [search, setSearch] = createSignal('');
const [isSearchLocked, setIsSearchLocked] = createSignal(false);
diff --git a/frontend-modern/src/utils/url.ts b/frontend-modern/src/utils/url.ts
index 6178a7a534..c961e87026 100644
--- a/frontend-modern/src/utils/url.ts
+++ b/frontend-modern/src/utils/url.ts
@@ -1,4 +1,53 @@
const FALLBACK_BASE_URL = 'http://localhost:7655';
+const KIOSK_MODE_KEY = 'pulse_kiosk_mode';
+
+/**
+ * Check and persist kiosk mode from URL parameters.
+ * When ?kiosk=1 or ?kiosk=true is in the URL, this stores the preference
+ * in sessionStorage so it persists across navigation and refreshes.
+ * Call this on app initialization.
+ */
+export function initKioskMode(): void {
+ if (typeof window === 'undefined') return;
+
+ try {
+ const params = new URLSearchParams(window.location.search);
+ const kioskParam = params.get('kiosk');
+
+ if (kioskParam === '1' || kioskParam === 'true') {
+ window.sessionStorage.setItem(KIOSK_MODE_KEY, 'true');
+ }
+ // Note: We don't clear kiosk mode if param is absent or false
+ // This allows navigating within the app while preserving kiosk mode
+ // User must explicitly clear session or pass kiosk=false to exit
+ if (kioskParam === '0' || kioskParam === 'false') {
+ window.sessionStorage.removeItem(KIOSK_MODE_KEY);
+ }
+ } catch {
+ // Ignore storage errors
+ }
+}
+
+/**
+ * Check if the app is in kiosk mode.
+ * Returns true if kiosk mode is stored in session or present in current URL.
+ */
+export function isKioskMode(): boolean {
+ if (typeof window === 'undefined') return false;
+
+ try {
+ // Check sessionStorage first (persists across navigation)
+ const stored = window.sessionStorage.getItem(KIOSK_MODE_KEY);
+ if (stored === 'true') return true;
+
+ // Fall back to URL check (for initial page load)
+ const params = new URLSearchParams(window.location.search);
+ const kioskParam = params.get('kiosk');
+ return kioskParam === '1' || kioskParam === 'true';
+ } catch {
+ return false;
+ }
+}
export function getPulseBaseUrl(): string {
if (typeof window === 'undefined' || !window.location) {