Omni.UI.TurnComponent (Omni UI v0.1.0)

Copy Markdown View Source

A LiveComponent that renders a completed conversation turn.

Displays the user message and assistant response for a single Omni.UI.Turn, with support for:

  • Inline editing — the user can edit their message, which sends {Omni.UI, :edit_message, turn_id, Omni.Message.t()} to the parent LiveView to create a new conversation branch.
  • Branch navigation — when a turn has multiple edits or regenerations, version navigation arrows are shown (delegated to version_nav in Omni.UI.CoreUI).
  • Copy to clipboard — pushes an "omni:clipboard" event to the client with the text content for a given role.

Events

Events handled locally:

  • "edit" — enters edit mode, populating the textarea with current text.
  • "cancel" — exits edit mode.
  • "change" — tracks textarea input.
  • "copy" — pushes clipboard event to client.

Events forwarded to parent via send/2:

  • "submit" — sends {Omni.UI, :edit_message, turn_id, message} to parent.

Events forwarded to parent via phx-click (no component handling):

  • "omni:navigate" — branch navigation, handled by parent's handle_event.
  • "omni:regenerate" — response regeneration, handled by parent's handle_event.

Summary

Functions

render(assigns)

Attributes

  • turn (Omni.UI.Turn) (required)
  • tool_components (:map) - Defaults to %{}.

Slots

  • user - custom user slot; forwarded to turn/1 unless editing.
  • assistant - custom assistant slot; forwarded to turn/1.