feat(ui): add reconnect button and session count in header

- Add retry button when SSE connection is lost
- Add reconnectSSE method for manual reconnection
- Add session count to header stats
- Include session costs in total cost calculation

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
arkon
2026-01-18 22:29:23 +01:00
co-authored by Claude Opus 4.5
parent 919e48a5cc
commit bc72bccc85
2 changed files with 31 additions and 6 deletions
+27 -6
View File
@@ -434,16 +434,29 @@ class ClaudemanApp {
const text = el.querySelector('span:last-child'); const text = el.querySelector('span:last-child');
dot.className = 'status-dot ' + status; dot.className = 'status-dot ' + status;
text.textContent = status === 'connected' ? 'Connected' : 'Disconnected';
// Show toast on disconnect if (status === 'connected') {
if (status === 'disconnected') { text.textContent = 'Connected';
this.showToast('Connection lost. Reconnecting...', 'warning'); text.onclick = null;
} else if (status === 'connected') { text.style.cursor = 'default';
this.showToast('Connected to server', 'success'); this.showToast('Connected to server', 'success');
} else {
text.innerHTML = '<span>Disconnected</span> <button class="btn btn-xs" style="margin-left:0.5rem">Retry</button>';
text.querySelector('button').onclick = () => this.reconnectSSE();
this.showToast('Connection lost. Click retry to reconnect.', 'warning');
} }
} }
// Manually reconnect SSE
reconnectSSE() {
if (this.eventSource) {
this.eventSource.close();
this.eventSource = null;
}
this.showToast('Reconnecting...', 'info');
this.connectSSE();
}
// Show a toast notification // Show a toast notification
showToast(message, type = 'info') { showToast(message, type = 'info') {
const toast = document.createElement('div'); const toast = document.createElement('div');
@@ -1113,7 +1126,15 @@ class ClaudemanApp {
// Stats // Stats
updateStats() { updateStats() {
document.getElementById('statCost').textContent = `$${this.totalCost.toFixed(2)}`; // Calculate total cost from sessions and total cost tracker
let sessionsCost = 0;
this.sessions.forEach(s => {
sessionsCost += s.totalCost || 0;
});
const displayCost = Math.max(this.totalCost, sessionsCost);
document.getElementById('statSessions').textContent = this.sessions.size;
document.getElementById('statCost').textContent = `$${displayCost.toFixed(2)}`;
document.getElementById('statTasks').textContent = this.totalTasks; document.getElementById('statTasks').textContent = this.totalTasks;
} }
+4
View File
@@ -24,6 +24,10 @@
</div> </div>
</div> </div>
<div class="header-stats"> <div class="header-stats">
<div class="stat-item">
<span class="stat-value" id="statSessions">0</span>
<span class="stat-label">Sessions</span>
</div>
<div class="stat-item"> <div class="stat-item">
<span class="stat-value" id="statCost">$0.00</span> <span class="stat-value" id="statCost">$0.00</span>
<span class="stat-label">Total Cost</span> <span class="stat-label">Total Cost</span>