From cff2c04732e976395de4fae2c353412aeca0d00a Mon Sep 17 00:00:00 2001 From: Nuwan Date: Mon, 2 Feb 2026 09:27:16 +0530 Subject: [PATCH] fix: add AlertCallback alias and proper error in profile guard Two fixes for built-in audio profile issues: 1. Add JK.AlertCallback as alias for JK.HandleAlertCallback - Native client calls default "JK.AlertCallback" before SessionSetAlertCallback is registered - Now both callback names point to same handler - Added logging for alert code 40 (audio profile issues) 2. Provide proper error when guardAgainstSinglePlayerProfile fails - Was calling reject() with no parameter (error = undefined) - Now creates Error object with message and canPlayResult data - Fixes "User profile is not appropriate for session: undefined" These issues manifest with MacBook built-in mic/speakers when the profile check fails canPlayWithOthers(), causing tracks to not display because session guards don't pass. Co-Authored-By: Claude Sonnet 4.5 --- jam-ui/src/components/client/JKSessionScreen.js | 13 +++++++++++-- jam-ui/src/hooks/useGearUtils.js | 4 +++- 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 e2e6decde..02c1d2882 100644 --- a/jam-ui/src/components/client/JKSessionScreen.js +++ b/jam-ui/src/components/client/JKSessionScreen.js @@ -298,17 +298,26 @@ const JKSessionScreen = () => { if (!window.JK) window.JK = {}; // Alert callback handler - routes backend alerts to appropriate handlers - window.JK.HandleAlertCallback = (type, text) => { + const alertCallbackHandler = (type, text) => { + console.log('[AlertCallback] type:', type, 'text:', text); // BACKEND_MIXER_CHANGE = 2 if (type === 2) { - console.log('[HandleAlertCallback] BACKEND_MIXER_CHANGE:', text); + console.log('[AlertCallback] BACKEND_MIXER_CHANGE:', text); if (sessionModel && sessionModel.onBackendMixerChanged) { sessionModel.onBackendMixerChanged(type, text); } } + // Alert code 40: Audio profile issues (common with built-in audio) + if (type === 40) { + console.warn('[AlertCallback] Audio profile alert (40):', text); + } // Handle other alert types as needed }; + // Register under both names (native client may use either) + window.JK.HandleAlertCallback = alertCallbackHandler; + window.JK.AlertCallback = alertCallbackHandler; + return () => { if (window.JK) { delete window.JK.HandleAlertCallback; diff --git a/jam-ui/src/hooks/useGearUtils.js b/jam-ui/src/hooks/useGearUtils.js index bc6436837..6b25c7917 100644 --- a/jam-ui/src/hooks/useGearUtils.js +++ b/jam-ui/src/hooks/useGearUtils.js @@ -486,7 +486,9 @@ const useGearUtils = () => { const canPlayResult = await canPlayWithOthers(); if (!canPlayResult.canPlay) { - reject(); + const error = new Error('Cannot play with others - profile check failed'); + error.canPlayResult = canPlayResult; + reject(error); } else { resolve(); }