defmodule LivebookWeb.SessionLive.AttachedLive do use LivebookWeb, :live_view alias Livebook.{Session, Runtime, Utils} @impl true def mount(_params, %{"session_id" => session_id, "current_runtime" => current_runtime}, socket) do {:ok, assign(socket, session_id: session_id, error_message: nil, name: if(current_runtime, do: current_runtime.node, else: "") )} end @impl true def render(assigns) do ~L"""
Connect the session to an already running node and evaluate code in the context of that node. Thanks to this approach you can work with an arbitrary Elixir runtime. Make sure to give the node a name, for example:
iex --sname test
<% else %>
iex --name test@127.0.0.1
<% end %>
Then enter the name of the node below:
<%= f = form_for :node, "#", phx_submit: "init" %> <%= text_input f, :name, value: @name, class: "input", placeholder: if(Livebook.Config.shortnames?, do: "test", else: "test@127.0.0.1") %> <%= submit "Connect", class: "mt-3 button" %>