Skip to content

feat(tui): add windowed, keyboard-navigable SelectList component#1074

Merged
Soner (shyim) merged 1 commit into
nextfrom
feat/tui-select-list-component
May 29, 2026
Merged

feat(tui): add windowed, keyboard-navigable SelectList component#1074
Soner (shyim) merged 1 commit into
nextfrom
feat/tui-select-list-component

Conversation

@shyim
Copy link
Copy Markdown
Member

Summary

Adds a reusable single-select list component to internal/tui, so fixed-height option pickers don't have to reimplement cursor and paging logic.

What's included

  • RenderSelectListWindowed — renders at most maxVisible options at once, scrolling to keep the cursor in view, with a Showing X–Y of N footer so the card height stays fixed regardless of option count. RenderSelectList keeps its existing render-all behaviour (delegates with maxVisible = 0).
  • SelectList — a stateful component that owns the cursor and windowing:
    • HandleKey(key) bool handles ↑/↓ (k/j), pgup/pgdown, home/g, end/G with clamping; returns false for keys it doesn't own (enter, esc) so the caller acts on them.
    • Cursor(), Selected() (SelectOption, bool), View().
    • Shortcuts() surfaces the PgUp/PgDn hint only when the list is windowed.

Notes

  • Scoped to the tui package only — no consumer changes. The project upgrade wizard will adopt it in a separate PR.
  • New unit tests cover windowing, paging/clamping, vim keys, non-nav passthrough, Selected, and the conditional paging shortcut.

Testing

  • go build ./internal/tui/...
  • go test ./internal/tui/...
  • golangci-lint run ./internal/tui/... — 0 issues

Adds a reusable single-select list to the tui package:

- RenderSelectListWindowed: renders at most maxVisible options at once,
  scrolling to keep the cursor in view, with a "Showing X–Y of N" footer so
  the height stays fixed regardless of option count. RenderSelectList keeps
  its existing render-all behaviour.
- SelectList: a stateful component owning the cursor and windowing. It
  handles up/down (k/j), pgup/pgdown, home/g and end/G with clamping via
  HandleKey, exposes Cursor/Selected/View, and Shortcuts that surface the
  PgUp/PgDn hint only when the list is windowed.

Lets callers drop in a fixed-height option picker without reimplementing
cursor and paging logic.
@shyim Soner (shyim) merged commit 71dfbbb into next May 29, 2026
2 checks passed
@shyim Soner (shyim) deleted the feat/tui-select-list-component branch May 29, 2026 08:28
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.

1 participant