Summary
Fixes for WebSocket reconnection after tunnel restart and manual pairing code flow.
Changes
-
WebSocket Service (services/websocket.service.ts)
pollTunnelUrl polls Supabase every 10s, detects tunnel URL change and auto-reconnects
- Limit Socket.IO auto-reconnect attempts to 3 (was Infinity) to prevent conflicts
- Remove
checkTunnelUrlOnDisconnect (was conflicting with poll mechanism)
-
App Layout (app/_layout.tsx)
- AppState foreground handler always checks tunnel URL vs current relay URL
- Reconnects if URL changed or connection lost
-
Add Device (app/(onboarding)/add-device.tsx)
- "Enter Code" mode now redirects to
device/pair.tsx for reliable pairing
-
Pair Device (app/device/pair.tsx)
- Support
?method=code query param to pre-select "Enter Code" mode
Bug Fixes
- Mobile stuck on "Connecting to server..." after tunnel restart (race condition between multiple reconnect mechanisms)
- Manual pairing code on Add Device page always failed (relay address was required)
add-device.tsx showed "Relay Address Required" dialog even in tunnel mode
Test Plan
Summary
Fixes for WebSocket reconnection after tunnel restart and manual pairing code flow.
Changes
WebSocket Service (
services/websocket.service.ts)pollTunnelUrlpolls Supabase every 10s, detects tunnel URL change and auto-reconnectscheckTunnelUrlOnDisconnect(was conflicting with poll mechanism)App Layout (
app/_layout.tsx)Add Device (
app/(onboarding)/add-device.tsx)device/pair.tsxfor reliable pairingPair Device (
app/device/pair.tsx)?method=codequery param to pre-select "Enter Code" modeBug Fixes
add-device.tsxshowed "Relay Address Required" dialog even in tunnel modeTest Plan