Log Viewer
LogViewer: a live log or terminal output viewer for any process. createLogStore takes lines from anywhere (append, or write for raw chunks with partial lines) into a bounded buffer and notifies once per frame; the viewer renders only the lines in view, on UI SDK's virtualizer inside a ScrollArea. It follows the end until the reader scrolls up, then shows Jump to end with a count of new lines (End or the button follows again); filters by source (a ToggleGroup, sources coloured with chart or tone colours) and by search; renders ANSI colours on theme tokens; marks error lines (by level or an isError pattern) and steps through them with F8 and Shift+F8; copies the shown lines or a selection as plain text; wraps on demand. A role=log with aria-live off and a polite status that announces new errors at most every 5 seconds. Agents read the shown lines and call filter, search, nextError, previousError, copy, jumpToEnd and setWrap.
Example
Installation
lucide-reactUsage
Use LogViewer for live output of any process: a dev server, a build, a local environment's frontend, backend and database. Feed a createLogStore from a WebSocket, an EventSource or a child process with append (whole lines) or write (raw chunks); it holds the newest maxLines and the viewer renders only the lines in view.
API reference
LogViewer
Takes Omit<ComponentProps<"div">, "children" | "onCopy"> &.
Other exports
createLogStoreisErrorLevelcreateLogIndexcreateLogScrollerlogViewerAnnouncementsformatLinelogViewerlogViewerLabelsLogRowssourceStylesLogViewerToolbartype LogInputtype LogLeveltype LogLinetype LogStoretype LogStoreOptionstype LogStoreSnapshottype LogWriteOptionstype LogFiltertype LogIndextype LogIndexChangetype LogScrollertype LogViewerAnnouncementstype LogViewerChangeReasontype LogViewerOptionstype LogViewerLabelstype LogSourcetype LogViewerApitype SourceStyletype LogViewerPropsAccessibility
- The lines are a named role=log that takes focus: arrows scroll a line, PageUp and PageDown a page, Home and End the edges, F8 and Shift+F8 step through errors.
- The log is aria-live off, since rows come and go as it scrolls; a polite status announces new errors at most every 5 seconds (announce="lines" counts every line, "off" stays quiet).
- Terminal colours keep their hue with their lightness clamped by theme tokens, so text holds 4.5:1 in light and dark; error lines carry a tinted fill and are counted, not marked by colour alone.
- Scrolling up stops following; Jump to end shows how many lines arrived and moves focus back to the log.
Agent actions
Agents read the shown lines as the log's items ("[source] text", by line id), query them by text, and call filter (sources), search, nextError, previousError, copy, jumpToEnd and setWrap. A step with nowhere to go, or a change the app cancels, fails with the reason.
Runs agent.snapshot() from @ui-sdk/react/agent on the live preview above.