Skip to content

fix: viewport scrolling in bumpy add prompt#99

Merged
theoephraim merged 1 commit into
mainfrom
fix/bumpy-add-scrolling-viewport
Jun 3, 2026
Merged

fix: viewport scrolling in bumpy add prompt#99
theoephraim merged 1 commit into
mainfrom
fix/bumpy-add-scrolling-viewport

Conversation

@theoephraim
Copy link
Copy Markdown
Member

Summary

Fix #96bumpy add snapped focus to the bottom when navigating a package list taller than the terminal.

The interactive bump-select prompt rendered every package at once and used \x1B[NA (cursor up) to clear the previous frame before each re-render. Once the rendered output exceeded terminal height, earlier lines had scrolled off-screen and the cursor-up no longer reached the original anchor — so subsequent frames drew at the wrong position.

Approach — windowed viewport rendering:

  • Build a flat row structure (Changed header → changed items → separator → Unchanged header → unchanged items) with a displayIdx → rowIdx map
  • Compute window size from stdout.rows minus fixed chrome (header + footer)
  • Track a scroll offset that adjusts to keep the focused row inside the window
  • Show ▲ N more / ▼ N more indicators when content is hidden above/below
  • Pin a sticky section header to the top of the window once the natural Changed or Unchanged header scrolls out of view, so the user always knows which section they're in
  • Re-render on SIGWINCH so resizing reflows the viewport

Total rendered output is now bounded by terminal height, so the cursor-up redraw always works.

Test plan

  • bun run check (lint + format + typecheck)
  • bun run test (258 tests passing)
  • Manual: tested locally in a 30-package pnpm workspace with 5 packages marked changed
    • Cursor stays visible when navigating past viewport edges
    • Changing levels with ←/→ from a scrolled position does not snap focus to terminal bottom
    • ▲ N more / ▼ N more indicators appear correctly
    • Sticky Unchanged header pins once the natural header scrolls off
    • Resizing the terminal mid-prompt reflows the viewport

The interactive bump-select prompt rendered all packages at once and
used cursor-up to clear the previous frame on each keypress. When the
list exceeded terminal height, lines scrolled off-screen and the
cursor-up lost its anchor — causing the focus to snap to the bottom
when navigating or interacting.

Render a viewport that fits within the terminal: window the row list,
adjust scroll to keep the focused row visible, show ▲/▼ "N more"
indicators, and pin a sticky section header once the natural Changed
or Unchanged header scrolls out of view. Re-renders on SIGWINCH.

Closes #96.
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 3, 2026

bumpy-frog

The changes in this PR will be included in the next version bump.

patch Patch releases

  • @varlock/bumpy 1.13.0 → 1.13.1

Bump files in this PR

Click here if you want to add another bump file to this PR


This comment is maintained by bumpy.

@theoephraim theoephraim merged commit b7bb4fc into main Jun 3, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Scrolling with a large amount of packages in the terminal is a bit iffy

1 participant