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:
+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 {
|
||||
|
||||
Reference in New Issue
Block a user