feat(tui-go): page-scroll the diff/preview/command fullscreen viewer

The ^x fullscreen viewer (OverlayDiff) backs every tool preview — split diff
for write/edit, the command card for shell, plain lines otherwise, plus any
transcript tool-output — but only scrolled one line per keypress, making a
long diff tedious to read.

- Add paging to the viewer, matching the OUTPUT free-scroll contract: ↑↓/jk
  by line, PgUp/PgDn by a full body, ^u/^d by half, g/G to the ends. New
  scrollDiff() clamps to [0, diffMaxScroll] so paging past either edge lands
  exactly (no dead presses). diff_scroll_test.go (2): clamp + no-op-when-fits.
- Update the modal hint to advertise paging (line / page / ends / close) and
  add a "diff / preview viewer (^x)" section to the ? help overlay. Also note
  the T3+ confirm-again behaviour in the approval-band help.

Approval ergonomics re-audit (BACKLOG §E): the spec'd band still holds —
single-key y/n/e for T0-T2, mandatory second-key confirm for T3+ (HighTier),
navigable queue with an i/n indicator, docked band never modal-stacked; all
covered green by approval_test.go. The scroll granularity above was the only
gap, now closed.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-06-22 09:09:54 +00:00
parent 08b5c63a0f
commit db27b3436b
3 changed files with 88 additions and 9 deletions
+18 -6
View File
@@ -630,15 +630,27 @@ func (m Model) handleOverlayKey(k tea.KeyMsg) (tea.Model, tea.Cmd) {
case OverlayPalette:
return m.handlePaletteKey(k)
case OverlayDiff:
// A long diff/preview is unreadable one line at a time, so the fullscreen
// viewer pages like the OUTPUT transcript: ↑↓/jk by line, PgUp/PgDn by a
// full body, ^u/^d by half, g/G to the ends. All clamp to the diff bounds.
page := m.diffBodyHeight()
switch {
case k.Type == tea.KeyUp || runeIs(k, "k"):
if m.diffScrollOffset > 0 {
m.diffScrollOffset--
}
m.scrollDiff(-1)
case k.Type == tea.KeyDown || runeIs(k, "j"):
if m.diffScrollOffset < m.diffMaxScroll() {
m.diffScrollOffset++
}
m.scrollDiff(1)
case k.Type == tea.KeyPgUp:
m.scrollDiff(-page)
case k.Type == tea.KeyPgDown:
m.scrollDiff(page)
case k.Type == tea.KeyCtrlU:
m.scrollDiff(-page / 2)
case k.Type == tea.KeyCtrlD:
m.scrollDiff(page / 2)
case runeIs(k, "g"):
m.diffScrollOffset = 0
case runeIs(k, "G"):
m.diffScrollOffset = m.diffMaxScroll()
case k.Type == tea.KeyCtrlX:
m.overlay = OverlayNone
}