From 5902b76e68618d01abd398401898959ae43de996 Mon Sep 17 00:00:00 2001 From: Jean-Pierre Martineau Date: Sun, 22 Nov 2026 12:06:15 -0500 Subject: [PATCH] A typed filter never hides the way out of an editor Apply has no keyboard key of its own. On the Preferences page, the Device config page, the repeater admin page, the outbound editor, the region editor, and the archive sweep, a typed query narrowed the rows and took the exit pair with them. The staged changes were then only reachable by a press of Esc that clears the filter, which nothing on the screen says. A Choice can now declare always_shown, and the filter keeps such a row as it keeps each separator. The exit pair of menus.exit_rows, the live-then-save pair of the region editor, and the Archive/Back pair of the sweep declare it. A verb row that a reader searches for, such as an Actions section or a menu, is content and filters as before. Co-Authored-By: Claude Opus 5 --- CLAUDE.md | 7 ++++++- meshterm/ui/menus.py | 2 ++ meshterm/ui/region_editor.py | 7 ++++++- meshterm/ui/sweep_screen.py | 3 ++- meshterm/ui/tui/select.py | 16 ++++++++++++++-- tests/test_preferences.py | 22 ++++++++++++++++++++++ 6 files changed, 52 insertions(+), 5 deletions(-) diff --git a/CLAUDE.md b/CLAUDE.md index 96ce85b..4e87dcb 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -226,7 +226,12 @@ deliberately, one at a time, and say why in the code. clean and, once changes are staged, one blank `Separator(" ")` line then `✓ Apply n staged changes` over `✗ Back — discard staged changes` — Apply has no key of its own, so it needs a visible counterpart naming what the other way out costs. Same - shape in `ReorderScreen`. A **Quit** row is likewise kept (main menu, device splash): + shape in `ReorderScreen`. **A filter never hides a way out**: the pair carries + `Choice.always_shown`, so a typed query narrows the content and leaves Apply and the + Back that names its cost (JP, 2026-11-22) — a filter that hid Apply put the only way to + commit behind an Esc nobody knew to press. Same flag on the live-then-save pair and the + sweep's Archive/Back; a verb row a reader *searches for* (an Actions section, a menu) is + content and filters like any row. A **Quit** row is likewise kept (main menu, device splash): it *initiates* the app's terminal action behind a confirm, and on the splash it is the only statement that the app can be left at all. - **An editor has one of two shapes, chosen by who holds the change.** Where MeshTerm diff --git a/meshterm/ui/menus.py b/meshterm/ui/menus.py index 2084a96..c7121b2 100644 --- a/meshterm/ui/menus.py +++ b/meshterm/ui/menus.py @@ -308,10 +308,12 @@ def exit_rows(staged: int, *, apply_value: Any, back_value: Any) -> list: Choice( title=Text.assemble(("✓ ", "ok"), f"Apply {changes_phrase(staged)}"), value=apply_value, + always_shown=True, ), Choice( title=Text.assemble(("✗ ", "err"), "Back — discard staged changes"), value=back_value, + always_shown=True, ), ] diff --git a/meshterm/ui/region_editor.py b/meshterm/ui/region_editor.py index 98bea09..aa95ad2 100644 --- a/meshterm/ui/region_editor.py +++ b/meshterm/ui/region_editor.py @@ -315,8 +315,13 @@ def _save_rows(unsaved: int) -> list: Choice( title=Text.assemble(("✓ ", "ok"), f"Save {unsaved} {noun} to the repeater"), value=_SAVE, + always_shown=True, + ), + Choice( + title=Text.assemble(("✗ ", "err"), "Back — a reboot undoes them"), + value=_BACK, + always_shown=True, ), - Choice(title=Text.assemble(("✗ ", "err"), "Back — a reboot undoes them"), value=_BACK), ] diff --git a/meshterm/ui/sweep_screen.py b/meshterm/ui/sweep_screen.py index 7504525..c9d52e8 100644 --- a/meshterm/ui/sweep_screen.py +++ b/meshterm/ui/sweep_screen.py @@ -625,12 +625,13 @@ def _preview_items(victims: list[ScoredContact], locks: list[ScoredContact] | No # of the other way out. This is not ``exit_rows`` itself, because these rows are not # staged changes to a set of values, and the pair must say what it archives. Separator(" "), - Choice(title=Text.assemble(("✓ ", "ok"), apply), value=_APPLY), + Choice(title=Text.assemble(("✓ ", "ok"), apply), value=_APPLY, always_shown=True), Choice( title=Text.assemble( ("✗ ", "err"), "Back — change nothing" if staged else "Back — keep them all" ), value=_BACK, + always_shown=True, ), ] diff --git a/meshterm/ui/tui/select.py b/meshterm/ui/tui/select.py index f5e4950..9452cd4 100644 --- a/meshterm/ui/tui/select.py +++ b/meshterm/ui/tui/select.py @@ -86,6 +86,13 @@ class Choice: row, there is nothing that is worth a slide. Also, if the highlight changes the row back to a chart that is cut off, the fit is lost on the row that the user reads. + always_shown: The row stays in the list while a find-as-you-type filter narrows + it. It is for an **action** row, which is a way out of the screen and not one + of the rows that the user searches: the ``✓ Apply …`` / ``✗ Back …`` pair of an + editor, and the save pair of a live page. Apply has no keyboard key of its own, + so a filter that hid it put the only way to commit the staged changes behind a + press of Esc that the user does not know to make. The filter looks through the + *content* of a list. An action is not content. pans: The row is a line of a table that ←→ pan as one unit. Each row and each column header that pans (:attr:`Separator.pans`) slides by the same shift. Thus the lanes stay under their labels, however far the user panned. The shift also @@ -101,6 +108,7 @@ class Choice: detail: str | Text | Callable[[], str | Text] | None = None hscroll_from: int = 0 fitted: bool = False + always_shown: bool = False pans: bool = False def __post_init__(self) -> None: @@ -624,7 +632,9 @@ class SelectScreen(Screen): Without a filter, groups and headings show as written. With a filter, only the choices that match are shown. But each separator stays, so the list keeps its - section landmarks (and column headers) while it narrows. + section landmarks (and column headers) while it narrows. An action row stays too + (:attr:`Choice.always_shown`): the filter searches the content of the list, and the + way out of the screen is not content. """ needle = self._filter.strip().lower() if not needle: @@ -632,7 +642,9 @@ class SelectScreen(Screen): return [ it for it in self._items - if isinstance(it, Separator) or needle in _plain(it.label).lower() + if isinstance(it, Separator) + or it.always_shown + or needle in _plain(it.label).lower() ] def _choices(self, rows: list | None = None) -> list: diff --git a/tests/test_preferences.py b/tests/test_preferences.py index 454912a..b3cd1ce 100644 --- a/tests/test_preferences.py +++ b/tests/test_preferences.py @@ -346,6 +346,28 @@ def test_a_staged_change_shows_its_arrow_and_the_save_action() -> None: assert any("✗ Back — discard staged changes" in row for row in rows) +def test_a_filter_narrows_the_settings_and_keeps_the_apply_and_back_rows() -> None: + """A typed filter hides the settings that do not match. The exit pair stays. + + Apply has no keyboard key of its own. Thus a filter that hid it left no way to commit + the staged changes. The filter searches the content of the page, and an action is not + content. + """ + from meshterm.ui.tui import SelectScreen + + title, items = _menu_items(Preferences(), {"history_days": 90}) + screen = SelectScreen(title, items) + screen.note_viewport(len(items) + 4) + for ch in "zzzz": # a query that no setting matches + screen.handle("text", ch) + rows = [line.strip() for line in _plain(screen.render_body(_WIDE)).splitlines()] + assert not any("Map tiles" in row for row in rows) + assert any("✓ Apply 1 staged change" in row for row in rows) + assert any("✗ Back — discard staged changes" in row for row in rows) + # They are still rows that the highlight can reach, and not only drawn lines. + assert [choice.value for choice in screen._choices()] == ["__apply__", "__cancel__"] + + def test_a_long_value_is_capped_so_the_descriptions_keep_their_lane() -> None: """The page makes the basemap URL shorter in the lane.