Merge origin/main into the peer-payments branch
Some checks failed
android-ci / android (pull_request) Has been cancelled
ci / test (pull_request) Successful in 5m44s
ci / sdk (pull_request) Successful in 1m26s
ci / fuzz (pull_request) Successful in 4m45s

main moved under this PR when #120 (clean-look chrome redesign) landed, which
touched the same three files (src/tui.rs, tests/tui_spec.rs, docs/TUI.md) and
left PR #121 unmergeable.

- docs/TUI.md: both sections kept — the peer-payment-history section from this
  branch, then #120's chrome-redesign section.
- tests/tui_spec.rs: #120's `fit_cells` flake relaxation kept (it is a superset
  of the one on this branch: same cut point plus the ellipsis assertion).
- src/tui.rs merged cleanly; `cargo test --locked` 383 passed / 0 failed and
  `cargo clippy --locked --all-targets -- -D warnings` clean afterwards.

The peer-payments frames are byte-identical after the merge, so the dumps in
this PR body still hold.
This commit is contained in:
agent 2026-09-19 00:36:38 -04:00
commit cbe889024b
No known key found for this signature in database
5 changed files with 1343 additions and 475 deletions

View file

@ -19,7 +19,7 @@ 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 |
| 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_*` |
@ -786,3 +786,127 @@ dumps the screen at 80x24, 120x40 and 200x60, populated and empty.
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<Node>`, 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`.