@@ -246,17 +246,34 @@ async function initializeSignalR() {
246246
247247 // Handle connection state changes
248248 state . connection . onreconnecting ( error => {
249+ // If we intentionally disconnected for idle, suppress reconnect UI
250+ if ( state . intentionalDisconnect ) return ;
249251 updateConnectionStatus ( 'connecting' , 'Reconnecting...' ) ;
250252 logEvent ( 'system' , 'Connection lost. Attempting to reconnect...' ) ;
251253 } ) ;
252254
253255 state . connection . onreconnected ( async connectionId => {
254- // Reset intentional disconnect flag - any successful connection means we're active
255256 state . intentionalDisconnect = false ;
256-
257- // WS is intentionally closed during idle, so any reconnect means we're active
258- updateConnectionStatus ( 'connected' , 'Connected' ) ;
259257 logEvent ( 'system' , 'Reconnected to server' ) ;
258+
259+ // After auto-reconnect, check if the server is idle.
260+ // The server does NOT send idle state on connect (to avoid a race
261+ // with WakeUp on initial page load), so we must query it explicitly.
262+ try {
263+ const idleData = await state . connection . invoke ( 'GetIdleState' ) ;
264+ if ( idleData . isIdle ) {
265+ // Server is idle — re-enter idle mode and disconnect
266+ handleIdleState ( idleData ) ;
267+ } else {
268+ // Server is active — show connected and resume chart
269+ state . isIdle = false ;
270+ updateConnectionStatus ( 'connected' , 'Connected' ) ;
271+ startLatencyChartUpdates ( ) ;
272+ }
273+ } catch ( err ) {
274+ // Query failed — assume connected
275+ updateConnectionStatus ( 'connected' , 'Connected' ) ;
276+ }
260277 } ) ;
261278
262279 state . connection . onclose ( error => {
0 commit comments