tui: peer payment history behind the F9 payments row (key p) #121

Merged
sirius merged 7 commits from onionwire/t_ef1d35d2-tui-payments-row-on-f9-render-peer-payme into main 2026-09-19 13:00:00 +00:00
Owner

Why

The F9 / /settings menu's only payment row showed the wallet's own transfer
list (Node::wallet_recent_transfers, F6). The signed /pay invoices and
/tip receipts a peer sent live in the payments table and had no path from
the TUI at all
— Store::list_payments was unreachable from Node. Parent
card t_21787cec (PR #119) added Node::list_payments; this card wires it into
the screen.

Depends on #119. This branch is main + #119's commit (86e2022), so its
diff includes that commit until #119 merges; my own commits are 2fa3466 (the screen) and b8fefe9 (review round 1); cbe8890 merges main back in after #120 landed and conflicted with this branch in docs/TUI.md and tests/tui_spec.rs (both sections kept / #120's superset assertion kept). Head is cbe8890.

What

  • Screen::PeerPayments { state } with PeerPaymentsState / PeerPaymentRow,
    built by PeerPaymentsState::from_payments from Node::list_payments'
    rows. Newest first — the store returns payments.id ascending, so the caller
    reverses and windows the vector, as the API doc requires.
  • Key handler: p on the F9 screen (open_peer_payments), up/down (or
    k/j) to move the selection, Esc back, F9 reopens the menu — from this
    screen as well as Main (function_key_for). F-keys stay live on both screens,
    so no row or footer prints a key that does nothing there.
  • Rows show direction, kind, amount (pay::atomic_to_xmr_str — the existing
    piconero formatter, no second one), memo, and verified / unverified for
    receipts. The focused row is marked > and bold (not colour-only), and
    unverified is spelled out as well as toned.
  • The selected row's tx and addr are spelled out under the rows: a 64-hex
    txid is useless truncated, and the 95-character base58 address is wrapped
    over two lines rather than clipped.
  • States: populated · no payments with {peer} · could not read payments · {reason} · a menu row that refuses with no friend selected. Empty history
    is a state, never an error (Ok(vec![])).
  • The wallet's own list is retitled transfers (F6, behaviour unchanged) so
    two different histories are not both called payments; the new payments row
    (key p) names the peer and the count.
  • memo is peer-signed text returned as stored, so it goes through the same
    menu_cell_text (sanitize::display_text + newline/tab strip) → fit_cells
    path the F9 menu uses before it can touch a frame.

Exact locations

Thing Symbol Line (src/tui.rs)
Screen state Screen::PeerPayments { state } 1244
Screen state struct pub struct PeerPaymentsState 3500
Row struct pub struct PeerPaymentRow 3477
Draw entry pub fn draw_peer_payments 3857
Body pub fn peer_payments_lines 3721
Builder PeerPaymentsState::from_payments 3516
Key: open KeyCode::Char('p') => open_payments = true (F9 arm) 1619
Key: screen Screen::PeerPayments { .. } => match key.code 1622
Open handler fn open_peer_payments 1949
Menu row MenuRow::new("payments", …, "p", …) 3248

Evidence — frames

Before (F9 menu on main): 19 rows, one payments row that was the wallet's
transfer count.

===== WALLETS & SETTINGS  80x24 =====                     ← BEFORE
┌(o) wallets & settings────────────────────────────────────────────────────────┐
│WALLET ───────────────────────────────────────────────────────────────────────│
│  endpoint   configured · connected                                           │
│  child      local node · running                                       F6 s/x│
│  sync       chain at tip · wallet answering                              F6 p│
│  receive    4AdUndXHHZ6cfufTMvppY6JwXNouMBzSkbLYfpAV5Usx3skxNgY… c copy  F6 r│
│  balance    0.250000000000                                                 F6│
│  payments   3 recent                                                       F6│
│  create     /wallet create · seed shown once                             F6 c│
│  import     /wallet import · 25-word seed                                F6 i│
│                                                                              │
│SETTINGS ─────────────────────────────────────────────────────────────────────│
...

After — F9 menu at 80x24 (transfers + the new payments row), 20 rows in 21
inner rows:

===== WALLETS & SETTINGS  80x24 =====                     ← AFTER
┌(o) wallets & settings────────────────────────────────────────────────────────┐
│WALLET ───────────────────────────────────────────────────────────────────────│
│  endpoint   configured · connected                                           │
│  child      local node · running                                       F6 s/x│
│  sync       chain at tip · wallet answering                              F6 p│
│  receive    4AdUndXHHZ6cfufTMvppY6JwXNouMBzSkbLYfpAV5Usx3skxNgY… c copy  F6 r│
│  balance    0.250000000000                                                 F6│
│  transfers  3 recent                                                       F6│
│  payments   3 with lance                                                    p│
│  create     /wallet create · seed shown once                             F6 c│
│  import     /wallet import · 25-word seed                                F6 i│
│                                                                              │
│SETTINGS ─────────────────────────────────────────────────────────────────────│
...

New screen, 80x24 — re-dumped after review round 1, so the last line is the
footer the app renders (F9 menu, commit b8fefe9; before that the fixture
hard-coded Esc back up/down select ? help and every frame below was a frame
the app never draws):

===== PEER PAYMENTS  80x24 =====
┌(o) payments · lance──────────────────────────────────────────────────────────┐
│  dir  kind          amount XMR  receipt     memo                             │
│> in   receipt            0.025  verified    lunch money                      │
│  out  tip                0.005              coffee                           │
│  out  invoice              0.1              rent                             │
│                                                                              │
│  tx    3f2a91c0d9e4b7a2c1f0e8d7b6a5948372615041324758697a8b9c0d1e2f3041      │
│  addr  4AdUndXHHZ6cfufTMvppY6JwXNouMBzSkbLYfpAV5Usx3skxNgYeYJKUGVktfzxayGbMWa│
│        C8iqPUE9XUBFGrLyDz4DpEBM                                              │
│                                                                              │
│                                                                              │
│                                                                              │
│                                                                              │
│                                                                              │
│                                                                              │
│                                                                              │
│                                                                              │
│                                                                              │
│                                                                              │
│                                                                              │
│                                                                              │
│                                                                              │
└──────────────────────────────────────────────────────────────────────────────┘
TOR  me:abcdef01… onion:abcdefgh… Esc back up/down select F9 menu ? help        

===== PEER PAYMENTS (empty)  80x24 =====
┌(o) payments · lance──────────────────────────────────────────────────────────┐
│  no payments with lance                                                      │
│  invoices, receipts and tips from this peer land here                        │
│                                                                              │
│                                                                              │
│                                                                              │
│                                                                              │
│                                                                              │
│                                                                              │
│                                                                              │
│                                                                              │
│                                                                              │
│                                                                              │
│                                                                              │
│                                                                              │
│                                                                              │
│                                                                              │
│                                                                              │
│                                                                              │
│                                                                              │
│                                                                              │
│                                                                              │
└──────────────────────────────────────────────────────────────────────────────┘
TOR  me:abcdef01… onion:abcdefgh… Esc back up/down select F9 menu ? help        

At 120x40 the address renders unwrapped on its one addr row, and the footer is
the widened status_footer form — still naming F9 menu:

===== PEER PAYMENTS  120x40 =====
┌(o) payments · lance──────────────────────────────────────────────────────────────────────────────────────────────────┐
│  dir  kind          amount XMR  receipt     memo                                                                     │
│> in   receipt            0.025  verified    lunch money                                                              │
│  out  tip                0.005              coffee                                                                   │
│  out  invoice              0.1              rent                                                                     │
│                                                                                                                      │
│  tx    3f2a91c0d9e4b7a2c1f0e8d7b6a5948372615041324758697a8b9c0d1e2f3041                                              │
│  addr  4AdUndXHHZ6cfufTMvppY6JwXNouMBzSkbLYfpAV5Usx3skxNgYeYJKUGVktfzxayGbMWaC8iqPUE9XUBFGrLyDz4DpEBM                │
│                                                                                                                      │
│                                                                                                                      │
│                                                                                                                      │
│                                                                                                                      │
│                                                                                                                      │
│                                                                                                                      │
│                                                                                                                      │
│                                                                                                                      │
│                                                                                                                      │
│                                                                                                                      │
│                                                                                                                      │
│                                                                                                                      │
│                                                                                                                      │
│                                                                                                                      │
│                                                                                                                      │
│                                                                                                                      │
│                                                                                                                      │
│                                                                                                                      │
│                                                                                                                      │
│                                                                                                                      │
│                                                                                                                      │
│                                                                                                                      │
│                                                                                                                      │
│                                                                                                                      │
│                                                                                                                      │
│                                                                                                                      │
│                                                                                                                      │
│                                                                                                                      │
│                                                                                                                      │
│                                                                                                                      │
└──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
TOR  me:abcdef01…  onion:abcdefghijklmnopqrstuvwxyz234567abcdefghijklmnopqrstuvwx.onion  up/down select F9 menu  ? help 

===== PEER PAYMENTS (empty)  120x40 =====
┌(o) payments · lance──────────────────────────────────────────────────────────────────────────────────────────────────┐
│  no payments with lance                                                                                              │
│  invoices, receipts and tips from this peer land here                                                                │
│                                                                                                                      │
│                                                                                                                      │
│                                                                                                                      │
│                                                                                                                      │
│                                                                                                                      │
│                                                                                                                      │
│                                                                                                                      │
│                                                                                                                      │
│                                                                                                                      │
│                                                                                                                      │
│                                                                                                                      │
│                                                                                                                      │
│                                                                                                                      │
│                                                                                                                      │
│                                                                                                                      │
│                                                                                                                      │
│                                                                                                                      │
│                                                                                                                      │
│                                                                                                                      │
│                                                                                                                      │
│                                                                                                                      │
│                                                                                                                      │
│                                                                                                                      │
│                                                                                                                      │
│                                                                                                                      │
│                                                                                                                      │
│                                                                                                                      │
│                                                                                                                      │
│                                                                                                                      │
│                                                                                                                      │
│                                                                                                                      │
│                                                                                                                      │
│                                                                                                                      │
│                                                                                                                      │
│                                                                                                                      │
└──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
TOR  me:abcdef01…  onion:abcdefghijklmnopqrstuvwxyz234567abcdefghijklmnopqrstuvwx.onion  up/down select F9 menu  ? help 

200x60 (both states) is dumped by
cargo test --locked --test tui_payments -- --nocapture peer_payments_frame_dumps;
at 200x60 the full 64-hex txid and the whole address render untruncated. The
menu dumps come from --test tui_spec -- --nocapture wallets_settings_menu_frame_dumps at all three sizes.

Review round 1 — two false affordances fixed (commit b8fefe9)

1. F9 was printed on the screen and did nothing there. footer_hints(Screen::PeerPayments)
returns Esc back up/down select F9 menu ? help and docs/TUI.md says F9
reopens the menu, but the KeyCode::F(9) arm opened it only from Screen::Main.

Fixed by removing the guard and routing the function keys through one table,
function_key_for(screen, code): F9 opens (or reopens) the menu from Main,
WalletsSettings and PeerPayments. The failure is pinned by tests that read the
screen's own hint string and assert every F<n> it names is answered there:

$ cargo test --locked --lib function_key_tests        # RED, before the fix
test tui::function_key_tests::f9_opens_the_menu_from_the_peer_payments_screen ... FAILED
  assertion `left == right` failed: the screen's footer names F9 but F9 does nothing there
    left: None
   right: Some(OpenMenu)
test tui::function_key_tests::every_function_key_named_by_the_peer_payments_hint_is_answered_there ... FAILED
  hint names F9 ("Esc back  up/down select  F9 menu  ? help") but the screen does not answer it
test result: FAILED. 1 passed; 3 failed

$ cargo test --locked --lib function_key_tests        # GREEN, after
test result: ok. 4 passed; 0 failed

2. The dumped frames used a footer the app never renders.
tests/tui_payments.rs passed "Esc back up/down select ? help" to
status_footer by hand. The fixture now reads peer_payments_footer_hint() —
the single source footer_hints also returns — and
peer_payments_frame_shows_the_shipped_footer pins the dumped frame's last line
to the shipped one:

$ cargo test --locked --test tui_payments peer_payments_frame_shows_the_shipped_footer   # RED
  left:  "TOR  me:abcdef01… onion:abcdefgh… Esc back up/down select ? help"
  right: "TOR  me:abcdef01… onion:abcdefgh… Esc back up/down select F9 menu ? help"

3. The menu's own frame dumps had the same drift — found while merging main
back in, because #120 (which is now in this branch) moved the menu's status line
to status_footer_phased while tests/tui_spec.rs::render_menu kept building a
phase-free status_footer from a hand-copied hint. The dumped menu frames
therefore showed no Tor phase at all. wallets_settings_footer_hint() is now the
single source for that hint and render_menu makes the app's own two calls:

$ cargo test --locked --test tui_spec wallets_settings_menu_frame_shows_the_shipped_footer  # RED
  left:  "TOR  me:abcdef01… onion:abcdefgh… Esc back c copy ? help"
  right: "✓ TOR ready  me:abcdef01… onion:abcdefgh… Esc back c copy ? help"

Also restored the rustfmt-only reflow of unrelated tests in tests/tui_spec.rs
(queued_row, a failed_row call, rgb_tokens_…, alert_line_…).

Evidence — tests

$ cargo test --locked
34 test binaries: test result: ok, 0 failed, 384 passed
TEST_EXIT=0

$ cargo clippy --locked --all-targets -- -D warnings
CLIPPY_EXIT=0

$ cargo test --locked --test tui_payments
test result: ok. 12 passed; 0 failed

$ cargo test --locked --lib function_key_tests
test result: ok. 4 passed; 0 failed

$ cargo test --locked --test tui_spec
test result: ok. 37 passed; 0 failed

tests/tui_payments.rs (12 tests) covers: every required field at 80x24 ·
the amount coming from pay::atomic_to_xmr_str · the empty history as an
explicit line at 80x24/120x40/200x60 · the error state naming the reason ·
selection as a marker, exactly one focused row · a 40-row history windowed with
… N older / … N newer and the end of the list reachable · a hostile memo
(ESC, BEL, C1, bidi, newline) never reaching the frame buffer while the inert
text survives · frame fit and cell_width ≤ width at 80x24/120x40/200x60 · no
line over the pane width for every width 20..=200 (columns are dropped, not
wrapped).

One flake fixed (not mine)

tests/tui_spec.rs's wallets_settings_menu_truncates_wide_values_in_cells
asserted fit_cells("abcdefghij", 8).starts_with("abcdef"), which only holds
when no other test has ONIONWIRE_ASCII set at that instant — the suite mutates
env vars without a global lock (documented hazard). It fails on an unmodified
tree too (git stash → 1 of 2 runs FAILED, verified here), so this relaxes the
assertion to the cut point both chromes share. No other assertion changed.

Docs

docs/TUI.md: the row table (transfers / payments), the row count 19 → 20,
a new "Peer payment history (F9 → payments, key p)" section with the layout,
states and guarantees, and the "peer payment history unreachable" gap entry is
marked closed.

## Why The F9 / `/settings` menu's only payment row showed the wallet's own transfer list (`Node::wallet_recent_transfers`, F6). The signed `/pay` invoices and `/tip` receipts a peer sent live in the `payments` table and had **no path from the TUI at all** — `Store::list_payments` was unreachable from `Node`. Parent card t_21787cec (PR #119) added `Node::list_payments`; this card wires it into the screen. **Depends on #119.** This branch is `main` + #119's commit (`86e2022`), so its diff includes that commit until #119 merges; my own commits are `2fa3466` (the screen) and `b8fefe9` (review round 1); `cbe8890` merges `main` back in after #120 landed and conflicted with this branch in `docs/TUI.md` and `tests/tui_spec.rs` (both sections kept / #120's superset assertion kept). Head is `cbe8890`. ## What - `Screen::PeerPayments { state }` with `PeerPaymentsState` / `PeerPaymentRow`, built by `PeerPaymentsState::from_payments` from `Node::list_payments`' rows. Newest first — the store returns `payments.id` ascending, so the caller reverses and windows the vector, as the API doc requires. - Key handler: `p` on the F9 screen (`open_peer_payments`), `up`/`down` (or `k`/`j`) to move the selection, `Esc` back, `F9` reopens the menu — from this screen as well as `Main` (`function_key_for`). F-keys stay live on both screens, so no row or footer prints a key that does nothing there. - Rows show direction, kind, amount (`pay::atomic_to_xmr_str` — the existing piconero formatter, no second one), memo, and `verified` / `unverified` for receipts. The focused row is marked `>` **and** bold (not colour-only), and `unverified` is spelled out as well as toned. - The selected row's `tx` and `addr` are spelled out under the rows: a 64-hex txid is useless truncated, and the 95-character base58 address is **wrapped** over two lines rather than clipped. - States: populated · `no payments with {peer}` · `could not read payments · {reason}` · a menu row that refuses with `no friend selected`. Empty history is a state, never an error (`Ok(vec![])`). - The wallet's own list is **retitled `transfers`** (F6, behaviour unchanged) so two different histories are not both called `payments`; the new `payments` row (key `p`) names the peer and the count. - `memo` is peer-signed text returned as stored, so it goes through the same `menu_cell_text` (`sanitize::display_text` + newline/tab strip) → `fit_cells` path the F9 menu uses before it can touch a frame. ## Exact locations | Thing | Symbol | Line (`src/tui.rs`) | |---|---|---| | Screen state | `Screen::PeerPayments { state }` | 1244 | | Screen state struct | `pub struct PeerPaymentsState` | 3500 | | Row struct | `pub struct PeerPaymentRow` | 3477 | | Draw entry | `pub fn draw_peer_payments` | 3857 | | Body | `pub fn peer_payments_lines` | 3721 | | Builder | `PeerPaymentsState::from_payments` | 3516 | | Key: open | `KeyCode::Char('p') => open_payments = true` (F9 arm) | 1619 | | Key: screen | `Screen::PeerPayments { .. } => match key.code` | 1622 | | Open handler | `fn open_peer_payments` | 1949 | | Menu row | `MenuRow::new("payments", …, "p", …)` | 3248 | ## Evidence — frames Before (F9 menu on `main`): 19 rows, one `payments` row that was the wallet's transfer count. ``` ===== WALLETS & SETTINGS 80x24 ===== ← BEFORE ┌(o) wallets & settings────────────────────────────────────────────────────────┐ │WALLET ───────────────────────────────────────────────────────────────────────│ │ endpoint configured · connected │ │ child local node · running F6 s/x│ │ sync chain at tip · wallet answering F6 p│ │ receive 4AdUndXHHZ6cfufTMvppY6JwXNouMBzSkbLYfpAV5Usx3skxNgY… c copy F6 r│ │ balance 0.250000000000 F6│ │ payments 3 recent F6│ │ create /wallet create · seed shown once F6 c│ │ import /wallet import · 25-word seed F6 i│ │ │ │SETTINGS ─────────────────────────────────────────────────────────────────────│ ... ``` After — F9 menu at 80x24 (`transfers` + the new `payments` row), 20 rows in 21 inner rows: ``` ===== WALLETS & SETTINGS 80x24 ===== ← AFTER ┌(o) wallets & settings────────────────────────────────────────────────────────┐ │WALLET ───────────────────────────────────────────────────────────────────────│ │ endpoint configured · connected │ │ child local node · running F6 s/x│ │ sync chain at tip · wallet answering F6 p│ │ receive 4AdUndXHHZ6cfufTMvppY6JwXNouMBzSkbLYfpAV5Usx3skxNgY… c copy F6 r│ │ balance 0.250000000000 F6│ │ transfers 3 recent F6│ │ payments 3 with lance p│ │ create /wallet create · seed shown once F6 c│ │ import /wallet import · 25-word seed F6 i│ │ │ │SETTINGS ─────────────────────────────────────────────────────────────────────│ ... ``` New screen, 80x24 — re-dumped after review round 1, so the last line is the footer the app renders (`F9 menu`, commit `b8fefe9`; before that the fixture hard-coded `Esc back up/down select ? help` and every frame below was a frame the app never draws): ``` ===== PEER PAYMENTS 80x24 ===== ┌(o) payments · lance──────────────────────────────────────────────────────────┐ │ dir kind amount XMR receipt memo │ │> in receipt 0.025 verified lunch money │ │ out tip 0.005 coffee │ │ out invoice 0.1 rent │ │ │ │ tx 3f2a91c0d9e4b7a2c1f0e8d7b6a5948372615041324758697a8b9c0d1e2f3041 │ │ addr 4AdUndXHHZ6cfufTMvppY6JwXNouMBzSkbLYfpAV5Usx3skxNgYeYJKUGVktfzxayGbMWa│ │ C8iqPUE9XUBFGrLyDz4DpEBM │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ TOR me:abcdef01… onion:abcdefgh… Esc back up/down select F9 menu ? help ===== PEER PAYMENTS (empty) 80x24 ===== ┌(o) payments · lance──────────────────────────────────────────────────────────┐ │ no payments with lance │ │ invoices, receipts and tips from this peer land here │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ TOR me:abcdef01… onion:abcdefgh… Esc back up/down select F9 menu ? help ``` At 120x40 the address renders unwrapped on its one `addr` row, and the footer is the widened `status_footer` form — still naming `F9 menu`: ``` ===== PEER PAYMENTS 120x40 ===== ┌(o) payments · lance──────────────────────────────────────────────────────────────────────────────────────────────────┐ │ dir kind amount XMR receipt memo │ │> in receipt 0.025 verified lunch money │ │ out tip 0.005 coffee │ │ out invoice 0.1 rent │ │ │ │ tx 3f2a91c0d9e4b7a2c1f0e8d7b6a5948372615041324758697a8b9c0d1e2f3041 │ │ addr 4AdUndXHHZ6cfufTMvppY6JwXNouMBzSkbLYfpAV5Usx3skxNgYeYJKUGVktfzxayGbMWaC8iqPUE9XUBFGrLyDz4DpEBM │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ └──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘ TOR me:abcdef01… onion:abcdefghijklmnopqrstuvwxyz234567abcdefghijklmnopqrstuvwx.onion up/down select F9 menu ? help ===== PEER PAYMENTS (empty) 120x40 ===== ┌(o) payments · lance──────────────────────────────────────────────────────────────────────────────────────────────────┐ │ no payments with lance │ │ invoices, receipts and tips from this peer land here │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ └──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘ TOR me:abcdef01… onion:abcdefghijklmnopqrstuvwxyz234567abcdefghijklmnopqrstuvwx.onion up/down select F9 menu ? help ``` 200x60 (both states) is dumped by `cargo test --locked --test tui_payments -- --nocapture peer_payments_frame_dumps`; at 200x60 the full 64-hex txid and the whole address render untruncated. The menu dumps come from `--test tui_spec -- --nocapture wallets_settings_menu_frame_dumps` at all three sizes. ## Review round 1 — two false affordances fixed (commit `b8fefe9`) **1. F9 was printed on the screen and did nothing there.** `footer_hints(Screen::PeerPayments)` returns `Esc back up/down select F9 menu ? help` and `docs/TUI.md` says `F9` reopens the menu, but the `KeyCode::F(9)` arm opened it only from `Screen::Main`. Fixed by removing the guard and routing the function keys through one table, `function_key_for(screen, code)`: F9 opens (or reopens) the menu from `Main`, `WalletsSettings` and `PeerPayments`. The failure is pinned by tests that read the screen's own hint string and assert every `F<n>` it names is answered there: ``` $ cargo test --locked --lib function_key_tests # RED, before the fix test tui::function_key_tests::f9_opens_the_menu_from_the_peer_payments_screen ... FAILED assertion `left == right` failed: the screen's footer names F9 but F9 does nothing there left: None right: Some(OpenMenu) test tui::function_key_tests::every_function_key_named_by_the_peer_payments_hint_is_answered_there ... FAILED hint names F9 ("Esc back up/down select F9 menu ? help") but the screen does not answer it test result: FAILED. 1 passed; 3 failed $ cargo test --locked --lib function_key_tests # GREEN, after test result: ok. 4 passed; 0 failed ``` **2. The dumped frames used a footer the app never renders.** `tests/tui_payments.rs` passed `"Esc back up/down select ? help"` to `status_footer` by hand. The fixture now reads `peer_payments_footer_hint()` — the single source `footer_hints` also returns — and `peer_payments_frame_shows_the_shipped_footer` pins the dumped frame's last line to the shipped one: ``` $ cargo test --locked --test tui_payments peer_payments_frame_shows_the_shipped_footer # RED left: "TOR me:abcdef01… onion:abcdefgh… Esc back up/down select ? help" right: "TOR me:abcdef01… onion:abcdefgh… Esc back up/down select F9 menu ? help" ``` **3. The menu's own frame dumps had the same drift** — found while merging `main` back in, because #120 (which is now in this branch) moved the menu's status line to `status_footer_phased` while `tests/tui_spec.rs::render_menu` kept building a phase-free `status_footer` from a hand-copied hint. The dumped menu frames therefore showed no Tor phase at all. `wallets_settings_footer_hint()` is now the single source for that hint and `render_menu` makes the app's own two calls: ``` $ cargo test --locked --test tui_spec wallets_settings_menu_frame_shows_the_shipped_footer # RED left: "TOR me:abcdef01… onion:abcdefgh… Esc back c copy ? help" right: "✓ TOR ready me:abcdef01… onion:abcdefgh… Esc back c copy ? help" ``` Also restored the rustfmt-only reflow of unrelated tests in `tests/tui_spec.rs` (`queued_row`, a `failed_row` call, `rgb_tokens_…`, `alert_line_…`). ## Evidence — tests ``` $ cargo test --locked 34 test binaries: test result: ok, 0 failed, 384 passed TEST_EXIT=0 $ cargo clippy --locked --all-targets -- -D warnings CLIPPY_EXIT=0 $ cargo test --locked --test tui_payments test result: ok. 12 passed; 0 failed $ cargo test --locked --lib function_key_tests test result: ok. 4 passed; 0 failed $ cargo test --locked --test tui_spec test result: ok. 37 passed; 0 failed ``` `tests/tui_payments.rs` (12 tests) covers: every required field at 80x24 · the amount coming from `pay::atomic_to_xmr_str` · the empty history as an explicit line at 80x24/120x40/200x60 · the error state naming the reason · selection as a marker, exactly one focused row · a 40-row history windowed with `… N older` / `… N newer` and the end of the list reachable · a hostile memo (ESC, BEL, C1, bidi, newline) never reaching the frame buffer while the inert text survives · frame fit and `cell_width` ≤ width at 80x24/120x40/200x60 · no line over the pane width for **every** width 20..=200 (columns are dropped, not wrapped). ## One flake fixed (not mine) `tests/tui_spec.rs`'s `wallets_settings_menu_truncates_wide_values_in_cells` asserted `fit_cells("abcdefghij", 8).starts_with("abcdef")`, which only holds when no other test has `ONIONWIRE_ASCII` set at that instant — the suite mutates env vars without a global lock (documented hazard). It fails on an unmodified tree too (`git stash` → 1 of 2 runs FAILED, verified here), so this relaxes the assertion to the cut point both chromes share. No other assertion changed. ## Docs `docs/TUI.md`: the row table (`transfers` / `payments`), the row count 19 → 20, a new "Peer payment history (F9 → `payments`, key `p`)" section with the layout, states and guarantees, and the "peer payment history unreachable" gap entry is marked closed.
node: expose peer payment history as Node::list_payments
Some checks failed
ci / test (pull_request) Successful in 8m27s
ci / sdk (pull_request) Successful in 1m29s
ci / fuzz (pull_request) Failing after 16m49s
android-ci / android (pull_request) Successful in 10m52s
86e20223cf
Store::list_payments existed but only the node's own tests called it, so the
signed /pay invoices and /tip receipts a peer sent were unreachable from the
app. Add the thinnest read-only accessor next to list_messages/friend_profile:
lock the store, map the error to String, no new state, no new schema, no dial.

Payment rows come back as stored; a renderer sanitizes memo with
sanitize::display_text at draw time, the same way it does for message bodies.
tui: peer payment history behind the F9 payments row (key p)
All checks were successful
ci / test (pull_request) Successful in 5m47s
ci / sdk (pull_request) Successful in 1m28s
ci / fuzz (pull_request) Successful in 4m51s
android-ci / android (pull_request) Successful in 10m36s
2fa3466019
The F9 / `/settings` menu's only payment row showed the wallet's own transfer
list (`Node::wallet_recent_transfers`, F6). The signed `/pay` invoices and
`/tip` receipts a peer sent live in the `payments` table and had no path from
the TUI, so they were invisible. `Node::list_payments` (PR #119) closes that
gap; this wires it into a screen.

- `Screen::PeerPayments { state }` + `PeerPaymentsState` /
  `PeerPaymentRow`, built by `PeerPaymentsState::from_payments` from
  `Node::list_payments`' rows (newest first: the store returns `payments.id`
  ascending, the screen windows the vector).
- Key handler: `p` on the F9 screen opens it (`open_peer_payments`); `up`/`down`
  (or `k`/`j`) move the selection, `Esc` goes back, `F9` reopens the menu.
- Rows carry direction, kind, amount (`pay::atomic_to_xmr_str`, the same
  piconero formatter the chat lines use), memo (sanitized at draw time) and the
  receipt's `verified` / `unverified` word; the focused row is marked with `>`
  and bold. The selected row's txid and address sit under the rows — the
  address wrapped over two lines rather than clipped.
- States: populated, `no payments with {peer}`, `could not read payments`, and
  a menu row that refuses when no friend is selected. An empty history is a
  state, never an error.
- Menu: the wallet's own list is retitled `transfers` (F6, unchanged), and the
  new `payments` row (key `p`) names the peer and the count. Two histories, two
  rows, no ambiguity.
- Widths are measured in cells (`Span::width`); trailing columns are dropped
  before they can wrap, so the body fits 80x24 (20 inner rows of 21) as well as
  120x40 and 200x60.

Tests: new `tests/tui_payments.rs` (11 tests) dumps and asserts the screen at
80x24, 120x40 and 200x60 including the empty history, asserts a memo carrying
ESC/BEL/C1/bidi/newline bytes never reaches the frame buffer, and asserts the
window/column invariants for every width from 20 to 200.

Also relaxes one width assertion in `tests/tui_spec.rs`: `fit_cells` was
asserted to start with `"abcdef"`, which only holds when another test's
in-flight `ONIONWIRE_ASCII` mutation is not visible — the suite mutates env vars
without a global lock, so that test flaked (it also fails on an unmodified tree,
1 run in 2). It now accepts either chrome's cut point, which is what the comment
already claimed.

Docs: `docs/TUI.md` gains the screen's section, the retitled/replaced rows and
the updated row count; the "peer payment history" gap entry is closed.
tui: F9 works on the peer-payments screen, and frames dump the real footer
Some checks failed
ci / test (pull_request) Successful in 6m33s
ci / sdk (pull_request) Successful in 1m31s
ci / fuzz (pull_request) Successful in 4m49s
android-ci / android (pull_request) Has been cancelled
b8fefe9c18
Review round 1 on the F9 `payments` row found two false affordances.

1. `footer_hints(Screen::PeerPayments)` prints `F9 menu`, and docs/TUI.md says
   F9 reopens the menu, but the `KeyCode::F(9)` arm opened it only from
   `Screen::Main`, so pressing F9 on the peer history did nothing.

   The function keys are now routed through one table, `function_key_for(screen,
   code)`, and the F9 arm no longer has the Main-only guard: it opens (or
   reopens) the menu from `Main`, `WalletsSettings` and `PeerPayments`. A screen
   that names a key has to answer it while it is open — that is what the table
   encodes, and `mod function_key_tests` locks it, including a test that reads
   the screen's own hint and asserts every `F<n>` it names is answered there.

2. The PR's frame dumps passed `"Esc back  up/down select  ? help"` to
   `status_footer` by hand, so every dumped frame showed a footer the app never
   renders. `peer_payments_footer_hint()` is now the single source both
   `footer_hints` and the fixture read, and
   `peer_payments_frame_shows_the_shipped_footer` pins the dumped frame's last
   line to the shipped one.

Also restores the rustfmt-only reflow of unrelated tests in `tests/tui_spec.rs`
(`queued_row`, a `failed_row` call, `rgb_tokens_…`, `alert_line_…`), keeping this
card's real edits there.

Presentation only: no wire, store, session, send-path or `Node` change.
Merge origin/main into the peer-payments branch
Some checks failed
android-ci / android (pull_request) Has been cancelled
ci / test (pull_request) Successful in 5m44s
ci / sdk (pull_request) Successful in 1m26s
ci / fuzz (pull_request) Successful in 4m45s
cbe889024b
main moved under this PR when #120 (clean-look chrome redesign) landed, which
touched the same three files (src/tui.rs, tests/tui_spec.rs, docs/TUI.md) and
left PR #121 unmergeable.

- docs/TUI.md: both sections kept — the peer-payment-history section from this
  branch, then #120's chrome-redesign section.
- tests/tui_spec.rs: #120's `fit_cells` flake relaxation kept (it is a superset
  of the one on this branch: same cut point plus the ellipsis assertion).
