Repository navigation
feat(tui): Bash checkbox menu (#495 Slice 2) - #505
Merged
Merged
Conversation
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>
This was referenced Aug 5, 2026
…ression test The arrow-mode redraw used cursor-up count+1, but _tui_render_list emits exactly count lines. The 3-line static header (blank + instruction + blank) printed once before the loop was progressively consumed into the cleared region on each keypress. After 3 keypresses CSIA overshot row 0 and the terminal scrolled upward on every subsequent key event. Fix: - Extract the three-line redraw sequence into _tui_arrow_redraw (move-up N, clear-to-end, render list), which makes the operation independently callable and directly testable. - Use cursor-up delta == count (not count+1). Header is static and remains anchored above the redrawn region. Regression test (T_arrow_redraw_stable): - Confirms _tui_render_list emits exactly N lines for N tools. - Calls _tui_arrow_redraw directly, captures raw stdout bytes via od, and asserts CSI 3A (0x1b5b3341) present and CSI 4A (0x1b5b3441, the buggy byte sequence) absent. Fails on the pre-fix inline code; passes on the extracted helper. 16 assertions / 14 named tests. ShellCheck clean. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Extract _tui_checked_toggle_all and _tui_arrow_handle_key as independently
testable pure functions. _tui_arrow_mode now delegates all key dispatch to
_tui_arrow_handle_key; _tui_numbered_mode reuses the same toggle-all helper
for consistent behavior across both nav paths.
Add a/A toggle-all dispatch to arrow mode (was previously absent); arrow
mode now supports the full keyset: Up/Down navigation with boundary clamps,
Space to toggle the cursor item, Enter to confirm, a/A to toggle-all, and
q/Q/ESC to cancel.
Stable redraw fix (cursor-up delta = N, not N+1) and the ANSI byte
regression guard are preserved from the previous commit.
Test suite expands to 32 assertions covering:
- none-to-all state transition via arrow-mode dispatch ('a' on '0 0 0')
- uppercase Q cancel dispatch (cancelled=1, done=0)
- bare ESC cancel dispatch (cancelled=1, done=0)
- Up/Down movement and boundary clamps, Space toggle, Enter done, noop
- _tui_arrow_redraw ANSI byte invariants (ESC[3A present, ESC[4A absent)
- E2E selection-file, subset ordering, opt-in placement, cancel/noop guards
All 32 pass; ShellCheck clean.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Arrow mode is gated at Bash >=4.2 in production; the three toggle-all assertions (a-lower-none, a-lower-mixed, A-upper) produce empty output on Bash 3.2 and falsely fail. Add a BASH_VERSINFO version guard that records proper skips on Bash <4.2 using the suite's existing skip() convention. No production code is changed. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Owner
Author
|
Manual validation completed successfully. Verified stable viewport behavior: A selects all then clears all; Q/Esc cancellation; final run-log behavior. All six CI jobs passed. Independent review approved. |
primetimetank21
marked this pull request as ready for review
August 7, 2026 10:38
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Integrate the merged PowerShell TUI slice while preserving Bash TUI CI coverage. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
4 tasks done
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.
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-fileseam 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:_TUI_ARROW_NAV_OVERRIDE=0env 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_toolsetengine viaARG_ONLY; order is always preserved by DEFAULT_TOOLS sequence.scripts/linux/setup.sh(modified)lib/tui.shalongsidelib/log.sh.main()now callsshow_tool_menuwhen interactive, or reads from--selection-file(CI seam) without rendering the menu.tests/test_tui_bash.sh(new)16 assertions across 14 named tests covering:
Excluded from this PR
lib/tui.ps1,Resolve-FinalToolset). Separate branch.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-scriptsjob: shellcheck on setup.sh + tools;test_setup_flags.shvalidate-linux/validate-macos: existing install and flag teststest_tui_bash.shis wired intovalidate-linux(Ubuntu, bash 5.x) andvalidate-macos(macOS, bash 3.2) via a Run TUI bash menu tests step in.github/workflows/validate.yml. All 16 assertions (14 named tests) gate both jobs on every push and pull request.Fix: ANSI viewport drift on keypress (addressed in review)
Symptom: the terminal scrolled upward on every keypress during arrow-mode navigation.
Root cause: the redraw cursor-up escape used
count + 1lines, but_tui_render_listemits exactlycountlines. The static instruction header (3 lines printed once before the loop) was not part of the redrawn region, so each keypress consumed one header line into the clear zone. After 3 keypressesCSI ${N+1}Aovershot row 0, causing the terminal to scroll.Fix: extracted the redraw sequence into
_tui_arrow_redrawand changed the cursor-up delta tocount(matching the render output exactly). The static header remains printed once and is never redrawn.Regression test:
T_arrow_redraw_stablecalls_tui_arrow_redrawdirectly, captures raw output bytes viaod, and assertsCSI 3A(0x1b 0x5b 0x33 0x41) is present andCSI 4A(the buggy byte sequence) is absent.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:
a, Enter,q.