@@ -21,16 +21,38 @@ import './theme.js';
2121// ─── Status Indicator ───────────────────────────────────────────────────────
2222
2323const statusDiv = document . getElementById ( 'websocket-status' ) ;
24+ let disconnectTimeout = null ;
25+ const DISCONNECT_DELAY_MS = 2000 ; // Show banner after 2 seconds of disconnection
2426
2527function updateStatus ( ) {
26- const n = app . websocketManager ? app . websocketManager . pending . size : 0 ;
27- if ( n === 0 ) {
28- statusDiv . textContent = '' ;
29- statusDiv . style . display = 'none' ;
28+ const isConnected = app . websocketManager && app . websocketManager . isConnected ;
29+ const pendingCount = app . websocketManager ? app . websocketManager . pending . size : 0 ;
30+
31+ if ( ! isConnected ) {
32+ // Only show banner after a delay to avoid flashing on page load
33+ if ( ! disconnectTimeout ) {
34+ disconnectTimeout = setTimeout ( ( ) => {
35+ if ( ! app . websocketManager ?. isConnected ) {
36+ statusDiv . innerHTML = '<div class="disconnected-banner">⚠ OpenROAD disconnected</div>' ;
37+ statusDiv . style . display = 'block' ;
38+ }
39+ } , DISCONNECT_DELAY_MS ) ;
40+ }
3041 } else {
31- statusDiv . textContent = `pending: ${ n } ` ;
32- statusDiv . style . display = '' ;
33- statusDiv . style . color = n > 20 ? 'var(--error)' : 'var(--fg-bright)' ;
42+ // Connected - clear timeout and show pending indicator if needed
43+ if ( disconnectTimeout ) {
44+ clearTimeout ( disconnectTimeout ) ;
45+ disconnectTimeout = null ;
46+ }
47+
48+ if ( pendingCount === 0 ) {
49+ statusDiv . style . display = 'none' ;
50+ } else {
51+ statusDiv . innerHTML = `<div class="pending-indicator">pending: ${ pendingCount } </div>` ;
52+ statusDiv . style . display = 'block' ;
53+ const color = pendingCount > 20 ? 'var(--error)' : 'var(--fg-bright)' ;
54+ statusDiv . querySelector ( '.pending-indicator' ) . style . color = color ;
55+ }
3456 }
3557}
3658
@@ -558,6 +580,9 @@ if (staticCache) {
558580 app . websocketManager = new WebSocketManager ( websocketUrl , updateStatus ) ;
559581}
560582
583+ // Check initial connection status
584+ updateStatus ( ) ;
585+
561586// Restore saved layout or use default
562587const savedLayout = localStorage . getItem ( 'gl-layout' ) ;
563588const savedVersion = parseInt ( localStorage . getItem ( 'gl-layout-version' ) , 10 ) ;
0 commit comments