From d56665d35919488f1ddbacef08981071b13fe90b Mon Sep 17 00:00:00 2001 From: liebertar Date: Tue, 5 Aug 2025 16:20:18 +0900 Subject: [PATCH] Auto-close dashboard tabs when server stops responding This addresses the dashboard tab accumulation issue that's been brought up. Having multiple tabs open gets disruptive during development. Implemented the approach @opcode81 suggested - detecting when the server stops responding and letting the tab close itself. The dashboard now monitors its connection and auto-closes after 3 failed polling attempts. Should help with the workflow disruption without being overly complex. Hope this helps\! Fixes #388 --- src/serena/resources/dashboard/dashboard.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/serena/resources/dashboard/dashboard.js b/src/serena/resources/dashboard/dashboard.js index 318d0c16..4edc0868 100644 --- a/src/serena/resources/dashboard/dashboard.js +++ b/src/serena/resources/dashboard/dashboard.js @@ -52,6 +52,7 @@ class Dashboard { this.toolNames = []; this.currentMaxIdx = -1; this.pollInterval = null; + this.failureCount = 0; this.$logContainer = $('#log-container'); this.$errorContainer = $('#error-container'); this.$loadButton = $('#load-logs'); @@ -161,6 +162,7 @@ class Dashboard { start_idx: self.currentMaxIdx + 1 }), success: function(response) { + self.failureCount = 0; // Only append new messages if we have any if (response.messages && response.messages.length > 0) { let wasAtBottom = false; @@ -190,6 +192,11 @@ class Dashboard { }, error: function(xhr, status, error) { console.error('Error polling for new logs:', error); + self.failureCount++; + if (self.failureCount >= 3) { + console.log('Server appears to be down, closing tab'); + window.close(); + } } }); }