Fix artifacts-view scrolling, narrow widths and capture wording

The Artifacts view re-clamped its scroll offset to the selected row on every
render, so the tail of the list - a trailing visit that recorded none (running
or finished) and its capture summary - could never be brought on screen, and
the image marker crowded out artifact names at narrow widths.

- Decouple the scroll offset from the selection: add PgUp/PgDn (and ctrl+u/
  ctrl+d) paging, and make G/end select the last artifact and scroll to the
  tail so a trailing visit stays reachable.
- Share artifactContent/clampArtifactTop/revealArtifactSelection between
  selection and render so both agree on the same page.
- Show the [img] marker only while the width still leaves room for a usable
  name, keeping columns aligned either way.
- Advertise the scroll keys in the artifacts footer help.
- Test the omitted-files capture wording, trailing-visit reachability via
  G/end and page scroll, and narrow-width no-overflow; render both the top and
  the scrolled tail in the env-gated live capture test.
- Update the packaged operations reference for the A artifacts view.
This commit is contained in:
2026-10-17 00:24:42 +01:00
parent 865993b200
commit 889d811858
5 changed files with 172 additions and 34 deletions
+72 -1
View File
@@ -23,7 +23,7 @@ func artifactsFixtureModel() Model {
Steps: []protocol.RunStep{
{Sequence: 1, Stage: "implementer", Status: "completed", Artifacts: []protocol.StageArtifact{
{Name: "build.log", SizeBytes: 2337, ContentType: "text/plain; charset=utf-8", URL: "/artifacts/169/1/build.log"},
}, ArtifactsSkipped: 1},
}, ArtifactsSkipped: 1, ArtifactsTruncated: 2},
{Sequence: 2, Stage: "ui_reviewer", Status: "completed", Artifacts: []protocol.StageArtifact{
{Name: "01-pill.png", SizeBytes: 80544, ContentType: "image/png", URL: "/artifacts/169/2/01-pill.png"},
{Name: "morph.mp4", SizeBytes: 645782, ContentType: "video/mp4", URL: "/artifacts/169/2/morph.mp4"},
@@ -72,6 +72,7 @@ func TestArtifactsViewGroupsMarkersAndWording(t *testing.T) {
"reviewer · visit 1",
"Artifacts · 1 recorded · partial capture",
"1 files excluded from artifact capture.",
"2 files omitted by artifact capture limits.",
"Artifacts · 2 recorded",
"Artifacts · not recorded for this visit",
"Artifacts · capture pending",
@@ -271,4 +272,74 @@ func TestArtifactsViewRenderedInRunDetail(t *testing.T) {
if !strings.Contains(m.activeFooter(), "y copy URL") {
t.Fatalf("footer does not advertise the artifact controls: %q", m.activeFooter())
}
if !strings.Contains(m.activeFooter(), "PgUp/PgDn scroll") {
t.Fatalf("footer does not advertise the scroll keys: %q", m.activeFooter())
}
}
// artifactsTrailingFixture is a run whose last visit is still running and
// recorded no artifacts, so its summary sits after every artifact row.
func artifactsTrailingFixture() Model {
m := New(context.Background(), "ws://127.0.0.1:8080/connect")
m.width, m.height = 80, 14
m.runOpen = true
m.keys.runs = true
m.runDetailFocus = true
m.requestedRunID = 7
var steps []protocol.RunStep
for i := 0; i < 12; i++ {
name := fmt.Sprintf("shot-%02d.png", i)
steps = append(steps, protocol.RunStep{Sequence: i + 1, Stage: "ui_reviewer", Status: "completed",
Artifacts: []protocol.StageArtifact{{Name: name, SizeBytes: 1024, ContentType: "image/png", URL: "/artifacts/7/" + name}}})
}
steps = append(steps, protocol.RunStep{Sequence: 13, Stage: "reviewer", Status: "running"})
m.runDetail = &protocol.RunDetail{RunSummary: protocol.RunSummary{ID: 7}, Steps: steps}
m.artifactsOpen = true
return m
}
func TestArtifactsViewEndRevealsTrailingVisit(t *testing.T) {
m := artifactsTrailingFixture()
if top := ansi.Strip(m.artifactsView(m.artifactsViewHeight())); strings.Contains(top, "capture pending") {
t.Fatalf("trailing running visit visible before scrolling:\n%s", top)
}
m = artifactKey(m, 'G')
view := ansi.Strip(m.View())
for _, want := range []string{"reviewer · visit 1", "Artifacts · capture pending"} {
if !strings.Contains(view, want) {
t.Fatalf("end did not reveal the trailing running visit (%q missing):\n%s", want, view)
}
}
if m.artifactIndex != 11 {
t.Fatalf("end did not keep the last artifact selected: %d", m.artifactIndex)
}
}
func TestArtifactsViewPageScrollRevealsTrailingVisit(t *testing.T) {
m := artifactsTrailingFixture()
for i := 0; i < 100; i++ {
before := m.artifactTop
updated, _ := m.Update(tea.KeyMsg{Type: tea.KeyCtrlD})
m = updated.(Model)
if m.artifactTop == before {
break
}
}
if view := ansi.Strip(m.View()); !strings.Contains(view, "capture pending") {
t.Fatalf("page scroll did not reveal the trailing running visit:\n%s", view)
}
}
func TestArtifactsViewNarrowKeepsNames(t *testing.T) {
m := artifactsFixtureModel()
m.width = 12
view := ansi.Strip(m.artifactsView(24))
if !strings.Contains(view, "build") {
t.Fatalf("narrow view dropped the artifact name:\n%s", view)
}
for _, line := range strings.Split(view, "\n") {
if got := ansi.StringWidth(line); got > m.width {
t.Fatalf("narrow view overflowed: line width %d: %q", got, line)
}
}
}