diff --git a/lib/livebook/hubs/fly.ex b/lib/livebook/hubs/fly.ex index da084a868..299a862c1 100644 --- a/lib/livebook/hubs/fly.ex +++ b/lib/livebook/hubs/fly.ex @@ -1,5 +1,6 @@ defmodule Livebook.Hubs.Fly do @moduledoc false + use Ecto.Schema import Ecto.Changeset diff --git a/lib/livebook/hubs/local.ex b/lib/livebook/hubs/local.ex index 930797a84..ff05235c8 100644 --- a/lib/livebook/hubs/local.ex +++ b/lib/livebook/hubs/local.ex @@ -1,5 +1,6 @@ defmodule Livebook.Hubs.Local do @moduledoc false + defstruct [:id, :hub_name, :hub_color] end diff --git a/lib/livebook/hubs/metadata.ex b/lib/livebook/hubs/metadata.ex index eecb23c67..59272b0ea 100644 --- a/lib/livebook/hubs/metadata.ex +++ b/lib/livebook/hubs/metadata.ex @@ -1,5 +1,6 @@ defmodule Livebook.Hubs.Metadata do @moduledoc false + defstruct [:id, :name, :provider, :color] @type t :: %__MODULE__{ diff --git a/lib/livebook/session.ex b/lib/livebook/session.ex index d39d55f39..68b5ec327 100644 --- a/lib/livebook/session.ex +++ b/lib/livebook/session.ex @@ -502,6 +502,14 @@ defmodule Livebook.Session do GenServer.cast(pid, {:set_file, self(), file}) end + @doc """ + Sends a secret addition request to the server. + """ + @spec put_secret(pid(), map()) :: :ok + def put_secret(pid, secret) do + GenServer.cast(pid, {:put_secret, self(), secret}) + end + @doc """ Sends save request to the server. @@ -537,14 +545,6 @@ defmodule Livebook.Session do :ok end - @doc """ - Sends a secret addition request to the server. - """ - @spec put_secret(pid(), map()) :: :ok - def put_secret(pid, secret) do - GenServer.cast(pid, {:put_secret, secret}) - end - @doc """ Disconnects one or more sessions from the current runtime. @@ -970,13 +970,14 @@ defmodule Livebook.Session do end end - def handle_cast(:save, state) do - {:noreply, maybe_save_notebook_async(state)} + def handle_cast({:put_secret, client_pid, secret}, state) do + client_id = client_id(state, client_pid) + operation = {:put_secret, client_id, secret} + {:noreply, handle_operation(state, operation)} end - def handle_cast({:put_secret, secret}, state) do - operation = {:put_secret, self(), secret} - {:noreply, handle_operation(state, operation)} + def handle_cast(:save, state) do + {:noreply, maybe_save_notebook_async(state)} end @impl true @@ -1052,7 +1053,7 @@ defmodule Livebook.Session do end def handle_info({:user_change, user}, state) do - operation = {:update_user, self(), user} + operation = {:update_user, @client_id, user} {:noreply, handle_operation(state, operation)} end