tui: F7 wallet config screen + wallet/chain setup redesign + doc sync
All checks were successful
ci / test (pull_request) Successful in 4m27s
ci / sdk (pull_request) Successful in 1m14s

Implement the F7 wallet-endpoint config screen (Screen::WalletConfig):
- Fields: rpc_url, rpc_login masked with reveal toggle, no_spend checkbox
- Test connection (t → PingResult::line), Save (s → wallet_save_config)
- Status line: 'saved · not connected', 'connected — ...', 'error: ...'
- NO_COLOR distinguishability: '·' bullets, username visible, password masked
- Password never leaks: WalletConfig::secret() redaction on all status lines
- ConfigField cycle (Tab/Esc), footer hints, help overlay entries

Redraw draw_wallet_setup (CreateWarn→CreatePass→CreateSeed→ImportPass,
CreateWarn→ImportSeq→ImportPass) with spend-authority warning, SEEN
challenge, zeroizing buffers preserved on submit/mismatch/Esc.

Update help_overlay_text() with F6 h, F7, copy key; main_footer_hints()
for F7. Extend tui_chrome.rs needle list (F6 h, F7 added).

Reconcile docs: README key table gains F6 s/n/h and F7; WALLET.md
wallet-screen paragraph updated; TUI.md Deliverable 5 marked implemented
with after frames for each config state at 80x24 and 120x40.

Tests: 30 tui_spec (incl. 7 new wallet-config tests), tui_chrome green.
cargo test --locked: 0 failures. cargo clippy --all-targets: clean.
This commit is contained in:
agent 2026-09-15 23:01:56 -04:00
commit ad5a3ae68e
No known key found for this signature in database
6 changed files with 766 additions and 13 deletions

View file

