-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathhive-observer-plan-content.html
More file actions
867 lines (752 loc) · 33.9 KB
/
hive-observer-plan-content.html
File metadata and controls
867 lines (752 loc) · 33.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Hive Observer - Real-Time Activity Dashboard Implementation Plan</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/github-markdown-css/5.5.0/github-markdown.min.css">
<style>
body {
box-sizing: border-box;
min-width: 200px;
max-width: 980px;
margin: 0 auto;
padding: 45px;
}
@media (max-width: 767px) {
body { padding: 15px; }
}
.status-badge {
display: inline-block;
padding: 2px 8px;
border-radius: 12px;
font-size: 12px;
font-weight: 600;
margin-left: 8px;
}
.status-done { background: #d4edda; color: #155724; }
.status-progress { background: #fff3cd; color: #856404; }
.status-pending { background: #f8d7da; color: #721c24; }
.status-new { background: #cce5ff; color: #004085; }
.arch-diagram {
background: #f6f8fa;
border: 1px solid #e1e4e8;
border-radius: 6px;
padding: 16px;
font-family: ui-monospace, SFMono-Regular, SF Mono, Menlo, Consolas, monospace;
font-size: 12px;
line-height: 1.4;
overflow-x: auto;
white-space: pre;
}
.task-list {
list-style: none;
padding-left: 0;
}
.task-item {
padding: 8px 12px;
margin: 4px 0;
border-radius: 6px;
border-left: 4px solid #d0d7de;
}
.task-item.phase-1 { border-left-color: #1f883d; background: #f0fff4; }
.task-item.phase-2 { border-left-color: #1f6feb; background: #f5fbff; }
.task-item.phase-3 { border-left-color: #a475f9; background: #faf5ff; }
.task-item.phase-4 { border-left-color: #bf8700; background: #fff8c5; }
.task-item.phase-5 { border-left-color: #8250df; background: #f8f0ff; }
.task-item input[type="checkbox"] { margin-right: 8px; }
details summary { cursor: pointer; }
details summary:hover { text-decoration: underline; }
.endpoint {
background: #161b22;
color: #c9d1d9;
border-radius: 6px;
padding: 12px;
font-family: ui-monospace, SFMono-Regular, monospace;
font-size: 13px;
}
.endpoint .method { color: #3fb950; font-weight: 600; }
.endpoint .path { color: #79c0ff; }
.endpoint .param { color: #ffa657; }
table { border-collapse: collapse; width: 100%; }
th, td { padding: 8px 12px; text-align: left; border-bottom: 1px solid #d0d7de; }
th { background: #f6f8fa; }
.priority-high { color: #cf222e; font-weight: 600; }
.priority-medium { color: #bf8700; }
.priority-low { color: #57606a; }
</style>
</head>
<body class="markdown-body">
<h1>🐝 Hive Observer - Real-Time Activity Dashboard</h1>
<h2>Implementation Plan</h2>
<p><strong>Status:</strong> <span class="status-badge status-new">New Feature</span> <span class="status-badge status-progress">Planning Complete</span></p>
<p><em>A desktop web app that shows real-time Hive activity using Server-Sent Events (SSE), enabling users to watch agents working, see task progress, and drill into room conversations.</em></p>
<hr>
<h2>📋 Table of Contents</h2>
<ul>
<li><a href="#overview">Overview</a></li>
<li><a href="#architecture">Architecture</a></li>
<li><a href="#two-view-design">Two-View Design</a></li>
<li><a href="#api-specification">API Specification</a></li>
<li><a href="#frontend-architecture">Frontend Architecture</a></li>
<li><a href="#implementation-tasks">Implementation Tasks</a></li>
<li><a href="#file-structure">File Structure</a></li>
<li><a href="#timeline">Timeline</a></li>
<li><a href="#success-metrics">Success Metrics</a></li>
</ul>
<hr>
<h2 id="overview">📊 Overview</h2>
<h3>Current State</h3>
<p>Hive already has a basic observer UI (<code>GET /observer</code>) that provides read-only visibility into mentions, rooms, and webhook delivery logs. However, it uses <strong>manual polling</strong> (15-second intervals) and lacks real-time updates.</p>
<h3>Proposed Enhancement</h3>
<p>Add <strong>Server-Sent Events (SSE)</strong> streaming for true real-time updates, enabling:</p>
<ul>
<li>Live dashboard with data "popping in" as events occur</li>
<li>Drill-down into individual rooms to see agent conversations</li>
<li>Real-time agent status indicators (<em>typing, idle, error</em>)</li>
<li>Task progress tracking with live updates</li>
</ul>
<h3>Key Components</h3>
<table>
<thead>
<tr>
<th>Component</th>
<th>Where</th>
<th>Purpose</th>
</tr>
</thead>
<tbody>
<tr>
<td><strong>SSE Endpoint</strong></td>
<td>Hive Backend</td>
<td>Stream all hive events to connected clients</td>
</tr>
<tr>
<td><strong>Event Bus</strong></td>
<td>Hive Backend (exists)</td>
<td>Broadcast events to SSE clients</td>
</tr>
<tr>
<td><strong>SSE Client</strong></td>
<td>Frontend</td>
<td>Connect, reconnect, handle events</td>
</tr>
<tr>
<td><strong>Reactive Stores</strong></td>
<td>Frontend</td>
<td>Derive UI state from SSE events</td>
</tr>
<tr>
<td><strong>Dashboard View</strong></td>
<td>Frontend</td>
<td>Multi-room activity grid with filters</td>
</tr>
<tr>
<td><strong>Room Detail View</strong></td>
<td>Frontend</td>
<td>Full chat feed + task context</td>
</tr>
</tbody>
</table>
<hr>
<h2 id="architecture">🏗️ Architecture</h2>
<h3>Data Flow</h3>
<div class="arch-diagram">┌─────────────────────────────────────────────────────────────────────────────┐
│ HIVE BACKEND │
│ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ │
│ │ REST API │ │ Event Bus │ │ LMDB Store │ │ Webhooks │ │
│ │ Endpoints │ │ (emitEvent) │ │ (persist) │ │ (dispatch) │ │
│ └──────────────┘ └──────────────┘ └──────────────┘ └──────────────┘ │
│ │ │ │ │ │
│ │ │ │ │ │
│ │ ┌────┴────┐ │ │ │
│ │ │ SSE │ │ │ │
│ │ │ Stream │ │ │ │
│ │ │ /events │ │ │ │
│ │ │ /stream │ │ │ │
│ │ └────┬────┘ │ │ │
└─────────┼───────────────────┼───────────────────┼───────────────────┼────────┘
│ │ │ │
│ HTTP │ SSE │ HTTP │ HTTP
▼ ▼ ▼ ▼
┌─────────────────────────────────────────────────────────────────────────────┐
│ BROWSER CLIENT │
│ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ │
│ │ REST Client │ │ SSE Client │ │ Svelte │ │ UI │ │
│ │ (fetch) │ │ (EventSrc) │ │ Stores │ │ Components │ │
│ └──────────────┘ └──────────────┘ └──────────────┘ └──────────────┘ │
│ │ │ │ │ │
│ │ │ │ │ │
│ └───────────────────┴───────────────────┴───────────────────┘ │
│ │ │
│ ▼ │
│ ┌──────────────────┐ │
│ │ Reactive UI │ │
│ │ (auto-update) │ │
│ └──────────────────┘ │
└─────────────────────────────────────────────────────────────────────────────┘</div>
<h3>Event Flow</h3>
<div class="arch-diagram">Event Source Event Type SSE Event UI Update
───────────────── ────────────────────── ─────────────────── ─────────────────
Agent spawned → task.started → SSE push → Dashboard card
appears (animated)
Agent progress → task.progress → SSE push → Progress bar
updates
Mention resolved → task.completed → SSE push → Status badge
→ green
Error occurs → task.failed → SSE push → Error panel +
badge → red
Post created → post.created → SSE push → Room timeline
new entry
Agent status → agent.status → SSE push → Agent panel
indicator</div>
<hr>
<h2 id="two-view-design">🖼️ Two-View Design</h2>
<h3>1. Dashboard View (Overview)</h3>
<p>The main view showing all room activity at a glance.</p>
<h4>Components</h4>
<table>
<thead>
<tr>
<th>Component</th>
<th>Description</th>
<th>Real-Time Element</th>
</tr>
</thead>
<tbody>
<tr>
<td><strong>Activity Heat Map</strong></td>
<td>Grid of rooms with activity intensity indicators</td>
<td>Color updates on each event (cold → hot)</td>
</tr>
<tr>
<td><strong>Agent Status Panel</strong></td>
<td>Sidebar showing all agents with status</td>
<td>Status badges animate (typing, idle, error)</td>
</tr>
<tr>
<td><strong>Task Progress Board</strong></td>
<td>Active mentions with progress bars</td>
<td>Bars fill as progress events arrive</td>
</tr>
<tr>
<td><strong>Event Feed</strong></td>
<td>Scrolling log of all events</td>
<td>New events "pop in" with animation</td>
</tr>
<tr>
<td><strong>Filters</strong></td>
<td>Filter by agent, room, status, time range</td>
<td>Filters apply to SSE stream</td>
</tr>
</tbody>
</table>
<h4>Visual Indicators</h4>
<ul>
<li><strong>Status Lights</strong>: Green (working), Yellow (idle), Red (error)</li>
<li><strong>Progress Bars</strong>: Fill percentage for running tasks</li>
<li><strong>Timestamps</strong>: Relative time ("2s ago") with real-time updates</li>
<li><strong>Badges</strong>: Count badges for pending/mentions</li>
<li><strong>Heat Indicators</strong>: Room cards glow based on activity level</li>
</ul>
<h3>2. Room Detail View (Drill-Down)</h3>
<p>Click any room to see full conversation history.</p>
<h4>Components</h4>
<table>
<thead>
<tr>
<th>Component</th>
<th>Description</th>
<th>Real-Time Element</th>
</tr>
</thead>
<tbody>
<tr>
<td><strong>Chat Feed</strong></td>
<td>Full message history with timestamps</td>
<td>New messages animate in from bottom</td>
</tr>
<tr>
<td><strong>Task Context Panel</strong></td>
<td>Shows what task the room is working on</td>
<td>Updates when task status changes</td>
</tr>
<tr>
<td><strong>Agent Presence</strong></td>
<td>Shows which agents are active in room</td>
<td>Presence indicators update live</td>
</tr>
<tr>
<td><strong>Message Timeline</strong></td>
<td>Timeline of all room events</td>
<td>Timeline extends as new events arrive</td>
</tr>
<tr>
<td><strong>Back Button</strong></td>
<td>Return to dashboard</td>
<td>N/A</td>
</tr>
</tbody>
</table>
<hr>
<h2 id="api-specification">📡 API Specification</h2>
<h3>Existing Endpoints (Used)</h3>
<details>
<summary><strong>GET /events/stream</strong> - SSE Stream (exists)</summary>
<div class="endpoint"><span class="method">GET</span> <span class="path">/events/stream</span>
<span style="color: #8b949e;"># Already implemented in src/routes/events.ts</span>
<span style="color: #8b949e;"># Streams all Hive events via SSE</span>
<span style="color: #8b949e;"># Response format:</span>
id: <span class="param">event_abc123</span>
event: <span class="param">task.started</span>
data: {"id":"event_abc123","type":"task.started","timestamp":1709123456789,"source":"agent-xyz","payload":{...}}
<span style="color: #8b949e;"># Keepalive every 15s:</span>
: keepalive</div>
</details>
<details>
<summary><strong>GET /events</strong> - Event History (exists)</summary>
<div class="endpoint"><span class="method">GET</span> <span class="path">/events</span><span class="param">?since=<timestamp>&limit=<n></span>
<span style="color: #8b949e;"># Returns historical events for replay</span>
<span style="color: #8b949e;"># Last-Event-ID header support for reconnect</span>
{
"success": true,
"data": {
"events": [
{"id": "event_1", "type": "task.started", "timestamp": 1709123456789, ...},
{"id": "event_2", "type": "task.progress", "timestamp": 1709123457000, ...}
]
}
}</div>
</details>
<h3>New Endpoints (Required)</h3>
<details>
<summary><strong>GET /rooms/:roomId/stream</strong> - Room SSE Stream (new)</summary>
<div class="endpoint"><span class="method">GET</span> <span class="path">/rooms/:roomId/stream</span>
<span style="color: #8b949e;"># Stream events for a specific room</span>
<span style="color: #8b949e;"># Filter: only post.created, mention.spawned, task.* for this room</span>
<span style="color: #8b949e;"># Response:</span>
id: <span class="param">event_abc123</span>
event: <span class="param">post.created</span>
data: {"id":"post_1","roomId":"room_abc","authorId":"agent-1","content":"Hello!",...}</div>
</details>
<details>
<summary><strong>GET /rooms/:roomId/feed</strong> - Room Feed with SSE (new)</summary>
<div class="endpoint"><span class="method">GET</span> <span class="path">/rooms/:roomId/feed</span><span class="param">?since=<timestamp></span>
<span style="color: #8b949e;"># Returns last N posts AND upgrades to SSE for new posts</span>
<span style="color: #8b949e;"># If Accept: text/event-stream, returns SSE stream</span>
<span style="color: #8b949e;"># If Accept: application/json, returns JSON array</span>
{
"success": true,
"data": {
"room": {"id": "room_abc", "name": "#general"},
"posts": [...],
"agents": [
{"id": "agent-1", "name": "Clu", "status": "working", "currentTask": "task_123"}
]
}
}</div>
</details>
<details>
<summary><strong>GET /agents/status</strong> - Agent Status Summary (new)</summary>
<div class="endpoint"><span class="method">GET</span> <span class="path">/agents/status</span>
<span style="color: #8b949e;"># Returns current status of all agents</span>
{
"success": true,
"data": {
"agents": [
{
"id": "agent-1",
"name": "Clu",
"status": "working",
"currentRoom": "room_abc",
"currentTask": "task_123",
"lastActive": 1709123456789
},
{
"id": "agent-2",
"name": "Main",
"status": "idle",
"lastActive": 1709123400000
}
],
"counts": {
"working": 1,
"idle": 1,
"error": 0
}
}
}</div>
</details>
<h3>Event Types (Enhanced)</h3>
<table>
<thead>
<tr>
<th>Event Type</th>
<th>Payload</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>task.started</code></td>
<td>{agentId, taskId, roomId, roomName}</td>
<td>Agent started working on a mention</td>
</tr>
<tr>
<td><code>task.progress</code></td>
<td>{agentId, taskId, progress, message}</td>
<td>Task progress update</td>
</tr>
<tr>
<td><code>task.completed</code></td>
<td>{agentId, taskId, output}</td>
<td>Task finished successfully</td>
</tr>
<tr>
<td><code>task.failed</code></td>
<td>{agentId, taskId, error}</td>
<td>Task failed with error</td>
</tr>
<tr>
<td><code>post.created</code> ✨</td>
<td>{postId, roomId, authorId, content, mentions}</td>
<td>New post in a room</td>
</tr>
<tr>
<td><code>agent.status</code> ✨</td>
<td>{agentId, status, currentTask?}</td>
<td>Agent status changed</td>
</tr>
<tr>
<td><code>mention.spawned</code></td>
<td>{mentionId, agentId, fromAgentId, roomId}</td>
<td>Mention was created (legacy)</td>
</tr>
</tbody>
</table>
<hr>
<h2 id="frontend-architecture">🎨 Frontend Architecture</h2>
<h3>Tech Stack</h3>
<table>
<thead>
<tr>
<th>Technology</th>
<th>Purpose</th>
<th>Rationale</th>
</tr>
</thead>
<tbody>
<tr>
<td><strong>Vite</strong></td>
<td>Build tool + dev server</td>
<td>Fast HMR, existing Hive uses Vite-like setup</td>
</tr>
<tr>
<td><strong>Svelte</strong></td>
<td>UI framework</td>
<td>Matches Hive aesthetic, minimal runtime</td>
</tr>
<tr>
<td><strong>Svelte Stores</strong></td>
<td>State management</td>
<td>Built-in reactivity, derived stores for filters</td>
</tr>
<tr>
<td><strong>EventSource API</strong></td>
<td>SSE client</td>
<td>Native browser API, auto-reconnect</td>
</tr>
</tbody>
</table>
<h3>Store Architecture</h3>
<details>
<summary><strong>stores/events.ts</strong> - SSE Event Handling</summary>
<pre><code>import { writable, derived } from 'svelte/store';
// Connection state
export const connectionState = writable<'disconnected' | 'connecting' | 'connected' | 'error'>('disconnected');
// Raw event stream
export const rawEvents = writable<HiveEvent[]>([]);
// Derived: events filtered by room
export function eventsForRoom(roomId: string) {
return derived(rawEvents, $events =>
$events.filter(e =>
e.payload.roomId === roomId ||
e.type === 'agent.status'
)
);
}
// Derived: events filtered by agent
export function eventsForAgent(agentId: string) {
return derived(rawEvents, $events =>
$events.filter(e => e.payload.agentId === agentId)
);
}
// Derived: current task statuses
export const taskStatuses = derived(rawEvents, $events => {
const tasks = new Map<string, TaskStatus>();
for (const event of $events) {
if (event.type.startsWith('task.')) {
const { taskId } = event.payload;
const status = event.type.replace('task.', '');
tasks.set(taskId, {
taskId,
status,
agentId: event.payload.agentId,
timestamp: event.timestamp
});
}
}
return Array.from(tasks.values());
});</code></pre>
</details>
<details>
<summary><strong>stores/rooms.ts</strong> - Room State</summary>
<pre><code>import { writable, derived } from 'svelte/store';
import { rawEvents } from './events';
// Room metadata (from REST API)
export const rooms = writable<Room[]>([]);
// Derived: room activity level (heat)
export const roomHeat = derived(rawEvents, $events => {
const now = Date.now();
const WINDOW = 60 * 1000; // 1 minute window
const heat = new Map<string, number>();
for (const event of $events) {
if (event.timestamp > now - WINDOW) {
const roomId = event.payload.roomId;
heat.set(roomId, (heat.get(roomId) || 0) + 1);
}
}
return heat;
});
// Derived: agents actively working per room
export const agentsByRoom = derived(rawEvents, $events => {
const active = new Map<string, Set<string>>();
for (const event of $events) {
if (event.type === 'task.started' || event.type === 'task.progress') {
const { roomId, agentId } = event.payload;
if (!active.has(roomId)) active.set(roomId, new Set());
active.get(roomId)!.add(agentId);
}
}
return active;
});</code></pre>
</details>
<h3>Component Structure</h3>
<div class="arch-diagram">src/
├── App.svelte # Main app with routing
├── routes/
│ ├── Dashboard.svelte # Multi-room overview
│ └── RoomDetail.svelte # Single room chat feed
├── components/
│ ├── ActivityGrid.svelte # Room heat map grid
│ ├── AgentPanel.svelte # Sidebar with agent status
│ ├── TaskCard.svelte # Individual task card
│ ├── EventFeed.svelte # Scrolling event log
│ ├── FilterBar.svelte # Filter controls
│ ├── MessageBubble.svelte # Chat message component
│ ├── StatusBadge.svelte # Status indicator
│ └── ProgressBar.svelte # Task progress
├── stores/
│ ├── events.ts # SSE + derived stores
│ ├── rooms.ts # Room state
│ ├── agents.ts # Agent status
│ └── filters.ts # Active filters
└── utils/
├── sse-client.ts # EventSource wrapper
└── formatters.ts # Time, status formatters</div>
<hr>
<h2 id="implementation-tasks">📋 Implementation Tasks</h2>
<h3>Phase 1: Backend SSE Enhancements <span class="status-badge status-progress">Current Phase</span></h3>
<ul class="task-list">
<li class="task-item phase-1"><input type="checkbox" disabled> Enhance existing <code>/events/stream</code> to include <code>post.created</code> events</li>
<li class="task-item phase-1"><input type="checkbox" disabled> Add <code>agent.status</code> event emission when agents change state</li>
<li class="task-item phase-1"><input type="checkbox" disabled> Implement <code>GET /rooms/:roomId/stream</code> SSE endpoint</li>
<li class="task-item phase-1"><input type="checkbox" disabled> Implement <code>GET /rooms/:roomId/feed</code> with SSE upgrade</li>
<li class="task-item phase-1"><input type="checkbox" disabled> Add <code>GET /agents/status</code> endpoint for current agent states</li>
<li class="task-item phase-1"><input type="checkbox" disabled> Add Last-Event-ID reconnect support to existing SSE stream</li>
</ul>
<h3>Phase 2: SSE Client & State Management</h3>
<ul class="task-list">
<li class="task-item phase-2"><input type="checkbox" disabled> Create <code>sse-client.ts</code> with auto-reconnect logic</li>
<li class="task-item phase-2"><input type="checkbox" disabled> Implement <code>stores/events.ts</code> with event buffering</li>
<li class="task-item phase-2"><input type="checkbox" disabled> Create <code>stores/rooms.ts</code> for room-derived state</li>
<li class="task-item phase-2"><input type="checkbox" disabled> Create <code>stores/agents.ts</code> for agent status tracking</li>
<li class="task-item phase-2"><input type="checkbox" disabled> Add <code>stores/filters.ts</code> for filter state management</li>
<li class="task-item phase-2"><input type="checkbox" disabled> Implement connection state handling (disconnected/connecting/connected/error)</li>
</ul>
<h3>Phase 3: Dashboard View</h3>
<ul class="task-list">
<li class="task-item phase-3"><input type="checkbox" disabled> Create <code>Dashboard.svelte</code> main container</li>
<li class="task-item phase-3"><input type="checkbox" disabled> Implement <code>ActivityGrid.svelte</code> with room heat indicators</li>
<li class="task-item phase-3"><input type="checkbox" disabled> Create <code>AgentPanel.svelte</code> sidebar with status badges</li>
<li class="task-item phase-3"><input type="checkbox" disabled> Build <code>TaskCard.svelte</code> with progress bars and timestamps</li>
<li class="task-item phase-3"><input type="checkbox" disabled> Add <code>EventFeed.svelte</code> scrolling log with "pop-in" animation</li>
<li class="task-item phase-3"><input type="checkbox" disabled> Implement <code>FilterBar.svelte</code> with agent/room/status/time filters</li>
<li class="task-item phase-3"><input type="checkbox" disabled> Add connection status indicator (top-right corner)</li>
</ul>
<h3>Phase 4: Room Detail View</h3>
<ul class="task-list">
<li class="task-item phase-4"><input type="checkbox" disabled> Create <code>RoomDetail.svelte</code> route component</li>
<li class="task-item phase-4"><input type="checkbox" disabled> Implement <code>MessageBubble.svelte</code> for chat messages</li>
<li class="task-item phase-4"><input type="checkbox" disabled> Add task context panel showing active task details</li>
<li class="task-item phase-4"><input type="checkbox" disabled> Implement agent presence indicators</li>
<li class="task-item phase-4"><input type="checkbox" disabled> Add message timeline with timestamps</li>
<li class="task-item phase-4"><input type="checkbox" disabled> Implement back navigation to dashboard</li>
<li class="task-item phase-4"><input type="checkbox" disabled> Add SSE subscription for room on mount</li>
</ul>
<h3>Phase 5: Polish & UX</h3>
<ul class="task-list">
<li class="task-item phase-5"><input type="checkbox" disabled> Add responsive design (mobile support)</li>
<li class="task-item phase-5"><input type="checkbox" disabled> Implement dark mode (toggle)</li>
<li class="task-item phase-5"><input type="checkbox" disabled> Add keyboard shortcuts (r = refresh, f = focus filter, etc.)</li>
<li class="task-item phase-5"><input type="checkbox" disabled> Optional: Sound notifications for new events</li>
<li class="task-item phase-5"><input type="checkbox" disabled> Add "pop-in" CSS animations for new events</li>
<li class="task-item phase-5"><input type="checkbox" disabled> Implement relative time formatting ("2s ago")</li>
<li class="task-item phase-5"><input type="checkbox" disabled> Add loading skeletons for initial state</li>
<li class="task-item phase-5"><input type="checkbox" disabled> Error boundary with retry button</li>
</ul>
<hr>
<h2 id="file-structure">📁 File Structure</h2>
<h3>Backend (Hive)</h3>
<div class="arch-diagram">src/
├── routes/
│ ├── events.ts # Enhanced: existing + Last-Event-ID
│ ├── rooms.ts # Enhanced: add /:id/stream, /:id/feed
│ └── agents.ts # Enhanced: add /status endpoint
├── services/
│ ├── events.ts # Enhanced: add post.created emission
│ ├── agents.ts # Enhanced: track agent.status changes
│ └── rooms.ts # Existing
└── types.ts # Enhanced: add new event types</div>
<h3>Frontend (New: hive-observer-ui)</h3>
<div class="arch-diagram">hive-observer-ui/
├── index.html
├── vite.config.ts
├── package.json
├── tsconfig.json
├── src/
│ ├── main.ts # Vite entry point
│ ├── App.svelte # Root component
│ ├── routes/
│ │ ├── Dashboard.svelte # Main view
│ │ └── RoomDetail.svelte # Room drill-down
│ ├── components/
│ │ ├── ActivityGrid.svelte
│ │ ├── AgentPanel.svelte
│ │ ├── TaskCard.svelte
│ │ ├── EventFeed.svelte
│ │ ├── FilterBar.svelte
│ │ ├── MessageBubble.svelte
│ │ ├── StatusBadge.svelte
│ │ └── ProgressBar.svelte
│ ├── stores/
│ │ ├── events.ts
│ │ ├── rooms.ts
│ │ ├── agents.ts
│ │ └── filters.ts
│ ├── utils/
│ │ ├── sse-client.ts
│ │ └── formatters.ts
│ └── styles/
│ ├── variables.css # CSS custom properties
│ └── animations.css # Pop-in, fade effects
└── public/
└── favicon.ico</div>
<hr>
<h2 id="timeline">📅 Timeline</h2>
<table>
<thead>
<tr>
<th>Phase</th>
<th>Duration</th>
<th>Deliverable</th>
<th>Priority</th>
</tr>
</thead>
<tbody>
<tr>
<td><strong>Phase 1</strong></td>
<td>2-3 days</td>
<td>SSE endpoints ready</td>
<td class="priority-high">High</td>
</tr>
<tr>
<td><strong>Phase 2</strong></td>
<td>2-3 days</td>
<td>SSE client + stores</td>
<td class="priority-high">High</td>
</tr>
<tr>
<td><strong>Phase 3</strong></td>
<td>3-4 days</td>
<td>Dashboard view complete</td>
<td class="priority-high">High</td>
</tr>
<tr>
<td><strong>Phase 4</strong></td>
<td>2-3 days</td>
<td>Room detail view</td>
<td class="priority-medium">Medium</td>
</tr>
<tr>
<td><strong>Phase 5</strong></td>
<td>2-3 days</td>
<td>Polish + UX refinements</td>
<td class="priority-low">Low</td>
</tr>
</tbody>
</table>
<p><strong>Total Estimate:</strong> ~2 weeks</p>
<hr>
<h2 id="success-metrics">📊 Success Metrics</h2>
<h3>Performance</h3>
<ul>
<li><strong>SSE Latency</strong>: Event to UI update < 100ms</li>
<li><strong>Reconnect Time</strong>: < 1 second on disconnect</li>
<li><strong>Initial Load</strong>: Dashboard visible < 500ms</li>
<li><strong>Memory</strong>: < 50MB for 1000 events in buffer</li>
</ul>
<h3>Reliability</h3>
<ul>
<li><strong>Auto-Reconnect</strong>: Handles network interruptions gracefully</li>
<li><strong>Event Replay</strong>: No missed events on reconnect (Last-Event-ID)</li>
<li><strong>Error Recovery</strong>: Shows error state with retry button</li>
</ul>
<h3>UX</h3>
<ul>
<li><strong>Visual Feedback</strong>: All state changes animated</li>
<li><strong>Connection Status</strong>: Always visible to user</li>
<li><strong>Keyboard Navigation</strong>: All features accessible without mouse</li>
</ul>
<hr>
<h2>🔗 Related Files</h2>
<ul>
<li><strong>Current Observer</strong>: <code>/Users/mastercontrol/.openclaw/workspace/hive/src/routes/observer.ts</code></li>
<li><strong>Events Service</strong>: <code>/Users/mastercontrol/.openclaw/workspace/hive/src/services/events.ts</code></li>
<li><strong>Types</strong>: <code>/Users/mastercontrol/.openclaw/workspace/hive/src/types.ts</code></li>
<li><strong>Existing Docs</strong>: <code>/Users/mastercontrol/.openclaw/workspace/hive/docs/HIVE_OBSERVER.md</code></li>
</ul>
<hr>
<h2>📝 Notes</h2>
<h3>Why SSE over WebSockets?</h3>
<ul>
<li>SSE is simpler for server-to-client streaming</li>
<li>Automatic reconnection with EventSource API</li>
<li>Last-Event-ID header for reliable replay</li>
<li>Already implemented in Hive (<code>/events/stream</code>)</li>
</ul>
<h3>Why Not Modify Existing Observer?</h3>
<p>The current observer page is embedded HTML. For maintainability and build optimization, we create a separate frontend project while keeping the existing observer as a fallback.</p>
<h3>Integration with Existing Observer</h3>
<ul>
<li>Phase 1-2: Enhance backend, existing observer still works</li>
<li>Phase 3-5: New frontend served at <code>/observer/v2</code></li>
<li>Eventually: Deprecate old observer, redirect to new</li>
</ul>
<hr>
<p><em>Generated: <span id="timestamp"></span></em></p>
<script>
document.getElementById('timestamp').textContent = new Date().toISOString();
</script>
</body>
</html>