UI

Realtime stream

Live scrolling time-series line that trails incoming readings by one interval, rolls the current value, pauses on inspection, and marks anomalies.

import { RealtimeStream } from '@uthereal/ui/realtime-stream'

Realtime stream playground

API p95 latency

API p95 latency
TimeValueNote
12:00:1082 ms
12:00:1191 ms
12:00:12186 msSpike
12:00:13134 ms
12:00:1496 ms
12:00:1581 ms
12:00:1676 ms
12:00:1773 ms
12:00:1869 ms
12:00:1974 ms
12:00:2079 ms
12:00:2185 ms
12:00:2288 ms
12:00:2394 ms
12:00:24164 msGC pause
12:00:25118 ms
12:00:2689 ms
12:00:2777 ms
12:00:2872 ms
12:00:2975 ms
Loading interactive preview…

Overview

A realtime stream monitors one continuous live metric where recent seconds or minutes matter more than long history. The line scrolls smoothly at 60 fps one interval behind the newest reading so each incoming point slides in rather than popping. The current value rolls in large display type beside a Live/Paused toggle pill. Hovering, focusing, or dragging holds the view while incoming readings queue up, and resuming glides back to the live edge. Flagged anomalies pop a marker, hairline, and pill tag as the head reaches them. A native data table exposes the latest 20 readings and their notes.

Use a realtime stream for live telemetry such as p95 latency, request throughput, queue depth, or CPU utilization. For static or multi-series time series, use a line chart. For long histories that readers zoom into, use a brush chart. For a compact inline trend beside a KPI, use Metric.

Usage

import { useEffect, useState } from 'react'
import {
  RealtimeStream,
  type RealtimeStreamPoint,
} from '@uthereal/ui/realtime-stream'

export function LatencyMonitor({ socket }: { socket: WebSocket }) {
  const [data, setData] = useState<RealtimeStreamPoint[]>([])

  useEffect(() => {
    const onMessage = (event: MessageEvent) => {
      const { t, p95 } = JSON.parse(String(event.data)) as {
        t: number
        p95: number
      }
      setData((list) => [
        ...list.slice(-199),
        { t, value: p95, anomaly: p95 > 160 ? 'Spike' : undefined },
      ])
    }
    socket.addEventListener('message', onMessage)
    return () => socket.removeEventListener('message', onMessage)
  }, [socket])

  return (
    <RealtimeStream
      label="p95 latency"
      unit="ms"
      data={data}
      interval={1000}
      windowMs={30000}
    />
  )
}

Pass data as an append-only array of up to 600 readings in strictly ascending epoch milliseconds ({ t, value, anomaly? }), trimmed to a few windows. Flag anomalies directly on incoming points with true or a short tag string; the chart does not detect anomalies on its own. Pair paused with onPausedChange to synchronize pause state across multiple charts.

Examples

Fixed axis bounds and anomaly tags

Omit min and max to let the value axis ease smoothly with visible readings. Set explicit min and max bounds for percentages or fixed SLA ranges so vertical movement reflects absolute capacity, and pass string anomaly values to label spikes or throttling events inline.

Cluster CPU utilization

Cluster CPU utilization
TimeValueNote
12:00:0038 %
12:00:0141 %
12:00:0244 %
12:00:0342 %
12:00:0447 %
12:00:0553 %
12:00:0689 %Spike
12:00:0776 %
12:00:0862 %
12:00:0955 %
12:00:1051 %
12:00:1149 %
12:00:1254 %
12:00:1361 %
12:00:1494 %Throttled
12:00:1578 %
12:00:1659 %
12:00:1748 %
12:00:1845 %
12:00:1943 %

Paused and empty states

Set defaultPaused to mount the stream held at the latest reading while incoming updates wait in the queue. Pass an empty data array with a custom emptyLabel to display a centered waiting message before the first reading arrives.

Held telemetry stream

Held telemetry stream
TimeValueNote
12:00:00420 req/s
12:00:01438 req/s
12:00:02452 req/s
12:00:03446 req/s
12:00:04468 req/s
12:00:05491 req/s
12:00:06479 req/s
12:00:07464 req/s
Pending telemetry

