From 8e6a017414198fc988d7a0ed26bc7b4de1bcba16 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonatan=20K=C5=82osko?= Date: Fri, 26 Jan 2024 13:51:05 +0100 Subject: [PATCH] Move session markup to a separate file (#2452) --- lib/livebook/file_system/local.ex | 8 +- .../runtime/erl_dist/runtime_server.ex | 4 +- .../components/form_components.ex | 4 +- lib/livebook_web/live/session_live.ex | 951 +------------ .../live/session_live/indicators_component.ex | 272 ---- lib/livebook_web/live/session_live/render.ex | 1247 +++++++++++++++++ 6 files changed, 1265 insertions(+), 1221 deletions(-) delete mode 100644 lib/livebook_web/live/session_live/indicators_component.ex create mode 100644 lib/livebook_web/live/session_live/render.ex diff --git a/lib/livebook/file_system/local.ex b/lib/livebook/file_system/local.ex index a46b1924c..8aacf78e5 100644 --- a/lib/livebook/file_system/local.ex +++ b/lib/livebook/file_system/local.ex @@ -218,10 +218,8 @@ defimpl Livebook.FileSystem, for: Livebook.FileSystem.Local do end def write_stream_chunk(_file_system, state, chunk) when is_binary(chunk) do - case IO.binwrite(state.device, chunk) do - :ok -> {:ok, state} - {:error, error} -> FileSystem.Utils.posix_error(error) - end + :ok = IO.binwrite(state.device, chunk) + {:ok, state} end def write_stream_finish(_file_system, state) do @@ -249,7 +247,7 @@ defimpl Livebook.FileSystem, for: Livebook.FileSystem.Local do try do result = path - |> File.stream!([], @stream_chunk_size_in_bytes) + |> File.stream!(@stream_chunk_size_in_bytes, []) |> Enum.into(collectable) {:ok, result} diff --git a/lib/livebook/runtime/erl_dist/runtime_server.ex b/lib/livebook/runtime/erl_dist/runtime_server.ex index a716690a1..acdd0f07b 100644 --- a/lib/livebook/runtime/erl_dist/runtime_server.ex +++ b/lib/livebook/runtime/erl_dist/runtime_server.ex @@ -180,7 +180,7 @@ defmodule Livebook.Runtime.ErlDist.RuntimeServer do {:transfer, target_path, target_pid} -> try do path - |> File.stream!([], 2048) + |> File.stream!(2048, []) |> Enum.each(fn chunk -> IO.binwrite(target_pid, chunk) end) target_path @@ -910,7 +910,7 @@ defmodule Livebook.Runtime.ErlDist.RuntimeServer do end defp file_md5(path) do - File.stream!(path, [], 2048) + File.stream!(path, 2048, []) |> Enum.reduce(:erlang.md5_init(), &:erlang.md5_update(&2, &1)) |> :erlang.md5_final() end diff --git a/lib/livebook_web/components/form_components.ex b/lib/livebook_web/components/form_components.ex index 27f04d2ae..1fad02ada 100644 --- a/lib/livebook_web/components/form_components.ex +++ b/lib/livebook_web/components/form_components.ex @@ -382,7 +382,7 @@ defmodule LivebookWeb.FormComponents do id={"#{@id}-button"} type="button" data-emoji-button - class="p-1 pl-3 pr-3 rounded-tr-lg rounded-br-lg bg-gray-50 hover:bg-gray-100 active:bg-gray-200 border-l-[1px] bg-white flex justify-center items-center cursor-pointer" + class="p-1 pl-3 pr-3 rounded-tr-lg rounded-br-lg bg-gray-50 hover:bg-gray-100 active:bg-gray-200 border-l-[1px] flex justify-center items-center cursor-pointer" > <.remix_icon icon="emotion-line" class="text-xl" /> @@ -478,7 +478,7 @@ defmodule LivebookWeb.FormComponents do def label(assigns) do ~H""" -