Skip to content

Add arrow-based team re-pick mode; remove --dispatch option#124

Merged
shouze merged 6 commits intomainfrom
feat/team-dispatch
Mar 31, 2026
Merged

Add arrow-based team re-pick mode; remove --dispatch option#124
shouze merged 6 commits intomainfrom
feat/team-dispatch

Conversation

@shouze
Copy link
Copy Markdown
Contributor

@shouze shouze commented Mar 31, 2026

Closes #86; closes #87

Design note: Issues #86 and #87 originally described a per-repo/extract dispatch model (--dispatch flag, numeric 1/2/… key assignment). After implementation experience, the whole-section re-pick model (←/→ + Enter) turned out to be simpler and sufficient for the ownership-resolution use-case. This PR intentionally closes both issues via a different design — the original --dispatch approach is not implemented.

Summary

This PR introduces an improved team re-pick UX in the TUI and removes the --dispatch CLI option entirely.

What changed

Re-pick mode redesign (src/tui.ts, src/render.ts)

  • Pressing t on a picked repo (marked ) now opens re-pick mode, consistent with pick mode UX.
  • Navigation uses ←/→ to cycle candidate teams, Enter to confirm, 0/u to restore (undo), Esc/t to cancel.
  • The hints bar reuses renderTeamPickHeader (single line, no multi-line fallback needed).

Fix: undo now clears --pick-team from replay command (src/tui.ts)

  • Previously, undoing a pick via 0 / u left confirmedPicks[combinedLabel] intact, so the replay command kept emitting --pick-team for the restored section.
  • Fix: the undo handler now reads pickedFrom before calling undoPickedRepo, then deletes the corresponding confirmedPicks entry.

Remove --dispatch option (src/group.ts, src/types.ts, src/output.ts, github-code-search.ts, docs/reference/cli-options.md)

  • Deleted applyDispatch, normaliseDispatchRepo, dispatchedTeam, extractDispatchedTeam and dispatch block from the replay command.
  • Replaced with moveRepoToSection(groups, repoFullName, targetTeam) — a simpler pure helper used internally by the TUI re-pick confirm handler.

Tests (src/group.test.ts)

  • Replaced applyDispatch test suite with moveRepoToSection tests.
  • Removed strips dispatchedTeam when undoing test (field no longer exists).

Documentation (docs/reference/keyboard-shortcuts.md, docs/usage/interactive-mode.md, docs/usage/team-grouping.md)

  • Consistent description of t key behaviour across all three files.
  • Re-pick mode key table updated: / cycle, Enter confirm, 0/u restore entire section, Esc/t exit.

How to test

bun test          # all tests green
bun run lint      # zero errors
bun run knip      # no unused exports

Manual: run with --group-by-team-prefix, navigate to a picked repo (), press t and verify arrow navigation works as expected.

- Re-pick mode (TUI 't' on a picked repo) now uses ←/→ to cycle
  candidate teams and Enter to confirm — consistent with pick mode UX.
  Single-line hints bar reuses renderTeamPickHeader.
- Fix: undoing a pick now clears confirmedPicks so --pick-team is
  correctly removed from the replay command.
- Remove --dispatch CLI option, applyDispatch helper, dispatchedTeam /
  extractDispatchedTeam types, and dispatch block from replay command.
  Repo moves go through the new moveRepoToSection pure helper.
- Add moveRepoToSection to group.ts with companion tests.
- Docs: keyboard-shortcuts.md, interactive-mode.md and team-grouping.md
  updated for consistent 't' key and re-pick mode descriptions.
Copilot AI review requested due to automatic review settings March 31, 2026 15:14
@github-actions
Copy link
Copy Markdown

Coverage after merging feat/team-dispatch into main will be

95.24%

