Courier recipient picker: the shared node list, Enter commits
The queueing flow's inline glyph rows give way to the app's one node list: full NAME/HEARD/PKTS/KEY lanes, key-hued names, recency-heat ages, PKTS from the recorder's overheard tallies, and the same Ctrl+arrow sort ring and type-to-filter as the Nodes screen and the Time Machine picker. It opens on the heard column freshest-first (the old fixed order, now just a default), name sorts A→Z, and Enter resolves the highlighted Contact into the flow; the footer spells the grammar out with Esc cancelling the step. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
98aa6ef7dc
commit
93c1937de7
2 files changed
+124
-31
No files matched your search
@@ -468,3 +468,58 @@ def test_outbox_rows_recompute_live_state_per_repaint(tmp_path: Path) -> None:
|
||||
# no refresh() needed, the callable title re-reads the entry on repaint.
|
||||
ctx.courier_store.note_attempt(entry.ident)
|
||||
assert "try 1" in _outbox_plain(screen)
|
||||
|
||||
|
||||
# --- the recipient picker ----------------------------------------------------------------
|
||||
|
||||
|
||||
def test_recipient_picker_rides_the_shared_node_list(tmp_path: Path) -> None:
|
||||
"""The picker draws the full lanes, opens freshest-heard first, and Enter commits."""
|
||||
from meshterm.ui.courier_screen import _PICK_HINT, CourierRecipientScreen
|
||||
from meshterm.ui.nodelist import SORT_COLUMNS, SORT_OPENS_ASCENDING
|
||||
from meshterm.ui.widgets import NodesSort
|
||||
|
||||
fresh = Contact(name="Fresh", public_key="aa" * 32, last_seen=utcnow())
|
||||
stale = Contact(
|
||||
name="Stale", public_key="bb" * 32, last_seen=utcnow() - timedelta(days=2)
|
||||
)
|
||||
counts = {"aa" * 6: 7}
|
||||
screen = CourierRecipientScreen(
|
||||
contacts=[stale, fresh],
|
||||
prefix_bytes=1,
|
||||
counts=counts,
|
||||
sort=NodesSort.from_name("heard", SORT_COLUMNS, SORT_OPENS_ASCENDING),
|
||||
)
|
||||
import re
|
||||
|
||||
body = "\n".join(
|
||||
re.sub(r"\x1b\[[0-9;]*m", "", ln) for ln in screen.render_body(80)
|
||||
)
|
||||
assert "NAME" in body and "HEARD" in body and "PKTS" in body and "KEY" in body
|
||||
assert body.index("Fresh") < body.index("Stale") # heard opens freshest-first
|
||||
assert " 7" in body # Fresh's overheard tally fills the PKTS lane
|
||||
assert screen.footer_hint == _PICK_HINT
|
||||
|
||||
# Enter resolves the highlighted row's value — the Contact itself.
|
||||
resolved: list = []
|
||||
screen.resolve = resolved.append # type: ignore[method-assign]
|
||||
screen.handle("enter")
|
||||
assert resolved == [fresh]
|
||||
|
||||
|
||||
def test_recipient_picker_sort_keys_walk_the_ring(tmp_path: Path) -> None:
|
||||
"""The same ^←→ keys the Nodes list uses re-sort the picker's columns."""
|
||||
from meshterm.ui.courier_screen import CourierRecipientScreen
|
||||
from meshterm.ui.nodelist import SORT_COLUMNS, SORT_OPENS_ASCENDING
|
||||
from meshterm.ui.widgets import NodesSort
|
||||
|
||||
a = Contact(name="Alpha", public_key="aa" * 32, last_seen=utcnow())
|
||||
z = Contact(name="Zulu", public_key="bb" * 32)
|
||||
sort = NodesSort.from_name("heard", SORT_COLUMNS, SORT_OPENS_ASCENDING)
|
||||
screen = CourierRecipientScreen(
|
||||
contacts=[z, a], prefix_bytes=0, counts={}, sort=sort
|
||||
)
|
||||
screen.handle("ctrl_left") # heard -> name (opens ascending)
|
||||
assert sort.column == "name" and sort.ascending
|
||||
values = [c.value for c in screen._choices()]
|
||||
assert values == [a, z]
|
||||
Reference in new issue
Block a user