diff --git a/docs/tui-wallet-ux-review.md b/docs/tui-wallet-ux-review.md new file mode 100644 index 0000000..644ad76 --- /dev/null +++ b/docs/tui-wallet-ux-review.md @@ -0,0 +1,1079 @@ +# TUI wallet surfaces: presentation and flow review + +Audit of the wallet screens as they render at `a1f5c878` (main). Report only — +no source file was changed by this review. Frames below are the real render +path unless the caption says RECONSTRUCTED; see **Method** and **Not examined**. + +## Summary + +The two wallet screens the user is most likely to reach first are the two that +do not render: a fresh install opens on the create-spend-wallet confirmation, and +pressing `F6` on that install exits the process with a one-line error. At the +width where wallets are actually named — `F6` then `w` — the flow is good: a +designed empty state, a designed failed-read state, fixed columns measured in +terminal cells, and the create row always last. Two structural faults account for +most of what is wrong here: `draw_wallet` gives its body pane `Constraint::Length(2)` +inside a full border (so the wallet data is never drawn at any width), and +`draw_text_overlay` pins every long body to its **tail** (so the SPEND warning, +the seed, the offset notice and the help overlay all lose their first lines). +Everything below the crash is copy and ordering, not architecture. + +## Method + +* Widths are terminal **cells**, via `onionwire::tui::cell_width` (`Span::width`, + `src/tui.rs:3895`) — never `chars().count()`. The dump helper asserts + `cells <= width` on every row of every frame below. +* Sizes: 80x24 (floor), 120x40 (target), 200x60. A frame is shown at each width + where the behaviour differs. +* The F6 wallet screen and the setup overlays are private (`draw_wallet` + `src/tui.rs:5277`, `draw_wallet_setup` `src/tui.rs:5386`), so their frames are + **RECONSTRUCTED** by a scratch driver that copies the layout constants and the + copy from those two functions verbatim, and draws through the real public + `draw_text_overlay`. The card forbids changes under `tests/`, so this driver is + not committed; its source and the raw dump are attached to the task and the + follow-up should add them to `tests/tui_frames.rs` as labelled dumps. + Everything marked **REAL** calls the shipped public render path + (`draw_wallet_select`, `draw_wallets_settings`, `draw_text_overlay`, + `status_footer_phased`) with the same footers `App::draw` builds. +* Styling (colour, weight) does not appear in a text dump. Tone claims below are + read from the `style_*` call sites, and are labelled as such. + +## Frames + +### 1. First run — what a fresh install sees (`App::new`, `src/tui.rs:1387-1390`) + +`list_wallets()` returning empty selects `Screen::WalletSetup(WalletSetup::CreateWarn)`, +drawn by `draw_wallet_setup` (`src/tui.rs:5388-5394`) through `draw_text_overlay`. + + +**RECONSTRUCTED — first run, `create spend wallet`, 80x24, nothing typed** + +``` + + + + + + + + + + ┌create spend wallet─────────────────────────────────────────────────────────┐ + │trust. │ + │ │ + │Type SPEND to confirm Esc to cancel │ + └────────────────────────────────────────────────────────────────────────────┘ + + + + + + + + + + + +``` + + +At the floor the whole warning is one word: `trust.` The popup has three inner +rows and the body wraps to four, so `draw_text_overlay`'s +`scroll = wrapped - inner_h` (`src/tui.rs:3820`) drops the head — which is where +the sentence that says what this wallet can do lives. + +**RECONSTRUCTED — first run, 120x40, nothing typed** + + +``` + + + + + + + + + + + + + + + + + + ┌create spend wallet─────────────────────────────────────────────────────────────────────────────────────────────────┐ + │do not leave it on a box you do not trust. │ + │ │ + │Type SPEND to confirm Esc to cancel │ + └────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘ + + + + + + + + + + + + + + + + + + + +``` + + +Still one sentence: `do not leave it on a box you do not trust.` + +**RECONSTRUCTED — first run, 200x60, nothing typed** + + +``` + + + + + + + + + + + + + + + + + + + + + + + + + + + + ┌create spend wallet────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐ + │this wallet file can spend. anyone with its passphrase or the RPC creds can move the balance. write down the seed. do not leave it on a box you do not trust. │ + │ │ + │Type SPEND to confirm Esc to cancel │ + └───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +``` + + +The warning only reads in full at 200 columns, where it happens to fit one row. +Nothing in the frame says the install has no wallet, or that this screen is a +dead end other than `Esc`. + +**RECONSTRUCTED — first run, 80x24, `SPEN` typed (before the gate opens)** + + +``` + + + + + + + + + + ┌create spend wallet─────────────────────────────────────────────────────────┐ + │trust. │ + │ │ + │Type SPEND to confirm Esc to cancel │ + │SPEN │ + └────────────────────────────────────────────────────────────────────────────┘ + + + + + + + + + + +``` + + +The typed buffer is echoed one row lower, unlabelled: the frame shows `SPEN` with +no prompt saying what is being collected. Accepting the gate is +case-insensitive (`handle_wallet_setup`, `src/tui.rs:2440-2448`), so `spend` +works too, and the frames give no hint of that. + +### 2. The F6 wallet screen with nothing configured + +`open_wallet` (`src/tui.rs:2022-2033`) asks `Node::wallet_receive_address` first; +on an install with no profile `xmr` and no `ONIONWIRE_WALLET_RPC` that call +returns `Err("no receive address — set profile xmr or ONIONWIRE_WALLET_RPC")` +(`src/node.rs:1322`, `:1345`). The key handler propagates it +(`FunctionKey::Wallet => self.open_wallet()?`, `src/tui.rs:1504`), the event loop +propagates it (`run`, `src/tui.rs:1438`), and `main` prints and exits +(`src/main.rs:30`). **The screen below is therefore not reachable at HEAD** — it +is what the same function draws whenever the address read *does* succeed, which +is why it is shown: it is the frame a user gets on any install that has a wallet +configured. + +**RECONSTRUCTED — F6 wallet, unconfigured (address empty, balance `off`), 80x24** + + +``` +┌wallet────────────────────────────────────────────────────────────────────────┐ +└──────────────────────────────────────────────────────────────────────────────┘ + + + + + + + + + + + + + + + + +┌──────────────────────────────────────────────────────────────────────────────┐ +└──────────────────────────────────────────────────────────────────────────────┘ +s start child x stop child p probe c create i import r qr Esc back + + + + +``` + + +**RECONSTRUCTED — F6 wallet, unconfigured, 120x40** + + +``` +┌wallet────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐ +└──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +┌──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐ +└──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘ +s start child x stop child p probe c create i import r qr Esc back + + + + +``` + + +**RECONSTRUCTED — F6 wallet, connected (address, balance and one transfer), 200x60** + + +``` +┌wallet────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐ +└──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +┌──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐ +└──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘ +s start child x stop child p probe c create i import r qr Esc back + + + + +``` + + +All three frames are the same screen: an empty `wallet` title box, a blank field, +a second empty box, one help line. `draw_wallet` renders the body — `address`, +`balance`, `recent transfers` — into `cols[2]`, and the layout at +`src/tui.rs:5327-5333` gives `cols[2]` `Constraint::Length(2)`. With +`Borders::ALL` (`src/tui.rs:5379`) that is zero inner rows, so the paragraph is +never drawn: address, balance, transfers and the child line are all invisible, at +every size, configured or not. The `Min(4)` row and the trailing `Length(1)` row +are never rendered into. + +### 3. `F6` then `w` — the wallet list (REAL) + + +**REAL — `draw_wallet_select`, empty list (`WalletSelectState::from_rows(vec![])`), 80x24** + +``` +┌(o) wallets───────────────────────────────────────────────────────────────────┐ +│ no saved wallets yet │ +│ create one to get an identity and an onion address │ +│ │ +│ │ +│ │ +│ │ +│> + create new wallet │ +│ │ +│ │ +│ │ +│ │ +│ │ +│ │ +│ │ +│ │ +│ │ +│ │ +│ │ +│ │ +│ │ +│ │ +└──────────────────────────────────────────────────────────────────────────────┘ +✓ TOR ready me:abcdef01… onion:abcdefgh… Esc back j k select Enter open ? help + +``` + + +The one row the card asks about is `> + create new wallet`, last, marked and +bold. The state above it is designed copy, not a blank pane. + +**REAL — `draw_wallet_select`, two saved wallets (one unlabelled, one unpublished), 120x40** + + +``` +┌(o) wallets · 2 saved─────────────────────────────────────────────────────────────────────────────────────────────────┐ +│ name identity locator since │ +│> spend 9f2c41ab… abcdefgh… 2026-09-21 │ +│ (unlabelled) - - unknown │ +│ │ +│ id 9f2c41ab8d7e0f13a5b6c7d8e9f0a1b2c3d4e5f60718293a4b5c6d7e8f90a1b2 │ +│ onion abcdefghijklmnopqrstuvwxyz234567abcdefghijklmnopqrstuvwx │ +│ │ +│ + create new wallet │ +│ │ +│ │ +│ │ +│ │ +│ │ +│ │ +│ │ +│ │ +│ │ +│ │ +│ │ +│ │ +│ │ +│ │ +│ │ +│ │ +│ │ +│ │ +│ │ +│ │ +│ │ +│ │ +│ │ +│ │ +│ │ +│ │ +│ │ +│ │ +│ │ +└──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘ +✓ TOR ready me:abcdef01… onion:abcdefghijklmnopqrstuvwxyz234567abcdefghijklmnopqrstuvwx.onion Enter open ? help + +``` + + +**REAL — `draw_wallet_select`, failed read (`WalletSelectState::error`), 80x24** + + +``` +┌(o) wallets───────────────────────────────────────────────────────────────────┐ +│ could not read saved wallets │ +│ no wallet store: database is locked by another process │ +│ │ +│ │ +│ │ +│ │ +│> + create new wallet │ +│ │ +│ │ +│ │ +│ │ +│ │ +│ │ +│ │ +│ │ +│ │ +│ │ +│ │ +│ │ +│ │ +│ │ +└──────────────────────────────────────────────────────────────────────────────┘ +✓ TOR ready me:abcdef01… onion:abcdefgh… Esc back j k select Enter open ? help + +``` + + +**REAL — `draw_wallet_select`, read in flight (`WalletSelectState::reading()`), 80x24** + + +``` +┌(o) wallets───────────────────────────────────────────────────────────────────┐ +│ reading saved wallets │ +│ one moment │ +│ │ +│ │ +│ │ +│ │ +│> + create new wallet │ +│ │ +│ │ +│ │ +│ │ +│ │ +│ │ +│ │ +│ │ +│ │ +│ │ +│ │ +│ │ +│ │ +│ │ +└──────────────────────────────────────────────────────────────────────────────┘ +✓ TOR ready me:abcdef01… onion:abcdefgh… Esc back j k select Enter open ? help + +``` + + +### 4. The create-spend-wallet warning frame + +The warning frame is frame 1: same function, same body, `src/tui.rs:5388-5394`. +Judged as a security gate at the moment of commitment: + +* **Unmissable**: yes. It owns the whole screen, the gate is a typed word, and + `SPEND` is stated on the frame (`Type SPEND to confirm Esc to cancel`). +* **A wall?** Only in the sense that its content is not readable: at 80x24 and + 120x40 the user confirms a warning they cannot see (finding 2). +* **The confirmation affordance**: the accepted word is on the frame, and the + typed echo is visible (`SPEN` above). It does not say the word is + case-insensitive, and it does not gate on the buffer being complete before + entering it — the transition fires on the last letter + (`src/tui.rs:2443`), which is the right behaviour for a typed gate. +* **Do not weaken it.** The warning text, the `type SPEND` gate, the seed's + `type SEEN` acknowledgement and the offset notice that `Esc` must not dismiss + (`handle_wallet_setup`, `src/tui.rs:2410-2415`) are deliberate. Finding 2 is a + rendering bug, not a request to shorten any of it. + +Supporting frame, same overlay idiom, same fault: + +**RECONSTRUCTED — `write down this seed`, 80x24 (25-word BIP39 test vector)** + + +``` + + + + + + + + + + ┌write down this seed────────────────────────────────────────────────────────┐ + │abandon abandon abandon abandon abandon abandon about │ + │ │ + │this is shown once. anyone with it can spend. │ + │Type SEEN when you have written it down │ + └────────────────────────────────────────────────────────────────────────────┘ + + + + + + + + + + +``` + + +Six words of twenty-five. The popup clips the seed to its last wrapped row. + +**RECONSTRUCTED — `write down this seed`, 200x60** + + +``` + + + + + + + + + + + + + + + + + + + + + + + + + + + + ┌write down this seed────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐ + │about │ + │ │ + │this is shown once. anyone with it can spend. │ + │Type SEEN when you have written it down │ + └────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +``` + + +At 200 columns the seed is 197 cells and the popup's inner width is 196, so it +wraps to two rows, the box shows four, and the scroll drops row one: the frame +reads `about` alone. A user who writes down what they can see writes down one +word. Same mechanism at every width, for `import seed`, `seed offset passphrase` +and `offset not saved` (`src/tui.rs:5403-5441`). + +### 5. The F9 WALLETS & SETTINGS menu (REAL) + +`menu_groups` (`src/tui.rs:3970`) builds **seventeen** rows — nine under WALLET +(`endpoint`, `child`, `sync`, `receive`, `balance`, `transfers`, `payments`, +`create`, `import`) and eight under SETTINGS (`nickname`, `profile`, `identity`, +`colour`, `backup`, `restore`, `wipe`, `wipe-all`). The card's brief says eleven; +the tree says seventeen. + +**REAL — `draw_wallets_settings`, unconfigured, 80x24** + + +``` +┌(o) wallets & settings────────────────────────────────────────────────────────┐ +│WALLET ───────────────────────────────────────────────────────────────────────│ +│ endpoint not configured · receive-only │ +│ child receive-only · not started F6 s/x│ +│ sync not probing · no chain source F6 p│ +│ receive no address yet · wallet unreachable │ +│ balance off F6│ +│ transfers no transfers yet F6│ +│ payments no friend selected │ +│ create /wallet create · seed shown once F6 c│ +│ import /wallet import · 25-word seed F6 i│ +│ │ +│SETTINGS ─────────────────────────────────────────────────────────────────────│ +│ nickname (none) /profile│ +│ profile bio unset · xmr unset /profile│ +│ identity abcdef01… · identity = pubkey F2│ +│ colour auto · follows NO_COLOR / TERM │ +│ backup encrypted identity export /backup│ +│ restore overwrite self keys from a backup /restore│ +│ wipe messages · identity and friends stay /wipe│ +│ wipe-all deletes your identity key · new person /wipe-all│ +│ │ +└──────────────────────────────────────────────────────────────────────────────┘ +✓ TOR ready me:abcdef01… onion:abcdefgh… Esc back c copy ? help + +``` + + +**REAL — `draw_wallets_settings`, configured and connected, 120x40** + + +``` +┌(o) wallets & settings────────────────────────────────────────────────────────────────────────────────────────────────┐ +│WALLET ───────────────────────────────────────────────────────────────────────────────────────────────────────────────│ +│ endpoint configured · connected │ +│ child local node · running F6 s/x│ +│ sync chain at tip · wallet answering F6 p│ +│ receive 4AdUndXHHZ6cfufTMvppY6JwXNouMBzSkbLYfpAV5Usx3skxNgYeYJKUGVktfzxayYmZreZ3Gvd1AAb1d1EU7oFyJX8… c copy F6 r│ +│ balance 12.500000000000 F6│ +│ transfers 3 recent F6│ +│ payments 4 with alice p│ +│ create /wallet create · seed shown once F6 c│ +│ import /wallet import · 25-word seed F6 i│ +│ │ +│SETTINGS ─────────────────────────────────────────────────────────────────────────────────────────────────────────────│ +│ nickname lance /profile│ +│ profile bio set · xmr set /profile│ +│ identity abcdef01… · identity = pubkey F2│ +│ colour auto · follows NO_COLOR / TERM │ +│ backup encrypted identity export /backup│ +│ restore overwrite self keys from a backup /restore│ +│ wipe messages · identity and friends stay /wipe│ +│ wipe-all deletes your identity key · new person /wipe-all│ +│ │ +│ │ +│ │ +│ │ +│ │ +│ │ +│ │ +│ │ +│ │ +│ │ +│ │ +│ │ +│ │ +│ │ +│ │ +│ │ +│ │ +└──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘ +✓ TOR ready me:abcdef01… onion:abcdefghijklmnopqrstuvwxyz234567abcdefghijklmnopqrstuvwx.onion Esc back c copy ? help + +``` + + +Scanning order is right: capability group first, then the identity/settings +group, with the wallet's own `transfers` and the peer-scoped `payments` kept +distinct and worded differently. Three rows carry no key at all (`endpoint`, +`receive` when empty, `colour`), and the value column truncates in cells with an +ellipsis so no row wraps or pushes its key off the row. + +### 6. Empty and error states + +Every distinct "nothing here yet" / "that failed" string the wallet surfaces can +render, and where it lands: + +| string | surface | tone | source | +|---|---|---|---| +| `no saved wallets yet` + `create one to get an identity and an onion address` | `F6`→`w`, no rows | dim | `src/tui.rs:5003-5007` | +| `could not read saved wallets` + the reason | `F6`→`w`, read failed | alert | `src/tui.rs:4990-4995` | +| `reading saved wallets` + `one moment` | `F6`→`w`, in flight | dim | `src/tui.rs:4996-5001` — unreachable, see finding 11 | +| `(none)` | `F6` body, no transfers | text | `src/tui.rs:5366` — never drawn, see finding 1 | +| `no address` | `F6` body, address empty | text | `src/tui.rs:5344` — never drawn | +| `(qr error)` | `F6`, QR modal | text | `src/tui.rs:5306` | +| `no transfers yet` | `F9`, `transfers` row | dim | `src/tui.rs:4042` | +| `no address yet · wallet unreachable` | `F9`, `receive` row | dim | `src/tui.rs:4018` | +| `off` | `F9`, `balance` row | dim | `src/node.rs:1092` | +| `err` | `F9`, `balance` row | alert | `src/node.rs:1096` | +| `not configured · receive-only` | `F9`, `endpoint` row | dim | `src/tui.rs:3972` | +| `configured · not connected` | `F9`, `endpoint` row | stale | `src/tui.rs:3976` | +| `child exited` | `F9`, `sync` row | alert | `src/tui.rs:4002` | +| `not probing · no chain source` | `F9`, `sync` row | dim | `src/tui.rs:4003` | +| `no friend selected` | `F9`, `payments` row / status note | dim / text | `src/tui.rs:4060`, `2106` | +| `history unreadable · ` | `F9`, `payments` row | — | `src/tui.rs:4064` | +| `no history with ` | `F9`, `payments` row | dim | `src/tui.rs:4065` | +| `-` (empty identity/locator cell) | `F6`→`w` row | dim | `src/tui.rs:5064-5079` | +| `(unlabelled)` (NULL name) | `F6`→`w` row | row style | `src/tui.rs:5056-5063` | +| `unknown` (no creation date) | `F6`→`w` row | dim | `src/tui.rs:4864` | +| `no receive address to copy` | status line, `c` on `F9` | text | `src/tui.rs:2216` | +| `could not write the clipboard sequence` | status line | text | `src/tui.rs:2227`, `:2247` | +| `no receive address — set profile xmr or ONIONWIRE_WALLET_RPC` | **process exit** | — | `src/node.rs:1322`, `:1345` | +| `the saved wallets changed — reopen the list` | `alert` | alert | `src/tui.rs:2187` | +| `wallet