Coverage Report
FileStmtsBranchesFuncsLinesUncovered Lines
src
   aggregate.ts100%100%100%100%
   api-utils.ts93.20%100%93.75%93.13%101–103, 65, 73, 86–87, 91–92
   api.ts94.57%100%100%93.89%319–323, 384, 401, 63–69
   cache.ts94.67%100%100%94.29%139–141, 39
   completions.ts99.42%100%100%99.37%270
   group.ts99.37%100%96.77%100%
   output.ts99.20%100%95%99.56%79
   regex.ts99.26%100%100%99.21%251
   render.ts87.42%100%89.47%87.34%167, 191–196, 198–200, 202–203, 254–255, 276, 463–464, 469, 472–478, 480–483, 485–487, 553–557, 569–570, 575–582, 584–592, 594–595
   upgrade.ts88.38%100%94.44%87.89%128, 131, 133, 153, 167–168, 188–195, 198–204, 209, 214, 250–253
src/render
   filter-match.ts97.44%100%92.31%100%
   filter.ts100%100%100%100%
   highlight.ts96.63%100%90.40%99.31%284–285
   rows.ts97.58%100%100%97.44%168, 54–55
   selection.ts100%100%100%100%
   summary.ts100%100%100%100%
   team-pick.ts100%100%100%100%

@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 31, 2026

🔦 Lighthouse Report

Page ⚡ Perf ♿ A11y 🛡️ BP 🔍 SEO Report
/github-code-search/ 🟢 98 (≥97) 🟢 100 (≥99) 🟢 100 (≥99) 🟢 100 (≥99) 🔗 view
/github-code-search/getting-started/ 🟢 99 (≥97) 🟢 100 (≥99) 🟢 100 (≥99) 🟢 100 (≥99) 🔗 view

Thresholds: Perf ≥ 97 · A11y ≥ 99 · BP ≥ 99 · SEO ≥ 99
commit c57855f · full workflow run

@shouze shouze self-assigned this Mar 31, 2026
@shouze shouze added the enhancement New feature or request label Mar 31, 2026
Copy link
Copy Markdown
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

This PR updates the interactive TUI to support an arrow-key-driven team re-pick mode for previously picked repos, and removes the legacy --dispatch workflow in favor of simpler internal helpers and updated documentation.

Changes:

  • Added a new TUI “re-pick mode” (triggered by t on a picked repo) with ←/→ navigation, Enter confirm, 0/u restore, Esc/t cancel.
  • Introduced pure grouping helpers to support re-pick/undo flows (moveRepoToSection, undoPickedRepo) and added corresponding unit tests.
  • Updated docs to reflect the new t behavior and re-pick bindings across interactive/team-grouping references.

Reviewed changes

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

Show a summary per file
File Description
src/tui.ts Adds re-pick mode state + key handling, and threads mode state into rendering.
src/render.ts Renders the re-pick hints bar (using the existing team pick header rendering) and updates global hints text.
src/group.ts Adds pure helpers for undoing a pick and moving a repo between team sections.
src/group.test.ts Adds unit tests for the new grouping helpers.
docs/usage/team-grouping.md Replaces --dispatch guidance with re-pick/undo pick documentation and examples.
docs/usage/interactive-mode.md Updates shortcut documentation for t to include re-pick behavior on picked repos.
docs/reference/keyboard-shortcuts.md Documents t behavior for team ownership and adds a re-pick mode key table.

@github-actions
Copy link
Copy Markdown

Coverage after merging feat/team-dispatch into main will be

95.72%

Coverage Report
FileStmtsBranchesFuncsLinesUncovered Lines
src
   aggregate.ts100%100%100%100%
   api-utils.ts93.20%100%93.75%93.13%101–103, 65, 73, 86–87, 91–92
   api.ts94.57%100%100%93.89%319–323, 384, 401, 63–69
   cache.ts94.67%100%100%94.29%139–141, 39
   completions.ts99.42%100%100%99.37%270
   group.ts99.37%100%96.77%100%
   output.ts99.20%100%95%99.56%79
   regex.ts99.26%100%100%99.21%251
   render.ts89.94%100%89.47%89.96%167, 191–196, 198–200, 202–203, 254–255, 276, 463–464, 485–487, 553–557, 569–570, 575–582, 584–592, 594–595
   upgrade.ts88.38%100%94.44%87.89%128, 131, 133, 153, 167–168, 188–195, 198–204, 209, 214, 250–253
