Click on fold arrow (▸/▾) or checkbox (✓) to toggle in TUI - #173
Merged
Conversation
shouze
added a commit
that referenced
this pull request
Aug 23, 2026
Issue: When clicking on any row in the TUI, getting 'Cannot access rows before initialization' error causing immediate exit with code 1. Root cause: rows was declared as a local variable inside redraw(), but hitTestClick tried to access it in the event loop where it didn't exist. Fix: Declare rows as a persistent variable outside redraw() and update it on each redraw() call. This makes rows available throughout the event loop. Also fixed normalizeScrollOffset calls for wheel scroll to use correct signature: normalizeScrollOffset(scrollOffset, rows, groups, viewportHeight). Closes #173 (partial - fixes the crash, functionality preserved)
shouze
marked this pull request as ready for review
August 23, 2026 18:25
Contributor
There was a problem hiding this comment.
Pull request overview
This PR aims to add click-based interactions to the interactive TUI by hit-testing mouse clicks and dispatching fold/select/navigate actions, aligning mouse behavior with existing keyboard shortcuts.
Changes:
- Added a new hit-testing module to map mouse
(x, y)coordinates to row-level actions (fold/select/navigate). - Wired mouse click handling into the TUI event loop to toggle fold/selection or move the cursor based on click location.
- Added unit tests for the new hit-testing logic.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 6 comments.
| File | Description |
|---|---|
| src/tui.ts | Adds mouse-event handling and dispatches fold/select/navigate actions from click targets. |
| src/render/mouse-hit.ts | Introduces pure hit-testing to map clicks to a Row and an action type. |
| src/render/mouse-hit.test.ts | Adds unit tests covering basic hit-testing behavior. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Implement click-to-toggle functionality for interactive TUI (#170): - Add src/render/mouse-hit.ts with hit-testing logic - Maps clicked (x, y) coordinates to logical Row and action type - Supports three actions: fold (repo arrow), select (checkbox), navigate (move cursor) - Wire hit-testing into tui.ts mouse event handler - Execute fold toggle, select toggle, or cursor movement on click - 9 unit tests with 100% coverage for hitTestClick - All validation checks pass
shouze
added a commit
that referenced
this pull request
Aug 23, 2026
Issue: When clicking on any row in the TUI, getting 'Cannot access rows before initialization' error causing immediate exit with code 1. Root cause: rows was declared as a local variable inside redraw(), but hitTestClick tried to access it in the event loop where it didn't exist. Fix: Declare rows as a persistent variable outside redraw() and update it on each redraw() call. This makes rows available throughout the event loop. Also fixed normalizeScrollOffset calls for wheel scroll to use correct signature: normalizeScrollOffset(scrollOffset, rows, groups, viewportHeight). Closes #173 (partial - fixes the crash, functionality preserved)
shouze
force-pushed
the
feat/mouse-click-toggle
branch
from
August 23, 2026 18:57
cacd989 to
6a5ac1e
Compare
|
Coverage after merging feat/mouse-click-toggle into feat/mouse-tracking-foundation will be
Coverage Report
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
1 similar comment
|
Coverage after merging feat/mouse-click-toggle into feat/mouse-tracking-foundation will be
Coverage Report
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
shouze
added a commit
that referenced
this pull request
Aug 23, 2026
Issue: When clicking on any row in the TUI, getting 'Cannot access rows before initialization' error causing immediate exit with code 1. Root cause: rows was declared as a local variable inside redraw(), but hitTestClick tried to access it in the event loop where it didn't exist. Fix: Declare rows as a persistent variable outside redraw() and update it on each redraw() call. This makes rows available throughout the event loop. Also fixed normalizeScrollOffset calls for wheel scroll to use correct signature: normalizeScrollOffset(scrollOffset, rows, groups, viewportHeight). Closes #173 (partial - fixes the crash, functionality preserved)
|
Coverage after merging feat/mouse-click-toggle into feat/mouse-tracking-foundation will be
Coverage Report
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Enables click-based interaction in the interactive TUI. Users can now click on fold arrows (▸/▾) to expand/collapse repository groups, and click on checkboxes (✓) to select/deselect repositories or extracts. Clicking elsewhere on a row moves the cursor.
Changes
src/render/mouse-hit.tswith hit-testing logicsrc/render/mouse-hit.test.tswith 9 unit tests (100% coverage)src/tui.tsto dispatch fold/select/navigate actions based on click locationgroup.foldedwhen clicking the arrow columngroup.repoSelectedorgroup.extractSelected[ei]when clicking checkbox columnrowsas a persistent variable in the event loop (was previously local to redraw), fixing "Cannot access 'rows' before initialization" crashHow did you verify your code works?
Closes #170