Skip to content

enh: substring filter for the board picker#9843

Open
iav wants to merge 3 commits into
mainfrom
enh/board-picker-substring-filter-v2
Open

enh: substring filter for the board picker#9843
iav wants to merge 3 commits into
mainfrom
enh/board-picker-substring-filter-v2

Conversation

@iav
Copy link
Copy Markdown
Contributor

@iav iav commented May 17, 2026

Summary

Add a substring filter to the interactive board picker (./compile.sh when BOARD is not set). With ~400 supported boards the alphabetical list is long; the dialog's built-in first-letter navigation is impractical when many boards share a prefix. The PR introduces a [set filter] sentinel at the top of the menu that opens a dialog --inputbox; matching is case-insensitive on both the board name and the description line.

Bundled with two related changes that make the picker itself snappier (see commits below) — without them, opening / toggling / filtering the picker each pays a ~800-fork-per-redraw cost.

Behaviour

  • No filter active — the menu looks exactly like before plus a single new top entry [set filter]. All boards remain visible, no buttons added, no layout shift.
  • Filter active — a second sentinel [clear filter] appears, and the first sentinel's description shows change filter (current: <X>, <N>/<TOTAL> boards). Only matching boards are listed beneath.
  • Filter state survives the Show CSC/WIP/EOS/TVB toggle.
  • Cancel / Esc / OK on an empty board selection behave as before.

Screens

Before — current behaviour with no sentinel, no filter:

putty_2026-05-17_10-22-19

After (no filter) — new sentinel at top:

putty_2026-05-17_10-13-22

Filter inputbox:

putty_2026-05-17_10-11-13

Filter active — 2/367 boards match helios:

putty_2026-05-17_10-11-37

Why a sentinel and not a button

The first attempt added --help-button --help-label "Filter" to the existing --menu. In a standard 80×24 PuTTY/xterm the four buttons (OK, Show CSC.., Cancel, Filter) plus the menu items don't fit; dialog returns 255 ("screen too small") before the user can interact. A sentinel menu entry sidesteps that — no extra button, no layout change.

Commits

  1. interactive: shfmt whole-file format pass — formatting-only pass on lib/functions/configuration/interactive.sh so the substantive diffs that follow show up clean. No behaviour change.
  2. interactive: cache board list across dialog redraws, drop per-file subshellsget_list_of_all_buildable_boards previously forked basename | cut and head | cut per board file (~800 forks for ~400 boards) and re-ran on every dialog redraw. Replaces the subshells with bash parameter expansion + a single read -r, and hoists the result out of the while loop so it only re-scans when WIP_STATE changes (Show CSC/WIP/EOS/TVB toggle).
  3. interactive: substring filter for the board picker — the actual feature, ~45 lines added in interactive_config_ask_board_list.

Test plan

  • Build a board interactively without setting BOARD: ./compile.sh build → dialog shows [set filter] at top alongside all boards
  • Select [set filter] → type helios → menu shows [set filter] (with current: helios, 2/367), [clear filter], helios4, helios64
  • Select [clear filter] → full list returns, only [set filter] sentinel remains
  • Toggle Show CSC/WIP/EOS/TVB while a filter is active → filter persists, re-scan happens once
  • Original button row is unchanged (OK / Show.. / Cancel) — no --help-button added
  • Board descriptions in the menu match the pre-PR cut/head output for a spot-checked sample

Summary by CodeRabbit

  • New Features

    • Added substring filtering for board selection with "[set filter]" and "[clear filter]" options; filter persists during interactive configuration.
    • Board selection now supports case-insensitive matching across name and description.
  • Performance

    • Faster board list handling by caching scans across dialog redraws and parsing board entries more efficiently to avoid redundant external calls.

Review Change Stack

iav added 2 commits May 17, 2026 10:15
Run shfmt -w on lib/functions/configuration/interactive.sh to normalise
pre-existing indentation drift (tabs vs spaces, comment alignment) so
that a follow-up substring-filter change in interactive_config_ask_board_list
shows up as a clean diff. No behaviour change.

Assisted-by: Claude:claude-opus-4.7
…bshells

`get_list_of_all_buildable_boards` is called once per redraw of the
interactive board picker (initial open, Show CSC/WIP/EOS/TVB toggle,
and any other dialog re-render). Two things made each call expensive
in proportion to the number of boards (~400 in the tree):

1. Per board file it forked `basename | cut` and `head | cut` -- two
   subshell pipelines per file, ~800 fork/exec cycles per scan.
2. The result was thrown away and recomputed on the next loop
   iteration even when nothing had changed.

This commit:

- Replaces the per-file subshells with bash parameter expansion
  (`${path##*/}`, `${name%.*}`, `${line#*#}`, `${line%%#*}`) plus a
  single `read -r` for the first line of each board file. Behaviour
  is equivalent to the previous `basename`/`cut`/`head` chain.
- Hoists the result arrays out of the while loop and re-scans only
  when `WIP_STATE` flips on the Show-CSC/WIP/EOS/TVB toggle, the
  only event that changes the set of types considered.

Visible effect: the "Generating list of all available boards" delay
on entering the picker stays the same, but redraws that previously
incurred the same delay (toggle, future filter changes) are now
instantaneous.