src/render
   filter-match.ts97.44%100%92.31%100%
   filter.ts100%100%100%100%
   highlight.ts96.63%100%90.40%99.31%284–285
   rows.ts97.58%100%100%97.44%168, 54–55
   selection.ts100%100%100%100%
   summary.ts100%100%100%100%
   team-pick.ts100%100%100%100%

@github-actions
Copy link
Copy Markdown

Coverage after merging feat/team-dispatch into main will be

95.72%

Coverage Report
FileStmtsBranchesFuncsLinesUncovered Lines
src
   aggregate.ts100%100%100%100%
   api-utils.ts93.20%100%93.75%93.13%101–103, 65, 73, 86–87, 91–92
   api.ts94.57%100%100%93.89%319–323, 384, 401, 63–69
   cache.ts94.67%100%100%94.29%139–141, 39
   completions.ts99.42%100%100%99.37%270
   group.ts99.37%100%96.77%100%
   output.ts99.20%100%95%99.56%79
   regex.ts99.26%100%100%99.21%251
   render.ts89.94%100%89.47%89.96%167, 191–196, 198–200, 202–203, 254–255, 276, 463–464, 485–487, 553–557, 569–570, 575–582, 584–592, 594–595
   upgrade.ts88.38%100%94.44%87.89%128, 131, 133, 153, 167–168, 188–195, 198–204, 209, 214, 250–253
src/render
   filter-match.ts97.44%100%92.31%100%
   filter.ts100%100%100%100%
   highlight.ts96.63%100%90.40%99.31%284–285
   rows.ts97.58%100%100%97.44%168, 54–55
   selection.ts100%100%100%100%
   summary.ts100%100%100%100%
   team-pick.ts100%100%100%100%

Copy link
Copy Markdown
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

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

- render.ts: wrap full re-pick hints line with clipAnsi() so it never
  wraps on extremely narrow terminals (prefix + bar + suffix all clipped)
- group.ts: insertBeforeOther() helper keeps 'other' section last when
  undoPickedRepo or moveRepoToSection must create a new section
- group.ts: add undoSectionPick() — restores ALL repos with matching
  pickedFrom back to the combined section in one operation (inverse of
  applyTeamPick); used by 0/u in re-pick mode
- tui.ts: 0/u now calls undoSectionPick instead of undoPickedRepo, so
  the entire combined section is undone atomically — confirmedPicks stays
  in sync with the restored visual state
- docs: update key table and Undoing a pick section to reflect that 0/u
  undoes the whole section pick, not just one repo
- group.test.ts: new tests for insert-before-other (undoPickedRepo &
  moveRepoToSection) and for undoSectionPick (multi-repo restore,
  insert-before-other, append-to-existing)
@github-actions
Copy link
Copy Markdown

Coverage after merging feat/team-dispatch into main will be

95.77%

Coverage Report
FileStmtsBranchesFuncsLinesUncovered Lines
src
   aggregate.ts100%100%100%100%
   api-utils.ts93.20%100%93.75%93.13%101–103, 65, 73, 86–87, 91–92
   api.ts94.57%100%100%93.89%319–323, 384, 401, 63–69
   cache.ts94.67%100%100%94.29%139–141, 39
   completions.ts99.42%100%100%99.37%270
   group.ts99.50%100%97.44%100%
   output.ts99.20%100%95%99.56%79
   regex.ts99.26%100%100%99.21%251
   render.ts89.94%100%89.47%89.96%167, 191–196, 198–200, 202–203, 254–255, 276, 463–464, 487–489, 555–559, 571–572, 577–584, 586–594, 596–597
   upgrade.ts88.38%100%94.44%87.89%128, 131, 133, 153, 167–168, 188–195, 198–204, 209, 214, 250–253
