diff --git a/jam-ui/src/components/client/JKSessionScreen.js b/jam-ui/src/components/client/JKSessionScreen.js index c9248a173..2bef88172 100644 --- a/jam-ui/src/components/client/JKSessionScreen.js +++ b/jam-ui/src/components/client/JKSessionScreen.js @@ -110,6 +110,7 @@ const JKSessionScreen = () => { guardAgainstInvalidConfiguration, guardAgainstActiveProfileMissing, guardAgainstSinglePlayerProfile, + resyncAudio, } = useGearUtils(); const { initialize: initializeMixer, onSessionChange } = useMixerStore(); @@ -195,6 +196,9 @@ const JKSessionScreen = () => { //state for video button const [videoLoading, setVideoLoading] = useState(false); + // State for resync button + const [resyncLoading, setResyncLoading] = useState(false); + // Redux backing track state (modal visibility and data) const backingTrackData = useSelector(selectBackingTrackData); const showBackingTrackPlayer = Boolean(backingTrackData); @@ -1012,6 +1016,27 @@ const JKSessionScreen = () => { } }; + // Handle Resync button click - performs audio resync via native client + const handleResync = useCallback(async (e) => { + e.preventDefault(); + if (resyncLoading) return; + + setResyncLoading(true); + try { + await resyncAudio(); + // Silent success (matches legacy behavior) + } catch (error) { + console.error('Audio resync failed:', error); + if (error.message === 'timeout') { + toast.error('Audio resync timed out. Please try again.'); + } else { + toast.error('Audio resync failed: ' + (error.message || 'Unknown error')); + } + } finally { + setResyncLoading(false); + } + }, [resyncAudio, resyncLoading]); + // Attach button handlers const handleAttachClick = useCallback(() => { if (attachFileInputRef.current) { @@ -1277,9 +1302,10 @@ const JKSessionScreen = () => { Attach {isUploading ? 'Uploading...' : 'Attach'} - + {resyncLoading ? <> Resyncing... : 'Resync'} +