Pixir.Renderer (pixir v0.1.12)

Copy Markdown View Source

The first thin front-end over the event bus (ADR 0004, decision D-05): a stdout subscriber that pattern-matches on event.type. It validates the seam — the core needs no changes for a new front-end.

Channel discipline (ADR 0005):

  • stdout — the model's answer: streamed text_deltas and the final newline.
  • stderr — activity and diagnostics: tool calls/results, reasoning, status.

render/1 is the pure mapping from an Event to writes ([{:stdout | :stderr, io}]), so it is unit-testable. consume_until_done/1 owns one canonical Session epoch, performing writes until that Session emits terminal status ("done" / "error"). The Session may be explicit in :session_id or safely derived from the first canonical Event; foreign-Session Events never contaminate the epoch.

Summary

Functions

Receive and render Events for the calling (already-subscribed) process until a terminal status. Returns :ok or :timeout after :idle_timeout ms of silence.

Render the terminal summary when a Presenter suppressed warnings over its cap.

Render one Provider-output truncation warning without changing model text.

Map an Event to a list of {:stdout | :stderr, iodata} writes.

Perform a single {:stdout | :stderr, iodata} write (used by front-ends).

Functions

consume_until_done(opts \\ [])

@spec consume_until_done(keyword()) :: :ok | :timeout

Receive and render Events for the calling (already-subscribed) process until a terminal status. Returns :ok or :timeout after :idle_timeout ms of silence.

output_truncation_suppression(total, shown)

@spec output_truncation_suppression(non_neg_integer(), non_neg_integer()) :: iodata()

Render the terminal summary when a Presenter suppressed warnings over its cap.

output_truncation_warning(warning)

@spec output_truncation_warning(map()) :: iodata()

Render one Provider-output truncation warning without changing model text.

render(event)

@spec render(map()) :: [{:stdout | :stderr, iodata()}]

Map an Event to a list of {:stdout | :stderr, iodata} writes.

write(arg)

@spec write({:stdout | :stderr, iodata()}) :: :ok

Perform a single {:stdout | :stderr, iodata} write (used by front-ends).