Waiting for first telemetry packet

Pending telemetry
TimeValueNote

Behavior

The live edge trails the newest reading by interval milliseconds and stops at the newest timestamp if the feed stalls, so the line never runs off into empty space. Match interval to the feed cadence and windowMs to a few dozen points. Neighboring anomalies that would collide share a single top pill tag, keeping tags legible during bursts.

Hovering with a mouse (when pauseOnHover is enabled), focusing the plot with the keyboard, pressing and dragging on touch, or toggling the status pill holds the scrolling window and counts incoming readings (Paused, 3 new). The animation loop stops automatically when the figure scrolls off screen or the browser tab is hidden. Default timestamps format in UTC (HH:MM:SS) so server rendering and client hydration match identically.

API reference

These serializable arguments and defaults come directly from the component schema.

ArgumentType / defaultDescription
labelstringDefault: "Realtime stream"What is measured, such as "p95 latency". Names the chart for assistive technology, the rolling current value, and the data table.
titlestring—Optional visible figure heading above the live readout and status button. Omit to keep only the accessible label.
descriptionstring—One or two sentences on what the chart shows, below the title; omit it when the title says enough.
dataRealtimeStreamPoint[]Default: [{"t":1793534400000,"value":64},{"t":1793534401000,"value":68},{"t":1793534402000,"value":62},{"t":1793534403000,"value":71},{"t":1793534404000,"value":69},{"t":1793534405000,"value":74},{"t":1793534406000,"value":78},{"t":1793534407000,"value":72},{"t":1793534408000,"value":67},{"t":1793534409000,"value":75},{"t":1793534410000,"value":82},{"t":1793534411000,"value":91},{"t":1793534412000,"value":186,"anomaly":"Spike"},{"t":1793534413000,"value":134},{"t":1793534414000,"value":96},{"t":1793534415000,"value":81},{"t":1793534416000,"value":76},{"t":1793534417000,"value":73},{"t":1793534418000,"value":69},{"t":1793534419000,"value":74},{"t":1793534420000,"value":79},{"t":1793534421000,"value":85},{"t":1793534422000,"value":88},{"t":1793534423000,"value":94},{"t":1793534424000,"value":164,"anomaly":"GC pause"},{"t":1793534425000,"value":118},{"t":1793534426000,"value":89},{"t":1793534427000,"value":77},{"t":1793534428000,"value":72},{"t":1793534429000,"value":75},{"t":1793534430000,"value":71},{"t":1793534431000,"value":68}]Append-only feed of up to 600 readings in strictly ascending epoch milliseconds ({ t, value, anomaly? }). A string anomaly becomes the marker tag.
unitstringDefault: ""Optional unit suffix appended after values, such as "ms", "MB/s", or "req/s".
valueFormatNumberFormat—How values appear in the tooltip, table and axis: decimal, percent or currency, with fraction digits. Axis ticks are compacted (12.9K).
windowMsintegerDefault: 30000Visible span of time in milliseconds (1000–3600000). Set to cover a few dozen readings.
intervalintegerDefault: 1000Typical milliseconds between readings (50–60000). The view trails the newest point by one interval so readings slide in smoothly.
heightintegerDefault: 200Plot height in pixels (100–520).
defaultPausedbooleanDefault: falseInitial paused state when uncontrolled. Later argument edits do not reset a mounted instance.
pauseOnHoverbooleanDefault: trueHold the scrolling view while a fine pointer hovers over the plot so moving points stay readable.
minnumber—Fixed lower bound of the value axis. Omit to ease smoothly with visible readings.
maxnumber—Fixed upper bound of the value axis. Omit to ease smoothly with visible readings.
emptyLabelstringDefault: "Waiting for data"Message shown centered over the plot before the first reading arrives.
tableTogglebooleanDefault: falseShow a button that reveals the data table. The table is always available to assistive technology.
tableLabelstringDefault: "Data table"Name of the data table button.
localestring—BCP 47 locale for numbers and dates. Omit it to inherit the application locale (en-US by default).
recipestudio | softDefault: "studio"Visual treatment. Both recipes use the same interaction behavior.
themeRealtimeStreamTheme—Color mode, accent, and semantic tokens including series1 (live line), series2 (anomaly markers), hairline borders, and display font family. See Theming.
motionnone | subtle | expressiveDefault: "subtle"Scrolling, rolling readout, anomaly pop, and tooltip glide preset. System reduced-motion preferences take precedence.
motionOptionsRealtimeStreamMotionOptions—Chart transition overrides.
dirltr | rtl—Reading direction for the readout, status button, plot progression, value axis, and tooltip. Omit to inherit the page direction.

