Raxol.UI.Components.Harness.MessageBlock (Raxol v2.6.1)

View Source

Renders a completed transcript message: item_completed{item_type: :message, content}.

content is a Markdown string. Body rendering is delegated entirely to Raxol.UI.Components.Harness.MarkdownBody, which adds a streaming-aware provisional close (mode: :streaming), control-char/ANSI sanitization, and a never-raise fallback on top of the plain Markdown parse -- this module only adds a dim, accent-colored role prefix (role: :user | :assistant) above it so turns are visually distinguishable without shouting. render/2 is pure content -> view: no state of its own is read or written.

The stable-prefix optimization (cache the parse of the durable prefix of a streaming message and only re-parse the live tail) is a documented follow-up seam in MarkdownBody, not implemented here.

Behavioral note: sanitization applies in BOTH modes, so even a :sealed render of control-char-bearing content is intentionally NOT byte-identical to the old raw MarkdownRenderer parse -- control/ESC bytes are stripped, invalid UTF-8 is recovered. Clean content renders identically.

Summary

Types

mode()

@type mode() :: :sealed | :streaming

role()

@type role() :: :user | :assistant

t()

@type t() :: %{
  id: String.t() | atom(),
  role: role(),
  content: String.t(),
  width: pos_integer(),
  mode: mode(),
  style: map(),
  theme: map()
}

Functions

broadcast(msg)

command(cmd)

handle_event(event, state, context)

Callback implementation for Raxol.UI.Components.Base.Component.handle_event/3.

mount(state)

Callback implementation for Raxol.UI.Components.Base.Component.mount/1.

schedule(msg, delay)

unmount(state)

Callback implementation for Raxol.UI.Components.Base.Component.unmount/1.

update(props, state)

Callback implementation for Raxol.UI.Components.Base.Component.update/2.