Reorder screen slims to glyph+name rows and hugs its content

Enter is now the sole grab/drop key (Space is ignored), the rows drop
the openness/hash lanes since reordering is about position, and the
screen gains a dialog_width sized for its fullest state so the popup
fits its content without resizing mid-interaction.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Jean-Pierre MartineauandClaude Fable 5 committed 2026-07-10 03:32:23 -04:00
1 parent 8c75aea3b0
commit 96813130d5
3 files changed
+68 -51

No files matched your search

+24 -25
View File
@@ -328,35 +328,23 @@ def test_scroll_screen_escape_resolves_none() -> None:
def test_reorder_apply_row_commits_new_order() -> None:
"""Space grabs/drops (spacebar arrives as printable text); Enter on Apply commits."""
"""Enter grabs and drops a list row; Enter on Apply commits the rearrangement."""
screen = ReorderScreen("order", ["a", "b", "c"])
screen.handle("text", " ") # grab "a"
assert screen._grabbed and "Space drop" in screen.footer_hint
screen.handle("enter") # grab "a"
assert screen._grabbed and "Enter drop" in screen.footer_hint
screen.handle("down") # carry it past "b"
screen.handle("space") # drop (the normalized action form also works)
assert not screen._grabbed and "Space grab" in screen.footer_hint
screen.handle("enter") # drop
assert not screen._grabbed and "Enter grab" in screen.footer_hint
screen.handle("down") # cursor from position 1 past "c"…
screen.handle("down") # …onto the Apply row
assert _run(screen, "enter") == [1, 0, 2]
def test_reorder_enter_grabs_and_drops_a_list_row() -> None:
"""Enter on a list row grabs/drops just like Space, so either key drives a move."""
screen = ReorderScreen("order", ["a", "b", "c"])
screen.handle("down") # cursor to "b"
screen.handle("enter") # grab
assert screen._grabbed
screen.handle("down") # carry to the end
screen.handle("enter") # drop
assert not screen._grabbed
assert screen._order == [0, 2, 1]
def test_reorder_actions_follow_the_dirty_state() -> None:
"""Untouched order offers a lone Back; a change swaps in Apply plus discard-Back."""
screen = ReorderScreen("order", ["a", "b", "c"])
assert [key for key, _ in screen._actions()] == ["back"]
screen.handle("space")
screen.handle("enter")
screen.handle("down") # dirty now
assert [key for key, _ in screen._actions()] == ["apply", "back"]
screen.handle("up") # moved back home — clean again
@@ -366,14 +354,14 @@ def test_reorder_actions_follow_the_dirty_state() -> None:
def test_reorder_back_row_and_escape_cancel_discarding_moves() -> None:
"""Enter on Back — like Esc — resolves the sentinel, so the caller keeps the old order."""
screen = ReorderScreen("order", ["a", "b", "c"])
screen.handle("text", " ")
screen.handle("enter")
screen.handle("down")
assert _run(screen, "escape") is CANCEL
screen = ReorderScreen("order", ["a", "b", "c"])
screen.handle("space")
screen.handle("enter")
screen.handle("down")
screen.handle("space") # drop at position 1; the order is dirty
screen.handle("enter") # drop at position 1; the order is dirty
for _ in range(3): # cursor 1 → 2 → Apply → Back
screen.handle("down")
assert _run(screen, "enter") is CANCEL
@@ -384,21 +372,32 @@ def test_reorder_cursor_wraps_through_the_action_rows() -> None:
screen = ReorderScreen("order", ["a", "b"])
screen.handle("up") # wrap: onto the lone Back row
assert screen._index == 2
screen.handle("space") # grabbing means nothing on an action row
assert not screen._grabbed
screen.handle("down") # wrap forward to the first list row
assert screen._index == 0
def test_reorder_ignores_other_typed_characters() -> None:
"""Printable keys other than the spacebar neither grab a row nor resolve the screen."""
def test_reorder_ignores_typed_characters_including_space() -> None:
"""Typed characters — the spacebar included — neither grab a row nor resolve the screen."""
screen = ReorderScreen("order", ["a", "b"])
screen.future = _Fut()
screen.handle("text", "x")
screen.handle("text", " ") # Space no longer grabs; Enter is the grab key
screen.handle("space")
assert not screen._grabbed
assert not screen.future.done()
def test_reorder_dialog_width_is_stable_across_states() -> None:
"""The natural width fits the widest of rows, hints, and dirty actions — and never
changes as the user grabs a row or dirties the order, so the popup doesn't resize."""
screen = ReorderScreen("order", ["🔒 alpha", "# b"])
w = screen.dialog_width
screen.handle("enter") # grab
assert screen.dialog_width == w
screen.handle("down") # dirty: Apply/discard rows appear
assert screen.dialog_width == w
# --- frame -------------------------------------------------------------------