Skip to content

Click on fold arrow (▸/▾) or checkbox (✓) to toggle it in the TUI #170

Description

@shouze

Context

Once mouse events are parsed (foundation issue), clicks need to be mapped to a specific row and column so the right action can be triggered — matching what the user currently does with keyboard shortcuts for fold and select.

Part of #166. Depends on the mouse tracking foundation sub-issue.

Solution

  • Add a pure hit-testing function that, given the current Row[] (from buildRows()), scrollOffset, and a clicked (x, y), returns which Row was clicked and the local column offset — reusing the same cumulative-height logic as rowTerminalLines() (src/render/rows.ts) and renderGroups() (src/render.ts).
  • Column-based dispatch, matching current fixed column offsets in src/render.ts:
    • Click on the ▸/▾ arrow column (repo rows only) → toggle group.folded.
    • Click on the ✓ checkbox column (repo or extract rows) → toggle repoSelected / extractSelected[ei].
    • Click anywhere else on a row → move cursor to that row (no toggle).
  • Wire the resulting action into the existing state-mutation + redraw() flow in tui.ts, reusing the same code paths as the corresponding keyboard shortcuts (no duplicated toggle logic).

Acceptance Criteria

  • Clicking the arrow on a repo row folds/unfolds it, identical in effect to the existing keyboard shortcut.
  • Clicking the checkbox on a repo or extract row toggles selection, identical in effect to the existing keyboard shortcut.
  • Clicking elsewhere on a row moves the cursor there without changing fold/selection state.
  • Works correctly with an active scrollOffset (i.e., clicking a visible row after scrolling down targets the correct logical row, not an offset one).
  • Works correctly with section rows and team-pick mode rows without crashing (clicks on non-actionable rows are simply no-ops or cursor moves).

Definition of Done

  • bun test passes, including a new companion *.test.ts for the hit-testing function covering: click on an arrow, click on a checkbox, click elsewhere, click with non-zero scrollOffset, click below the last row, click on a section row.
  • bun run lint passes.
  • bun run format:check passes.
  • bun run knip passes (no unused exports/imports).
  • bun run build.ts compiles successfully.
  • Documentation updated: docs/reference/keyboard-shortcuts.md updated with a short "mouse" note.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions