Skip to content

Commit 7340d4b

Browse files
committed
Fix for idle status indicator
1 parent 16deeac commit 7340d4b

3 files changed

Lines changed: 33 additions & 3 deletions

File tree

.vscode/settings.json

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,15 @@
1111
".specify/scripts/powershell/": true
1212
},
1313
"java.compile.nullAnalysis.mode": "disabled",
14-
"java.configuration.updateBuildConfiguration": "interactive"
14+
"java.configuration.updateBuildConfiguration": "interactive",
15+
"java.jdt.ls.java.home": "C:\\Program Files\\Microsoft\\jdk-21.0.10.7-hotspot",
16+
"java.configuration.runtimes": [
17+
{
18+
"name": "JavaSE-21",
19+
"path": "C:\\Program Files\\Microsoft\\jdk-21.0.10.7-hotspot",
20+
"default": true
21+
}
22+
],
23+
"java.suppressUpgradeNotification": true
1524
}
1625

src/main/resources/static/js/dashboard.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -411,13 +411,20 @@ const Dashboard = (function() {
411411

412412
// Update connection status based on idle state changes
413413
if (event.event === 'GOING_IDLE') {
414+
// Lock the status indicator before updating it, so that any
415+
// WebSocket reconnect/disconnect events that fire while the server
416+
// is idle cannot overwrite the Idle indicator.
417+
SocketClient.setServerIdle(true);
414418
const statusEl = document.getElementById('connection-status');
415419
if (statusEl) {
416420
statusEl.classList.remove('status-connected', 'status-disconnected', 'status-reconnecting', 'status-idle');
417421
statusEl.classList.add('status-idle');
418422
statusEl.textContent = 'Idle';
419423
}
420424
} else if (event.event === 'WAKING_UP') {
425+
// Unlock the status indicator before updating it, restoring normal
426+
// WebSocket status reporting now that the server is active again.
427+
SocketClient.setServerIdle(false);
421428
const statusEl = document.getElementById('connection-status');
422429
if (statusEl) {
423430
statusEl.classList.remove('status-connected', 'status-disconnected', 'status-reconnecting', 'status-idle');

src/main/resources/static/js/socket-client.js

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ const SocketClient = (function() {
2020

2121
// Idle state tracking
2222
let activityRecorded = false;
23+
let serverIsIdle = false;
2324

2425
// Callbacks
2526
const callbacks = {
@@ -56,9 +57,12 @@ const SocketClient = (function() {
5657
}
5758

5859
/**
59-
* Updates the connection status UI
60+
* Updates the connection status UI.
61+
* While the server is idle, all status transitions are suppressed — only
62+
* dashboard.js (via setServerIdle) may change the indicator in that state.
6063
*/
6164
function updateConnectionStatus(status) {
65+
if (serverIsIdle) return;
6266
const statusEl = document.getElementById('connection-status');
6367
if (statusEl) {
6468
// Remove all status classes
@@ -303,13 +307,23 @@ const SocketClient = (function() {
303307
}
304308
}
305309

310+
/**
311+
* Marks the server as idle or active, controlling whether WebSocket
312+
* reconnect/disconnect events may update the status indicator.
313+
* Call with true on GOING_IDLE, false on WAKING_UP.
314+
*/
315+
function setServerIdle(idle) {
316+
serverIsIdle = idle;
317+
}
318+
306319
// Public API
307320
return {
308321
connect,
309322
disconnect,
310323
send,
311324
on,
312325
isConnected,
313-
recordActivity
326+
recordActivity,
327+
setServerIdle
314328
};
315329
})();

0 commit comments

Comments
 (0)