tui: clean-look chrome redesign (one accent, honest tor phase, real frames)
Applies the bitchat-tui clean-look principles to the OnionWire main screen. - Hierarchy: header, roster + one primary chat pane, one status line, one footer hint line. The header gives up the accent (the accent is reserved for focus), so it stops competing with the panes. - Tor phase is a first-class state: Node::tor_state() -> TorPhase (glyph + word, header and footer) so connecting / ready / degraded / off are never colour-only and never implied. No new data field. - Footer changes with the focused pane (pane_footer_hints) and the phase; the main footer drops the redundant onion (the header already prints it) and uses those cells for hints. status_footer keeps its signature and strings. - Empty roster / empty chat / connecting / degraded / off are designed states with their own copy, not blank panes. - draw_main_chrome + MainView: the real main render path is public and Node-free, so tests/tui_frames.rs dumps the actual chrome at 80x24, 120x40 and 200x60 (12 tests, 5 states, real Message/OutboxEntry rows) instead of a reconstructed stand-in. - Widths in cells everywhere touched: status_footer*, alert_line, main_header_line*, draw_text_overlay, roster_row_text. The roster spends its budget name-first, so a 22-cell pane reads `bob-the-sta… stale` instead of `… bbbbbbbb… stale`. - draw_text_overlay is centered with a one-cell side margin and clears underneath; never full-bleed. Also fixes a pre-existing race in tests/tui_spec.rs (the ellipsis-form assertion did not tolerate ONIONWIRE_ASCII being set by a parallel test). Co-Authored-By: Hermes <[email protected]>
This commit is contained in:
parent
14f9284463
commit
eefa7e5cc6
5 changed files with 1344 additions and 471 deletions
127
docs/TUI.md
127
docs/TUI.md
|
|
@ -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_*` |
|
||||
|
|
@ -704,3 +704,128 @@ sibling-card work, not presentation:
|
|||
- `Node::set_wallet_child_config(cfg)` — the child can be started/stopped and
|
||||
probed, not edited.
|
||||
- `Node::set_petname(..)` — no petname editor exists.
|
||||
|
||||
## 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`.
|
||||
|
|
|
|||
Loading…
Reference in a new issue