CI wall: a full-height card's log reaches its top

3ef13bc · gmorell · 2026-11-03 17:04

9 files +32 -2
Message
{commit_body(@commit)}

Files changed

modified lib/git_gud_web/live/ci_wall_live.ex
+18 −2
@@ -40,7 +40,12 @@ defmodule GitGudWeb.CiWallLive do
40 40 alias GitGudWeb.CiWallLive.Layout
41 41
42 42 @max_cols 6
43 − @tail_lines 40
43 + # Enough log to fill a full-height card on a 4K screen (11px lines),
44 + # kept per job; a card is sent only the share its height can show
45 + # (`visible_lines/2`), so a stacked card doesn't carry the lines a
46 + # full-height one needs.
47 + @tail_lines 160
48 + @min_visible_lines 24
44 49 @reload_ms 250
45 50 @flush_ms 200
46 51
@@ -219,7 +224,10 @@ defmodule GitGudWeb.CiWallLive do
219 224 # Re-inserted for a new tail with the span it was tiled with.
220 225 defp card(socket, job, span \\ nil) do
221 226 span = span || span_of(socket, job)
222 − %{id: job.id, job: job, span: span, tail: Map.get(socket.assigns.tails, job.id, [])}
227 + tail = Map.get(socket.assigns.tails, job.id, [])
228 + visible = visible_lines(span, socket.assigns.tiling.rows)
229 +
230 + %{id: job.id, job: job, span: span, tail: Enum.take(tail, -visible)}
223 231 end
224 232
225 233 defp span_of(socket, job) do
@@ -227,6 +235,14 @@ defmodule GitGudWeb.CiWallLive do
227 235 Enum.at(socket.assigns.tiling.spans, index, 1)
228 236 end
229 237
238 + # A card spanning `span` of `rows` rows is that share of the wall's
239 + # height, so it shows that share of the lines, with a floor for the
240 + # phone layout, where every card is the same height.
241 + defp visible_lines(span, rows) when rows > 0,
242 + do: max(@min_visible_lines, ceil(@tail_lines * span / rows))
243 +
244 + defp visible_lines(_span, _rows), do: @tail_lines
245 +
230 246 defp stored_tail(job),
231 247 do: job |> Workflows.job_log_tail(@tail_lines) |> Enum.map(&line(&1.body))
232 248
modified test/git_gud_web/live/ci_wall_live/user_test.exs
+14 −0
@@ -132,6 +132,20 @@ defmodule GitGudWeb.CiWallLive.UserTest do
132 132 assert card_ids(lv) == []
133 133 end
134 134
135 + test "a full-height card holds enough log to fill it", %{conn: conn, run: run} do
136 + job = job_fixture(run, "running", 60)
137 + step = Repo.get_by!(WorkflowStep, workflow_job_id: job.id, number: 1)
138 + :ok = Workflows.append_log(step, 0, for(n <- 1..100, do: %{content: "line #{n}"}))
139 +
140 + {:ok, lv, _} = live(conn, ~p"/users/ci/live")
141 +
142 + assert lv
143 + |> render()
144 + |> LazyHTML.from_fragment()
145 + |> LazyHTML.query("#ci-card-#{job.id} .ci-wall-log pre > span")
146 + |> Enum.count() == 100
147 + end
148 +
135 149 test "log lines reach the job's card", %{conn: conn, run: run} do
136 150 job = job_fixture(run, "running", 60)
137 151 {:ok, lv, _} = live(conn, ~p"/users/ci/live")

Parents: 9ce1a6e