Omni.UI.SessionsComponent (Omni UI v0.1.0)

Copy Markdown View Source

A LiveComponent that renders the sessions sidebar.

Permanently mounted as a left sidebar over the main chat interface. Lists every persisted session plus any currently-running session that hasn't been persisted yet, with running sessions sorted to the top. Updates live in response to Omni.Session.Manager events.

Assigns from parent

  • id — required Phoenix component id
  • current_id — the currently active session id (for row highlighting)
  • manager — the Omni.Session.Manager module to query

Live updates

Manager events are not delivered to LiveComponents directly — the parent LiveView receives {:manager, _, _, _} messages and forwards them with send_update/2, passing the event under a manager_event: assign that this component pattern-matches:

def handle_info({:manager, _, _, _} = msg, socket) do
  send_update(Omni.UI.SessionsComponent, id: "sessions", manager_event: msg)
  {:noreply, socket}
end

Events bubbled to the parent LiveView (not phx-target-ed)

  • open_session with session-id — parent should push_patch to the session URL
  • new_session — parent should push_patch to /
  • :active_session_deleted — sent as a process message when the user deletes the currently active session

Summary

Functions

render(assigns)

Attributes

  • current_id (:string) - Defaults to nil.
  • manager (:atom) (required)