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 <noreply@anthropic.com>
This commit is contained in:
Jean-Pierre MartineauandClaude Opus 5 committed 2026-11-22 12:06:15 -05:00
1 parent cd38012506
commit 5902b76e68
6 files changed
+52 -5

No files matched your search

+6 -1
View File
@@ -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
+2
View File
@@ -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,
),
]
+6 -1
View File
@@ -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),
]
+2 -1
View File
@@ -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,
),
]
+14 -2
View File
@@ -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:
+22
View File
@@ -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.