Skip to content

Commit

Permalink
Show cell evaluation time also when stale and aborted
Browse files Browse the repository at this point in the history
  • Loading branch information
jonatanklosko committed Feb 15, 2024
1 parent f9f744a commit cc92a6d
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions lib/livebook_web/live/session_live/cell_component.ex
Original file line number Diff line number Diff line change
Expand Up @@ -704,7 +704,7 @@ defmodule LivebookWeb.SessionLive.CellComponent do
<.cell_status_indicator
variant={if(@cell_view.eval.errored, do: :error, else: :success)}
change_indicator={true}
tooltip={evaluated_label(@cell_view.eval.evaluation_time_ms)}
tooltip={duration_label(@cell_view.eval.evaluation_time_ms)}
>
Evaluated
</.cell_status_indicator>
Expand All @@ -713,15 +713,22 @@ defmodule LivebookWeb.SessionLive.CellComponent do

defp cell_status(%{cell_view: %{eval: %{validity: :stale}}} = assigns) do
~H"""
<.cell_status_indicator variant={:warning} change_indicator={true}>
<.cell_status_indicator
variant={:warning}
change_indicator={true}
tooltip={duration_label(@cell_view.eval.evaluation_time_ms)}
>
Stale
</.cell_status_indicator>
"""
end

defp cell_status(%{cell_view: %{eval: %{validity: :aborted}}} = assigns) do
~H"""
<.cell_status_indicator variant={:inactive}>
<.cell_status_indicator
variant={:inactive}
tooltip={duration_label(@cell_view.eval.evaluation_time_ms)}
>
Aborted
</.cell_status_indicator>
"""
Expand Down Expand Up @@ -749,7 +756,7 @@ defmodule LivebookWeb.SessionLive.CellComponent do
"""
end

defp evaluated_label(time_ms) when is_integer(time_ms) do
defp duration_label(time_ms) when is_integer(time_ms) do
evaluation_time =
if time_ms > 100 do
seconds = time_ms |> Kernel./(1000) |> Float.floor(1)
Expand All @@ -761,7 +768,7 @@ defmodule LivebookWeb.SessionLive.CellComponent do
"Took " <> evaluation_time
end

defp evaluated_label(_time_ms), do: nil
defp duration_label(_time_ms), do: nil

defp smart_cell_js_view_ref(%{type: :smart, status: :started, js_view: %{ref: ref}}), do: ref
defp smart_cell_js_view_ref(_cell_view), do: nil
Expand Down

0 comments on commit cc92a6d

Please sign in to comment.