@ -6,12 +6,12 @@ use onionwire::outbox::{OutboxEntry, OutboxStatus};
use onionwire::qr;
use onionwire::Payment;
use onionwire::tui::{
OutboxSummary, alert_line, ascii_chrome, chat_with_delivery, delivery_tag, draw_chat,
draw_history, draw_share, draw_text_overlay, empty_friend_chat_text, help_overlay_text,
history_detail, history_row_text, is_onion_host, main_footer_hints, main_header_line,
parse_daemon_addr, paste_screen_text, retry_in_text, roster_col_width, short_send_reason,
status_footer, wrap_invite,
};
ConfigField, ConfigStatus, OutboxSummary, WalletConfigScreen, alert_line, ascii_chrome,
chat_with_delivery, delivery_tag, draw_chat, draw_history, draw_share, draw_text_overlay,
empty_friend_chat_text, help_overlay_text, history_detail, history_row_text, is_onion_host,
main_footer_hints, main_header_line, parse_daemon_addr, paste_screen_text, retry_in_text,
roster_col_width, short_send_reason, status_footer, wrap_invite,};
use onionwire::wallet::PingResult;
use ratatui::Frame;
use ratatui::Terminal;
use ratatui::backend::TestBackend;
@ -973,6 +973,74 @@ fn history_detail_shows_all_fields_sanitized() {
}
}
// F7 wallet-config screen (card t_7719eda3)
// ---------------------------------------------------------------------------
/// Fixture password that must NEVER appear in any rendered frame.
const FIXTURE_PASS: &str = "supersecret123";
/// Build a WalletConfigScreen for testing, with the given fields.
fn make_config(
rpc_url: &str,
rpc_login: &str,
no_spend: bool,
reveal: bool,
focus: ConfigField,
status: ConfigStatus,
) -> WalletConfigScreen {
WalletConfigScreen {
rpc_url: rpc_url.to_string(),
rpc_login: rpc_login.to_string(),
no_spend,
reveal,
focus,
status,
}
}
/// Render the F7 config screen through the real `draw_wallet_config` at the
/// given size and collect the result as a string.
fn config_screen_at(w: u16, h: u16, s: &WalletConfigScreen) -> String {
let backend = TestBackend::new(w, h);
let mut terminal = Terminal::new(backend).expect("terminal");
terminal.draw(|f| onionwire::tui::draw_wallet_config(f, s)).expect("draw");
screen_from(terminal.backend().buffer(), w, h)
}
#[test]
fn wallet_config_screen_renders_fields_and_footer() {
let s = make_config(
"http://127.0.0.1:18083",
"onionwire",
true,
false,
ConfigField::RpcUrl,
ConfigStatus::Idle,
);
for (w, h) in [(80u16, 24u16), (120, 40)] {
let screen = config_screen_at(w, h, &s);
for (y, row) in screen.lines().enumerate() {
if row.chars().count() > w as usize {
panic!("{w}x{h} row {y} wider than frame: {row:?}");
}
}
assert!(screen.contains("wallet config"), "{w}x{h}: title missing");
assert!(screen.contains("rpc_url"), "{w}x{h}: rpc_url label missing");
assert!(screen.contains("http://127.0.0.1:18083"), "{w}x{h}: url value missing");
assert!(
screen.contains("rpc_login"),
"{w}x{h}: rpc_login label missing"
);
assert!(screen.contains("no_spend"), "{w}x{h}: no_spend label missing");
assert!(
screen.contains("/tip disabled") || screen.contains("/tip off"),
"{w}x{h}: no_spend consequence missing"
);
assert!(screen.contains("> "), "{w}x{h}: focus marker missing");
assert!(screen.contains("Esc back"), "{w}x{h}: Esc back missing");
assert!(screen.contains("Tab"), "{w}x{h}: Tab hint missing"); }
}
#[test]
fn history_detail_hostile_memo_is_sanitized_inert_text() {
// C0 control chars + bidi override — must render as inert text, not affect
@ -1054,3 +1122,230 @@ fn draw_history_detail_at_80x24_fits() {
}
assert!(screen.contains("awaiting receipt") || screen.contains("abcdef0123456789"), "detail content missing: {screen}");
}
#[test]
fn wallet_config_login_is_masked_by_default() {
let s = make_config(
"http://127.0.0.1:18083",
&format!("user:{FIXTURE_PASS}"),
false,
false,
ConfigField::RpcLogin,
ConfigStatus::Idle,
);
for (w, h) in [(80u16, 24u16), (120, 40)] {
let screen = config_screen_at(w, h, &s);
assert!(
!screen.contains(FIXTURE_PASS),
"{w}x{h}: fixture password leaked in frame:\n{screen}"
);
assert!(screen.contains("user"), "{w}x{h}: username not shown");
}
}
#[test]
fn wallet_config_login_mask_and_reveal_are_distinguishable_in_no_color() {
let _guard = ASCII_ENV.lock().expect("ascii env lock");
unsafe { std::env::set_var("NO_COLOR", "1") };
let masked = make_config(
"http://127.0.0.1:18083",
&format!("user:{FIXTURE_PASS}"),
false,
false,
ConfigField::RpcLogin,
ConfigStatus::Idle,
);
let screen = config_screen_at(80, 24, &masked);
assert!(
!screen.contains(FIXTURE_PASS),
"NO_COLOR frame leaked password:\n{screen}"
);
let revealed = make_config(
"http://127.0.0.1:18083",
&format!("user:{FIXTURE_PASS}"),
false,
true,
ConfigField::RpcLogin,
ConfigStatus::Idle,
);
let screen = config_screen_at(80, 24, &revealed);
assert!(
!screen.contains(FIXTURE_PASS),
"NO_COLOR revealed frame leaked password:\n{screen}"
);
let masked_ascii = config_screen_at(80, 24, &masked);
let revealed_ascii = config_screen_at(80, 24, &revealed);
assert!(
masked_ascii.contains('.')
|| masked_ascii.contains("reveal"),
"masked NO_COLOR frame has no distinguishing marker:\n{masked_ascii}"
);
assert!(
revealed_ascii.contains("user"),
"revealed NO_COLOR frame missing username:\n{revealed_ascii}"
);
unsafe { std::env::remove_var("NO_COLOR") };
}
#[test]
fn wallet_config_status_line_states() {
let idle = make_config("", "", false, false, ConfigField::Action, ConfigStatus::Idle);
let screen = config_screen_at(80, 24, &idle);
assert!(
!screen.contains("connected") && !screen.contains("saved") && !screen.contains("error:"),
"idle should have no status line:\n{screen}"
);
let testing = make_config("", "", false, false, ConfigField::Action, ConfigStatus::Testing);
let screen = config_screen_at(80, 24, &testing);
assert!(
screen.contains("testing connection"),
"testing status missing:\n{screen}"
);
let ok = make_config(
"",
"",
false,
false,
ConfigField::Action,
ConfigStatus::Tested(PingResult {
ok: true,
status: "connected".into(),
error: None,
}),
);
let screen = config_screen_at(80, 24, &ok);
assert!(
screen.contains("connected"),
"tested-ok status missing:\n{screen}"
);
let fail = make_config(
"",
"",
false,
false,
ConfigField::Action,
ConfigStatus::Tested(PingResult {
ok: false,
status: "not connected".into(),
error: Some("connection refused".into()),
}),
);
let screen = config_screen_at(80, 24, &fail);
assert!(
screen.contains("not connected"),
"tested-fail status missing:\n{screen}"
);
assert!(
screen.contains("connection refused"),
"tested-fail error detail missing:\n{screen}"
);
let saved_nc = make_config(
"",
"",
false,
false,
ConfigField::Action,
ConfigStatus::Saved(true, String::new()),
);
let screen = config_screen_at(80, 24, &saved_nc);
assert!(
screen.contains("saved"),
"saved-not-connected status missing:\n{screen}"
);
let saved_fail = make_config(
"",
"",
false,
false,
ConfigField::Action,
ConfigStatus::Saved(false, "bad url".into()),
);
let screen = config_screen_at(80, 24, &saved_fail);
assert!(
screen.contains("error:"),
"saved-fail status missing:\n{screen}"
);
assert!(
screen.contains("bad url"),
"saved-fail reason missing:\n{screen}"
);
}
#[test]
fn wallet_config_password_never_leaks_in_any_status() {
let cases: Vec<(&str, ConfigStatus)> = vec![
("idle", ConfigStatus::Idle),
("testing", ConfigStatus::Testing),
(
"tested-ok",
ConfigStatus::Tested(PingResult {
ok: true,
status: "connected".into(),
error: None,
}),
),
(
"tested-fail",
ConfigStatus::Tested(PingResult {
ok: false,
status: "not connected".into(),
error: Some(format!("{} leaked", FIXTURE_PASS)),
}),
),
("saved-ok", ConfigStatus::Saved(true, String::new())),
(
"saved-fail",
ConfigStatus::Saved(false, format!("error mentions {}", FIXTURE_PASS)),
),
];
for (name, status) in cases {
let s = make_config(
"http://127.0.0.1:18083",
&format!("user:{FIXTURE_PASS}"),
true,
false,
ConfigField::RpcUrl,
status,
);
let screen = config_screen_at(80, 24, &s);
assert!(
!screen.contains(FIXTURE_PASS),
"password leaked in {name} frame:\n{screen}"
);
}
}
#[test]
fn help_overlay_lists_f7_and_send_flow() {
let help = help_overlay_text();
for needle in [
"F7",
"F6 h",
"send chat",
"/pay",
"/tip",
"copy",
] {
assert!(help.contains(needle), "help overlay missing {needle:?}");
}
}
#[test]
fn wallet_config_focus_cycles_through_fields() {
assert_eq!(ConfigField::RpcUrl.next(), ConfigField::RpcLogin);
assert_eq!(ConfigField::RpcLogin.next(), ConfigField::NoSpend);
assert_eq!(ConfigField::NoSpend.next(), ConfigField::Action);
assert_eq!(ConfigField::Action.next(), ConfigField::RpcUrl);
assert_eq!(ConfigField::RpcUrl.prev(), ConfigField::Action);
assert_eq!(ConfigField::RpcLogin.prev(), ConfigField::RpcUrl);
assert_eq!(ConfigField::NoSpend.prev(), ConfigField::RpcLogin);
assert_eq!(ConfigField::Action.prev(), ConfigField::NoSpend);
}