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

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.
This commit is contained in:
agent 2026-09-19 00:31:42 -04:00
commit b8fefe9c18
No known key found for this signature in database
4 changed files with 185 additions and 54 deletions

View file

@ -12,7 +12,8 @@
use onionwire::Payment;
use onionwire::tui::{
PeerPaymentRow, PeerPaymentsState, WalletMenuState, cell_width, draw_peer_payments,
peer_payments_lines, peer_payments_text, status_footer, wallets_settings_menu_text,
peer_payments_footer_hint, peer_payments_lines, peer_payments_text, status_footer,
wallets_settings_menu_text,
};
use ratatui::Terminal;
use ratatui::backend::TestBackend;
@ -59,7 +60,9 @@ fn peer_state() -> PeerPaymentsState {
fn render(w: u16, h: u16, st: &PeerPaymentsState) -> String {
let backend = TestBackend::new(w, h);
let mut terminal = Terminal::new(backend).expect("terminal");
let footer = status_footer(w, FP, ONION, None, "Esc back up/down select ? help");
// The same two calls the app makes, so a dumped frame can never show a
// footer (or a hint) the app does not render.
let footer = status_footer(w, FP, ONION, None, peer_payments_footer_hint());
terminal
.draw(|f| draw_peer_payments(f, st, &footer))
.expect("draw");
@ -74,6 +77,18 @@ fn render(w: u16, h: u16, st: &PeerPaymentsState) -> String {
screen
}
#[test]
fn peer_payments_frame_shows_the_shipped_footer() {
let shipped = status_footer(80, FP, ONION, None, peer_payments_footer_hint());
let frame = render(80, 24, &peer_state());
let last = frame.lines().nth(23).unwrap_or_default();
assert_eq!(
last.trim_end(),
shipped.trim_end(),
"the dumped frame's footer is not the one the app renders"
);
}
#[test]
fn peer_payments_lists_every_required_field() {
let body = peer_payments_text(78, 21, &peer_state());