# OnionWire TUI — visual audit and design spec This card does not change `src/`. Frames come from: ``` cargo test --locked --test tui_frames -- --nocapture dump_audit_frames ``` `tests/tui_chrome.rs` still locks helper **names** and **return strings**. Implementation must keep `wordmark_banner`, `compact_banner`, `banner_for_width`, `onion_glyph`, `status_footer`, `main_footer_hints`, `help_overlay_text`, `draw_share`, and `Pane` working. Add helpers; do not rename those. ## Gaps (could not render the live `App` frame) `App`, `App::draw`, `App::draw_main`, and every overlay except `draw_share` are private and need `Arc` (Arti + store). This presentation-only test cannot construct that. | Screen / state | What you get | Why | |---|---|---| | Main chat (empty, messages, long line, stale roster, alert) | **RECONSTRUCTED** at the time of the audit; since the clean-look redesign (`draw_main_chrome`) it is **REAL** — see “Clean-look chrome redesign” below | `App` private | | Help / `/who` overlay | **RECONSTRUCTED** — Rect math copied from private `draw_text_overlay` | private | | Share / invite | **REAL** `draw_share` | public | | Profile, paste, approve, rotate, wipe, quit, backup, restore, passphrase | **RECONSTRUCTED** — public `*_screen_text` / `ProfileEditor` copy inside `Block::bordered`, titles taken from `src/tui.rs` | private `draw_*` | | Pay / invoice / file transfer | **No screen exists.** Footer `status_note` only (`invoice sent`, `sending`, `sent file {name}`, `send failed: {e}`) | not a gap in the test — a product finding | | Tor bootstrap / disconnected HS | Not a TUI screen. `hs status: Bootstrapping` is stderr before `ratatui::init` | out of TUI draw | | Color / `NO_COLOR` | Glyph dumps only. Color findings are from reading `src/tui.rs` | TestBackend prints symbols | Color, focus-by-border, and RGB-only styling are invisible in these dumps. Treat the reconstruction as the glyph skeleton, not a screenshot of Color. ## Deliverable 1 — before frames Trailing spaces in the live buffer are omitted here. Re-run the command for byte-identical dumps, including 120x40 and 200x60. ### 80x24 — chrome (`banner_for_width` + `status_footer`, real helpers) ``` .-~~-. .-~~-. .-~~-. ONIONWIRE ( o )( o )( o ) identity = pubkey onion = locator `-..-' `-..-' `-..-' tor messenger no server TOR me:abcdef01… onion:abcdefgh… Tab F2 F3 F4 F5 Ctrl-Q ? help ``` Same footer with `status_note = "send failed: connection timed out"` — the note **does not appear**. Ident + hints win. Fail-closed copy is gone at 80 and at 120 (full onion eats the row). It only survives at 200. ### 80x24 — RECONSTRUCTED main, empty ``` .-~~-. .-~~-. .-~~-. ONIONWIRE ( o )( o )( o ) identity = pubkey onion = locator `-..-' `-..-' `-..-' tor messenger no server ┌roster 0───────────────────┐┌chat─────────────────────────────────────────────┐ │ ││no friends yet │ │ ││F3 paste an invite to add one │ │ ││ │ │ ││ │ │ ││ │ │ ││ │ │ ││ │ │ ││ │ │ ││ │ │ ││ │ │ ││ │ │ ││ │ │ ││ │ │ ││ │ │ ││ │ └───────────────────────────┘└─────────────────────────────────────────────────┘ ┌composer──────────────────────────────────────────────────────────────────────┐ │/wipe /wipe-all /profile /who /pay /tip /file │ └──────────────────────────────────────────────────────────────────────────────┘ TOR me:abcdef01… onion:abcdefgh… Tab F2 F3 F4 F5 Ctrl-Q ? help ``` ### 80x24 — RECONSTRUCTED main, messages + stale + alert ``` .-~~-. .-~~-. .-~~-. ONIONWIRE ( o )( o )( o ) identity = pubkey onion = locator `-..-' `-..-' `-..-' tor messenger no server passphrases do not match ┌roster 2 1 stale──────────┐┌chat alice──────────────────────────────────────┐ │> alice aaaaaaaa… ││you: ping │ │ bob-the-stale-peer bbbbb││them: pong │ │ ││them: this is a very long chat line that should │ │ ││wrap inside the chat pane instead of running off │ │ ││the right edge of an 80-column terminal and │ │ ││colliding with the roster border │ │ ││ │ │ ││ │ │ ││ │ │ ││ │ │ ││ │ │ ││ │ │ ││ │ │ ││ │ └───────────────────────────┘└─────────────────────────────────────────────────┘ ┌composer──────────────────────────────────────────────────────────────────────┐ │hello from composer │ └──────────────────────────────────────────────────────────────────────────────┘ sent TOR me:abcdef01… onion:abcdefgh… Tab F2 F3 F4 F5 Ctrl-Q ? help ``` Roster clips `bob-the-stale-peer bbbbb` mid-glyph. Chat wraps (good). Focus on chat/composer is **not** visible in the glyph dump (color-only in `pane_block`). ### 80x24 — RECONSTRUCTED main, fail-closed send (note dropped) ``` .-~~-. .-~~-. .-~~-. ONIONWIRE ( o )( o )( o ) identity = pubkey onion = locator `-..-' `-..-' `-..-' tor messenger no server ┌roster 2 1 stale──────────┐┌chat bob-the-stale-peer─────────────────────────┐ │ alice aaaaaaaa… ││no messages │ │> bob-the-stale-peer bbbbb││ │ │ ││ │ │ ││ │ │ ││ │ │ ││ │ │ ││ │ │ ││ │ │ ││ │ │ ││ │ │ ││ │ │ ││ │ │ ││ │ │ ││ │ │ ││ │ └───────────────────────────┘└─────────────────────────────────────────────────┘ ┌composer──────────────────────────────────────────────────────────────────────┐ │/wipe /wipe-all /profile /who /pay /tip /file │ └──────────────────────────────────────────────────────────────────────────────┘ TOR me:abcdef01… onion:abcdefgh… Tab F2 F3 F4 F5 Ctrl-Q ? help ``` `status_note` was `send failed: peer onion down`. The before frame above drops it. `tests/tui_frames.rs` `status_footer_drops_send_failed_when_crowded` now asserts the note **is** present at 80, 120, and 200, along with `TOR` / `me:` / `? help`. ### 80x24 — `draw_share` (real) Invite is 346 chars. Inner width 78. Wraps mid-hex. Full v3 onion fits on its own line. No QR blocks (locked). ``` ┌(o) invite────────────────────────────────────────────────────────────────────┐ │give this string to a friend; they F3 paste it │ │ │ │fp ea4a6c63… │ │onion abcdefghijklmnopqrstuvwxyz234567abcdefghijklmnopqrstuvwx.onion │ │ │ │onionwire:v1:k=ea4a6c63e29c520abef5507b132ec5f9954776aebebe7b92421eea691446d22│ │c:o=abcdefghijklmnopqrstuvwxyz234567abcdefghijklmnopqrstuvwx.onion:spk=0101010│ │101010101010101010101010101010101010101010101010101010101:sig=46caf16b6da95e86│ │… │ └──────────────────────────────────────────────────────────────────────────────┘ ``` ### 80x24 — RECONSTRUCTED help overlay (private `draw_text_overlay` math) Help is 22 content lines + border. Popup height is `min(lines, height-2)` = 22, so it covers the banner, punches through roster/composer borders, and **clips** `Esc closes this overlay`. ``` .-~~-. .-~~-. .-~~-. ONIONWIRE ( o ┌? help─────────────────────────────────────────────────────────┐ `-..-' │OnionWire keys │ ┌roster│ │───────┐ │ │Tab / Shift-Tab cycle roster, chat, composer │ │ │ │… │ │ │ │/backup /path encrypted identity export │ │ └──────│/restore /path overwrite self keys │───────┘ ┌compos│? this help │───────┐ │/wipe │Ctrl-Q quit; type CLEAR or QUIT │ │ └──────└───────────────────────────────────────────────────────────────┘───────┘ TOR me:abcdef01… onion:abcdefgh… Tab F2 F3 F4 F5 Ctrl-Q ? help ``` ### 80x24 — other overlays (copy is real) - Profile: `> name:` marker (good). Empty xmr is a blank value, not `(none)`. - Paste: same wrap-mid-hex as share. Error state replaces the hint with the error string (no "what next"). - Approve / rotate / wipe / quit / backup / passphrase: full-screen bordered column of copy + typed buffer. Readable. Fine as modal confirmations. - `/who`: overlay Clear is only the popup rect; chat remnants (`d`, `ff`) show in the side gutters. Full onion is shown (good). ### 120x40 / 200x60 At 120, `status_footer` shows the **full** 62-char onion and still drops `send failed: …`. At 200 the note survives in front of `TOR`. Banner stays the 3-line wordmark (width ≥ 63). Chat pane is large; hierarchy problem is worse (more empty bordered void), not better. Dump: same cargo command. ## Deliverable 2 — findings Walked in `tui-aesthetics` ladder order. ### 1. Clipping / overlap | Sev | Where | Wrong | User impact | |---|---|---|---| | **blocker** | `src/tui.rs:1505` `status_footer` candidate list | Fail-closed `status_note` (`send failed: …`) is skipped when ident+hints fill the row. Proven at 80 and 120. | Peer down looks like success. The product rule is "send visibly fails". | | **major** | `src/tui.rs:1702` `draw_text_overlay` | No `Wrap`. Height clipped to `area.height-2`. At 80x24 help overlaps banner/roster/composer and drops the last line. | `?` is unreadable on the floor size. | | **major** | `src/tui.rs:1355` roster `format!("{name} {fp}")` | No truncate. `bob-the-stale-peer bbbbb` clips inside the 36% pane. | Cannot tell who is selected/stale. | | **major** | `src/tui.rs:1570` `draw_share` (and paste body) | 346-char invite wraps mid-token at inner width 78. | Mouse-select copy is split; easy to miss a continuation line. | | **minor** | `src/tui.rs:1334` alert | Alert is one raw line, no wrap/truncate. | Long error will collide with roster on the next row. | | **nit** | `tests/tui_chrome.rs:15` (and `src/tui.rs:1512`, `1707`) | Width via `chars().count()`. See deliverable 4. | CJK/emoji can wrap in a real terminal while tests stay green. | ### 2. Hierarchy | Sev | Where | Wrong | User impact | |---|---|---|---| | **major** | `src/tui.rs:1314` `draw_main` | Three-line wordmark + two equal bordered panes + bordered composer + footer. Chat is not the primary element. At 80x24, 3 rows of art + 3 composer + 1 footer + 2×2 borders leave the transcript starved. | First glance is ASCII onions, not the conversation. | | **major** | `src/tui.rs:1340` | Roster is 36% of width on every size. | Chat (the primary pane) is the leftover. | | **minor** | every `themed_block` / `pane_block` | Border on every pane, including composer and full-screen modals. | Eye cannot find content; "box drawing UI". | ### 3. Spacing | Sev | Where | Wrong | User impact | |---|---|---|---| | **minor** | `src/tui.rs:1328` banner vs `1367` lists | Banner has no inner pad; list/paragraph sit against borders; footer has no pad. Mixed 0 and 1. | Ragged left edge: chat `no friends yet` vs roster empty. | | **nit** | `src/tui.rs:93` `/file /path` extra space vs other slash rows | Help columns almost align, one extra space. | Looks unfinished. Do **not** change `help_overlay_text` unless `tui_chrome` is updated — the string is locked. Leave the space. | ### 4. States | Sev | Where | Wrong | User impact | |---|---|---|---| | **major** | `src/tui.rs:1349` empty roster | `List` with zero items → blank pane titled `roster 0`. Empty copy lives only in chat. | Looks broken, not empty. | | **major** | pay / tip / file | No pane. Outcome is a footer note that 80/120 may drop. | `/pay` and `/file` feel like they did nothing. | | **minor** | `src/tui.rs:1414` empty composer | Placeholder is the slash cheatsheet, dim color only. | Reads as commands already typed. | | **minor** | `src/tui.rs:1456` `no messages` | One word. No "type below, Enter sends". | Dead pane. | | **nit** | loading | `sending` in footer, 100 ms poll, no spinner. | Correct. Keep. | There is no dedicated disconnected screen. Stale friends get a `stale` suffix (`src/tui.rs:1357`) — keep the word, not color-only. ### 5. Color | Sev | Where | Wrong | User impact | |---|---|---|---| | **major** | `src/tui.rs:15-21` | Seven RGB colors. No 16-color map. No `NO_COLOR`. | 16-color and `NO_COLOR` terminals get garbage or still emit ANSI. | | **minor** | `src/tui.rs:1359-1372` | Stale is `C_STALE` plus the word `stale` (ok). Selection is bg+fg+bold+`> ` (ok for roster). | Chat/composer focus is color-only (see focus). | Accent RGB `(232,165,75)` is fine as **the** accent. Do not add more hues. ### 6. Focus | Sev | Where | Wrong | User impact | |---|---|---|---| | **major** | `src/tui.rs:1468` `pane_block` | Focused chat/composer: accent border + bold title. No marker. Roster has `> `. | Monochrome / `NO_COLOR`: cannot see focus unless roster. Typing `j`/`k` feels dead. | ### 7. Motion | Sev | Where | Wrong | User impact | |---|---|---|---| | **nit** | `src/tui.rs:24` `TUI_POLL` 100 ms | Full `terminal.draw` every poll even with no keys, so background send can refresh status. | Acceptable. No decorative spinner. Do not redraw faster. | ### 8. Copy | Sev | Where | Wrong | User impact | |---|---|---|---| | **minor** | `src/tui.rs:1583` paste error | Error replaces the paste hint. No "what next". | User sees `bad invite` and an empty buffer. | | **minor** | `src/tui.rs:1415` | Composer placeholder is a command dump, not a verb. | Conflicts with `?` help. | | **nit** | `src/tui.rs:36` | `fingerprint mismatch` is a good short fail-closed string when it actually reaches the footer. | Often dropped (finding 1). | ### Untrusted text `src/tui.rs:1461` `String::from_utf8_lossy(&m.plaintext)` goes into `Paragraph` with wrap, **no** control/bidi strip, **no** ellipsis cap. Profile `bio` / `display_name` and paste buffer are the same class. A separate in-flight PR owns sanitization — do not duplicate it here. Implementation must call that helper (or the agreed strip) on every peer-supplied string before draw. ## Deliverable 3 — spec (implement this) ### Pane structure One primary element per screen. | Screen | Primary | Secondary | Chrome | |---|---|---|---| | Main | Chat transcript | Roster (left, **22 cells** at 80, **28** at 120+, not 36%) | 1-line header, 3-row composer, 1-row status | | Share / paste / approve | The invite string / typed buffer | fp + onion above it | title `(o) invite` etc. Keep `draw_share` public | | Profile | The three fields with `>` on the active one | — | title `(o) profile` | | Rotate / wipe / quit / backup / restore / passphrase | The confirm copy + typed token | — | existing titles | | Help | The help text, **full screen** when `height < 28`, else a centered overlay that **fits** (wrap, scroll if needed, never clip the last line) | — | title `? help` | | `/who` | Profile fields | — | same overlay rules as help | | Pay / file | **None.** Stay on main. Status line carries the result. | — | — | `draw_main` at `height <= 24` **must not** spend 3 rows on `wordmark_banner()`. Use a one-line header. Do **not** change `banner_for_width(80)` — chrome tests lock it to the wordmark. Add `main_header_line(width, fp, onion)` or call `compact_banner()` plus ident. At `height >= 40`, the 3-line wordmark **may** sit above the one-line ident; it is optional, not required. ### Spacing unit **1 cell.** Apply as: - Header: no box. One space between fields. - Roster / chat: `Block` with `Borders::ALL` **only on those two** (the primary split). Inner text starts one cell after the border (ratatui default). - Composer: **no** outer box. Prefix `> ` when focused, ` ` when not. One blank row is not required; the 3-row slot stays for wrapped input. - Footer: no box. One space between clusters, two spaces between clusters if width ≥ 120. - Overlays: one box around the popup. No nested padding. ### Palette One accent. Semantic color only for state. Pair every color with a glyph or label. | Role | RGB (keep) | 16-color | `NO_COLOR` | |---|---|---|---| | accent | `Rgb(232,165,75)` | `Yellow` | default + bold / reverse | | text | `Rgb(196,214,176)` | `White` | default | | dim | `Rgb(98,110,92)` | `DarkGray` | default | | alert | `Rgb(220,80,70)` | `Red` | default + `! ` prefix | | stale | `Rgb(210,180,80)` | `Yellow` | default + ` stale` (already) | | highlight bg | `Rgb(48,42,28)` | `Reverse` | reverse | | border | `Rgb(72,84,64)` | `DarkGray` | default | `NO_COLOR` set (empty or any value): no `Style` fg/bg at all. Glyphs and weight only. Detection: `std::env::var_os("NO_COLOR")` is Some → no color. Else if the backend is not a TTY or `TERM=dumb` → 16-color or no color, never RGB. Else RGB as today. ### Glyphs | Use | Unicode | ASCII fallback | |---|---|---| | onion / share title | `(o)` (already) | `(o)` | | focus | `> ` | `> ` | | truncate | `…` (`src/tui.rs:1730`) | `...` (budget 3 cells) | | box | ratatui `Borders::ALL` (light) | `+` `-` `\|` via `border::Set` | | alert prefix | `! ` | `! ` | | stale | word `stale` | `stale` | | delivery: delivered | `✓` | `ok` | | delivery: queued | `◷` | (word) `queued` | | delivery: sending | `»` | (word) `sending` | | delivery: failed | `✗` | (word) `failed` | `queued` / `sending` / `failed` always carry their state word, so the ASCII fallback drops the glyph instead of inventing one. Only `✓` is wordless, so it falls back to `ok`. `delivery_glyph()` / `tests/tui_spec.rs::delivery_markers_have_exercised_ascii_fallbacks` exercise the fallback path. No emoji. `onion_glyph()` stays for callers that already use it; do not put it on the main header. ASCII chrome when `ONIONWIRE_ASCII` is set **or** when `NO_COLOR` is set (same switch is enough; do not add a crate). ### Focus Never color alone. - Roster: keep `highlight_symbol("> ")` + bold. Unselected rows start with two spaces so columns align. - Chat: title becomes `> chat {name}` when focused, ` chat {name}` when not, plus bold on the `> ` title. - Composer: `> ` prefix on the input row when focused (see spacing). - `Tab` cycle unchanged (`Pane` tests lock it). ### `status_footer` priority (must change) Replace the current "first candidate that fits, dropping the note" list. Build left-to-right, **never drop** a non-empty `status_note`: 1. `status_note` (truncate with `…`/`...` to a minimum of 12 cells if needed). 2. `TOR me:{8}…` (keep `me:` — chrome tests require it). 3. `onion:` + full onion if it fits, else 8-char truncate (keep today's `width >= 110` full-onion rule if it still fits **after** the note). 4. Hints from `main_footer_hints()`, dropping from the left of that list. 5. Always end with `? help`. `? help` and `TOR` and `me:` must still be present at 80 and 120 so `tests/tui_chrome.rs` stays green. Fail-closed copy is `send failed: {e}` or `fingerprint mismatch`. Prefix `! ` when color is off. ### Copy — non-happy states Do not soften fail-closed into a loader. | State | Copy | |---|---| | no friends, roster | list item `no friends` (so the pane is not blank) | | no friends, chat | `no friends yet` / `F3 paste an invite to add one` (keep) | | friend, no messages | `no messages` / `type below, Enter sends` | | nothing selected send | `no friend selected` (keep) | | sending | `sending` (keep, no spinner) | | sent | `sent` | | peer down / send err | `send failed: {e}` (visible) | | queued (outbox) | `{n} queued` — replaces the flat `sent`/`send failed` while rows are outstanding | | queued + terminal failure | `{n} queued, send failed: {short}` | | terminal failure | `send failed: {short}` (`{f} failed` when more than one) | | already sending | `already sending` (keep) | | stale friend | `stale` suffix (keep) | | empty composer | `message` as dim placeholder (not the slash list). Slash list stays in `?` | | paste error | `{err}` then `Enter resubmits Esc back` | | unknown slash | `unknown command {cmd}` (keep) | | passphrase mismatch | `passphrases do not match` (keep, alert line) | ### Before → after mockup (80x24 main) **After** (target). Header 1 line. Roster 22-ish. Chat primary. Composer no box. Fail-closed note kept. Focus marker on composer. ``` onionwire tor me:abcdef01 onion:abcdefgh ┌friends 2 1 stale┐┌chat alice───────────────────────────────────────────────┐ │ alice aaaaaaaa…││you: ping │ │> bob bbbbbbbb… s││them: pong │ │ ││them: this is a very long chat line that should wrap │ │ ││inside the chat pane instead of running off the edge │ │ ││ │ │ ││ │ │ ││ │ │ ││ │ │ ││ │ │ ││ │ │ ││ │ │ ││ │ │ ││ │ │ ││ │ │ ││ │ └──────────────────┘└──────────────────────────────────────────────────────────┘ > hello from composer ! send failed: peer onion down TOR me:abcdef01 ? help ``` Roster names truncate with ellipsis, not mid-letter. `stale` may abbreviate to `s` only if the word does not fit; prefer keeping `stale`. ### Before → after mockup (80x24 help) **After:** full-screen, no punch-through. Last line visible. `help_overlay_text()` body unchanged (chrome tests). ``` ┌? help────────────────────────────────────────────────────────────────────────┐ │OnionWire keys │ │ │ │ Tab / Shift-Tab cycle roster, chat, composer │ │ 1 / 2 / 3 focus roster / chat / composer │ │ j k or Up Down move or scroll focused pane │ │ g / G jump to top / bottom │ │ Enter send chat to selected friend, or a /command │ │ Esc close overlay, go back, clear composer │ │ F2 share invite │ │ F3 paste invite │ │ F4 rotate onion locator │ │ F5 selected friend's profile (/who) │ │ /profile edit name, bio, Monero address │ │ /pay [memo] invoice to receive │ │ /tip [memo] pay selected friend │ │ /file /path send file to selected friend (1 MiB) │ │ /backup /path encrypted identity export │ │ /restore /path overwrite self keys │ │ ? this help │ │ Ctrl-Q quit; type CLEAR or QUIT │ │ │ │Esc closes this overlay │ └──────────────────────────────────────────────────────────────────────────────┘ ``` If the body still overflows 24 rows with the border, **scroll** the paragraph; do not clip. Do not edit the locked help string to shrink it. ### Left alone (on purpose) - Wire protocol, session, store, send path. - Peer-text sanitization (other PR). Render must call it once it exists. - Fail-closed semantics. Only the **visibility** of the error changes. - Locked helper names and `help_overlay_text` / wordmark strings. - No QR. Invite stays a string. - No dedicated pay/invoice/file screens in v1. - No spinner. `TUI_POLL` 100 ms stays. - `docs/PROTOCOL.md` unchanged. - No new crates on the implementation card unless `unicode-width` is approved (deliverable 4). ## Deliverable 4 — `chars().count()` is not terminal cells `tests/tui_chrome.rs` asserts `line.chars().count() <= width`. Same metric in `status_footer` (`src/tui.rs:1512`) and `draw_text_overlay` (`src/tui.rs:1707`). | Input | `chars().count()` | Terminal cells (East Asian Width; emoji Wide) | |---|---|---| | `你好` | 2 | **4** (both Wide) | | `e\u{0301}` (e + combining acute) | 2 | **1** | | `🧅` (U+1F9C5) | 1 | **2** | A line of twenty `你` is 20 chars and 40 cells: the test passes at width 80, the terminal wraps. A combining-mark string can look "too long" to the test and still fit. **Fix (implementation card, approved-then):** measure in cells. `unicode-width` is already in the lockfile via ratatui but **not** a direct dependency. Do not add it on this card. Preferred: depend on `unicode-width` explicitly and assert `UnicodeWidthStr::width(line) <= width as usize`. Until then, keep the existing `chars().count()` tests green; do not rewrite them to fit a redesign. `tests/tui_frames.rs` `chars_count_is_not_terminal_cells` documents the three examples without adding a crate. ## After frames (spacing / ASCII / wrap / copy) Base: `origin/main` after PR #24 (`33beede`). Hierarchy, fail-closed footer, 1-line header, roster width, help overlay, and `NO_COLOR` palette are unchanged here. Optional 3-line wordmark at height ≥ 40 was skipped (it fights the 1-line header without buying hierarchy). ### 80x24 — `draw_share` after (field-boundary wrap) Invite lines break on `:`. `sig=` hex that does not fit continues as an all-hex line. Joining those lines (no extra spaces) is the original payload. ``` ┌(o) invite────────────────────────────────────────────────────────────────────┐ │give this string to a friend; they F3 paste it │ │ │ │fp ea4a6c63… │ │onion abcdefghijklmnopqrstuvwxyz234567abcdefghijklmnopqrstuvwx.onion │ │ │ │onionwire:v1: │ │k=ea4a6c63e29c520abef5507b132ec5f9954776aebebe7b92421eea691446d22c: │ │o=abcdefghijklmnopqrstuvwxyz234567abcdefghijklmnopqrstuvwx.onion: │ │spk=0101010101010101010101010101010101010101010101010101010101010101: │ │sig=46caf16b6da95e86bf93a6ee80605ec74d9e24a419c4ef802632af74f46406fae9953690e0│ │5401b0af934cefea617f71466f406af4bef956847200a8e915190b │ └──────────────────────────────────────────────────────────────────────────────┘ ``` ### 80x24 — ASCII switch (`ONIONWIRE_ASCII=1`) No non-ASCII byte. Truncation marker is `...`. Borders are `+` `-` `|`. ``` +(o) invite--------------------------------------------------------------------+ |give this string to a friend; they F3 paste it | | | |fp ea4a6c63... | |onion abcdefghijklmnopqrstuvwxyz234567abcdefghijklmnopqrstuvwx.onion | | | |onionwire:v1: | |k=ea4a6c63e29c520abef5507b132ec5f9954776aebebe7b92421eea691446d22c: | |o=abcdefghijklmnopqrstuvwxyz234567abcdefghijklmnopqrstuvwx.onion: | |spk=0101010101010101010101010101010101010101010101010101010101010101: | |sig=46caf16b6da95e86bf93a6ee80605ec74d9e24a419c4ef802632af74f46406fae9953690e0| |5401b0af934cefea617f71466f406af4bef956847200a8e915190b | +------------------------------------------------------------------------------+ ``` ### 80x24 / 120x40 — main chrome after Same 1-line header, unboxed composer, fail-closed footer as PR #24. Dump: ``` cargo test --locked --test tui_spec -- --nocapture dump_spec_frames ``` Copy wired in `src/tui.rs` (not in the reconstructed standin): empty thread is `no messages` / `type below, Enter sends`; paste error is `{err}` then `Enter resubmits Esc back`; alerts truncate to the frame width. ## Delivery state (outbox) — implemented Per-message state, read from the local outbox. The states are the store's own (`Queued` / `Sending` / `Sent` / `Failed`) — no parallel model, no new wire prefix, no server. | Row | Marker | |---|---| | delivered | `you: ping ✓` | | queued (2nd attempt, 45s out) | `you: pong ◷ queued (try 2/8, retry 45s)` | | sending | `you: pong » sending` | | failed | `you: pong ✗ failed: connection timed out` | | inbound | `them: pong` (no marker) | - `try {n}/{8}` is the outbox attempt count; `retry {s}s` / `retry {m}m` / `retry now` comes from the stored absolute `next_attempt_at`. - Failed reasons are sanitized, cut to the tail of the `a: b: c` chain and capped at 24 cells (`short_send_reason`). - Footer while rows are outstanding: `{n} queued`; any terminal failure keeps a fail-closed `send failed: {short}` statement (with `! ` when colour is off). - The tag trails the body and wraps with it, so it is never clipped away. Correlation: a delivered row is deleted from the outbox, so an outbound message with no row is `Sent`; pending rows are joined to messages on the row id — `store::Message::id` equals `OutboxEntry::message_id` (`chat_with_delivery`). Two identical bodies are distinct rows with distinct ids, so the marker always lands on the row that actually owns the outbox entry. ### Size floor / target - **Floor: 80x24.** Everything above must render there. - **Target: 120x40.** - `tests/tui_spec.rs::chat_and_footer_rows_fit_80x24_and_wrap_instead_of_clipping` draws the real `draw_chat` + `status_footer` at 80x24 and asserts every chat 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`. ## WALLETS & SETTINGS menu (F9 / `/settings`) — implemented The Monero wallet and the cuprate node shipped behind function keys only: a user who did not already know F6 opened the wallet could not find wallet setup, the child wallet, the chain source or the settings. F9 (`/settings`) is the discoverable surface. It is a **screen, not a popup**, and it is a discovery layer, not a replacement: F2, F3, F4, F5, F6 and F8 all keep working, and they stay live *on this screen* so no row can print a key that does nothing there. ``` cargo test --locked --test tui_spec -- --nocapture wallets_settings_menu_frame_dumps ``` dumps the menu at 80x24, 120x40 and 200x60 in both the configured and the unconfigured state. ### Rows Layout is ` label value … keys`: a 9-cell label column, the value truncated in **cells** with the chrome's ellipsis, and a 12-cell key column right-aligned so the eye can run down it. Every actionable row names the key or command that fires it, including the F6 wallet screen's own keys (`F6 c`, `F6 i`, `F6 r`, `F6 s/x`, `F6 p`), so the menu teaches the shortcuts it sits beside. | Group | Row | Value | Key | |---|---|---|---| | WALLET | endpoint | `configured · connected` / `configured · not connected` / `not configured · receive-only` | — | | WALLET | child | `{chain source} · running` / `not started` | `F6 s/x` | | WALLET | sync | chain readiness word (`chain at tip · wallet answering`, `wallet answering · chain not at tip`, `wallet RPC not answering yet`, `child exited`, `not probing · no chain source`) | `F6 p` | | WALLET | receive | the receive address (truncated) or `no address yet · wallet unreachable` | `c copy` / `F6 r` | | WALLET | balance | `{xmr}` / `off` / `err` | `F6` | | WALLET | transfers | `{n} recent` / `no transfers yet` — the wallet's **own** transfer list | `F6` | | WALLET | payments | `{n} with {peer}` / `no history with {peer}` / `no friend selected` / `history unreadable · {peer}` — the **peer's** payment rows | `p` | | WALLET | create | `/wallet create · seed shown once` | `F6 c` | | WALLET | import | `/wallet import · 25-word seed` | `F6 i` | | SETTINGS | nickname | the self-profile name, or `(none)` | `/profile` | | SETTINGS | profile | `bio set · xmr set` | `/profile` | | SETTINGS | identity | `{fp}… · identity = pubkey` | `F2` | | SETTINGS | colour | `auto · follows NO_COLOR / TERM` | — | | SETTINGS | backup | `encrypted identity export` | `/backup` | | SETTINGS | restore | `overwrite self keys from a backup` | `/restore` | | SETTINGS | wipe | `messages · identity and friends stay` | `/wipe` | | SETTINGS | wipe-all | `deletes your identity key · new person` | `/wipe-all` | 20 rows at 80x24 against 21 available inner rows: nothing clips or scrolls. `transfers` and `payments` are deliberately two rows: `transfers` is the wallet's own list (`Node::wallet_recent_transfers`, F6), `payments` is the peer-scoped history (`Node::list_payments`, `p`). Signed `/pay` invoices and `/tip` receipts a peer sent never appear in the wallet's own transfers, so the two histories are not interchangeable and the menu names both. ### Guarantees - **No credentials.** `WalletMenuState` carries booleans, labels and display-ready error strings from `Node`'s getters. It is never given `WalletConfig::rpc_login`, `secret()`, a seed or a passphrase, so the screen cannot render one. - **Untrusted text is display data.** Every value goes through `sanitize::display_text` plus a newline/tab strip before it is placed on a row, so a multi-line or bidi-laden error cannot split a row or reorder it. - **Cells, not chars.** `cell_width()` measures with ratatui's own `Span::width` — the same code path the renderer truncates with. `unicode-width` is not a direct dependency of this crate, so no crate was added; `chars().count()` is never used for a width. - **Colour is never the only signal.** Each state word is present as a word (`not connected`, `child exited`, `not probing`, `no transfers yet`); the tone only answers "what is this?". - **Copy without a clipboard crate.** `c` writes the receive address through OSC 52 (`ESC ] 52 ; c ; BEL`): the terminal owns the clipboard, the address never touches a file, and it still works over SSH. A terminal that does not implement OSC 52 ignores the sequence; `F6 r` still shows the QR. - **ASCII fallback.** The section rule is `─`, or `-` under `ONIONWIRE_ASCII` / `NO_COLOR`, alongside the existing ellipsis swap. No emoji. ### Reachable-from-the-TUI gaps this card does not close Named in the PR body's feature-analysis table. All of them need backend or sibling-card work, not presentation: - `Node::wallet_config()` / `Node::wallet_save_config(cfg)` / `Node::wallet_test_connection(..)` — the endpoint config screen is F7 on `feat/wallet-create-import`; the menu shows the endpoint's *state* and leaves the key free. - Peer payment history — **closed by this screen.** `Node::list_payments` exists on `main`; the `payments` row (key `p`) opens the peer-scoped history, and the row is distinct from the wallet's own transfer list (`transfers`, F6). - `Node::set_wallet_child_config(cfg)` — the child can be started/stopped and probed, not edited. - `Node::set_petname(..)` — no petname editor exists. ## Peer payment history (F9 → `payments`, key `p`) A screen, not a popup, and peer-scoped: it renders what `Node::list_payments(&friend_pk)` returns for the chat's selected friend, so the signed `/pay` invoices and `/tip` receipts a peer sent are visible even though they never appear in the wallet's own transfer list (F6). The call takes the store lock only — no Tor dial, no wallet RPC — so it is safe while offline or while Arti is still bootstrapping, and an empty result (`Ok(vec![])`) is the **no history** state, never an error. ``` cargo test --locked --test tui_payments -- --nocapture peer_payments_frame_dumps ``` dumps the screen at 80x24, 120x40 and 200x60, populated and empty. ### Layout ``` dir kind amount XMR receipt memo > in receipt 0.025 verified lunch money out tip 0.005 coffee out invoice 0.1 rent tx 3f2a91c0d9e4b7a2c1f0e8d7b6a5948372615041324758697a8b9c0d1e2f3041 addr 4AdUndXHHZ6cfufTMvppY6JwXNouMBzSkbLYfpAV5Usx3skxNgYeYJKUGVktfzxayGbMW aC8iqPUE9XUBFGrLyDz4DpEBM ``` - Rows are **newest first**: `payments.id` ascending is oldest first, so `PeerPaymentsState::from_payments` reverses it and the render path windows the result. Rows outside the window are counted in an explicit `… N older` / `… N newer` line — nothing is dropped silently. - The focused row is marked with `>` **and** bold, so focus survives a monochrome terminal. `up`/`down` (or `k`/`j`) move it, `Esc` returns to the main screen, `F9` reopens the menu. - `F9` is honoured **while this screen is open**, not only from the main screen: the function-key table (`function_key_for`) answers it from `Main`, `WalletsSettings` and `PeerPayments` alike, so the hint the screen prints cannot be a no-op there. `peer_payments_footer_hint()` is the single place that hint string is written, and the frame-dump fixture is driven from it — a dumped frame cannot show a footer the app does not render. - The selected row's `tx` and `addr` are spelled out under the rows: a 64-hex txid is unusable truncated, and a 95-character base58 address is **wrapped** over two lines rather than clipped to a prefix. - Amounts use `pay::atomic_to_xmr_str`, the same piconero formatter the chat lines use; the XMR unit is stated once, in the column header. - Columns are dropped from the right when the pane is narrower than they need, so no row can wrap or overrun at any width — not just at 80. ### States | State | Frame | |---|---| | populated | the rows, plus the selected row's `tx` / `addr` | | empty | `no payments with {peer}` and `invoices, receipts and tips from this peer land here` | | read failed | `could not read payments` plus the sanitized reason — never a blank pane | | no friend selected | the menu row refuses before the screen opens (`no friend selected` in the status line) | ### Guarantees - **Memo is peer-signed text, sanitized at draw time.** `Node::list_payments` returns `memo` as stored; the row goes through the same `menu_cell_text`-then-`fit_cells` path the F9 menu uses, so C0/C1 controls, ESC, bidi marks and newlines cannot reach the frame buffer or split a row. `tests/tui_payments.rs` asserts a hostile memo (ESC, BEL, C1, bidi, newline) never appears in a rendered frame. - **Only receipts carry `verified`.** The flag column prints `verified` / `unverified` for receipts and stays blank for invoices and tips, which have no signature to check; `unverified` also takes the warn tone, so colour is never the only signal. - **Read-only.** The screen reads one getter and draws; it cannot send, sign or dial. ## Clean-look chrome redesign — implemented The main screen was restructured around one accent, one primary pane and honest states. The render path is no longer reconstructed in the dump: `App::draw_main` builds a `MainView` of plain data and hands it to the public `draw_main_chrome`, which is exactly what `tests/tui_frames.rs` draws. There is no stand-in layout, so a frame dump is the real screen. ``` cargo test --locked --test tui_frames -- --nocapture dump_audit_frames ``` dumps every state below at 80x24, 120x40 and 200x60. ### Hierarchy | Row | Content | Style | |---|---|---| | 0 | `onionwire {glyph} tor {phase} me:{fp8} onion:{onion8}` | app name bold text, phase semantic, identity muted | | 1 | the alert (`send failed: …`, `fingerprint mismatch`) — only when set | alert | | 2..h-4 | roster (22 cells at 80, 28 at 120+) next to the chat transcript | roster rows text/stale, focus marker on the focused pane | | h-3..h-1 | composer, **no frame**, 3-row slot for wrapped input | `> ` marker + bold when focused, `message` muted when empty | | h-1 | `{note} {glyph} TOR {phase} me:{fp8} {pane hints} ? help` | muted; phase semantic | The header no longer takes the accent — the accent is reserved for focus, which is what let the header stop competing with the panes. ### Tor phase is a first-class state `Node::tor_state()` was already cheap, read-only and unused by the TUI. It now feeds `TorPhase` (one word + one glyph, both in the header and the footer), so "connected" is never implied: | `hs::TorState` | `TorPhase` | glyph / ASCII | word | tone | |---|---|---|---|---| | `Bootstrapping` | `Connecting` | `…` / `...` | `connecting` | muted | | `Published` | `Ready` | `✓` / `ok` | `ready` | text | | `DegradedReachable` | `Degraded` | `!` | `degraded` | stale | | `Stopped` | `Off` | `x` | `off` | alert | No new data field was needed: `App` already holds `Arc`, and this is a read-only getter, not a store read from the render path. ### States ``` onionwire ✓ tor ready me:abcdef01 onion:abcdefgh ┌roster 2 1 stale───┐┌> chat alice───────────────────────────────────────────┐ │> alice aaaaaaaa… ││you: ping ✓ │ │ bob-the-sta… stale││them: pong │ │ ││them: this is a very long chat line that should wrap │ │ ││inside the chat pane instead of running off the right │ │ ││edge of an 80-column terminal and colliding with the │ │ ││roster border │ └────────────────────┘└────────────────────────────────────────────────────────┘ message ✓ TOR ready me:abcdef01… j k scroll g G ends F4 rotate F9 settings ? help ``` ``` onionwire … tor connecting me:abcdef01 onion:abcdefgh ┌roster 0────────────┐┌ chat──────────────────────────────────────────────────┐ │no friends ││no friends yet │ │F3 adds one ││F3 paste an invite to add one │ │ ││tor connecting — first publish takes a few minutes │ └────────────────────┘└────────────────────────────────────────────────────────┘ message … TOR connecting me:abcdef01… j k select F3 add F6 wallet F9 settings ? help ``` ``` onionwire x tor off me:abcdef01 onion:unset fingerprint mismatch ┌roster 0────────────┐┌ chat──────────────────────────────────────────────────┐ │no friends ││no friends yet │ │F3 adds one ││F3 paste an invite to add one │ │ ││tor off — no onion service is running │ └────────────────────┘└────────────────────────────────────────────────────────┘ message x TOR off me:abcdef01… j k select F3 add F6 wallet F9 settings ? help ``` The error state puts the fail-closed sentence on the alert row **once**; the footer keeps the phase and the hints instead of repeating it. The outbox note (`peer unreachable, queued (1/8, retry 45s)`) still outranks the hints when a row is outstanding. ### Footer variants | Helper | Identity | Used by | |---|---|---| | `status_footer(w, fp, onion, note, hints)` | `TOR`, `onion:` | locked chrome tests and every non-main screen | | `status_footer_phased(w, fp, onion, phase, note, hints)` | `{glyph} TOR {word}`, `onion:` | F9 menu | | `status_footer_compact(w, fp, phase, note, hints)` | `{glyph} TOR {word}` only | main (its header already carries `me:` and `onion:`) | The main footer drops the onion because the header one line above already prints it; those cells go to the hints. `TOR`, `me:` and `? help` survive at 80, 120 and 200 in every variant — `tests/tui_chrome.rs` asserts it. `pane_footer_hints(Pane)` changes the hint cluster with the focused pane (roster / chat / composer) and every variant keeps `F9` and `? help`, so the menu stays discoverable and the overlay stays reachable wherever the cursor is. ### Levers from the reference (applied / skipped) Applied: one accent for focus (focused border, selected row, active-conversation marker); focus as marker + weight (`> ` plus bold title, visible with colour stripped); border weight = focus; one unframed muted footer that follows the pane and the phase; designed empty / connecting / degraded / off states; semantic colour only; outbox and stale state as marker + word. Skipped: the 3-line wordmark above the header at height ≥ 40 (fights the 1-line header without buying hierarchy); bottom-anchoring the composer inside its 3-row slot (needs cell-accurate wrap prediction for no legibility gain); per-row colour in the roster (name and fingerprint share one style so a narrow pane can drop the fingerprint without changing the row's meaning). ### Width `status_footer*`, `alert_line`, `main_header_line*`, `draw_text_overlay`, `roster_row_text` and `fit_cells` all measure cells (`Span::width`), never `chars().count()`. The roster row spends its budget on the name first, then the `stale` word, then whatever is left on a fingerprint prefix — a 22-cell pane reads `bob-the-sta… stale`, not `… bbbbbbbb… stale`.