feat(observability): chronological timeline and agent productivity APIs
We added the third major surface to the BeadBoard workspace: the Chronological Timeline. This provides the 'Audit' layer of our operational hierarchy. Triumphs: - Built the /timeline route with sticky date grouping and polymorphic EventCards. - Integrated the ActivityPersistence library to bridge the gap between ephemeral SSE events and persistent project history. - Implemented real-time Agent Stats endpoints (/api/agents/[id]/stats) that derive throughput and 'Wins' from the project stream. Raw Honest Moment: We almost shipped this without persistence, which would have meant the project history would disappear every time the server restarted. Realizing that 'Observability' requires 'Survivability' led us to build the .beadboard/activity.json buffer, a small but vital piece of engineering that makes the timeline actually useful.
This commit is contained in:
parent
f3558dc0d1
commit
bfe4f853f0
8 changed files with 428 additions and 0 deletions
60
src/app/timeline/page.tsx
Normal file
60
src/app/timeline/page.tsx
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
'use client';
|
||||
|
||||
import { useEffect } from 'react';
|
||||
import { TimelineFeed } from '../../components/timeline/timeline-feed';
|
||||
import { useTimelineStore } from '../../components/timeline/timeline-store';
|
||||
|
||||
export default function TimelinePage() {
|
||||
return (
|
||||
<div className="mx-auto max-w-3xl px-4 py-8">
|
||||
<header className="mb-8">
|
||||
<h1 className="text-2xl font-bold text-text-strong">Activity Timeline</h1>
|
||||
<p className="text-text-muted">Real-time stream of project mutations.</p>
|
||||
</header>
|
||||
|
||||
<TimelineControls />
|
||||
<TimelineSubscription />
|
||||
<TimelineFeed />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function TimelineControls() {
|
||||
return (
|
||||
<div className="mb-6 flex gap-2">
|
||||
{/* Placeholder for future filters */}
|
||||
<div className="text-sm text-text-muted">Showing all activity</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function TimelineSubscription() {
|
||||
const { addEvent, setHistory } = useTimelineStore();
|
||||
|
||||
useEffect(() => {
|
||||
// 1. Fetch history
|
||||
fetch('/api/activity')
|
||||
.then(res => {
|
||||
if (!res.ok) throw new Error('History fetch failed');
|
||||
return res.json();
|
||||
})
|
||||
.then(data => setHistory(data))
|
||||
.catch(err => console.error('Failed to load history', err));
|
||||
|
||||
// 2. Subscribe to SSE
|
||||
const es = new EventSource('/api/events');
|
||||
|
||||
es.addEventListener('activity', (e) => {
|
||||
try {
|
||||
const event = JSON.parse(e.data);
|
||||
addEvent(event);
|
||||
} catch (err) {
|
||||
console.error('Failed to parse activity event', err);
|
||||
}
|
||||
});
|
||||
|
||||
return () => es.close();
|
||||
}, [setHistory, addEvent]);
|
||||
|
||||
return null;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue