feat: add web interface with real-time streaming and timed runs

- Add Fastify-based web server with SSE for real-time updates
- Create responsive dark-themed UI with:
  - Prompt input with directory and duration options
  - Live countdown timer for timed runs
  - Real-time output streaming
  - Collapsible sessions panel
  - Cost and task tracking
- Support timed runs that repeat prompts for specified duration
- Add /api endpoints for sessions, scheduled runs, and status
- Update Session class to parse Claude CLI JSON output
- Add 'claudeman web' command to start the interface

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
arkon
2026-01-18 05:14:34 +01:00
co-authored by Claude Opus 4.5
parent e1bb800473
commit c4aae98a01
9 changed files with 2835 additions and 65 deletions
+522
View File
@@ -0,0 +1,522 @@
/* Variables */
:root {
--bg-dark: #0a0a0a;
--bg-card: #141414;
--bg-input: #1a1a1a;
--bg-hover: #222;
--border: #2a2a2a;
--text: #eee;
--text-dim: #888;
--text-muted: #555;
--accent: #3b82f6;
--accent-hover: #60a5fa;
--green: #22c55e;
--yellow: #eab308;
--red: #ef4444;
--radius: 8px;
}
/* Reset */
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
background: var(--bg-dark);
color: var(--text);
min-height: 100vh;
}
/* Layout */
.app {
display: flex;
flex-direction: column;
min-height: 100vh;
}
/* Header */
.header {
display: flex;
justify-content: space-between;
align-items: center;
padding: 1rem 1.5rem;
background: var(--bg-card);
border-bottom: 1px solid var(--border);
}
.header-left {
display: flex;
align-items: center;
gap: 1.5rem;
}
.logo {
font-size: 1.25rem;
font-weight: 600;
}
.connection-status {
display: flex;
align-items: center;
gap: 0.5rem;
font-size: 0.75rem;
color: var(--text-dim);
}
.status-dot {
width: 8px;
height: 8px;
border-radius: 50%;
background: var(--yellow);
}
.status-dot.connected { background: var(--green); }
.status-dot.disconnected { background: var(--red); }
.header-stats {
display: flex;
gap: 2rem;
}
.stat-item {
display: flex;
flex-direction: column;
align-items: flex-end;
}
.stat-value {
font-size: 1.25rem;
font-weight: 600;
color: var(--green);
}
.stat-label {
font-size: 0.7rem;
color: var(--text-muted);
text-transform: uppercase;
letter-spacing: 0.05em;
}
/* Timer Banner */
.timer-banner {
background: linear-gradient(135deg, #1e3a5f 0%, #0f172a 100%);
border-bottom: 1px solid var(--accent);
padding: 1rem 1.5rem;
}
.timer-info {
display: flex;
align-items: baseline;
gap: 1rem;
margin-bottom: 0.75rem;
}
.timer-label {
font-size: 0.875rem;
color: var(--text-dim);
}
.timer-value {
font-size: 2.5rem;
font-weight: 700;
font-family: 'SF Mono', Monaco, monospace;
color: var(--accent-hover);
letter-spacing: 0.05em;
}
.timer-progress {
height: 6px;
background: var(--bg-input);
border-radius: 3px;
overflow: hidden;
margin-bottom: 0.75rem;
}
.timer-progress-fill {
height: 100%;
background: var(--accent);
transition: width 1s linear;
}
.timer-meta {
display: flex;
align-items: center;
gap: 1.5rem;
font-size: 0.875rem;
color: var(--text-dim);
}
/* Main */
.main {
display: grid;
grid-template-columns: 350px 1fr;
flex: 1;
overflow: hidden;
}
/* Control Panel */
.control-panel {
padding: 1.5rem;
background: var(--bg-card);
border-right: 1px solid var(--border);
overflow-y: auto;
}
.control-panel h2 {
font-size: 1rem;
font-weight: 600;
margin-bottom: 1.25rem;
color: var(--text-dim);
}
.form-group {
margin-bottom: 1rem;
}
.form-group label {
display: block;
font-size: 0.75rem;
font-weight: 500;
color: var(--text-dim);
margin-bottom: 0.5rem;
text-transform: uppercase;
letter-spacing: 0.05em;
}
.form-group input,
.form-group textarea {
width: 100%;
padding: 0.75rem;
background: var(--bg-input);
border: 1px solid var(--border);
border-radius: var(--radius);
color: var(--text);
font-size: 0.875rem;
font-family: inherit;
}
.form-group textarea {
min-height: 120px;
resize: vertical;
}
.form-group input:focus,
.form-group textarea:focus {
outline: none;
border-color: var(--accent);
}
.form-hint {
display: block;
font-size: 0.7rem;
color: var(--text-muted);
margin-top: 0.25rem;
}
.form-row {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 1rem;
}
.form-actions {
margin-top: 1.5rem;
}
/* Buttons */
.btn {
display: inline-flex;
align-items: center;
justify-content: center;
gap: 0.5rem;
padding: 0.5rem 1rem;
border: none;
border-radius: var(--radius);
font-size: 0.875rem;
font-weight: 500;
cursor: pointer;
transition: all 0.15s;
}
.btn-primary {
background: var(--accent);
color: white;
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:disabled {
opacity: 0.5;
cursor: not-allowed;
}
.btn-danger {
background: var(--red);
color: white;
}
.btn-large {
width: 100%;
padding: 0.875rem 1.5rem;
font-size: 1rem;
}
.btn-sm {
padding: 0.375rem 0.75rem;
font-size: 0.75rem;
background: var(--bg-input);
color: var(--text-dim);
border: 1px solid var(--border);
}
.btn-sm:hover {
background: var(--bg-hover);
color: var(--text);
}
.btn-icon {
font-size: 0.875rem;
}
/* Output Panel */
.output-panel {
display: flex;
flex-direction: column;
padding: 1.5rem;
overflow: hidden;
}
.output-header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 1rem;
}
.output-header h2 {
font-size: 1rem;
font-weight: 600;
color: var(--text-dim);
}
.output-container {
flex: 1;
background: var(--bg-card);
border: 1px solid var(--border);
border-radius: var(--radius);
padding: 1rem;
overflow-y: auto;
font-family: 'SF Mono', Monaco, Consolas, monospace;
font-size: 0.8125rem;
line-height: 1.7;
white-space: pre-wrap;
word-break: break-word;
}
.output-placeholder {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
height: 100%;
color: var(--text-muted);
text-align: center;
}
.placeholder-icon {
font-size: 3rem;
margin-bottom: 1rem;
opacity: 0.3;
}
.placeholder-text {
font-size: 0.875rem;
}
/* Sessions Panel */
.sessions-panel {
position: fixed;
bottom: 0;
left: 0;
right: 0;
background: var(--bg-card);
border-top: 1px solid var(--border);
max-height: 50vh;
overflow: hidden;
transition: max-height 0.3s ease;
}
.sessions-panel.collapsed {
max-height: 44px;
}
.sessions-header {
display: flex;
justify-content: space-between;
align-items: center;
padding: 0.75rem 1.5rem;
cursor: pointer;
user-select: none;
}
.sessions-header:hover {
background: var(--bg-hover);
}
.sessions-header h3 {
font-size: 0.875rem;
font-weight: 500;
color: var(--text-dim);
}
.session-count {
display: inline-flex;
align-items: center;
justify-content: center;
min-width: 20px;
height: 20px;
padding: 0 6px;
background: var(--accent);
border-radius: 10px;
font-size: 0.7rem;
color: white;
margin-left: 0.5rem;
}
.toggle-icon {
color: var(--text-muted);
transition: transform 0.3s;
}
.sessions-panel.collapsed .toggle-icon {
transform: rotate(180deg);
}
.sessions-list {
display: flex;
gap: 1rem;
padding: 0 1.5rem 1rem;
overflow-x: auto;
}
.session-card {
flex-shrink: 0;
width: 300px;
background: var(--bg-input);
border: 1px solid var(--border);
border-radius: var(--radius);
overflow: hidden;
}
.session-card-header {
display: flex;
justify-content: space-between;
align-items: center;
padding: 0.75rem 1rem;
background: var(--bg-dark);
border-bottom: 1px solid var(--border);
}
.session-status {
display: flex;
align-items: center;
gap: 0.5rem;
font-size: 0.75rem;
}
.session-status-dot {
width: 8px;
height: 8px;
border-radius: 50%;
}
.session-status-dot.idle { background: var(--green); }
.session-status-dot.busy { background: var(--yellow); animation: pulse 1.5s infinite; }
.session-status-dot.error { background: var(--red); }
@keyframes pulse {
0%, 100% { opacity: 1; }
50% { opacity: 0.4; }
}
.session-cost {
font-size: 0.75rem;
color: var(--green);
font-weight: 500;
}
.session-output {
height: 120px;
padding: 0.75rem;
overflow-y: auto;
font-family: 'SF Mono', Monaco, monospace;
font-size: 0.7rem;
line-height: 1.6;
color: var(--text-dim);
white-space: pre-wrap;
}
.session-output:empty::after {
content: 'Waiting...';
color: var(--text-muted);
}
/* Message styling in output */
.msg-system { color: var(--text-muted); }
.msg-assistant { color: var(--text); }
.msg-error { color: var(--red); }
.msg-cost { color: var(--green); font-weight: 500; }
/* Scrollbar */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg-dark); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }
/* Responsive */
@media (max-width: 768px) {
.main {
grid-template-columns: 1fr;
grid-template-rows: auto 1fr;
}
.control-panel {
border-right: none;
border-bottom: 1px solid var(--border);
}
.form-row {
grid-template-columns: 1fr;
}
.header-stats {
display: none;
}
.sessions-panel {
position: relative;
max-height: none;
}
.sessions-list {
flex-direction: column;
}
.session-card {
width: 100%;
}
}
/* Loading state */
.loading {
display: inline-block;
width: 16px;
height: 16px;
border: 2px solid var(--border);
border-top-color: var(--accent);
border-radius: 50%;
animation: spin 0.8s linear infinite;
}
@keyframes spin {
to { transform: rotate(360deg); }
}