Remove process all button from apps when interrupted/errored (#2117)

Co-authored-by: Jonatan Kłosko <jonatanklosko@gmail.com>
This commit is contained in:
ByeongUk Choi 2023-07-28 01:28:14 +09:00 committed by GitHub
parent 3ecc0b3653
commit dcca36a28a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 86 additions and 1 deletions

View file

@ -185,7 +185,10 @@ defmodule LivebookWeb.AppSessionLive do
</div>
<div class="fixed right-3 bottom-4 flex flex-col gap-2 items-center text-gray-600 w-10">
<span
:if={@data_view.app_status.execution != :executing and @data_view.any_stale?}
:if={
@data_view.app_status.execution == :executed and
@data_view.any_stale?
}
class="tooltip left"
data-tooltip={
~S'''

View file

@ -165,4 +165,86 @@ defmodule LivebookWeb.AppSessionLiveTest do
Livebook.App.close(app.pid)
end
test "shows the reprocessing button when there are changed inputs and no errors",
%{conn: conn, test: test} do
slug = Livebook.Utils.random_short_id()
app_settings = %{Livebook.Notebook.AppSettings.new() | slug: slug}
Process.register(self(), test)
input = %{
ref: :input_ref,
id: "input1",
type: :number,
label: "Name",
default: 1,
destination: test
}
notebook = %{
Livebook.Notebook.new()
| app_settings: app_settings,
sections: [
%{
Livebook.Notebook.Section.new()
| cells: [
%{
Livebook.Notebook.Cell.new(:code)
| source: source_for_output({:input, input})
},
%{
Livebook.Notebook.Cell.new(:code)
| source: source_for_input_read(input.id)
},
%{
Livebook.Notebook.Cell.new(:code)
| id: "error-cell",
source: """
# Fail on the first run
unless :persistent_term.get(#{inspect(test)}, false) do
:persistent_term.put(#{inspect(test)}, true)
raise "oops"
end
"""
}
]
}
]
}
Livebook.Apps.subscribe()
{:ok, app_pid} = Apps.deploy(notebook)
assert_receive {:app_created, %{pid: ^app_pid} = app}
assert_receive {:app_updated,
%{
pid: ^app_pid,
sessions: [%{pid: session_pid, app_status: %{execution: :error}}]
}}
Livebook.Session.set_input_value(session_pid, input.id, 10)
{:ok, view, _} = conn |> live(~p"/apps/#{slug}") |> follow_redirect(conn)
# The button should not appear on error
refute render(view) =~
"Some inputs have changed.\nClick this button to process with latest values."
view
|> element("button", "Retry")
|> render_click()
assert_receive {:app_updated,
%{pid: ^app_pid, sessions: [%{app_status: %{execution: :executed}}]}}
Livebook.Session.set_input_value(session_pid, input.id, 20)
Livebook.SessionHelpers.wait_for_session_update(session_pid)
assert render(view) =~
"Some inputs have changed.\nClick this button to process with latest values."
Livebook.App.close(app.pid)
end
end