diff --git a/bot/static/index.html b/bot/static/index.html
index 20c2e8d..b72ba1f 100644
--- a/bot/static/index.html
+++ b/bot/static/index.html
@@ -1908,10 +1908,33 @@ document.addEventListener('DOMContentLoaded', function() {
}, { passive: false });
}
- // Set up periodic updates
- setInterval(loadStatus, 10000);
- setInterval(loadLogs, 5000);
- setInterval(loadActiveArguments, 5000); // Refresh active arguments
+ // Set up periodic updates with visibility-aware polling
+ let statusInterval, logsInterval, argsInterval;
+
+ function startPolling() {
+ if (!statusInterval) statusInterval = setInterval(loadStatus, 10000);
+ if (!logsInterval) logsInterval = setInterval(loadLogs, 5000);
+ if (!argsInterval) argsInterval = setInterval(loadActiveArguments, 5000);
+ }
+
+ function stopPolling() {
+ clearInterval(statusInterval); statusInterval = null;
+ clearInterval(logsInterval); logsInterval = null;
+ clearInterval(argsInterval); argsInterval = null;
+ }
+
+ document.addEventListener('visibilitychange', () => {
+ if (document.hidden) {
+ stopPolling();
+ console.log('⏸ Tab hidden — polling paused');
+ } else {
+ loadStatus(); loadLogs(); loadActiveArguments();
+ startPolling();
+ console.log('▶️ Tab visible — polling resumed');
+ }
+ });
+
+ startPolling();
});
// Utility functions