Skip to content

feat(tui): Bash checkbox menu (#495 Slice 2) - #505

Draft
primetimetank21 wants to merge 2 commits into
developfrom
squad/495-tui-picker-bash-slice-2
Draft

feat(tui): Bash checkbox menu (#495 Slice 2)#505
primetimetank21 wants to merge 2 commits into
developfrom
squad/495-tui-picker-bash-slice-2

Conversation

@primetimetank21

@primetimetank21 primetimetank21 commented Aug 5, 2026

Copy link
Copy Markdown
Owner

Summary

Implements Slice 2 of #495: the Bash interactive checkbox menu for Linux/macOS/WSL.

Depends on merged #504 (Slice 1) — all non-interactive guards, TTY detection, and the --selection-file seam landed in Slice 1.

Part of #495


What ships in this PR

scripts/linux/lib/tui.sh (new)

Sourced by setup.sh. Two navigation modes:

  • Bash >=4.2: arrow up/down, Space to toggle, Enter to confirm, q/ESC to cancel. ANSI cursor repositioning redraws the list in place.
  • Bash 3.2 fallback: numbered-toggle line mode. _TUI_ARROW_NAV_OVERRIDE=0 env var forces this path for testing without needing a real bash 3.2 environment.

Default tools are pre-checked and labeled (default); opt-in tools (available but not default) are unchecked and labeled (opt-in), sorted alphabetically.

Cancel exits 0 with Install cancelled.
Empty confirm exits 0 with Nothing selected, exiting.
Selection feeds the existing build_final_toolset engine via ARG_ONLY; order is always preserved by DEFAULT_TOOLS sequence.

scripts/linux/setup.sh (modified)

  • Sources lib/tui.sh alongside lib/log.sh.
  • main() now calls show_tool_menu when interactive, or reads from --selection-file (CI seam) without rendering the menu.
  • Updated stale Slice 1 comment.

tests/test_tui_bash.sh (new)

13 tests covering:

Test Type Covers
T_tui_sh_sources_clean smoke tui.sh sources without error
T_menu_resolve_defaults integration all defaults selected → run-log == defaults.txt
T_menu_resolve_subset integration reversed-input subset → order preserved
T_menu_resolve_optin integration opt-in tool appended after defaults
T_menu_resolve_empty integration empty selection → exit 0, "Nothing selected"
T_menu_selection_file_e2e integration selection-file seam → correct ordered run-log
T_menu_cancel_aborts unit _MENU_CANCELLED=1 guard → exit 0
T_menu_noop_empty unit empty _MENU_SELECTION guard → exit 0, correct message
T_numbered_render_runs unit _tui_numbered_render draws list with states and labels
T_render_list_runs unit _tui_render_list renders cursor, checkboxes, labels
T_noninteractive_compat regression --non-interactive still runs defaults (Slice 1 compat)
T_selection_file_no_noninteractive_conflict regression --non-interactive + --selection-file → error
T_help_no_selection_file regression --help does not expose hidden --selection-file

Excluded from this PR

  • Slice 3: PowerShell 5.1 ASCII menu (lib/tui.ps1, Resolve-FinalToolset). Separate branch.
  • Slice 4: docs additions (README, ARCHITECTURE). No changes to those files in this PR.
  • No changes to PowerShell scripts, docs, or CI workflow files.

CI validation

ShellCheck passes locally via pre-commit hook and pre-push hook (both ran successfully on commit and push).

CI will run on Ubuntu (bash 5.x) and macOS (bash 3.2):

  • lint-shell-scripts job: shellcheck on setup.sh + tools; test_setup_flags.sh
  • validate-linux / validate-macos: existing install and flag tests

test_tui_bash.sh is wired into validate-linux (Ubuntu, bash 5.x) and validate-macos (macOS, bash 3.2) via a Run TUI bash menu tests step in .github/workflows/validate.yml. All 13 tests gate both jobs on every push and pull request.


Manual verification required (not covered by automated tests)

The following cases require a live interactive TTY and are not verified by CI or this PR's automated tests:

  1. Arrow-key navigation on bash 5.x (Ubuntu/Linux terminal) — up/down moves cursor, Space toggles, Enter confirms.
  2. ANSI in-place redraw in tmux / screen.
  3. Numbered-toggle mode on macOS bash 3.2 (Terminal.app) — enter a number, a, Enter, q.
  4. ESC / Q cancel from within the rendered menu.
  5. "All defaults checked + Enter" produces identical install to a no-arg run.
  6. Opt-in tool checked produces correct install appended after defaults.

These cases are documented here rather than claimed as tested.

primetimetank21 and others added 2 commits August 5, 2026 03:29
Add scripts/linux/lib/tui.sh: interactive checkbox menu sourced by setup.sh.
- Bash >=4.2: arrow-key navigation, Space toggle, Enter confirm, q/ESC cancel
- Bash 3.2: numbered-toggle fallback (no fractional timeout, no mapfile, no local -n)
- Version detection via BASH_VERSION; _TUI_ARROW_NAV_OVERRIDE seam for tests
- Default tools pre-checked, opt-in tools unchecked and labeled
- Cancel sets _MENU_CANCELLED=1, exits 0 with "Install cancelled."
- Empty confirm exits 0 with "Nothing selected, exiting."
- Selection feeds existing --only engine; order preserved by build_final_toolset

Wire show_tool_menu into setup.sh main():
- --interactive + --selection-file: CI-testable seam, bypasses TTY guard
- Headless/CI/default/--non-interactive paths unchanged (Slice 1 compat)

Add tests/test_tui_bash.sh:
- T_tui_sh_sources_clean, T_menu_resolve_defaults, T_menu_resolve_subset
- T_menu_resolve_optin, T_menu_resolve_empty, T_menu_selection_file_e2e
- T_menu_cancel_aborts, T_menu_noop_empty, T_numbered_render_runs
- T_render_list_runs, T_noninteractive_compat
- T_selection_file_no_noninteractive_conflict, T_help_no_selection_file

Part of #495
Depends on merged #504 (Slice 1)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…495)

Add 'Run TUI bash menu tests' step to validate-linux and validate-macos
jobs so all 13 Slice 2 tests gate CI on both platforms. No new jobs or
dependencies. Corrects omission from Hardcase's Slice 2 commit.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.

1 participant