- src/tui.rs merged cleanly; `cargo test --locked` 383 passed / 0 failed and
  `cargo clippy --locked --all-targets -- -D warnings` clean afterwards.

The peer-payments frames are byte-identical after the merge, so the dumps in
this PR body still hold.
Author
Owner

Review round 1 — both defects fixed (b8fefe9), branch merged with main (cbe8890)

1. F9 menu on the peer-payments footer was a no-op. The KeyCode::F(9) arm
carried an inner if matches!(self.screen, Screen::Main) guard, so the key the
screen's own footer printed did nothing while that screen was open. The guard is
gone and the function keys are now routed through one table,
function_key_for(screen, code), which answers F9 from Main, WalletsSettings
and PeerPayments.

Pinned by mod function_key_tests in src/tui.rs — one test reads the screen's
own hint string and asserts every F<n> it names is answered there, so the
copy and the routing can no longer drift apart silently:

$ cargo test --locked --lib function_key_tests        # RED, before the fix
test ...::f9_opens_the_menu_from_the_peer_payments_screen ... FAILED
  assertion `left == right` failed: the screen's footer names F9 but F9 does nothing there
    left: None
   right: Some(OpenMenu)
test ...::every_function_key_named_by_the_peer_payments_hint_is_answered_there ... FAILED
  hint names F9 ("Esc back  up/down select  F9 menu  ? help") but the screen does not answer it
