Skip to content

feat: fast navigation — gg/G (top/bottom) and Page Up/Down#71

Merged
shouze merged 2 commits intofeat/tui-navigation-result-managementfrom
feat/tui-fast-navigation
Mar 1, 2026
Merged

feat: fast navigation — gg/G (top/bottom) and Page Up/Down#71
shouze merged 2 commits intofeat/tui-navigation-result-managementfrom
feat/tui-fast-navigation

Conversation

@shouze
Copy link
Contributor

@shouze shouze commented Mar 1, 2026

Context

Part of the 🗂 TUI — Navigation & result management EPIC #66.
Closes #68.

Root cause / motivation

With hundreds of results, line-by-line navigation (/) is slow. Power users expect Vim-style gg/G jumps and paged scrolling.

What changed

File Change
src/tui.ts gg (two consecutive g): jump to first row. G (Shift+G): jump to last row. Page Up / Ctrl+U: scroll up one page. Page Down / Ctrl+D: scroll down one page. Added KEY_PAGE_UP, KEY_PAGE_DOWN, KEY_CTRL_U, KEY_CTRL_D constants. pendingFirstG boolean tracks the first g keypress and is reset on every other key.
src/render.ts renderHelpOverlay: new gg/G and PgUp/PgDn lines. Status bar hint: gg/G top/bot PgUp/Dn page.
src/render.test.ts 3 new tests: overlay + status bar contain the new shortcut labels.
docs/reference/keyboard-shortcuts.md New rows in the Navigation table.

How to test manually

bun github-code-search.ts query --org <your-org> <some-query>
# In the TUI:
#   gg → jumps to the very first result
#   G  → jumps to the very last result
#   Page Down / Ctrl+D → scrolls down a full page
#   Page Up  / Ctrl+U → scrolls up  a full page
#   ? → help overlay shows gg/G and PgUp/PgDn entries

Validation

bun test        ✅ 404 pass, 0 fail
bun run lint    ✅ 0 warnings, 0 errors
bun run format:check  ✅
bun run knip    ✅

Copilot AI review requested due to automatic review settings March 1, 2026 23:04
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds fast navigation shortcuts to the interactive TUI to make moving through large result sets significantly faster, aligning with the TUI navigation epic.

Changes:

  • Implement gg (top) and G (bottom) cursor jumps in the TUI.
  • Implement Page Up/Down paging via Page Up/Page Down and Vim-style Ctrl+U/Ctrl+D.
  • Update help overlay, status bar hints, tests, and keyboard shortcuts documentation to reflect the new bindings.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.

File Description
src/tui.ts Adds key handling for gg, G, PgUp/PgDn, Ctrl+U/Ctrl+D navigation behaviors.
src/render.ts Updates help overlay and status bar hint line to document new shortcuts.
src/render.test.ts Adds tests asserting help overlay and status bar include the new shortcut labels.
docs/reference/keyboard-shortcuts.md Documents the new navigation shortcuts in the Navigation table.

@shouze shouze self-assigned this Mar 1, 2026
shouze added 2 commits March 2, 2026 00:25
Closes #68

- gg: two consecutive g presses jump to the first row
- G (Shift+G): jumps to the last row
- Page Up / Ctrl+U: scroll up one full page
- Page Down / Ctrl+D: scroll down one full page
- All jumps skip section-header rows and keep cursor visible
- pendingFirstG state tracks the first g keypress; reset on any other key
- renderHelpOverlay: add gg/G and PgUp/PgDn lines
- Status bar hint line: add gg/G top/bot and PgUp/Dn page entries
- Tests: overlay and status bar contain the new shortcut labels
- docs/reference/keyboard-shortcuts.md: documents all new shortcuts
@shouze shouze force-pushed the feat/tui-fast-navigation branch from a8094dc to 54460e9 Compare March 1, 2026 23:26
@shouze
Copy link
Contributor Author

shouze commented Mar 1, 2026

All 4 review points addressed in commit 54460e9:

  1. Multi-character chunk gg — replaced if (key !== "g") pendingFirstG = false with if (!/^g+$/.test(key)) pendingFirstG = false, and changed the g handler condition from key === "g" to /^g+$/.test(key) with pendingFirstG || key.length >= 2. This handles both two separate single-g chunks and a single "gg" chunk from terminals that batch keypresses.

  2. G with empty rows (cursor = -1) — added an early continue guard when rows.length === 0 to avoid setting cursor = rows.length - 1 = -1.

  3. Page Up at position 0 on a section row — added a follow-up block after the existing while (cursor > 0 && ...) loop:

    if (cursor === 0 && rows[0]?.type === "section") {
      while (cursor < rows.length - 1 && rows[cursor]?.type === "section") cursor++;
    }

    This mirrors the gg behavior (skip section headers at the top).

  4. keyboard-shortcuts.md "lowercase" claim — updated to: "Keys are case-sensitive — most use lowercase letters, but a few bindings (such as Z and G) require an uppercase letter."

Also rebased onto the updated feat/tui-navigation-result-management (now includes merged PRs #70 and #72). The status bar hint, help overlay, and tests have been updated to reflect all active shortcuts (Z fold-all, gg/G top/bot, PgUp/Dn page, o open). 406 tests, all green.

@shouze shouze merged commit c672d7d into feat/tui-navigation-result-management Mar 1, 2026
2 checks passed
@shouze shouze deleted the feat/tui-fast-navigation branch March 1, 2026 23: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.

2 participants