diff --git a/lib/livebook/session.ex b/lib/livebook/session.ex index 9183b5e8d..e574b7f86 100644 --- a/lib/livebook/session.ex +++ b/lib/livebook/session.ex @@ -642,8 +642,8 @@ defmodule Livebook.Session do {:noreply, state} end - def handle_info({:evaluation_output, cell_id, string}, state) do - operation = {:add_cell_evaluation_output, self(), cell_id, string} + def handle_info({:evaluation_output, cell_id, output}, state) do + operation = {:add_cell_evaluation_output, self(), cell_id, output} {:noreply, handle_operation(state, operation)} end diff --git a/lib/livebook_web/live/output.ex b/lib/livebook_web/live/output.ex index 30ffb4f07..c90a27256 100644 --- a/lib/livebook_web/live/output.ex +++ b/lib/livebook_web/live/output.ex @@ -99,10 +99,20 @@ defmodule LivebookWeb.Output do ) end - defp render_output({:frame_dynamic, pid}, %{id: id, socket: socket, input_values: input_values}) do + defp render_output({:frame_dynamic, pid}, %{ + id: id, + socket: socket, + input_values: input_values, + cell_validity_status: cell_validity_status + }) do live_render(socket, LivebookWeb.Output.FrameDynamicLive, id: id, - session: %{"id" => id, "pid" => pid, "input_values" => input_values} + session: %{ + "id" => id, + "pid" => pid, + "input_values" => input_values, + "cell_validity_status" => cell_validity_status + } ) end diff --git a/lib/livebook_web/live/output/frame_dynamic_live.ex b/lib/livebook_web/live/output/frame_dynamic_live.ex index 60da22733..68693862d 100644 --- a/lib/livebook_web/live/output/frame_dynamic_live.ex +++ b/lib/livebook_web/live/output/frame_dynamic_live.ex @@ -2,12 +2,27 @@ defmodule LivebookWeb.Output.FrameDynamicLive do use LivebookWeb, :live_view @impl true - def mount(_params, %{"pid" => pid, "id" => id, "input_values" => input_values}, socket) do + def mount( + _params, + %{ + "pid" => pid, + "id" => id, + "input_values" => input_values, + "cell_validity_status" => cell_validity_status + }, + socket + ) do if connected?(socket) do send(pid, {:connect, self()}) end - {:ok, assign(socket, id: id, output: nil, input_values: input_values)} + {:ok, + assign(socket, + id: id, + output: nil, + input_values: input_values, + cell_validity_status: cell_validity_status + )} end @impl true @@ -20,7 +35,8 @@ defmodule LivebookWeb.Output.FrameDynamicLive do id={"#{@id}-frame"} socket={@socket} runtime={nil} - input_values={@input_values} /> + input_values={@input_values} + cell_validity_status={@cell_validity_status} /> <% else %>
Empty output frame diff --git a/lib/livebook_web/live/session_live/cell_component.ex b/lib/livebook_web/live/session_live/cell_component.ex index 421cd7dc8..dd137cde5 100644 --- a/lib/livebook_web/live/session_live/cell_component.ex +++ b/lib/livebook_web/live/session_live/cell_component.ex @@ -115,6 +115,7 @@ defmodule LivebookWeb.SessionLive.CellComponent do <%= if @cell_view.outputs != [] do %>
+ <%# There is an akin render in LivebookWeb.Output.FrameDynamicLive %> + output = {:text, "Dynamic output in frame"} + + receive do + {:connect, pid} -> send(pid, {:connect_reply, %{output: output}}) + end + end) + + frame_output = {:frame_dynamic, frame_pid} + + section_id = insert_section(session.pid) + cell_id = insert_text_cell(session.pid, section_id, :elixir) + # Evaluate the cell + Session.queue_cell_evaluation(session.pid, cell_id) + # Send an additional output + send(session.pid, {:evaluation_output, cell_id, frame_output}) + + {:ok, view, _} = live(conn, "/sessions/#{session.id}") + + assert render(view) =~ "Dynamic output in frame" + end + end + describe "runtime settings" do test "connecting to elixir standalone updates connect button to reconnect", %{conn: conn, session: session} do