Spaces:
Sleeping
Sleeping
Claude Code Claude Opus 4.6 commited on
Commit ·
d664b0a
1
Parent(s): 230bdd7
Claude Code: add 5-second polling to /debug/health endpoint
Browse files- Add #debug-stats panel with uptime and memory display
- Implement setInterval polling every 5 seconds to fetch health data
- Handle fetch errors gracefully with error state display
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
frontend/agent-dashboard.html
CHANGED
|
@@ -503,6 +503,27 @@
|
|
| 503 |
</div>
|
| 504 |
</div>
|
| 505 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 506 |
<!-- Resource Exchange Panel -->
|
| 507 |
<div class="resource-panel">
|
| 508 |
<h2>
|
|
@@ -557,7 +578,9 @@
|
|
| 557 |
setInterval(fetchThoughts, POLL_INTERVAL);
|
| 558 |
setInterval(updateStats, 1000);
|
| 559 |
setInterval(fetchResources, RESOURCE_INTERVAL);
|
|
|
|
| 560 |
fetchResources(); // Initial fetch
|
|
|
|
| 561 |
});
|
| 562 |
|
| 563 |
// Connect to event bus
|
|
@@ -826,6 +849,46 @@
|
|
| 826 |
const latest = history[history.length - 1];
|
| 827 |
showTransferNotification(latest.to, latest.amount);
|
| 828 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 829 |
</script>
|
| 830 |
</body>
|
| 831 |
</html>
|
|
|
|
| 503 |
</div>
|
| 504 |
</div>
|
| 505 |
|
| 506 |
+
<!-- Resource Exchange Panel -->
|
| 507 |
+
<!-- Debug Stats Panel -->
|
| 508 |
+
<div class="resource-panel">
|
| 509 |
+
<h2>
|
| 510 |
+
<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" style="vertical-align: middle; margin-right: 8px;">
|
| 511 |
+
<path d="M22 12h-4l-3 9L9 3l-3 9H2"></path>
|
| 512 |
+
</svg>
|
| 513 |
+
System Health
|
| 514 |
+
</h2>
|
| 515 |
+
<div id="debug-stats" class="resource-grid">
|
| 516 |
+
<div class="stat-item">
|
| 517 |
+
<div class="stat-value" id="uptime">-</div>
|
| 518 |
+
<div class="stat-label">Uptime (sec)</div>
|
| 519 |
+
</div>
|
| 520 |
+
<div class="stat-item">
|
| 521 |
+
<div class="stat-value" id="memory">-</div>
|
| 522 |
+
<div class="stat-label">Memory (MB)</div>
|
| 523 |
+
</div>
|
| 524 |
+
</div>
|
| 525 |
+
</div>
|
| 526 |
+
|
| 527 |
<!-- Resource Exchange Panel -->
|
| 528 |
<div class="resource-panel">
|
| 529 |
<h2>
|
|
|
|
| 578 |
setInterval(fetchThoughts, POLL_INTERVAL);
|
| 579 |
setInterval(updateStats, 1000);
|
| 580 |
setInterval(fetchResources, RESOURCE_INTERVAL);
|
| 581 |
+
setInterval(fetchDebugHealth, 5000); // Poll /debug/health every 5 seconds
|
| 582 |
fetchResources(); // Initial fetch
|
| 583 |
+
fetchDebugHealth(); // Initial health fetch
|
| 584 |
});
|
| 585 |
|
| 586 |
// Connect to event bus
|
|
|
|
| 849 |
const latest = history[history.length - 1];
|
| 850 |
showTransferNotification(latest.to, latest.amount);
|
| 851 |
}
|
| 852 |
+
|
| 853 |
+
// ========== Debug Health Monitoring ==========
|
| 854 |
+
|
| 855 |
+
// Fetch debug health from API
|
| 856 |
+
async function fetchDebugHealth() {
|
| 857 |
+
try {
|
| 858 |
+
const response = await fetch(`${API_BASE}/debug/health`);
|
| 859 |
+
if (response.ok) {
|
| 860 |
+
const data = await response.json();
|
| 861 |
+
updateDebugStats(data);
|
| 862 |
+
} else {
|
| 863 |
+
console.error('Failed to fetch debug health:', response.statusText);
|
| 864 |
+
setDebugStatsError();
|
| 865 |
+
}
|
| 866 |
+
} catch (error) {
|
| 867 |
+
console.error('Error fetching debug health:', error);
|
| 868 |
+
setDebugStatsError();
|
| 869 |
+
}
|
| 870 |
+
}
|
| 871 |
+
|
| 872 |
+
// Update debug stats display
|
| 873 |
+
function updateDebugStats(data) {
|
| 874 |
+
const uptimeEl = document.getElementById('uptime');
|
| 875 |
+
const memoryEl = document.getElementById('memory');
|
| 876 |
+
|
| 877 |
+
if (uptimeEl && data.uptime_seconds !== undefined) {
|
| 878 |
+
uptimeEl.textContent = data.uptime_seconds.toFixed(1);
|
| 879 |
+
}
|
| 880 |
+
if (memoryEl && data.memory && data.memory.rss_mb !== undefined) {
|
| 881 |
+
memoryEl.textContent = data.memory.rss_mb.toFixed(1);
|
| 882 |
+
}
|
| 883 |
+
}
|
| 884 |
+
|
| 885 |
+
// Set error state for debug stats
|
| 886 |
+
function setDebugStatsError() {
|
| 887 |
+
const uptimeEl = document.getElementById('uptime');
|
| 888 |
+
const memoryEl = document.getElementById('memory');
|
| 889 |
+
if (uptimeEl) uptimeEl.textContent = 'Error';
|
| 890 |
+
if (memoryEl) memoryEl.textContent = 'Error';
|
| 891 |
+
}
|
| 892 |
</script>
|
| 893 |
</body>
|
| 894 |
</html>
|