src/render
   filter-match.ts97.44%100%92.31%100%
   filter.ts100%100%100%100%
   highlight.ts96.63%100%90.40%99.31%284–285
   rows.ts97.58%100%100%97.44%168, 54–55
   selection.ts100%100%100%100%
   summary.ts100%100%100%100%
   team-pick.ts100%100%100%100%

renderTeamPickHeader now uses a sliding window algorithm:
- The focused team is always visible in [ brackets ], regardless of
  how many candidates exist and how narrow the available bar width is.
- Candidates hidden to the left/right of the visible window are indicated
  with '…' ellipsis markers (left and right independently).
- The window expands greedily right then left from the focused item to
  fill as much of maxWidth as possible.
- Previously the function always rendered from candidate 0 and clipped
  at the right; scrolling past the second item left the focused team
  off-screen even though the index was advancing.

Re-pick bar right-alignment:
- The hints block ('0/u restore  ← → move  ↵ confirm  Esc/t cancel')
  is now always anchored at the right terminal edge via padding, instead
  of being attached directly to the bar content (which caused it to drift
  left when the candidate bar was shorter than its allocated width).

New tests:
- renderTeamPickHeader: left ellipsis, both ellipses, focused always
  visible for all indices, window shift, clipped focused, symmetrical fill.
- renderGroups re-pick bar: right-alignment assertion (suffix ends at
  termWidth), suffix fixed position as focusedIndex changes, focused team
  visible for all 8 candidates on a narrow (80-char) terminal.
@shouze shouze force-pushed the feat/team-dispatch branch from 4804e57 to ce6e76a Compare March 31, 2026 19:21
@github-actions
Copy link
Copy Markdown

Coverage after merging feat/team-dispatch into main will be

95.83%

Coverage Report
FileStmtsBranchesFuncsLinesUncovered Lines
src
   aggregate.ts100%100%100%100%
   api-utils.ts93.20%100%93.75%93.13%101–103, 65, 73, 86–87, 91–92
   api.ts94.57%100%100%93.89%319–323, 384, 401, 63–69
   cache.ts94.67%100%100%94.29%139–141, 39
   completions.ts99.42%100%100%99.37%270
   group.ts99.50%100%97.44%100%
   output.ts99.20%100%95%99.56%79
   regex.ts99.26%100%100%99.21%251
   render.ts89.87%100%89.47%89.89%167, 191–196, 198–200, 202–203, 254–255, 276, 463–464, 487–489, 555–559, 571–572, 577–584, 586–594, 596–597
   upgrade.ts88.38%100%94.44%87.89%128, 131, 133, 153, 167–168, 188–195, 198–204, 209, 214, 250–253
src/render
   filter-match.ts97.44%100%92.31%100%
   filter.ts100%100%100%100%
   highlight.ts96.63%100%90.40%99.31%284–285
   rows.ts97.58%100%100%97.44%168, 54–55
   selection.ts100%100%100%100%
   summary.ts100%100%100%100%
   team-pick.ts100%100%100%100%

@github-actions
Copy link
Copy Markdown

Coverage after merging feat/team-dispatch into main will be

95.83%

Coverage Report
FileStmtsBranchesFuncsLinesUncovered Lines
src
   aggregate.ts100%100%100%100%
   api-utils.ts93.20%100%93.75%93.13%101–103, 65, 73, 86–87, 91–92
   api.ts94.57%100%100%93.89%319–323, 384, 401, 63–69
   cache.ts94.67%100%100%94.29%139–141, 39
   completions.ts99.42%100%100%99.37%270
   group.ts99.50%100%97.44%100%
   output.ts99.20%100%95%99.56%79
   regex.ts99.26%100%100%99.21%251
   render.ts89.87%100%89.47%89.89%167, 191–196, 198–200, 202–203, 254–255, 276, 463–464, 487–489, 555–559, 571–572, 577–584, 586–594, 596–597
   upgrade.ts88.38%100%94.44%87.89%128, 131, 133, 153, 167–168, 188–195, 198–204, 209, 214, 250–253
