From 298faecf72788ea8b27d49c6f0be97fb117968f2 Mon Sep 17 00:00:00 2001 From: Jared Miller Date: Wed, 28 Jan 2026 13:52:01 -0500 Subject: [PATCH] Add state badges to session card headers --- public/index.html | 98 ++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 97 insertions(+), 1 deletion(-) diff --git a/public/index.html b/public/index.html index 04b425e..9017b09 100644 --- a/public/index.html +++ b/public/index.html @@ -100,6 +100,60 @@ overflow: hidden; text-overflow: ellipsis; white-space: nowrap; + display: flex; + align-items: center; + gap: 8px; + } + + .state-badge { + padding: 2px 8px; + border-radius: 4px; + font-size: 11px; + font-weight: 600; + text-transform: uppercase; + letter-spacing: 0.5px; + flex-shrink: 0; + } + + .state-ready { + background: #6b7280; + color: white; + } + + .state-thinking { + background: #3b82f6; + color: white; + } + + .state-thinking::after { + content: '...'; + animation: dots 1.5s infinite; + } + + @keyframes dots { + 0%, 20% { content: '.'; } + 40% { content: '..'; } + 60%, 100% { content: '...'; } + } + + .state-permission { + background: #f59e0b; + color: white; + } + + .state-question { + background: #f59e0b; + color: white; + } + + .state-complete { + background: #10b981; + color: white; + } + + .state-interrupted { + background: #ef4444; + color: white; } .session-cwd { @@ -566,6 +620,7 @@ output: '', outputRenderedLength: 0, expanded: false, + state: 'ready', }); renderSessions(); }); @@ -602,6 +657,15 @@ renderPrompts(); }); + es.addEventListener('state', (e) => { + const data = JSON.parse(e.data); + const session = state.sessions.get(data.session_id); + if (session) { + session.state = data.state; + updateSessionCard(data.session_id); + } + }); + state.eventSource = es; } @@ -615,6 +679,19 @@ } }; + function renderStateBadge(sessionState) { + const labels = { + ready: 'Ready', + thinking: 'Thinking', + permission: 'Permission Required', + question: 'Question', + complete: 'Complete', + interrupted: 'Interrupted' + }; + const label = labels[sessionState] || sessionState; + return `${label}`; + } + function renderSessions() { if (state.sessions.size === 0) { $sessions.innerHTML = '
No active sessions
'; @@ -625,7 +702,10 @@
-
${escapeHtml(s.command || 'claude')}
+
+ ${escapeHtml(s.command || 'claude')} + ${renderStateBadge(s.state || 'ready')} +
${escapeHtml(s.cwd || '~')}
@@ -655,6 +735,22 @@ } } + function updateSessionCard(sessionId) { + const session = state.sessions.get(sessionId); + if (!session) return; + + const $sessionCard = document.querySelector(`[data-session="${sessionId}"]`); + if ($sessionCard) { + const $commandDiv = $sessionCard.querySelector('.session-command'); + if ($commandDiv) { + $commandDiv.innerHTML = ` + ${escapeHtml(session.command || 'claude')} + ${renderStateBadge(session.state || 'ready')} + `; + } + } + } + function renderPrompts() { if (state.prompts.size === 0) { $prompts.innerHTML = '
No pending prompts
';