diff --git a/lib/livebook_web/live/session_live.ex b/lib/livebook_web/live/session_live.ex index ba3cfa046..f88a577a4 100644 --- a/lib/livebook_web/live/session_live.ex +++ b/lib/livebook_web/live/session_live.ex @@ -1821,9 +1821,13 @@ defmodule LivebookWeb.SessionLive do defp after_operation( socket, _prev_socket, - {:smart_cell_started, _client_id, _cell_id, _delta, _chunks, _js_view, _editor} + {:smart_cell_started, _client_id, cell_id, _delta, _chunks, _js_view, _editor} ) do - prune_cell_sources(socket) + {:ok, cell, _section} = Notebook.fetch_cell_and_section(socket.private.data.notebook, cell_id) + + socket + |> push_cell_editor_payloads(socket.private.data, [cell], [:secondary]) + |> prune_cell_sources() end defp after_operation(socket, _prev_socket, {:erase_outputs, _client_id}) do @@ -2060,9 +2064,10 @@ defmodule LivebookWeb.SessionLive do end end - defp push_cell_editor_payloads(socket, data, cells) do + defp push_cell_editor_payloads(socket, data, cells, tags \\ :all) do for cell <- cells, {tag, payload} <- cell_editor_init_payloads(cell, data.cell_infos[cell.id]), + tags == :all or tag in tags, reduce: socket do socket -> push_event(socket, "cell_editor_init:#{cell.id}:#{tag}", payload) @@ -2106,7 +2111,7 @@ defmodule LivebookWeb.SessionLive do end } ] ++ - if cell.editor do + if cell.editor && cell_info.status == :started do [ secondary: %{ source: cell.editor.source, diff --git a/lib/livebook_web/live/session_live/secrets_list_component.ex b/lib/livebook_web/live/session_live/secrets_list_component.ex index d716ea045..22f499b3e 100644 --- a/lib/livebook_web/live/session_live/secrets_list_component.ex +++ b/lib/livebook_web/live/session_live/secrets_list_component.ex @@ -156,7 +156,7 @@ defmodule LivebookWeb.SessionLive.SecretsListComponent do ***** <.link - id="edit-secret-button" + id={"#{@id}-edit-button"} navigate={~p"/hub/#{@secret.hub_id}/secrets/edit/#{@secret.name}"} class="hover:text-gray-900" role="button" diff --git a/test/livebook_web/live/integration/session_live_test.exs b/test/livebook_web/live/integration/session_live_test.exs index 146051a37..1a199c8eb 100644 --- a/test/livebook_web/live/integration/session_live_test.exs +++ b/test/livebook_web/live/integration/session_live_test.exs @@ -121,7 +121,7 @@ defmodule LivebookWeb.Integration.SessionLiveTest do # clicks the button to edit a secret view |> with_target("#secrets_list") - |> element("#hub-#{id}-secret-#{secret_name}-detail #edit-secret-button") + |> element("#hub-#{id}-secret-#{secret_name}-edit-button") |> render_click() # redirects to hub page and loads the modal with diff --git a/test/livebook_web/live/session_live_test.exs b/test/livebook_web/live/session_live_test.exs index dd5b31b74..b012e6038 100644 --- a/test/livebook_web/live/session_live_test.exs +++ b/test/livebook_web/live/session_live_test.exs @@ -1322,7 +1322,7 @@ defmodule LivebookWeb.SessionLiveTest do # clicks the button to edit a secret view |> with_target("#secrets_list") - |> element("#hub-#{hub.id}-secret-#{secret_name}-detail #edit-secret-button") + |> element("#hub-#{hub.id}-secret-#{secret_name}-edit-button") |> render_click() # redirects to hub page and loads the modal with