diff --git a/docs/TUI.md b/docs/TUI.md index bfb0879..e1655d9 100644 --- a/docs/TUI.md +++ b/docs/TUI.md @@ -621,384 +621,3 @@ lands on the row that actually owns the outbox entry. and footer row is `<=` the terminal width, that the markers render, and that an over-long message wraps instead of being clipped. - Dump frames: `cargo test --locked --test tui_spec -- --nocapture dump_spec_frames`. - ---- - -## Deliverable 5 — wallet surfaces (copy + pane structure) - -Presentation-only. The base branch already owns the API on the table in plan §1.3. This deliverable names the pane on each wallet-family screen, the primary element, and the exact copy for every non-happy state. The copy table is binding: a later card must render these strings (or their ASCII/word variants), not invent new refusal text. - -### Wallet screen (`Screen::Wallet`, `draw_wallet` — `src/tui.rs:3072`) - -Layout: vertical 2-line title, a bordered body that fills the middle, 1-line action footer. - -``` -┌wallet────────────────────────┐ -└──────────────────────────────┘ -┌──────────────────────────────┐ -│address 4AdY… │ -│balance not synced — unavailable│ -│ │ -│chain │ -│chain: local monerod … │ -│daemon: stopped … │ -│sync: unknown — … │ -│storage: 412 GB free … │ -│not ready: wallet RPC … │ -│pruned nodes … │ -│ │ -│recent transfers │ -│ (none shown) │ -│ │ -│ │ -│ │ -│ │ -└──────────────────────────────┘ -s chain n start/stop c create i import r qr -``` - -Primary: address + balance + chain block. Largest element on screen. - -**Copy table** — every state the wallet screen can show (sources verified at base commit `b20313e`): - -| State | On-screen copy | Source | -|---|---|---| -| Receive-only / no wallet | address: `no address yet — /profile xmr, or create a wallet`; balance: `not synced — unavailable` | `draw_wallet` empty branch; `wallet_view` not-ready branch | -| Receive-only configured (no daemon) | chain: `chain: receive-only — no daemon, no chain traffic`; daemon: `daemon: not configured — press s to choose a chain source`; readiness: `not ready: no wallet — receive-only until c create / i import` | `chain_view` `ChainSource::None` + `WalletChildState::Off` | -| Local monerod chosen, stopped | `chain: local monerod ({bin}) — chain in {dir}`; `daemon: stopped — press n to start it` | `ChainSource::Local` + `WalletChildState::Stopped` | -| Local monerod running | `daemon: running (child owned by this app)` | `WalletChildState::Running` | -| Remote daemon | `chain: remote daemon {host}:{port}` | `ChainSource::Remote` | -| Daemon unreachable | `sync: unknown — {note}` | `DaemonSync.reachable == false` | -| Daemon reachable, syncing | `sync: syncing — {h}/{target}` | `DaemonSync` height/target | -| Daemon synced | `sync: synced — height {h}` | `DaemonSync.synced()` | -| Sync unknown (never probed) | balance: `not synced — unavailable` (never the real balance) | `wallet_view` `!chain.ready` | -| Balance ready | the real balance line (e.g. `12.5 XMR`) | `wallet_view` `chain.ready` | -| No transfers | ` (none shown)` | `draw_wallet` empty transfers branch | -| View-only | spend badge: `view-only — /tip off` (word + glyph, never color-only) | `WalletConfig.no_spend` / `VIEW_ONLY_MSG` | -| Not configured (wallet screen) | readiness: `not ready: no wallet — receive-only until c create / i import` | `WalletReadiness::NotConfigured.line()` | -| Configured, RPC down | readiness: `not ready: wallet RPC not answering — balance is not authoritative` | `WalletReadiness::NotConnected.line()` | -| Ready | readiness: `ready: wallet synced — spend and receipt verification available` | `WalletReadiness::Ready.line()` | -| `/tip` on view-only | status_note exactly: `wallet is in view-only/no-spend mode — /tip is disabled; /pay and receipt verification still work` | `wallet::VIEW_ONLY_MSG` | -| `/tip` or `/pay`, not configured | status_note exactly: `wallet not configured — open F7 to set it up, or set ONIONWIRE_WALLET_RPC` | `wallet::NOT_CONFIGURED_MSG` | -| `/tip` or `/pay`, not connected | status_note exactly: `wallet not connected — check endpoint, login, daemon` | `wallet::NOT_CONNECTED_MSG` | -| Friend has no address (`/tip`) | status_note exactly: `friend has no Monero address — they must /profile` | existing `tip` refusal (src/tui.rs:1738) | -| Address empty (both profile + RPC empty) | status_note: `no receive address — set profile xmr or ONIONWIRE_WALLET RPC` | existing `wallet_receive_address` guard | - -Action row (`src/tui.rs:3164`): `s chain n start/stop c create i import r qr` - -### Chain setup screen (`Screen::ChainSetup`, `draw_chain_setup` — `src/tui.rs:3170`) - -Overlay via `draw_text_overlay`. Three modes: - -| Mode | Title | Body | Hint | -|---|---|---|---| -| `Choose` | `chain source` | `where should the chain come from?` + 3 choices (Receive-only / Local monerod / Remote daemon) with detail lines + `receive-only needs no wallet file…` + `Up/Down choose Enter select Esc back` | `ChainChoice::ALL` order; never preselects Remote | -| `RemoteAddr` | `enter daemon address` | `daemon address, as host:port` + `e.g. 127.0.0.1:18081 or yournode.onion:18089` + `> {buf}` + error line or `Enter continues Esc goes back` | parses via `parse_daemon_addr` | -| `RemoteWarn` | `trust shift` | `use {host}:{port} for chain traffic?` + `the daemon operator sees your addresses during sync,` + `and every spend. a remote daemon is untrusted:` + `this app never passes --trusted-daemon.` + `.onion` branch: `this is a .onion host, so Tor would hide the transport.` + `it still does not hide your addresses from the operator.` + `ONION_NO_SOCKS_MSG` | `Enter saves it Esc cancels` | - -### Wallet setup screen (`draw_wallet_setup` — `src/tui.rs:3235`) - -Five overlays, all via `draw_text_overlay`. The spend-authority warning is `wallet::SPEND_AUTHORITY_WARNING` (exact, `src/wallet.rs:308`). - -| Screen | Title | Body | Exit | -|---|---|---|---| -| `CreateWarn` | `create spend wallet` | `SPEND_AUTHORITY_WARNING` + blank + `Type SPEND to confirm Esc to cancel` + `{typed}` | type SPEND / Esc | -| `CreatePass` (1st) | `wallet passphrase` | `set a passphrase for the wallet file` + `Enter continues Esc cancels` | Enter / Esc | -| `CreatePass` (2nd) | `wallet passphrase` | `re-type passphrase` + `Enter submits Esc cancels` | Enter / Esc | -| `CreatePass` mismatch | — | alert: `passphrases do not match` | alert_line | -| `CreateSeed` | `write down this seed` | `{seed}` + blank + `this is shown once. anyone with it can spend.` + `Type SEEN when you have written it down` + `{typed}` | type SEEN / Esc (zeroizes seed on Esc) | -| `ImportSeed` | `import wallet` | `paste the 25-word seed. this is the only path that takes an existing key.` + blank + `{buf}` + blank + `Enter continues Esc cancels` | Enter / Esc | -| `ImportSeed` empty | — | alert: `seed required to import a wallet` | error | -| `ImportPass` (1st) | `wallet passphrase` | `passphrase for the imported wallet file` + `Enter continues Esc cancels` | Enter / Esc | -| `ImportPass` (2nd) | `wallet passphrase` | `re-type passphrase` + `Enter submits Esc cancels` | Enter / Esc | -| `ImportPass` mismatch | — | alert: `passphrases do not match` | alert_line | -| RPC failure | — | alert: the RPC error exactly as returned | error | - -### New send/tip flow (`Screen::Send` — **new screen, spec only**) - -No screen exists yet in `src/tui.rs`. Primary: recipient + amount field + memo field + resolved atomic value + confirm action. Opens from the wallet screen and from main with a friend selected. - -| State | Copy | Source | -|---|---|---| -| No friend selected / empty recipient | action row disabled: `recipient required` | spec | -| Amount unparsed (junk / negative / >8 dp) | field error: `amount: {parse_atomic error}` | `pay::parse_atomic` | -| Amount 0 | field error: `amount must be > 0`; confirm disabled | `pay::parse_atomic` rejection | -| View-only / no-spend refusal | confirm disabled; line exactly: `wallet is in view-only/no-spend mode — /tip is disabled; /pay and receipt verification still work` | `VIEW_ONLY_MSG` | -| Not configured refusal | confirm disabled; line exactly: `wallet not configured — open F7 to set it up, or set ONIONWIRE_WALLET_RPC` | `NOT_CONFIGURED_MSG` | -| Friend has no address | line exactly: `friend has no Monero address — they must /profile` | existing `tip` guard | -| Amount too large for RPC | line: the overflow error from `pay::xmr_to_atomic` | `pay::xmr_to_atomic` | -| Address fails checksum | the address-check error verbatim | `pay::check_address` | -| Sending | status_note: `sending` | existing flow | -| Sent | status_note: `tip sent` (tip) / `invoice sent` (pay) | existing | -| Send failed | status_note: `send failed: {short}` (`! ` when colour off) | `short_send_reason` | -| Esc | no side effect; return to wallet screen | spec | - -Spend badge visible on this screen (a view-only wallet cannot reach confirm). Same badge as the wallet screen: `view-only — /tip off`. - -### New payment history (`Screen::History` — **new screen; API gap**) - -`Node::list_payments(friend_pk)` exists at `src/node.rs:520` and returns `Vec`. The `Payment` struct (`src/store.rs:94`): - -``` -pub struct Payment { - pub id: i64, // store row id - pub dir: String, // "in" | "out" - pub kind: String, // "tip" | "invoice" | "payment" - pub amount_atomic: String, - pub address: String, - pub memo: String, - pub txid: Option, - pub verified: bool, - pub created_at: i64, // unix secs -} -``` - -Row copy (derived from `Payment`): - -| State | Copy | Source | -|---|---|---| -| Empty history | `no payments with this friend yet` | spec (designed, never blank) | -| Outbound, verified | `> {amount} XMR ✓ verified {age}` | `pay::atomic_to_xmr_str` + `Payment.verified` | -| Outbound, unverified | `> {amount} XMR unverified {age}` | word + glyph, never color-only | -| Inbound | `< {amount} XMR {verified/unverified} {age}` | `dir == "in"` | -| No txid | line: `awaiting receipt` | `Payment.txid == None` | -| Long memo | wrap or truncate with `…`/`...` after `sanitize::display_text` | sanitize first | -| Hostile memo (control chars + bidi) | sanitized before draw | `sanitize::display_text` | -| Detail view — txid absent | `txid: awaiting receipt` | `Payment.txid == None` | - -Amount is displayed via `pay::atomic_to_xmr_str(&t.amount_atomic)` (`src/pay.rs:144`) — never raw piconero. - -### New F7 wallet-config screen (`Screen::WalletConfig` — **spec only**) - -The base branch owns `WalletConfig` (`src/wallet.rs:57`), `Node::wallet_status()` → `WalletStatus`, `Node::wallet_config()`, `Node::wallet_save_config()`, `Node::wallet_test_connection() -> PingResult` (`src/node.rs:520+`). There is **no** `Screen::WalletConfig` or `draw_wallet_config` in `src/tui.rs` — confirmed by grep. This is the screen to build. - -Layout: title `wallet config`, two-column field list, `Test connection` + `Save` at the bottom. - -| State | Copy | Source | -|---|---|---| -| Not configured | `wallet not configured — set rpc_url` | spec | -| rpc_url empty, Test pressed | `rpc_url required` | `WalletConfig::from_config` error | -| rpc_login masked (default) | `rpc_login: •••••••` | `WalletConfig::secret()` redaction | -| rpc_login revealed | `rpc_login: {user}:{mask}` | reveal toggle; real password never printed | -| Test connecting | `testing connection …` (no spinner) | `PingResult` in flight | -| Test OK | `connected — {PingResult::line()}` | `PingResult::line()` | -| Test failed | `error: {short}` (sanitized, never the login) | `Wallet::sanitize` / `redact` | -| Save success, not connected | `saved · not connected` | spec | -| Save success, connected | `connected · {PingResult::line()}` | spec | -| Save failure | `error: {short}` | sanitized | -| no_spend off | `spend on — /tip enabled` | word + glyph | -| no_spend on | `view-only — /tip off` | word + glyph | - -Masking rule: `WalletConfig::secret()` (`src/wallet.rs:79`) exists for redaction. The fixture password must not appear in any rendered frame, status note, alert, or help string. The toggle is distinguishable in `NO_COLOR` by the word `•••••••` vs the user, not by color alone. - -### Copy rules for every wallet surface - -1. Refusal text is the existing string from `wallet.rs` / `Node` — never invent a softer version. -2. Spend badge is always word + glyph (`view-only — /tip off`; `spend on`). Never color-only. -3. Addresses from a friend's profile are peer-supplied — pass through `sanitize::display_text` before draw. -4. Memos are peer-supplied — sanitize first, then wrap/truncate with ellipsis. -5. Empty states are designed copy, not blank panes. -6. Fail-closed status notes (`send failed`, `fingerprint mismatch`, view-only refusal) keep the `! ` prefix when colour is off (`src/tui.rs:64`). - ---- - -## Deliverable 6 — visual identity v2 - -This replaces palette values, glyph fallbacks, spacing, and focus rules. It does **not** add hues. The locked helper names and strings in `tests/tui_chrome.rs` survive. - -### Color palette - -The palette lives as RGB constants in `src/tui.rs:21-27`, each with an ANSI16 fallback via `style_fg()` / `style_accent()` / `style_highlight()`. `NO_COLOR` (`ColorMode::None`) drops fg entirely and uses bold/reverse for accent/highlight. - -| Role | RGB (current) | ANSI16 fallback | `NO_COLOR` treatment | Where | -|---|---|---|---|---| -| accent | `Rgb(232, 165, 75)` | `Yellow` | bold | titles, focus marks, QR border | -| text | `Rgb(196, 214, 176)` | `White` | plain | body copy, chat, address/balance | -| dim | `Rgb(98, 110, 92)` | `DarkGray` | plain | action row, hints, help | -| alert | `Rgb(220, 80, 70)` | `Red` | `! ` prefix | fail-closed, view-only refusal | -| stale | `Rgb(210, 180, 80)` | `Yellow` | plain + `stale` text | stale roster suffix | -| highlight bg | `Rgb(48, 42, 28)` | `Reverse` | reverse | focused roster row | -| border | `Rgb(72, 84, 64)` | `DarkGray` | plain | pane borders | - -`style_highlight()` (`src/tui.rs:379`) uses bold + reverse for NO_COLOR. `style_accent()` (`src/tui.rs:351`) uses bold for NO_COLOR. `style_fg()` (`src/tui.rs:343`) drops fg entirely for NO_COLOR. - -**No change to these six values on this card.** Deliverable 6 is the *specification* of how they apply to the wallet surfaces — not a recolor. - -### Glyph set (use → unicode → ASCII fallback) - -| Glyph | Unicode | ASCII | Cell width (unicode) | Where | -|---|---|---|---|---| -| onion / share | `(o)` | `(o)` | 3 | title (locked) | -| focus | `> ` | `> ` | 2 | focused pane title / roster | -| truncate | `…` | `...` | 1 | `truncate_chars` tail | -| box (border) | `─ │ ┌ ┐ └ ┘` | `+ - |` | 1 each | ratatui `Block::borders` | -| alert prefix | `! ` | `! ` | 2 | fail-closed (`src/tui.rs:64`) | -| stale | word `stale` | `stale` | 5 | roster suffix | -| delivered | `✓` | `ok` | 1 | delivery marker | -| queued | `◷` | `queued` (word) | 1 | delivery marker | -| sending | `»` | `sending` (word) | 1 | delivery marker | -| failed | `✗` | `failed` (word) | 1 | delivery marker | -| bullet (masked) | `•` | `·` | 1 | password mask | - -Glyphs are never color-only. ASCII mode (triggered by `ONIONWIRE_ASCII=1` or `NO_COLOR=1`) swaps all unicode glyphs per the table. `delivery_glyph()` (`src/tui.rs:138`) and `tests/tui_spec.rs::delivery_markers_have_exercised_ascii_fallbacks` exercise the fallback. - -### Spacing unit - -**1 cell.** All internal padding is a single space after the label: `address {value}`, `balance {value}`, `chain: {detail}`. A single blank `String::new()` row separates blocks. Pane borders add no inner pad on the title line. - -### Focus rules per pane - -- Main: roster > chat > composer. Focused title gets `> ` prefix + bold; unfocused gets ` `. -- Wallet: body block (address/balance/chain/transfers) is primary; action row is dim, never bold. No in-body focus — keys drive navigation. -- Overlays (chain setup, wallet setup, send, history, F7): full-screen, Escape returns. The active field gets `> ` prefix. -- Focus is never color-only. `NO_COLOR` keeps bold/reverse and the `> `/` ` prefix. - -### Pane structure per wallet-family screen - -| Screen | Panes (top → bottom) | -|---|---| -| Wallet (`draw_wallet`) | title `wallet` (2 rows) / body border (fill) / action row (1 row) | -| `draw_wallet` body | address line / balance line / blank / `chain` header / 5 chain lines / PRUNED_NOTE wrapping / blank / `recent transfers` / transfer rows or `(none shown)` / remaining blank | -| Chain setup (`draw_chain_setup`) | single overlay, full-screen | -| Wallet setup (`draw_wallet_setup`) | single overlay, full-screen | -| Send flow | **to spec** — single overlay, full-screen | -| Payment history | **to spec** — single overlay, full-screen | -| F7 config | **to spec** — single overlay, full-screen | - -`WALLET_LINE_MAX` = 76 (`src/tui.rs:1169`). Every chain line is `truncate_chars(&line, WALLET_LINE_MAX)` (`src/tui.rs:1373`). - ---- - -## Before frames (identity v1) - -Real `draw_wallet` frames from the base branch at `b20313e`, rendered via `TestBackend` at 80x24. The dump test (`tests/tui_wallet_dump.rs`) was a throwaway — removed after capture, touches no `src/`. Trailing spaces omitted. - -### Wallet screen — not-ready / daemon stopped (80x24) - -``` -┌wallet────────────────────────────────────────────────────────────────────────┐ -└──────────────────────────────────────────────────────────────────────────────┘ -┌──────────────────────────────────────────────────────────────────────────────┐ -│address 4AdYaG7wVQ3nHvWoXbN9dQkXj1uYcR2mS8pT5LzE6fK7gD │ -│balance not synced — unavailable │ -│ │ -│chain │ -│chain: local monerod (monerod) — chain in /home/user/.onionwire/chain │ -│daemon: stopped — press n to start it │ -│sync: unknown — 127.0.0.1:18081: Connection refused (os error 111) │ -│storage: 412 GB free here — pruned mainnet wants ~50-60 GB, a full node ~20… │ -│not ready: wallet RPC not answering — balance is not authoritative │ -│pruned nodes are not archives: a deep seed restore can degrade. once this │ -│wallet has scanned, its own cache is the history │ -│ │ -│recent transfers │ -│ (none shown) │ -│ │ -│ │ -│ │ -│ │ -│ │ -└──────────────────────────────────────────────────────────────────────────────┘ -s chain n start/stop c create i import r qr -``` - -### Wallet screen — receive-only (80x24) - -``` -┌wallet────────────────────────────────────────────────────────────────────────┐ -└──────────────────────────────────────────────────────────────────────────────┘ -┌──────────────────────────────────────────────────────────────────────────────┐ -│address no address yet — /profile xmr, or create a wallet │ -│balance not synced — unavailable │ -│ │ -│chain │ -│chain: receive-only — no daemon, no chain traffic │ -│daemon: not configured — press s to choose a chain source │ -│sync: unknown — receive-only: no daemon │ -│storage: nothing stored on this device │ -│not ready: no wallet — receive-only until c create / i import │ -│pruned nodes are not archives: a deep seed restore can degrade. once this │ -│wallet has scanned, its own cache is the history │ -│ │ -│recent transfers │ -│ (none shown) │ -│ │ -│ │ -│ │ -│ │ -│ │ -└──────────────────────────────────────────────────────────────────────────────┘ -s chain n start/stop c create i import r qr -``` - -### Wallet screen — ready / synced (80x24) - -``` -┌wallet────────────────────────────────────────────────────────────────────────┐ -└──────────────────────────────────────────────────────────────────────────────┘ -┌──────────────────────────────────────────────────────────────────────────────┐ -│address 4AdYaG7wVQ3nHvWoXbN9dQkXj1uYcR2mS8pT5LzE6fK7gD │ -│balance 12.5 XMR │ -│ │ -│chain │ -│chain: local monerod (monerod) — chain in /home/user/.onionwire/chain │ -│daemon: running (child owned by this app) │ -│sync: synced — height 3210000 │ -│storage: 412 GB free here — pruned mainnet wants ~50-60 GB, a full node ~20… │ -│ready: wallet synced — spend and receipt verification available │ -│pruned nodes are not archives: a deep seed restore can degrade. once this │ -│wallet has scanned, its own cache is the history │ -│ │ -│recent transfers │ -│ (none shown) │ -│ │ -│ │ -│ │ -│ │ -│ │ -└──────────────────────────────────────────────────────────────────────────────┘ -s chain n start/stop c create i import r qr -``` - -### Wallet screen — ready / synced (120x40) - -Wider: the truncated storage line reads in full — `…a full node ~200 GB` — and the body block has 27 rows of empty space. - -``` -┌wallet────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐ -└──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘ -┌──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐ -│address 4AdYaG7wVQ3nHvWoXbN9dQkXj1uYcR2mS8pT5LzE6fK7gD │ -│balance 12.5 XMR │ -│ │ -│chain │ -│chain: local monerod (monerod) — chain in /home/user/.onionwire/chain │ -│daemon: running (child owned by this app) │ -│sync: synced — height 3210000 │ -│storage: 412 GB free here — pruned mainnet wants ~50-60 GB, a full node ~200 GB │ -│ready: wallet synced — spend and receipt verification available │ -│pruned nodes are not archives: a deep seed restore can degrade. once this wallet has scanned, its own cache is the │ -│history │ -│ │ -│recent transfers │ -│ (none shown) │ -│ │ -│ │ -│ │ -│ │ -│ │ -└──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘ -s chain n start/stop c create i import r qr -``` - ---- - -## Evidence - -- `TMPDIR=/var/tmp/onionwire-tui-tmp` set for all compile steps (§1.5 disk-quota trap on `/tmp`). -- `cargo test --locked --test tui_frames -- --nocapture dump_audit_frames` — ok. -- `cargo test --locked --test tui_spec -- --nocapture dump_spec_frames` — ok. -- Wallet screen assertion tests: `wallet_screen_says_not_ready_and_never_a_balance_before_sync`, `wallet_screen_says_receive_only_when_nothing_is_configured`, `wallet_screen_keeps_the_balance_when_the_wallet_is_ready`, `a_view_only_wallet_says_so_instead_of_offering_a_spend` — all green. -- `ChainChoice::ALL.len() == 3` (three choices, never a public node) — asserted. -- `status_footer` keeps `send failed`, `TOR`, `me:`, `? help` at 80 and 120 — asserted by `status_footer_drops_send_failed_when_crowded`. -- `chars().count() <= width` on all locked public copy — asserted by `public_copy_fits_80_by_chars_count`.