Skip to content

feat: global fold/unfold — Z to collapse or expand all repositories at once#70

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

feat: global fold/unfold — Z to collapse or expand all repositories at once#70
shouze merged 2 commits intofeat/tui-navigation-result-managementfrom
feat/tui-global-fold-unfold

Conversation

@shouze
Copy link
Contributor

@shouze shouze commented Mar 1, 2026

Context

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

Root cause / motivation

The TUI only allows folding/unfolding one repo at a time ( / ). With many repositories in the result set, collapsing everything to get a quick overview required pressing dozens of times.

What changed

File Change
src/tui.ts Z keypress: fold all repos if any is unfolded; unfold all if all are folded. Clamps cursor + scrollOffset after bulk fold.
src/render.ts renderHelpOverlay: new line Z fold / unfold all repos. Status bar hint: Z fold-all.
src/render.test.ts 2 new tests: overlay contains Z + fold / unfold all repos; status bar contains Z fold-all.
docs/reference/keyboard-shortcuts.md New row in the Navigation table.

How to test manually

bun github-code-search.ts query --org <your-org> <some-query>
# In the TUI: press Z → all repos collapse
# Press Z again → all repos expand
# Press ? → help overlay shows the Z entry

Validation

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

Closes #67

- Z folds all repos if any is unfolded; unfolds all when all are folded
- Clamps cursor and scrollOffset after bulk fold to keep view consistent
- renderHelpOverlay: adds Z line next to ← / → fold bindings
- Status bar hint line: adds 'Z fold-all' entry
- Tests: help overlay contains 'Z' + 'fold / unfold all repos',
  renderGroups status bar contains 'Z fold-all'
- docs/reference/keyboard-shortcuts.md: documents the new shortcut
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 a global fold/unfold shortcut to the interactive TUI so users can collapse/expand all repositories at once, improving navigation when many repos are present.

Changes:

  • Add Z key handling in the TUI to fold all repos if any are unfolded, otherwise unfold all.
  • Update TUI help overlay + status bar hints to document the new shortcut.
  • Add tests and update the keyboard shortcuts reference docs.

Reviewed changes

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

File Description
src/tui.ts Implements Z global fold/unfold behavior and cursor/scroll clamping after bulk fold.
src/render.ts Documents Z in the help overlay and status bar hint line.
src/render.test.ts Adds regression tests asserting Z appears in help overlay and status bar hints.
docs/reference/keyboard-shortcuts.md Documents Z in the Navigation shortcuts table.

- tui.ts: when Z folds all repos from an extract row, preserve cursor
  context by finding the repo header row in newRows rather than doing
  a blind numeric clamp — avoids landing on a different repository
- keyboard-shortcuts.md: remove incorrect 'must be typed in lowercase'
  claim; note that some bindings (Z, G) require uppercase
@shouze shouze merged commit d240966 into feat/tui-navigation-result-management Mar 1, 2026
2 checks passed
@shouze shouze deleted the feat/tui-global-fold-unfold branch March 1, 2026 23:10
@shouze
Copy link
Contributor Author

shouze commented Mar 1, 2026

Addressed in commit 9cf3ba2:

Cursor preservation (lines 398-401): implemented the exact approach suggested — when Z folds all repos from a repo or extract row, the cursor is now mapped to that row's repo header in newRows (via findIndex r.type === "repo" && r.repoIndex === row.repoIndex), with a fallback to numeric clamp if the header is somehow not found.

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

Closes #67 reference: confirmed correct — #67 is the "global fold/unfold" issue, which is precisely what this PR implements.

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