Replaces the /settings/live-events placeholder with a working page that streams server-wide events from /api/v1/attach. Shares the leader-owned cross-tab EventSource so additional tabs subscribe without opening parallel connections. The page keeps an in-memory ring buffer (newest first, max 1,000) with id or run_id:seq dedupe and resets on remount; live-only by design, nothing is replayed on connect or persisted in the browser. Reuses the existing event-debug filters, search, and details panel, and links each row's run_id to /runs/:id. The category filter is the static set of DebugCategory values so "All types" always matches. Settings layout is now fullHeight-aware so the events page can fill the viewport alongside the sub-nav. DebugEventDetailsPanel's event prop is broadened to a shared EventDisplayPayload shape so it accepts both EventEnvelope and the live payload. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
3.3 KiB
Live Events Page Implementation Plan
For agentic workers: REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (
- [ ]) syntax for tracking.
Goal: Add a live-only /events page that streams server-wide Fabro run events received after the page is opened.
Architecture: Reuse the existing web SSE coordination layer. One browser tab owns the global /api/v1/attach EventSource and rebroadcasts events through BroadcastChannel; the new page subscribes to that stream and stores only an in-memory ring buffer for the current page lifetime.
Tech Stack: React, React Router, SWR mutate plumbing, EventSource, BroadcastChannel, Bun tests.
Summary
Build a live-only /events page that shows server-wide Fabro run events received after the page is opened. Do not add backend replay, persistence, or a server-side recent-events buffer. Reuse the existing web SSE coordination: one tab owns /api/v1/attach, other tabs receive events via BroadcastChannel.
Key Changes
- Add a top-level route
eventsinapps/fabro-web/app/router.tsx, rendered inside the existing app shell withwideandfullHeighthandles. - Add a top-level nav item named
Eventsinapps/fabro-web/app/layouts/app-shell.tsxusing an existing outline icon such asBoltIcon. - Add
apps/fabro-web/app/lib/live-events.ts:- Export
subscribeToLiveEvents(onEvent, options?). - Use
subscribeToCrossTabSsewithsubscriptionKey: "live-events". - In coordinated mode, rely on the existing leader-owned
/api/v1/attachstream. - In fallback mode, use
subscribeToSharedEventSourcewithqueryKeys.system.attachUrl(). - Return no SWR invalidation keys; call
onEvent(payload)from the resolver.
- Export
- Add
apps/fabro-web/app/routes/live-events.tsx:- Keep a local in-memory ring buffer, newest first, max 1,000 events.
- Deduplicate by
idwhen present, otherwise byrun_id:seq. - Start empty on mount and reset on refresh/navigation remount.
- Reuse existing event debug controls: category filter, search input, details panel.
- Render a global row shape that includes category, event name,
run_id, optionalnode_id/stage_id, and absolute timestamp. - Link
run_idto/runs/:idwhen present. - Empty state text should make live-only behavior clear: events appear only after this page is opened.
Testing
- Add
apps/fabro-web/app/lib/live-events.test.tsx:- Coordinated mode opens
/api/v1/attach. - Fallback mode opens
/api/v1/attach, not/api/v1/runs/:id/attach. onEventreceives all run IDs.- No SWR mutate keys are emitted.
- Coordinated mode opens
- Add
apps/fabro-web/app/routes/live-events.test.tsx:- Renders empty live-only state initially.
- Appends incoming events newest first.
- Deduplicates repeated event IDs.
- Caps retained events at 1,000.
- Filters by category/search and opens details panel.
- Run:
cd apps/fabro-web && bun testcd apps/fabro-web && bun run typecheck
Assumptions
- No Rust/server changes are needed because
GET /api/v1/attachalready streams global live events. - “Live-only” means no replay on connect and no persistence in the browser beyond the current page lifetime.
- The page should be discoverable from main navigation as
Events; the direct URL/eventsremains the canonical route.