From 92137d915a8b7c0ca544340052fbf125c7d4ba3d Mon Sep 17 00:00:00 2001 From: Adarsh Bhardwaj <140477488+Adarsh-9182@users.noreply.github.com> Date: Tue, 7 Jul 2026 00:29:58 +0530 Subject: [PATCH] Guard persistent user choices storage access --- hooks/agents-ui/use-agent-control-bar.ts | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/hooks/agents-ui/use-agent-control-bar.ts b/hooks/agents-ui/use-agent-control-bar.ts index 4d9305daf..cc62a76b0 100644 --- a/hooks/agents-ui/use-agent-control-bar.ts +++ b/hooks/agents-ui/use-agent-control-bar.ts @@ -22,6 +22,18 @@ const trackSourceToProtocol = (source: Track.Source) => { } }; +const canAccessLocalStorage = () => { + try { + if (typeof window === 'undefined') { + return false; + } + window.localStorage.getItem('__lk_storage_check__'); + return true; + } catch { + return false; + } +}; + export interface PublishPermissions { camera: boolean; microphone: boolean; @@ -93,7 +105,7 @@ export function useInputControls({ saveVideoInputEnabled, saveAudioInputDeviceId, saveVideoInputDeviceId, - } = usePersistentUserChoices({ preventSave: !saveUserChoices }); + } = usePersistentUserChoices({ preventSave: !saveUserChoices || !canAccessLocalStorage() }); const handleAudioDeviceChange = useCallback( (deviceId: string) => {