onionwire/docs/TUI.md
agent 0131803f9c
Some checks failed
android-ci / android (pull_request) Has been cancelled
ci / sdk (pull_request) Has been cancelled
ci / fuzz (pull_request) Has been cancelled
ci / test (pull_request) Has been cancelled
tui: WALLETS and SETTINGS menu (F9 / /settings) over the landed wallet + node features
The Monero wallet and the cuprate node shipped behind function keys only, so 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 (also /settings) now opens one discoverable screen with the two groups the
card fixes: WALLET (endpoint, child, sync, receive, balance, payments, create,
import) then SETTINGS (nickname, profile, identity, colour, backup, restore,
wipe, wipe-all). Every actionable row prints the key or command that fires it,
including the F6 wallet screen's own keys, and those keys stay live on the
screen so no row can name a dead key.

- Screen, not popup: 19 rows at 80x24 against 21 inner rows; 120x40 and 200x60
  hold. The footer is the shared status_footer, so TOR / identity / ? help stay
  put.
- No credentials: WalletMenuState carries booleans, labels and display-ready
  error strings only. rpc_login, secret(), seeds and passphrases have no field
  to travel in.
- Untrusted values are display data: sanitize + newline/tab strip, then
  truncated in cells.
- Cells, not chars: cell_width() measures through ratatui's own Span::width, so
  no unicode-width dependency was added and chars().count() is never a width.
- Copy without a clipboard crate: c writes the receive address as an OSC 52
  sequence; the terminal owns the clipboard and it survives SSH.
- Colour is never the only signal: every state also spells itself out.
- F7 stays free for the endpoint config screen that names it (db208be,
  docs/WALLET.md).

F2/F3/F4/F5/F6/F8 keep working: the function keys are now handled once, for Main
and this screen, instead of inside the Main arm.
2026-09-18 22:26:57 -04:00

706 lines
42 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 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<Node>` (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** — same `Layout` constraints as `src/tui.rs` `draw_main` (banner height, 36% roster, composer 3, footer 1) plus the real `banner_for_width` / `status_footer` | `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 <xmr> [memo] invoice to receive │
│ /tip <xmr> [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 | payments | `{n} recent` / `no transfers yet` | `F6` |
| 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` |
19 rows at 80x24 against 21 available inner rows: nothing clips or scrolls.
### 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 ; <base64> 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 — `store.list_payments(..)` has no `Node` accessor, so
the menu can only offer the wallet's own transfer list (F6).
- `Node::set_wallet_child_config(cfg)` — the child can be started/stopped and
probed, not edited.
- `Node::set_petname(..)` — no petname editor exists.