test ...::function_keys_stay_live_on_the_wallets_settings_screen ... FAILED
test result: FAILED. 1 passed; 3 failed

$ cargo test --locked --lib function_key_tests        # GREEN, after
test result: ok. 4 passed; 0 failed

2. The frame dumps used a footer the app never renders. tests/tui_payments.rs
passed "Esc back up/down select ? help" to status_footer by hand. The fixture
now reads peer_payments_footer_hint(), the same single source footer_hints
returns, and this is the RED it produced:

$ cargo test --locked --test tui_payments peer_payments_frame_shows_the_shipped_footer
  left:  "TOR  me:abcdef01… onion:abcdefgh… Esc back up/down select ? help"
  right: "TOR  me:abcdef01… onion:abcdefgh… Esc back up/down select F9 menu ? help"

PR body re-dumped at 80x24 and 120x40 (populated + empty) with the real footer.

Evidence after the fix

$ cargo test --locked
383 passed, 0 failed (34 binaries), exit 0

$ cargo clippy --locked --all-targets -- -D warnings
exit 0

$ cargo test --locked --test tui_payments
test result: ok. 12 passed; 0 failed

$ cargo test --locked --lib function_key_tests
test result: ok. 4 passed; 0 failed

Degradation checked too: the pinned footer assertion and all 12 tui_payments
tests pass with ONIONWIRE_ASCII=1 and with NO_COLOR=1; at 80x24 in ASCII
chrome the last line still reads
TOR me:abcdef01... onion:abcdefgh... Esc back up/down select F9 menu ? help.