React integration

PropPurpose
pausedControlled pause state; holds the scrolling view while new readings queue
onPausedChangeFires with the next boolean pause state when the status button, Space/Enter, or Escape fires
formatValueCustom formatter (value: number) => string for the readout, axis ticks, tooltip, and data table
formatTimeCustom formatter (t: number) => string for timestamps in the tooltip, live region, and data table
presetApplication defaults, overridden by explicit instance props
tokensCSS variables applied after the typed theme
refRef forwarded to the root <figure>
className, styleApplied to the root <figure>
Native attributesid, data-*, and remaining <figure> attributes forwarded to the root

Keyboard & accessibility

KeyInteraction
TabFocus the status toggle pill or the plot (focusing the plot holds reading)
ArrowLeft, ArrowRightStep backward or forward one visible reading (mirrored in dir="rtl")
PageUp, PageDownJump ten readings backward or forward
Home, EndJump to the oldest or newest visible reading
Space, EnterPause or resume the live stream
EscapeClear the active reading and resume the stream

The component renders a <figure> named by title (or visually hidden label when title is omitted), described by description, and linked via aria-details to a native data table containing the latest 20 readings with their timestamps, formatted values, and anomaly notes. The current value readout exposes its full text through aria-label while hiding the rolling digits from assistive technology.

The Live/Paused control is a native toggle button with aria-pressed that pairs a morphing icon shape (filled circle when live, twin vertical bars when paused) with a text label so state never relies on color alone. Incoming anomalies announce once in a polite role="status" live region, and scrubbing points announces each reading in a separate polite live region. Layout, time progression, axis gutter, and keyboard direction mirror cleanly in dir="rtl". Under forced-colors: active, system colors (Canvas, CanvasText, Highlight, ButtonFace, ButtonText) replace tinted fills and borders.

Motion and theming

The plot updates pooled SVG primitives in a single requestAnimationFrame loop with zero per-frame React re-renders. Incoming points slide smoothly across the window, the value axis eases toward visible bounds, anomalies pop in with a single overshoot, the current value rolls on a critically damped smooth spring (0.4 s, zero bounce), the status pill width morphs on a spring as queued counts change, and the tooltip glides on a responsive spring.

Under prefers-reduced-motion: reduce or motion="none", continuous scrolling, axis easing, anomaly pops, rolling digits, pill width morphing, and tooltip glides stop. The chart redraws only when data, container width, or the active reading changes, and all transitions resolve immediately (0 ms).

theme accepts a mode, an accent, and semantic tokens across the core, control, and chart groups (using series1 for the live line and head dot and series2 for anomaly markers) plus borderSubtle and fontFamilyDisplay. An application-wide UtherealProvider supplies defaults.

Composition

In an agent composition, RealtimeStream is a leaf with no actions. onPausedChange is a transient UI control bound to paused. The host appends readings to data through composition updates. See Building with agents.

{
  "type": "RealtimeStream",
  "props": {
    "label": "p95 latency",
    "unit": "ms",
    "windowMs": 30000,
    "interval": 1000,
    "data": [
      { "t": 1793534400000, "value": 68 },
      { "t": 1793534401000, "value": 74 },
      { "t": 1793534402000, "value": 182, "anomaly": "Spike" },
      { "t": 1793534403000, "value": 92 }
    ]
  },
  "children": []
}

On this page