Assisted-by: Claude:claude-opus-4.7
@iav iav requested a review from a team as a code owner May 17, 2026 07:54
@iav iav requested review from lanefu and sgjava and removed request for a team May 17, 2026 07:54
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 17, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 0e1e461d-3050-4342-aa25-a8d5c854be63

📥 Commits

Reviewing files that changed from the base of the PR and between 7113743 and 25336d3.

📒 Files selected for processing (1)
  • lib/functions/configuration/interactive.sh
🚧 Files skipped from review as they are similar to previous changes (1)
  • lib/functions/configuration/interactive.sh

📝 Walkthrough

Walkthrough

This pull request optimizes the interactive board selection interface in Armbian's build configuration system. Board metadata extraction is streamlined to use native bash parameter expansion instead of external command pipelines. The board list selection dialog gains a caching mechanism to avoid re-scanning on every redraw and introduces substring filtering via menu sentinels, with filter state persisted across selections. Adjacent functions receive formatting normalization with no logic changes.

Changes

Interactive Board Selection and Filtering

Layer / File(s) Summary
Board metadata extraction optimization
lib/functions/configuration/interactive.sh
get_list_of_all_buildable_boards replaces external basename/cut/head subshells with bash parameter expansion and string operations, reading board files once and parsing descriptions via slicing instead of cut pipelines.
Board list caching and filtering
lib/functions/configuration/interactive.sh
interactive_config_ask_board_list caches board scanning results across dialog redraws via board_list_needs_refresh flag, eliminates per-loop re-globbing, adds substring filtering through sentinel menu entries ([set filter], [clear filter]), persists BOARD_FILTER across selections, and branches result handling on WIP toggle (refresh), filter actions (prompt and update filter), and board selection (set configuration).
Formatting and whitespace normalization
lib/functions/configuration/interactive.sh
get_kernel_info_for_branch and interactive_config_ask_branch receive indentation and whitespace consistency updates with no functional logic changes.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐰 Cached lists in bash I tend to keep,
No subshells digging, just a single read deep,
A filter to whisper which board to pick,
Menus that remember, responses quick,
Hooray — tiny hops, and the dialogs leap!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 20.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly and clearly summarizes the main change: adding a substring filter feature to the interactive board picker, which is the primary objective of this PR.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch enh/board-picker-substring-filter-v2

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions github-actions Bot added size/medium PR with more then 50 and less then 250 lines 05 Milestone: Second quarter release Needs review Seeking for review Framework Framework components labels May 17, 2026
@iav iav changed the title interactive: substring filter for the board picker enh: substring filter for the board picker May 17, 2026
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@lib/functions/configuration/interactive.sh`:
- Around line 158-179: The filter is matching the raw dialog payload (which
includes color escapes and a leading "(type)" badge) so searches hit those
tokens; modify the loop that builds arr_filter_hits (involving
arr_all_board_options, item, tag, hay) to first strip dialog color escape
sequences like \Z1...\Zn and remove a leading "(...)" type badge from item
(produce a cleaned_item), then perform the case-insensitive match against
"${tag,,} ${cleaned_item,,}" instead of against the raw item; keep the rest
(arr_filter_hits population, match_count, and arr_menu_options with
FILTER_TAG/CLEAR_TAG) unchanged.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 9f16eec4-3c55-441a-971b-e4ed17963d3f

📥 Commits

Reviewing files that changed from the base of the PR and between cff548c and 7113743.

📒 Files selected for processing (1)
  • lib/functions/configuration/interactive.sh

Comment thread lib/functions/configuration/interactive.sh
When BOARD is not set on the command line, the interactive board picker
shows all 400+ boards alphabetically with no built-in way to narrow the
list down. Finding a known board by typing only its first letter (the
default dialog behaviour) is impractical when several share a prefix.

Prepend a sentinel `[set filter]` entry at the top of the menu that
opens a dialog --inputbox; the substring is matched case-insensitively
against both the board name and its short description. Once a filter is
active, a second sentinel `[clear filter]` appears alongside, and the
first sentinel shows the current filter and match count.

Implementation notes:
- A separate dialog button (e.g. --help-button) was tried first but it
  doesn't fit in an 80x24 terminal alongside the existing OK / Show
  CSC.. / Cancel triplet -- dialog returns 255 ("screen too small")
  before the user can react. A sentinel menu entry has no such
  constraint and keeps the existing button layout intact.
- Filter state survives the existing CSC/WIP/EOS toggle and re-filtering
  on a fresh full list, so toggling expert mode does not lose the
  substring.
- Filtering iterates the cached arr_all_board_options in pure bash
  (no subshells), so it stays cheap regardless of how many times the
  user re-opens the inputbox.

Assisted-by: Claude:claude-opus-4.7
@iav iav force-pushed the enh/board-picker-substring-filter-v2 branch from 7113743 to 25336d3 Compare May 17, 2026 08:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

05 Milestone: Second quarter release Framework Framework components Needs review Seeking for review size/medium PR with more then 50 and less then 250 lines

Development

Successfully merging this pull request may close these issues.

1 participant