BB.TUI.Live (BB.TUI v0.6.0)

Copy Markdown View Source

The dashboard as a Phoenix LiveView — the browser transport.

Available when the optional phoenix_ex_ratatui dependency is present; without it this module is not compiled. Add it next to bb_tui:

{:bb_tui, "~> 0.6"},
{:phoenix_ex_ratatui, "~> 0.2"}

Define a LiveView and route to it like any other:

defmodule MyAppWeb.RobotLive do
  use BB.TUI.Live, robot: MyApp.Robot
end

# router.ex
live "/robot", MyAppWeb.RobotLive

The use options are the dashboard's mount options — the same keyword list BB.TUI.start/2 takes (:robot is required; :node, :subscribe_paths, and :renderers pass through). For per-session options — picking the robot from the session or params — override tui_mount_opts/1, which receives the LiveView socket after mount:

defmodule MyAppWeb.RobotLive do
  use BB.TUI.Live, robot: MyApp.Robot

  def tui_mount_opts(socket) do
    [robot: socket.assigns.robot]
  end
end

Each browser connection runs its own isolated dashboard session over the shared robot, exactly as concurrent SSH clients do. The JS side needs phoenix_ex_ratatui's hook registered once in app.js — see the phoenix_ex_ratatui docs and the dev/web demo endpoint in this repository for the wiring.