feat(observer): draw relayflow runs; carry message metadata on realtime events

Merged
KH
2mo ago
+424-9

Problem

A relayflow run's observer link showed nothing about the flow. The dashboard has no notion of a run, and even structured messages could not render live: the realtime message.created event dropped metadata (which GET /v1/channels/:name/messages returns), and @relaycast/react's reducer dropped it again.

Change

  • engine wsTransform.ts: message.created carries the message metadata when it is an object. It is the same document the REST list already returns to the same token, so no new exposure.
  • react reducer.ts: handleMessageCreated keeps metadata.
  • observer-dashboard: lib/relayflow-run.ts parses the newest metadata.relayflow (version 1) run snapshot in a channel, field by field, ignoring anything malformed. RunPanel draws it as a step graph (columns by dependency depth, state and timing per step), pinned above the feed.

Companion flows PR (the producer): AgentWorkforce/flows — fix/observer-run-projection.

Evidence

  • packages/engine: npx vitest run src/engine/__tests__/wsTransform.test.ts → Tests 35 passed (35)
  • packages/react: npx vitest run src/__tests__/reducer.test.ts → Tests 26 passed (26)
  • packages/observer-dashboard: npx vitest run src/lib/relayflow-run.test.ts → Tests 5 passed (5); tsc --noEmit clean for engine, react, dashboard.
  • End to end: a self-hosted engine built from this branch (dist/bin/serve.js --port 8799) + this dashboard + a flows run from the companion branch. One page session's panel went 0/4 → 1/4 → 2/4 → 3/4 → 4/4 steps with no reload. Against production cast.agentrelay.com (without this engine change) the panel froze at its first REST load while the text feed kept updating, which is the bug this fixes.

Known, not addressed here

A channel-scoped observer token (filters.channel_names, include_dms: false) still receives other agents' dm.received events in the Activity panel, and the agents sidebar lists the whole workspace.

🤖 Generated with Claude Code


[!NOTE]
Medium Risk
Changes realtime event shape and client ordering semantics across engine, SDK, and React; behavior is backward-compatible via optional fields and createdAt fallback, but observers and agents depending on old payloads may see different message ordering or new metadata fields.

Overview
Realtime message.created now matches REST list payloads: the engine and direct-node WebSocket paths forward message.metadata (object-only) and the persisted createdAt, and @relaycast/react stores both instead of stamping client time and stripping metadata. MessageCreatedEvent gains optional created_at; OpenAPI/README document the behavior.

The observer dashboard parses the newest valid metadata.relayflow v1 snapshot in a channel (snowflake ID order, tolerant parsing) and pins a RunPanel above the feed with a dependency-column step graph, textual step states, and timing. Vitest is configured for automatic JSX in dashboard tests.

Reviewed by Cursor Bugbot for commit f4a1c56d51c159d37a860053b47190ee57f90ed3. Bugbot is set up for automated code reviews on this repo. Configure here.


Agent Relay sessions

  • claude session 110a8f49 · opened via gh pr create · last active 2026-09-24
  • codex session 01a0d1bf · contributor · pushed commits · last active 2026-09-24