Note on the merge commit

main advanced while this PR was open: #120 (clean-look chrome redesign) touched
the same three files and made #121 unmergeable. cbe8890 merges main in —
docs/TUI.md keeps both sections (peer payments, then the chrome section),
tests/tui_spec.rs keeps #120's superset of the fit_cells flake relaxation,
src/tui.rs merged cleanly. The peer-payments frames are byte-identical before
and after the merge, so the dumps in the body still hold. CI on cbe8890 is
queued behind other runs on the Pi runner; I will report the result here when it
finishes.

## Review round 1 — both defects fixed (`b8fefe9`), branch merged with `main` (`cbe8890`) **1. `F9 menu` on the peer-payments footer was a no-op.** The `KeyCode::F(9)` arm carried an inner `if matches!(self.screen, Screen::Main)` guard, so the key the screen's own footer printed did nothing while that screen was open. The guard is gone and the function keys are now routed through one table, `function_key_for(screen, code)`, which answers F9 from `Main`, `WalletsSettings` and `PeerPayments`. Pinned by `mod function_key_tests` in `src/tui.rs` — one test reads the screen's *own* hint string and asserts every `F<n>` it names is answered there, so the copy and the routing can no longer drift apart silently: ``` $ cargo test --locked --lib function_key_tests # RED, before the fix test ...::f9_opens_the_menu_from_the_peer_payments_screen ... FAILED assertion `left == right` failed: the screen's footer names F9 but F9 does nothing there left: None right: Some(OpenMenu) test ...::every_function_key_named_by_the_peer_payments_hint_is_answered_there ... FAILED hint names F9 ("Esc back up/down select F9 menu ? help") but the screen does not answer it test ...::function_keys_stay_live_on_the_wallets_settings_screen ... FAILED test result: FAILED. 1 passed; 3 failed $ cargo test --locked --lib function_key_tests # GREEN, after test result: ok. 4 passed; 0 failed ``` **2. The frame dumps used a footer the app never renders.** `tests/tui_payments.rs` passed `"Esc back up/down select ? help"` to `status_footer` by hand. The fixture now reads `peer_payments_footer_hint()`, the same single source `footer_hints` returns, and this is the RED it produced: ``` $ cargo test --locked --test tui_payments peer_payments_frame_shows_the_shipped_footer left: "TOR me:abcdef01… onion:abcdefgh… Esc back up/down select ? help" right: "TOR me:abcdef01… onion:abcdefgh… Esc back up/down select F9 menu ? help" ``` PR body re-dumped at 80x24 and 120x40 (populated + empty) with the real footer. ## Evidence after the fix ``` $ cargo test --locked 383 passed, 0 failed (34 binaries), exit 0 $ cargo clippy --locked --all-targets -- -D warnings exit 0 $ cargo test --locked --test tui_payments test result: ok. 12 passed; 0 failed $ cargo test --locked --lib function_key_tests test result: ok. 4 passed; 0 failed ``` Degradation checked too: the pinned footer assertion and all 12 `tui_payments` tests pass with `ONIONWIRE_ASCII=1` and with `NO_COLOR=1`; at 80x24 in ASCII chrome the last line still reads `TOR me:abcdef01... onion:abcdefgh... Esc back up/down select F9 menu ? help`. ## Note on the merge commit `main` advanced while this PR was open: #120 (clean-look chrome redesign) touched the same three files and made #121 unmergeable. `cbe8890` merges `main` in — `docs/TUI.md` keeps both sections (peer payments, then the chrome section), `tests/tui_spec.rs` keeps #120's superset of the `fit_cells` flake relaxation, `src/tui.rs` merged cleanly. The peer-payments frames are byte-identical before and after the merge, so the dumps in the body still hold. CI on `cbe8890` is queued behind other runs on the Pi runner; I will report the result here when it finishes.
ci: re-trigger android-ci for cbe8890 (run 458 was cancelled after 19s)
All checks were successful
ci / test (pull_request) Successful in 5m13s
ci / sdk (pull_request) Successful in 1m5s
ci / fuzz (pull_request) Successful in 4m52s
android-ci / android (pull_request) Successful in 10m38s
e9b4156cf5
The merge commit cbe8890 got a green ci/test and ci/sdk, but its android-ci run
(actions/runs/458) was cancelled by the runner 19 seconds in, which Forgejo
records as a failure on the commit. Nothing in this commit changes the tree;
it exists so the android job runs against the same content.
tui: settings-menu frame dumps use the footer the app renders
All checks were successful
ci / test (pull_request) Successful in 5m17s
ci / sdk (pull_request) Successful in 1m8s
ci / fuzz (pull_request) Successful in 4m50s
android-ci / android (pull_request) Successful in 10m19s
c1d13178b6
The same defect as the peer-payments fixture, one screen over: after the
clean-look chrome redesign (now merged) `App::draw` renders the F9 menu's one
status line with `status_footer_phased` and the hint from `footer_hints`, while
`tests/tui_spec.rs::render_menu` still built a phase-free `status_footer` from a
hand-copied hint string — so every menu frame in the PR body showed a footer the
app does not draw (no Tor phase).

