Live data: SSE-driven charts + live admin dashboard
Live data: SSE-driven charts + live admin dashboard
#17 in tonybierman/dx-blog — merged 2026-05-30
Builds out the real-time layer on top of the existing per-post SSE hub, in two parts.
1. Server-driven live charts (5d3…→ first commit)
- The
livechartMDX embed now subscribes to the post's SSE channel instead of running a client-side timer with synthetic data. - New topic-keyed
LiveEvent::Data { topic, value }; the hub keeps a per-(post, topic)ring buffer andlive_handlerreplays the backlog on connect so late joiners see recent history (no client change — backfill rides the samedataevents). - A background producer samples real host CPU (
/proc/stat) and memory (/proc/meminfo) and publishes them on thecpu/memtopics; it resolves the chart post by slug so reseeds keep working. push_data_pointserver fn for manual/ingest pushes.
2. Live admin dashboard & moderation queue (second commit)
- A separate, authorized, site-wide admin channel (
AdminEvent+ singletonadmin_txonLiveHub) — kept distinct from the public per-post channel so pending/unmoderated comment bodies never leak. The admin stream carries notification metadata only. GET /api/admin/liveis gated on a signed-inCOMMENTS_MODERATEholder (via the session cookie); returns 403 on refusal.- Publishes wired into
create_comment(incl. pending),moderate_comment(every status),delete_comment,add_reaction. use_admin_liveclient hook mirrorsuse_live(SSR-safe, web-gated, reactive on permission).- Dashboard: new Reactions tile, a live activity feed (moderators only), authoritative refetch on comment events + local reaction delta. Moderation queue refetches live on comment events.
- Activity/status badges use the theme accent (
brand-*).
Docs & verification
docs/live-data.mddocuments both the per-post and admin streams.TODO_VERIFICATION.mdhas the end-to-end manual checklist.
Checks
cargo check/cargo clippy -D warningspass on both targets (server,sqlite and wasm web);cargo fmt --checkclean.- Live charts verified end-to-end in the running app. The admin-dashboard flows are covered by the
TODO_VERIFICATION.mdchecklist (not yet manually driven).
🤖 Generated with Claude Code
Last updated 2026-05-31
Links to this note
Credits
Merged pull requests, newest first.