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:
@@ -135,9 +135,17 @@ runs natively through `./install` by default (`scripts/setup-native.py`, with
|
||||
`--native` equivalent); the Docker server + ntfy installation is explicit with
|
||||
`./install --docker`.
|
||||
|
||||
In the TUI, Home advertises `/` search and `:` commands. Run Tab switches only
|
||||
In the TUI, Home advertises `/` omni search and `:` commands. Home `/` opens one
|
||||
popup over pipelines, versions, runs, steps/visits, artifact names and stage
|
||||
input/output/evidence text; each row shows a short type badge and a text match
|
||||
shows a bracketed snippet, and a bare status word or date selects runs. The same
|
||||
query is available as `pipelines search QUERY [--type KIND]`, where `--type`
|
||||
narrows the kind. Run Tab switches only
|
||||
Details ↔ Graph. `n/p` select recorded visits, including repeated stages; `d`
|
||||
focuses/toggles file changes, `a` selects the active/latest retained
|
||||
focuses/toggles file changes, `A` opens the run's grouped artifacts view (name,
|
||||
content type, size and URL per entry, `PgUp`/`PgDn` scroll so a trailing visit
|
||||
that recorded none stays reachable, `Enter`/`o` to open the selected URL and
|
||||
`y` to copy it), `a` selects the active/latest retained
|
||||
configured-harness agent session's bounded, redacted tool evidence, `D`/`:debug`
|
||||
opens fresh investigation, and `P` opens the pinned pipeline version. `:quit`
|
||||
exits; `q` does not. Results are retained reports, not independently confirmed
|
||||
@@ -184,7 +192,10 @@ The instruction is general: save images, screenshots, reports and logs there.
|
||||
|
||||
After the visit the server makes one bounded inventory and records each file's
|
||||
name, size, content type (extension, sniff fallback) and a relative url; these
|
||||
appear under each step's `artifacts` in `inspect RUN_ID --json` and the TUI.
|
||||
appear under each step's `artifacts` in `inspect RUN_ID --json` and the TUI's
|
||||
`A` artifacts view, which groups them by stage and visit, marks images and shows
|
||||
the recorded count, capture-pending/not-recorded wording and partial-capture
|
||||
notes.
|
||||
`GET /artifacts/<run>/<step>/<name>` serves the bytes (correct Content-Type and
|
||||
Content-Length, HEAD, and Range/206/416 via `http.ServeContent`), refusing
|
||||
traversal, absolute paths, symlink escapes and unknown runs/steps.
|
||||
|
||||
+69
-24
@@ -162,11 +162,17 @@ func artifactRowText(artifact protocol.StageArtifact, widths artifactWidths, wid
|
||||
if selected {
|
||||
prefix = "› "
|
||||
}
|
||||
marker := strings.Repeat(" ", artifactMarkerWidth)
|
||||
if isImageContentType(artifact.ContentType) {
|
||||
marker = "[img]"
|
||||
// Keep the image marker only while it still leaves room for a usable name:
|
||||
// at very narrow widths the name is more useful than the marker, and the
|
||||
// decision depends only on width, so every row's columns stay aligned
|
||||
// whether or not the marker is shown.
|
||||
if width >= artifactCursorWidth+artifactMarkerWidth+1+artifactMinName {
|
||||
if isImageContentType(artifact.ContentType) {
|
||||
prefix += "[img] "
|
||||
} else {
|
||||
prefix += strings.Repeat(" ", artifactMarkerWidth) + " "
|
||||
}
|
||||
}
|
||||
prefix += marker + " "
|
||||
available := width - lipgloss.Width(prefix)
|
||||
if available <= 0 {
|
||||
return ansi.Truncate(prefix, max(1, width), "")
|
||||
@@ -253,26 +259,56 @@ func (m *Model) selectArtifactByName(name string) {
|
||||
m.clampArtifactScroll()
|
||||
}
|
||||
|
||||
// clampArtifactScroll keeps the selected artifact row inside the visible page
|
||||
// after a selection move, using the same page size as the renderer.
|
||||
// artifactContent renders the grouped artifact lines and the line index of each
|
||||
// flat artifact ref for the model's current width and selection, so selection
|
||||
// and the scroll offset always agree on the same content.
|
||||
func (m Model) artifactContent() ([]string, []int) {
|
||||
visits, _ := m.artifactViewVisits()
|
||||
widths := artifactWidthsFor(visits)
|
||||
return artifactViewContent(visits, widths, max(1, m.width-4), m.artifactIndex)
|
||||
}
|
||||
|
||||
// clampArtifactTop bounds the scroll offset to the range the current page can
|
||||
// actually show.
|
||||
func (m *Model) clampArtifactTop() {
|
||||
lines, _ := m.artifactContent()
|
||||
m.artifactTop = max(0, min(m.artifactTop, max(0, len(lines)-m.artifactsPageSize())))
|
||||
}
|
||||
|
||||
// scrollArtifactBy moves the scroll offset by delta and clamps it, independent
|
||||
// of the selection, so the offset can reach lines past the last artifact (a
|
||||
// trailing visit's header and capture summary).
|
||||
func (m *Model) scrollArtifactBy(delta int) {
|
||||
m.artifactTop += delta
|
||||
m.clampArtifactTop()
|
||||
}
|
||||
|
||||
// scrollArtifactToEnd puts the window's last line on screen, exposing any
|
||||
// trailing visits that recorded no artifacts.
|
||||
func (m *Model) scrollArtifactToEnd() {
|
||||
lines, _ := m.artifactContent()
|
||||
m.artifactTop = max(0, len(lines)-m.artifactsPageSize())
|
||||
}
|
||||
|
||||
// revealArtifactSelection nudges the scroll offset by the minimum needed to put
|
||||
// the selected artifact row on screen; it never scrolls past the end.
|
||||
func (m *Model) revealArtifactSelection() {
|
||||
lines, refLines := m.artifactContent()
|
||||
if m.artifactIndex < len(refLines) {
|
||||
m.artifactTop = artifactScrollTop(m.artifactTop, refLines[m.artifactIndex], m.artifactsPageSize(), len(lines))
|
||||
}
|
||||
}
|
||||
|
||||
// clampArtifactScroll keeps the selection valid and its row on screen after a
|
||||
// selection move.
|
||||
func (m *Model) clampArtifactScroll() {
|
||||
if m.runDetail == nil {
|
||||
m.artifactIndex, m.artifactTop = 0, 0
|
||||
return
|
||||
}
|
||||
visits, refs := m.artifactViewVisits()
|
||||
_, refs := m.artifactViewVisits()
|
||||
m.artifactIndex = max(0, min(m.artifactIndex, max(0, len(refs)-1)))
|
||||
if len(refs) == 0 {
|
||||
m.artifactTop = 0
|
||||
return
|
||||
}
|
||||
widths := artifactWidthsFor(visits)
|
||||
inner := max(1, m.width-4)
|
||||
lines, refLines := artifactViewContent(visits, widths, inner, m.artifactIndex)
|
||||
if m.artifactIndex >= len(refLines) {
|
||||
return
|
||||
}
|
||||
m.artifactTop = artifactScrollTop(m.artifactTop, refLines[m.artifactIndex], m.artifactsPageSize(), len(lines))
|
||||
m.revealArtifactSelection()
|
||||
}
|
||||
|
||||
func (m Model) updateArtifacts(msg tea.KeyMsg) (tea.Model, tea.Cmd) {
|
||||
@@ -289,7 +325,18 @@ func (m Model) updateArtifacts(msg tea.KeyMsg) (tea.Model, tea.Cmd) {
|
||||
case "g", "home":
|
||||
m.artifactIndex = 0
|
||||
case "G", "end":
|
||||
// Select the last artifact and show the tail of the list, so a trailing
|
||||
// visit that recorded none (running or finished) is on screen.
|
||||
m.artifactIndex = max(0, count-1)
|
||||
m.clampArtifactScroll()
|
||||
m.scrollArtifactToEnd()
|
||||
return m, nil
|
||||
case "pgdown", "ctrl+d":
|
||||
m.scrollArtifactBy(max(1, m.artifactsPageSize()))
|
||||
return m, nil
|
||||
case "pgup", "ctrl+u":
|
||||
m.scrollArtifactBy(-max(1, m.artifactsPageSize()))
|
||||
return m, nil
|
||||
case "enter", "o":
|
||||
if count == 0 {
|
||||
return m, nil
|
||||
@@ -316,14 +363,12 @@ func (m Model) artifactsView(height int) string {
|
||||
widths := artifactWidthsFor(visits)
|
||||
selected := max(0, min(m.artifactIndex, max(0, len(refs)-1)))
|
||||
inner := max(1, m.width-4)
|
||||
lines, refLines := artifactViewContent(visits, widths, inner, selected)
|
||||
lines, _ := artifactViewContent(visits, widths, inner, selected)
|
||||
page := max(0, height-4)
|
||||
// The offset is authoritative and free: selection moves keep the selected
|
||||
// row on screen, while page scroll and end can move past the last artifact
|
||||
// to a trailing visit's header and capture summary.
|
||||
top := max(0, min(m.artifactTop, max(0, len(lines)-page)))
|
||||
if selected < len(refLines) {
|
||||
// Keep the selected row on screen even if a slightly different page
|
||||
// size left the stored offset behind.
|
||||
top = artifactScrollTop(top, refLines[selected], page, len(lines))
|
||||
}
|
||||
body := lines[top:min(len(lines), top+page)]
|
||||
title := fmt.Sprintf("Artifacts · run #%d", m.runDetail.ID)
|
||||
if len(visits) > 0 {
|
||||
|
||||
@@ -23,7 +23,9 @@ func TestLiveArtifactsFromCapture(t *testing.T) {
|
||||
t.Skip("set PIPELINES_ARTIFACT_CAPTURES to comma-separated `pipelines inspect RUN_ID --json` files")
|
||||
}
|
||||
m := New(context.Background(), "ws://127.0.0.1:8080/connect")
|
||||
m.width, m.height = 120, 60
|
||||
// Height chosen so artifactsViewHeight() is 50, keeping the view's page size
|
||||
// and the model's scroll page size identical (as they are in the app).
|
||||
m.width, m.height = 120, 54
|
||||
var rendered strings.Builder
|
||||
for _, path := range strings.Split(list, ",") {
|
||||
path = strings.TrimSpace(path)
|
||||
@@ -39,9 +41,18 @@ func TestLiveArtifactsFromCapture(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
m.runDetail = &detail
|
||||
view := ansi.Strip(m.artifactsView(50))
|
||||
t.Logf("capture %s (run #%d executing=%t):\n%s", path, detail.ID, detail.Executing, view)
|
||||
rendered.WriteString(view)
|
||||
m.artifactsOpen = true
|
||||
m.artifactIndex, m.artifactTop = 0, 0
|
||||
top := ansi.Strip(m.artifactsView(m.artifactsViewHeight()))
|
||||
t.Logf("capture %s (run #%d executing=%t) top:\n%s", path, detail.ID, detail.Executing, top)
|
||||
rendered.WriteString(top)
|
||||
// Scroll to the tail so a trailing running visit's capture summary is
|
||||
// rendered regardless of how many artifacts precede it; a fixed top
|
||||
// page used to clip it once a run accumulated enough artifacts.
|
||||
m = artifactKey(m, 'G')
|
||||
tail := ansi.Strip(m.artifactsView(m.artifactsViewHeight()))
|
||||
t.Logf("capture %s (run #%d executing=%t) tail:\n%s", path, detail.ID, detail.Executing, tail)
|
||||
rendered.WriteString(tail)
|
||||
}
|
||||
text := rendered.String()
|
||||
for _, want := range []string{"[img]", "partial capture", "capture pending", "not recorded for this visit", "image/png", "KiB"} {
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ func (m Model) activeFooter() string {
|
||||
case m.decisionOpen:
|
||||
text = "↑/↓ choose · Tab feedback · Enter decide · Esc cancel"
|
||||
case m.artifactsOpen:
|
||||
text = "j/k select · Enter open · y copy URL · Esc back"
|
||||
text = "j/k select · PgUp/PgDn scroll · Enter open · y copy URL · Esc back"
|
||||
case m.actionConfirm != nil || m.mutationCommand != nil:
|
||||
text = "y confirm · n/Esc cancel · j/k read"
|
||||
case m.draftDeletingPath != "":
|
||||
@@ -66,7 +66,7 @@ func (m Model) activeFooter() string {
|
||||
case m.decisionOpen:
|
||||
text = "Esc cancel · Enter decide · ↑↓ select"
|
||||
case m.artifactsOpen:
|
||||
text = "Esc back · Enter open · y copy"
|
||||
text = "Esc back · Enter open · y copy · PgUp/PgDn"
|
||||
case m.actionConfirm != nil || m.mutationCommand != nil:
|
||||
text = "Esc cancel · y confirm · j/k read"
|
||||
case m.draftDeletingPath != "":
|
||||
|
||||
Reference in New Issue
Block a user