src/render
   filter-match.ts97.44%100%92.31%100%
   filter.ts100%100%100%100%
   highlight.ts96.63%100%90.40%99.31%284–285
   rows.ts97.58%100%100%97.44%168, 54–55
   selection.ts100%100%100%100%
   summary.ts100%100%100%100%
   team-pick.ts100%100%100%100%

Copy link
Copy Markdown
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

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

@github-actions
Copy link
Copy Markdown

Coverage after merging feat/team-dispatch into main will be

95.83%

Coverage Report
FileStmtsBranchesFuncsLinesUncovered Lines
src
   aggregate.ts100%100%100%100%
   api-utils.ts93.20%100%93.75%93.13%101–103, 65, 73, 86–87, 91–92
   api.ts94.57%100%100%93.89%319–323, 384, 401, 63–69
   cache.ts94.67%100%100%94.29%139–141, 39
   completions.ts99.42%100%100%99.37%270
   group.ts99.50%100%97.44%100%
   output.ts99.20%100%95%99.56%79
   regex.ts99.26%100%100%99.21%251
   render.ts89.87%100%89.47%89.89%167, 191–196, 198–200, 202–203, 254–255, 276, 463–464, 487–489, 555–559, 571–572, 577–584, 586–594, 596–597
   upgrade.ts88.38%100%94.44%87.89%128, 131, 133, 153, 167–168, 188–195, 198–204, 209, 214, 250–253
src/render
   filter-match.ts97.44%100%92.31%100%
   filter.ts100%100%100%100%
   highlight.ts96.63%100%90.40%99.31%284–285
   rows.ts97.58%100%100%97.44%168, 54–55
   selection.ts100%100%100%100%
   summary.ts100%100%100%100%
   team-pick.ts100%100%100%100%

@shouze shouze force-pushed the feat/team-dispatch branch from 684df81 to 143c582 Compare March 31, 2026 19:59
@github-actions
Copy link
Copy Markdown

Coverage after merging feat/team-dispatch into main will be

95.83%

Coverage Report
FileStmtsBranchesFuncsLinesUncovered Lines
src
   aggregate.ts100%100%100%100%
   api-utils.ts93.20%100%93.75%93.13%101–103, 65, 73, 86–87, 91–92
   api.ts94.57%100%100%93.89%319–323, 384, 401, 63–69
   cache.ts94.67%100%100%94.29%139–141, 39
   completions.ts99.42%100%100%99.37%270
   group.ts99.50%100%97.44%100%
   output.ts99.20%100%95%99.56%79
   regex.ts99.26%100%100%99.21%251
   render.ts89.87%100%89.47%89.89%167, 191–196, 198–200, 202–203, 254–255, 276, 463–464, 487–489, 555–559, 571–572, 577–584, 586–594, 596–597
   upgrade.ts88.38%100%94.44%87.89%128, 131, 133, 153, 167–168, 188–195, 198–204, 209, 214, 250–253
src/render
   filter-match.ts97.44%100%92.31%100%
   filter.ts100%100%100%100%
   highlight.ts96.63%100%90.40%99.31%284–285
   rows.ts97.58%100%100%97.44%168, 54–55
   selection.ts100%100%100%100%
   summary.ts100%100%100%100%
   team-pick.ts100%100%100%100%

@shouze shouze merged commit 9c779fa into main Mar 31, 2026
9 checks passed
@shouze shouze deleted the feat/team-dispatch branch March 31, 2026 20:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

2 participants