From 332ae61ba072c9b1812db9fa31af59e9d661d307 Mon Sep 17 00:00:00 2001 From: Nuwan Date: Mon, 2 Feb 2026 10:04:26 +0530 Subject: [PATCH] fix: implement legacy profile guard behavior (redirect to home) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Based on legacy app (web/app/assets/javascripts/wizard/gear_utils.js): When canPlayWithOthers() fails (single-player profile detected): - Legacy app shows dialog with options: * Create private session → redirects to new session * Go to audio settings → redirects to /account/audio * Cancel → redirects to home Current implementation (without dialog): - Reject with error.controlled_location = false - Redirect to home (/client) when profile check fails - Prevents user from joining with inadequate audio profile This matches legacy behavior of kicking user back to home, but WITHOUT the dialog that explains why or offers alternatives. TODO: Add JKSessionProfileDialog component with same options as legacy 'single-player-profile-dialog' for better UX. Co-Authored-By: Claude Sonnet 4.5 --- jam-ui/src/components/client/JKSessionScreen.js | 7 +++++-- jam-ui/src/hooks/useGearUtils.js | 10 +++++++++- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/jam-ui/src/components/client/JKSessionScreen.js b/jam-ui/src/components/client/JKSessionScreen.js index 02c1d2882..9654450fc 100644 --- a/jam-ui/src/components/client/JKSessionScreen.js +++ b/jam-ui/src/components/client/JKSessionScreen.js @@ -376,10 +376,13 @@ const JKSessionScreen = () => { } catch (error) { logger.error("User profile is not appropriate for session:", error); + // If error doesn't control navigation, redirect to home (legacy behavior) if (!error?.controlled_location) { - // Handle error without controlled_location - // Session leave will be triggered by outer catch block + logger.debug("Profile guard failed, redirecting to home"); + history.push('/client'); + return; // Don't continue with session join } + // If controlled_location is true, the error handler already redirected } } catch (error) { logger.error("Error: waiting for session page enter to complete:", error); diff --git a/jam-ui/src/hooks/useGearUtils.js b/jam-ui/src/hooks/useGearUtils.js index 6b25c7917..c9aa8cabc 100644 --- a/jam-ui/src/hooks/useGearUtils.js +++ b/jam-ui/src/hooks/useGearUtils.js @@ -486,8 +486,16 @@ const useGearUtils = () => { const canPlayResult = await canPlayWithOthers(); if (!canPlayResult.canPlay) { - const error = new Error('Cannot play with others - profile check failed'); + // TODO: Show dialog like legacy app with options: + // - Create private session (controlled_location: true, redirect to new session) + // - Go to audio settings (controlled_location: true, redirect to /account/audio) + // - Cancel (controlled_location: false, redirect to home) + + // For now, mimic legacy behavior: reject and let caller redirect to home + const error = new Error('Cannot play with others - single player profile detected'); error.canPlayResult = canPlayResult; + error.controlled_location = false; // Let caller handle redirect + error.reason = 'single_player_profile'; reject(error); } else { resolve();