tui: peer payment history behind the F9 payments row (key p) #121
Loading…
Reference in a new issue
No description provided.
Delete branch "onionwire/t_ef1d35d2-tui-payments-row-on-f9-render-peer-payme"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Why
The F9 /
/settingsmenu's only payment row showed the wallet's own transferlist (
Node::wallet_recent_transfers, F6). The signed/payinvoices and/tipreceipts a peer sent live in thepaymentstable and had no path fromthe TUI at all —
Store::list_paymentswas unreachable fromNode. Parentcard t_21787cec (PR #119) added
Node::list_payments; this card wires it intothe screen.
Depends on #119. This branch is
main+ #119's commit (86e2022), so itsdiff includes that commit until #119 merges; my own commits are
2fa3466(the screen) andb8fefe9(review round 1);cbe8890mergesmainback in after #120 landed and conflicted with this branch indocs/TUI.mdandtests/tui_spec.rs(both sections kept / #120's superset assertion kept). Head iscbe8890.What
Screen::PeerPayments { state }withPeerPaymentsState/PeerPaymentRow,built by
PeerPaymentsState::from_paymentsfromNode::list_payments'rows. Newest first — the store returns
payments.idascending, so the callerreverses and windows the vector, as the API doc requires.
pon the F9 screen (open_peer_payments),up/down(ork/j) to move the selection,Escback,F9reopens the menu — from thisscreen 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.
pay::atomic_to_xmr_str— the existingpiconero formatter, no second one), memo, and
verified/unverifiedforreceipts. The focused row is marked
>and bold (not colour-only), andunverifiedis spelled out as well as toned.txandaddrare spelled out under the rows: a 64-hextxid is useless truncated, and the 95-character base58 address is wrapped
over two lines rather than clipped.
no payments with {peer}·could not read payments · {reason}· a menu row that refuses withno friend selected. Empty historyis a state, never an error (
Ok(vec![])).transfers(F6, behaviour unchanged) sotwo different histories are not both called
payments; the newpaymentsrow(key
p) names the peer and the count.memois peer-signed text returned as stored, so it goes through the samemenu_cell_text(sanitize::display_text+ newline/tab strip) →fit_cellspath the F9 menu uses before it can touch a frame.
Exact locations
src/tui.rs)Screen::PeerPayments { state }pub struct PeerPaymentsStatepub struct PeerPaymentRowpub fn draw_peer_paymentspub fn peer_payments_linesPeerPaymentsState::from_paymentsKeyCode::Char('p') => open_payments = true(F9 arm)Screen::PeerPayments { .. } => match key.codefn open_peer_paymentsMenuRow::new("payments", …, "p", …)Evidence — frames
Before (F9 menu on
main): 19 rows, onepaymentsrow that was the wallet'stransfer count.
After — F9 menu at 80x24 (
transfers+ the newpaymentsrow), 20 rows in 21inner rows:
New screen, 80x24 — re-dumped after review round 1, so the last line is the
footer the app renders (
F9 menu, commitb8fefe9; before that the fixturehard-coded
Esc back up/down select ? helpand every frame below was a framethe app never draws):
At 120x40 the address renders unwrapped on its one
addrrow, and the footer isthe widened
status_footerform — still namingF9 menu: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_dumpsat 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 ? helpanddocs/TUI.mdsaysF9reopens the menu, but the
KeyCode::F(9)arm opened it only fromScreen::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 fromMain,WalletsSettingsandPeerPayments. The failure is pinned by tests that read thescreen's own hint string and assert every
F<n>it names is answered there:2. The dumped frames used a footer the app never renders.
tests/tui_payments.rspassed"Esc back up/down select ? help"tostatus_footerby hand. The fixture now readspeer_payments_footer_hint()—the single source
footer_hintsalso returns — andpeer_payments_frame_shows_the_shipped_footerpins the dumped frame's last lineto the shipped one:
3. The menu's own frame dumps had the same drift — found while merging
mainback in, because #120 (which is now in this branch) moved the menu's status line
to
status_footer_phasedwhiletests/tui_spec.rs::render_menukept building aphase-free
status_footerfrom a hand-copied hint. The dumped menu framestherefore showed no Tor phase at all.
wallets_settings_footer_hint()is now thesingle source for that hint and
render_menumakes the app's own two calls:Also restored the rustfmt-only reflow of unrelated tests in
tests/tui_spec.rs(
queued_row, afailed_rowcall,rgb_tokens_…,alert_line_…).Evidence — tests
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 anexplicit 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 newerand 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 · noline over the pane width for every width 20..=200 (columns are dropped, not
wrapped).
One flake fixed (not mine)
tests/tui_spec.rs'swallets_settings_menu_truncates_wide_values_in_cellsasserted
fit_cells("abcdefghij", 8).starts_with("abcdef"), which only holdswhen no other test has
ONIONWIRE_ASCIIset at that instant — the suite mutatesenv 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 theassertion 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, keyp)" section with the layout,states and guarantees, and the "peer payment history unreachable" gap entry is
marked closed.
paymentsrow (key p)Review round 1 — both defects fixed (
b8fefe9), branch merged withmain(cbe8890)1.
F9 menuon the peer-payments footer was a no-op. TheKeyCode::F(9)armcarried an inner
if matches!(self.screen, Screen::Main)guard, so the key thescreen'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 fromMain,WalletsSettingsand
PeerPayments.Pinned by
mod function_key_testsinsrc/tui.rs— one test reads the screen'sown hint string and asserts every
F<n>it names is answered there, so thecopy and the routing can no longer drift apart silently:
2. The frame dumps used a footer the app never renders.
tests/tui_payments.rspassed
"Esc back up/down select ? help"tostatus_footerby hand. The fixturenow reads
peer_payments_footer_hint(), the same single sourcefooter_hintsreturns, and this is the RED it produced:
PR body re-dumped at 80x24 and 120x40 (populated + empty) with the real footer.
Evidence after the fix
Degradation checked too: the pinned footer assertion and all 12
tui_paymentstests pass with
ONIONWIRE_ASCII=1and withNO_COLOR=1; at 80x24 in ASCIIchrome the last line still reads
TOR me:abcdef01... onion:abcdefgh... Esc back up/down select F9 menu ? help.Note on the merge commit
mainadvanced while this PR was open: #120 (clean-look chrome redesign) touchedthe same three files and made #121 unmergeable.
cbe8890mergesmainin —docs/TUI.mdkeeps both sections (peer payments, then the chrome section),tests/tui_spec.rskeeps #120's superset of thefit_cellsflake relaxation,src/tui.rsmerged cleanly. The peer-payments frames are byte-identical beforeand after the merge, so the dumps in the body still hold. CI on
cbe8890isqueued behind other runs on the Pi runner; I will report the result here when it
finishes.
cbe8890(run 458 was cancelled after 19s)CI on
c1d1317— all four checks greenThe first android run on the merge commit (
cbe8890, run 458) was cancelled bythe 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
mainmain's chrome redesign (#120) moved the F9 menu's one status line tostatus_footer_phased, buttests/tui_spec.rs::render_menustill built aphase-free
status_footerfrom a hand-copied hint string — so the menu frames inthis 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, andLocal evidence on the final head
c1d1317:Presentation only: no wire, store, session, send-path or
Nodechange.