actions list: live-update on run status change; header badge links to latest run
5af55d9 · gmorell · 2026-07-03 03:33
Files changed
modified
lib/git_gud_web/live/repo_live/header.ex
+8
−7
@@ -80,13 +80,14 @@ defmodule GitGudWeb.RepoLive.Header do
| 80 | 80 | class="link link-hover" |
| 81 | 81 | > |
| 82 | 82 | Actions |
| 83 | − <span | |
| 84 | − :if={@latest_run} | |
| 85 | − class={["badge badge-xs ml-1", run_badge(@latest_run.status)]} | |
| 86 | − title={"latest run: #{@latest_run.status}"} | |
| 87 | − > | |
| 88 | − {@latest_run.status} | |
| 89 | − </span> | |
| 83 | + </.link> | |
| 84 | + <.link | |
| 85 | + :if={@latest_run} | |
| 86 | + navigate={~p"/r/#{@handle}/#{@repo.name}/actions/#{@latest_run.number}"} | |
| 87 | + class={["badge badge-xs ml-1", run_badge(@latest_run.status)]} | |
| 88 | + title={"latest run ##{@latest_run.number}: #{@latest_run.status}"} | |
| 89 | + > | |
| 90 | + {@latest_run.status} | |
| 90 | 91 | </.link> |
| 91 | 92 | <%= if @has_packages? do %> |
| 92 | 93 | · |
modified
lib/git_gud_web/live/workflow_live/index.ex
+17
−0
@@ -12,6 +12,11 @@ defmodule GitGudWeb.WorkflowLive.Index do
| 12 | 12 | Repositories.get_repository_by_path!(owner, name) |
| 13 | 13 | |> GitGud.Repo.preload([:owner, :organization]) |
| 14 | 14 | |
| 15 | + # Live-update the run list + header badge as runs change (a job | |
| 16 | + # starting flips a run to `running`). | |
| 17 | + if connected?(socket), | |
| 18 | + do: Phoenix.PubSub.subscribe(GitGud.PubSub, Workflows.ci_topic()) | |
| 19 | + | |
| 15 | 20 | runs = Workflows.list_runs(repo) |
| 16 | 21 | |
| 17 | 22 | {:ok, |
@@ -23,6 +28,18 @@ defmodule GitGudWeb.WorkflowLive.Index do
| 23 | 28 | |> assign(:page_title, "Actions — #{owner}/#{name}")} |
| 24 | 29 | end |
| 25 | 30 | |
| 31 | + @impl true | |
| 32 | + def handle_info({:ci_run_changed, _run_id}, socket) do | |
| 33 | + repo = socket.assigns.repo | |
| 34 | + | |
| 35 | + {:noreply, | |
| 36 | + socket | |
| 37 | + |> stream(:runs, Workflows.list_runs(repo), reset: true) | |
| 38 | + |> assign(:latest_run, Workflows.latest_run(repo))} | |
| 39 | + end | |
| 40 | + | |
| 41 | + def handle_info(_msg, socket), do: {:noreply, socket} | |
| 42 | + | |
| 26 | 43 | @impl true |
| 27 | 44 | def render(assigns) do |
| 28 | 45 | ~H""" |
Parents: 1f1d9e9