diff --git a/src/get-next-connection-state.ts b/src/get-next-connection-state.ts index 861aa219a..0348aaac8 100644 --- a/src/get-next-connection-state.ts +++ b/src/get-next-connection-state.ts @@ -108,7 +108,6 @@ export const getNextConnectionState = ( : ConnectionStatus.FailedToReconnect; return { status, flowType }; } - if ( // If user starts or restarts connection flow. // Disconnection happens for newly started / restarted @@ -190,5 +189,17 @@ export const getNextConnectionState = ( ) { return { status: ConnectionStatus.ReconnectingAutomatically, flowType }; } + if ( + DeviceConnectionStatus.NO_AUTHORIZED_DEVICE && + ConnectionStatus.ReconnectingAutomatically && + currConnType === "radio" + ) { + // The link micro:bit was unplugged while the user was viewing another tab. + // On return, show failed to reconnect. + return { + status: ConnectionStatus.FailedToReconnect, + flowType: ConnectionFlowType.ConnectRadioBridge, + }; + } return undefined; };