- `wallets_settings_footer_hint()` is now the single source for that hint, the
  way `peer_payments_footer_hint()` is for the history screen.
- `render_menu` makes the app's own two calls, `TorPhase::Ready` for the
  healthy-wallet state the fixture describes.
- `wallets_settings_menu_frame_shows_the_shipped_footer` pins the dumped frame's
  last line to the shipped one (RED first: the fixture's line read
  `TOR  me:… Esc back c copy ? help`, the app's `✓ TOR ready  me:…`).

`cargo test --locked` 384 passed / 0 failed, clippy clean.
Author
Owner

CI on c1d1317 — all four checks green

android-ci / android (pull_request)  success   (run 464)
ci / test (pull_request)             success   (run 465)
ci / sdk (pull_request)              success   (run 465)
ci / fuzz (pull_request)             success   (run 465)
commit status: success

The first android run on the merge commit (cbe8890, run 458) was cancelled by
the runner 19 s in and Forgejo recorded it as a failure; the retriggered run
succeeded, as did the one on the immediately preceding head.

Third defect, same class, found while merging main

main's chrome redesign (#120) moved the F9 menu's one status line to
status_footer_phased, but tests/tui_spec.rs::render_menu still built a
phase-free status_footer from a hand-copied hint string — so the menu frames in
this body showed no Tor phase at all. Fixed the same way as the peer-payments
fixture: wallets_settings_footer_hint() is the single source of that hint, and

$ cargo test --locked --test tui_spec wallets_settings_menu_frame_shows_the_shipped_footer
  # RED, before:  left:  "TOR  me:abcdef01… onion:abcdefgh… Esc back c copy ? help"
  #               right: "✓ TOR ready  me:abcdef01… onion:abcdefgh… Esc back c copy ? help"
  # GREEN, after: test result: ok. 37 passed; 0 failed

Local evidence on the final head c1d1317:

$ cargo test --locked                      384 passed, 0 failed (34 binaries), exit 0
$ cargo clippy --locked --all-targets -- -D warnings   exit 0
$ cargo test --locked --test tui_payments  12 passed, 0 failed
$ cargo test --locked --test tui_spec      37 passed, 0 failed
$ cargo test --locked --lib function_key_tests  4 passed, 0 failed

Presentation only: no wire, store, session, send-path or Node change.

## CI on `c1d1317` — all four checks green ``` android-ci / android (pull_request) success (run 464) ci / test (pull_request) success (run 465) ci / sdk (pull_request) success (run 465) ci / fuzz (pull_request) success (run 465) commit status: success ``` The first android run on the merge commit (`cbe8890`, run 458) was cancelled by the runner 19 s in and Forgejo recorded it as a failure; the retriggered run succeeded, as did the one on the immediately preceding head. ## Third defect, same class, found while merging `main` `main`'s chrome redesign (#120) moved the F9 menu's one status line to `status_footer_phased`, but `tests/tui_spec.rs::render_menu` still built a phase-free `status_footer` from a hand-copied hint string — so the menu frames in this body showed no Tor phase at all. Fixed the same way as the peer-payments fixture: `wallets_settings_footer_hint()` is the single source of that hint, and ``` $ cargo test --locked --test tui_spec wallets_settings_menu_frame_shows_the_shipped_footer # RED, before: left: "TOR me:abcdef01… onion:abcdefgh… Esc back c copy ? help" # right: "✓ TOR ready me:abcdef01… onion:abcdefgh… Esc back c copy ? help" # GREEN, after: test result: ok. 37 passed; 0 failed ``` Local evidence on the final head `c1d1317`: ``` $ cargo test --locked 384 passed, 0 failed (34 binaries), exit 0 $ cargo clippy --locked --all-targets -- -D warnings exit 0 $ cargo test --locked --test tui_payments 12 passed, 0 failed $ cargo test --locked --test tui_spec 37 passed, 0 failed $ cargo test --locked --lib function_key_tests 4 passed, 0 failed ``` Presentation only: no wire, store, session, send-path or `Node` change.
Merge branch 'main' into onionwire/t_ef1d35d2-tui-payments-row-on-f9-render-peer-payme
All checks were successful
ci / test (pull_request) Successful in 5m13s
ci / sdk (pull_request) Successful in 1m6s
ci / fuzz (pull_request) Successful in 4m45s
android-ci / android (pull_request) Successful in 11m59s
0c00c6f912
sirius merged commit 04fa7ec7f1 into main 2026-09-19 13:00:00 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
sirius/onionwire!121
No description provided.