2026-09-12 14:22:38 -04:00
|
|
|
|
use std::collections::HashMap;
|
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
|
|
|
|
use std::io::{self, IsTerminal, Write};
|
2026-09-12 00:15:19 -04:00
|
|
|
|
use std::sync::{Arc, mpsc};
|
2026-09-12 14:22:38 -04:00
|
|
|
|
use std::time::{Duration, SystemTime, UNIX_EPOCH};
|
2026-09-10 01:54:19 -04:00
|
|
|
|
|
|
|
|
|
|
use ratatui::crossterm::event::{self, Event, KeyCode, KeyEvent, KeyEventKind, KeyModifiers};
|
tui: ASCII onion chrome, themed panes, and real keyboard navigation
- Hand-written wordmark banner (<=80 cols, auto-collapses to a compact
mark below banner width) plus onion glyph and themed screen headings
- Color-palette consts, stateful pane titles, highlighted selection row
(accent + bg), context-sensitive footer that always keeps '? help'
- Pane focus model (roster/chat/composer) with Tab/Shift-Tab, 1/2/3,
j/k + arrows, g/G, and a '?' help overlay; Esc closes any overlay
- New tests/tui_chrome.rs: banner widths, help overlay bindings, real
footer helper at 80 and 120 cols, 80x24 draw smoke test
- README keybinding table updated to match
Locked helper strings (fingerprint_mismatch_banner, rotate_screen_text,
wipe_screen_text, parse_slash) unchanged; UI-only (src/tui.rs).
2026-09-10 13:01:40 -04:00
|
|
|
|
use ratatui::layout::{Constraint, Layout, Rect};
|
|
|
|
|
|
use ratatui::style::{Color, Modifier, Style};
|
2026-09-12 00:54:16 -04:00
|
|
|
|
use ratatui::symbols::border;
|
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
|
|
|
|
use ratatui::text::{Line, Span};
|
tui: ASCII onion chrome, themed panes, and real keyboard navigation
- Hand-written wordmark banner (<=80 cols, auto-collapses to a compact
mark below banner width) plus onion glyph and themed screen headings
- Color-palette consts, stateful pane titles, highlighted selection row
(accent + bg), context-sensitive footer that always keeps '? help'
- Pane focus model (roster/chat/composer) with Tab/Shift-Tab, 1/2/3,
j/k + arrows, g/G, and a '?' help overlay; Esc closes any overlay
- New tests/tui_chrome.rs: banner widths, help overlay bindings, real
footer helper at 80 and 120 cols, 80x24 draw smoke test
- README keybinding table updated to match
Locked helper strings (fingerprint_mismatch_banner, rotate_screen_text,
wipe_screen_text, parse_slash) unchanged; UI-only (src/tui.rs).
2026-09-10 13:01:40 -04:00
|
|
|
|
use ratatui::widgets::{Block, Borders, Clear, List, ListItem, ListState, Paragraph, Wrap};
|
2026-09-10 01:54:19 -04:00
|
|
|
|
use ratatui::{DefaultTerminal, Frame};
|
2026-09-12 14:06:20 -04:00
|
|
|
|
use zeroize::{Zeroize, Zeroizing};
|
2026-09-10 01:54:19 -04:00
|
|
|
|
|
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]>
2026-09-18 23:13:12 -04:00
|
|
|
|
use crate::hs::TorState;
|
2026-09-10 02:43:45 -04:00
|
|
|
|
use crate::node::Node;
|
2026-09-12 14:22:38 -04:00
|
|
|
|
use crate::outbox::DEFAULT_MAX_ATTEMPTS;
|
2026-09-10 01:54:19 -04:00
|
|
|
|
use crate::qr::{self, QrPayload};
|
2026-09-11 23:42:48 -04:00
|
|
|
|
use crate::sanitize;
|
tui: peer payment history behind the F9 `payments` row (key p)
The F9 / `/settings` menu's only payment row showed the wallet's own transfer
list (`Node::wallet_recent_transfers`, F6). The signed `/pay` invoices and
`/tip` receipts a peer sent live in the `payments` table and had no path from
the TUI, so they were invisible. `Node::list_payments` (PR #119) closes that
gap; this wires it into a screen.
- `Screen::PeerPayments { state }` + `PeerPaymentsState` /
`PeerPaymentRow`, built by `PeerPaymentsState::from_payments` from
`Node::list_payments`' rows (newest first: the store returns `payments.id`
ascending, the screen windows the vector).
- Key handler: `p` on the F9 screen opens it (`open_peer_payments`); `up`/`down`
(or `k`/`j`) move the selection, `Esc` goes back, `F9` reopens the menu.
- Rows carry direction, kind, amount (`pay::atomic_to_xmr_str`, the same
piconero formatter the chat lines use), memo (sanitized at draw time) and the
receipt's `verified` / `unverified` word; the focused row is marked with `>`
and bold. The selected row's txid and address sit under the rows — the
address wrapped over two lines rather than clipped.
- States: populated, `no payments with {peer}`, `could not read payments`, and
a menu row that refuses when no friend is selected. An empty history is a
state, never an error.
- Menu: the wallet's own list is retitled `transfers` (F6, unchanged), and the
new `payments` row (key `p`) names the peer and the count. Two histories, two
rows, no ambiguity.
- Widths are measured in cells (`Span::width`); trailing columns are dropped
before they can wrap, so the body fits 80x24 (20 inner rows of 21) as well as
120x40 and 200x60.
Tests: new `tests/tui_payments.rs` (11 tests) dumps and asserts the screen at
80x24, 120x40 and 200x60 including the empty history, asserts a memo carrying
ESC/BEL/C1/bidi/newline bytes never reaches the frame buffer, and asserts the
window/column invariants for every width from 20 to 200.
Also relaxes one width assertion in `tests/tui_spec.rs`: `fit_cells` was
asserted to start with `"abcdef"`, which only holds when another test's
in-flight `ONIONWIRE_ASCII` mutation is not visible — the suite mutates env vars
without a global lock, so that test flaked (it also fails on an unmodified tree,
1 run in 2). It now accepts either chrome's cut point, which is what the comment
already claimed.
Docs: `docs/TUI.md` gains the screen's section, the retitled/replaced rows and
the updated row count; the "peer payment history" gap entry is closed.
2026-09-18 23:53:10 -04:00
|
|
|
|
use crate::store::{Friend, FriendProfile, Message, OutboxEntry, OutboxStatus, Payment};
|
wallet: land the in-process Cuprate chain source on main
`ChainSource::InProcessCuprate { datadir }` is the fourth chain source: P2P,
consensus and RandomX run inside the OnionWire process instead of as a spawned
`monerod`. The wallet layer does not move — the daemon binds the same loopback
unrestricted RPC (`127.0.0.1:18081`) that `WalletChild::daemon_address` already
returns for a local source, so `wallet_rpc_argv`, the RPC client, the payment
frames and the receipt-verification path are untouched.
- Cargo.toml: `cuprated` (git, rev 4f8fcd1b) + `toml`, both optional, behind the
`cuprate-daemon` feature, OFF by default. `cuprated`'s own `arti` feature is
disabled (`default-features = false`): its arti-client 0.44 cannot unify with
this crate's 0.46, and the in-process daemon is clearnet-only. One Tor stack in
the process. `Cargo.lock` gains the graph; a default build's
`cargo tree --locked -e normal -i cuprated` still says "did not match any
packages", and only `arti-client v0.46.0` is in the lock.
- src/cuprate.rs (new): `CuprateNode` builds the cuprated config as TOML
(testnet, unrestricted RPC on loopback, restricted RPC disabled, inbound P2P
off), launches it on a runtime it owns, and owns the node. `launch` is
synchronous on purpose: `WalletChild::start` is sync (the TUI calls it from its
blocking thread, UniFFI calls it from an async context) and a runtime cannot be
started from inside a runtime, so the launch runs on a thread of its own and
the node + its runtime come back over a channel. Dropping the value asks the
node to shut down and `shutdown_background`s the runtime, which is the only
exit that cannot panic when the value is dropped inside another runtime.
The type exists in every build (feature off: `launch` fails with the feature
name), so the chain-source type, its stored record and its copy do not fork on
a cargo feature.
- src/wallet.rs: the variant, its label (`in-process node`), and the chain-daemon
client the wallet line carried (typed `WalletError`, de-chunked HTTP,
`get_height` over the URI endpoint, an above-the-tip height as one typed
error). Cuprate answers those three differently from monerod and the
in-process source is what makes them the *local* case.
- src/wallet_child.rs: launches/holds/stops the node, `chain_datadir` for the
free-space/ownership question, the honest `chain_copy` line, `kind =
"cuprate"` in the sealed record, and `ChildConfig::validate` for it.
- src/tui.rs: the wallet screen's chain line carries the testnet caveat when the
configured source is the in-process one. It computes the line at draw time, so
`Screen::Wallet`'s shape (which tests construct) does not change.
- docs/WALLET.md, docs/THREAT_MODEL.md, docs/cuprate-android-spike.md: the
feature flag and how to enable it, where the (fjall) chain store lives, the
**measured** +11.8 MiB delta, the pre-production/testnet caveat, and the
in-repo aarch64-linux-android proof with exit codes.
Scope deviations, stated plainly:
- `src/cuprate.rs` and its one `src/lib.rs` module line are not in the card's
allowed list; the card's own deliverable describes the module's behaviour.
- `crates/onionwire-sdk/src/lib.rs` is forbidden, but adding a variant to a
`pub enum` that the SDK matches exhaustively breaks the SDK workspace, and the
root CI `sdk` job runs on every PR. One variant plus two match arms land here
so the SDK keeps compiling (`cargo test --locked` + clippy clean); the SDK card
owns the rest — feature passthrough, the config field's semantics, the label
and its tests, and the Android check.
- `tests/wallet.rs` carries the launch test. `tests/tui_frames.rs` is untouched:
main has no `ChainChoice` to pin (the chain-source picker is the unmerged F7
work, and `docs/WALLET.md` says so rather than describing a picker that does
not exist).
Proof (all on this tree):
- Default build: `cargo test --locked --target x86_64-unknown-linux-gnu` → 345
passed / 0 failed across 33 suites, exit 0; `cargo clippy --locked
--all-targets --target x86_64-unknown-linux-gnu -- -D warnings` exit 0.
- Feature on: `cargo test --locked --features cuprate-daemon --target
x86_64-unknown-linux-gnu` → 347 passed / 0 failed, exit 0; same clippy with
`--features cuprate-daemon` exit 0. The two extra tests are the real thing:
`wallet_child::tests::in_process_source_launches_a_daemon_and_stop_shuts_it_down`
and `tests/wallet.rs::an_in_process_cuprate_node_answers_the_typed_daemon_client`
— the latter launches the node, drives `get_info` / `get_height` / `get_block`
through the typed client, checks the above-the-tip 500 maps to
`DaemonHeightOutOfRange`, checks the chain store is under the chain datadir,
and checks the listener dies with the node.
- aarch64: `cargo check --locked --release --target aarch64-linux-android
--features cuprate-daemon` exit 0 (1m 50s), and the full link exit 0
(`cargo rustc ... --bin onionwire -- <NDK C++ runtime / compiler-rt link
args>`) producing `ELF 64-bit LSB pie executable, ARM aarch64, for Android 26,
built by NDK r28c`.
- Size: stripped aarch64 release binary, 24,725,704 bytes without the feature and
37,053,472 with it — +12,327,768 bytes (≈ +11.8 MiB), the figure
`docs/WALLET.md` now quotes.
2026-09-18 13:45:59 -04:00
|
|
|
|
use crate::wallet::{self, ChainSource};
|
2026-09-10 01:54:19 -04:00
|
|
|
|
|
tui: ASCII onion chrome, themed panes, and real keyboard navigation
- Hand-written wordmark banner (<=80 cols, auto-collapses to a compact
mark below banner width) plus onion glyph and themed screen headings
- Color-palette consts, stateful pane titles, highlighted selection row
(accent + bg), context-sensitive footer that always keeps '? help'
- Pane focus model (roster/chat/composer) with Tab/Shift-Tab, 1/2/3,
j/k + arrows, g/G, and a '?' help overlay; Esc closes any overlay
- New tests/tui_chrome.rs: banner widths, help overlay bindings, real
footer helper at 80 and 120 cols, 80x24 draw smoke test
- README keybinding table updated to match
Locked helper strings (fingerprint_mismatch_banner, rotate_screen_text,
wipe_screen_text, parse_slash) unchanged; UI-only (src/tui.rs).
2026-09-10 13:01:40 -04:00
|
|
|
|
const C_ACCENT: Color = Color::Rgb(232, 165, 75);
|
|
|
|
|
|
const C_TEXT: Color = Color::Rgb(196, 214, 176);
|
|
|
|
|
|
const C_DIM: Color = Color::Rgb(98, 110, 92);
|
|
|
|
|
|
const C_ALERT: Color = Color::Rgb(220, 80, 70);
|
|
|
|
|
|
const C_STALE: Color = Color::Rgb(210, 180, 80);
|
|
|
|
|
|
const C_HL_BG: Color = Color::Rgb(48, 42, 28);
|
|
|
|
|
|
const C_BORDER: Color = Color::Rgb(72, 84, 64);
|
|
|
|
|
|
|
2026-09-12 00:15:19 -04:00
|
|
|
|
|
2026-09-12 00:54:16 -04:00
|
|
|
|
/// ASCII chrome when `ONIONWIRE_ASCII` or `NO_COLOR` is set. No extra crate.
|
|
|
|
|
|
pub fn ascii_chrome() -> bool {
|
|
|
|
|
|
std::env::var_os("ONIONWIRE_ASCII").is_some() || std::env::var_os("NO_COLOR").is_some()
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const ASCII_BORDERS: border::Set = border::Set {
|
|
|
|
|
|
top_left: "+",
|
|
|
|
|
|
top_right: "+",
|
|
|
|
|
|
bottom_left: "+",
|
|
|
|
|
|
bottom_right: "+",
|
|
|
|
|
|
vertical_left: "|",
|
|
|
|
|
|
vertical_right: "|",
|
|
|
|
|
|
horizontal_top: "-",
|
|
|
|
|
|
horizontal_bottom: "-",
|
|
|
|
|
|
};
|
|
|
|
|
|
|
2026-09-12 00:15:19 -04:00
|
|
|
|
fn ellipsis() -> &'static str {
|
2026-09-12 00:54:16 -04:00
|
|
|
|
if ascii_chrome() { "..." } else { "…" }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// Truncate or keep an alert so it cannot spill into the roster row.
|
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]>
2026-09-18 23:13:12 -04:00
|
|
|
|
///
|
|
|
|
|
|
/// Cells, not chars: the message can carry a peer-supplied transport error, and
|
|
|
|
|
|
/// a CJK/emoji byte there must not push the alert into the next pane.
|
2026-09-12 00:54:16 -04:00
|
|
|
|
pub fn alert_line(msg: &str, width: u16) -> String {
|
|
|
|
|
|
let mut text = msg.to_string();
|
|
|
|
|
|
if color_mode() == ColorMode::None && !text.starts_with("! ") {
|
|
|
|
|
|
text = format!("! {text}");
|
|
|
|
|
|
}
|
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]>
2026-09-18 23:13:12 -04:00
|
|
|
|
fit_cells(&text, width as usize)
|
2026-09-12 00:54:16 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// Wrap an invite at `:` so a mouse-copy cannot lose a mid-hex continuation.
|
|
|
|
|
|
/// Joining the lines (no extra spaces) reconstructs `payload`.
|
|
|
|
|
|
pub fn wrap_invite(payload: &str, width: usize) -> String {
|
|
|
|
|
|
if width == 0 {
|
|
|
|
|
|
return String::new();
|
|
|
|
|
|
}
|
|
|
|
|
|
let mut lines: Vec<String> = Vec::new();
|
|
|
|
|
|
let mut cur = String::new();
|
|
|
|
|
|
let parts: Vec<&str> = payload.split(':').collect();
|
|
|
|
|
|
for (i, part) in parts.iter().enumerate() {
|
|
|
|
|
|
let piece = if i + 1 < parts.len() {
|
|
|
|
|
|
format!("{part}:")
|
|
|
|
|
|
} else {
|
|
|
|
|
|
(*part).to_string()
|
|
|
|
|
|
};
|
|
|
|
|
|
for chunk in char_chunks(&piece, width) {
|
|
|
|
|
|
if cur.is_empty() {
|
|
|
|
|
|
cur = chunk;
|
|
|
|
|
|
} else if char_len(&cur) + char_len(&chunk) <= width {
|
|
|
|
|
|
cur.push_str(&chunk);
|
|
|
|
|
|
} else {
|
|
|
|
|
|
lines.push(std::mem::take(&mut cur));
|
|
|
|
|
|
cur = chunk;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
if !cur.is_empty() {
|
|
|
|
|
|
lines.push(cur);
|
|
|
|
|
|
}
|
|
|
|
|
|
lines.join("\n")
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
fn char_chunks(s: &str, width: usize) -> Vec<String> {
|
|
|
|
|
|
if width == 0 {
|
|
|
|
|
|
return Vec::new();
|
|
|
|
|
|
}
|
|
|
|
|
|
if char_len(s) <= width {
|
|
|
|
|
|
return vec![s.to_string()];
|
|
|
|
|
|
}
|
|
|
|
|
|
let chars: Vec<char> = s.chars().collect();
|
|
|
|
|
|
chars.chunks(width).map(|c| c.iter().collect()).collect()
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// Friend selected, no messages yet.
|
|
|
|
|
|
pub fn empty_friend_chat_text() -> &'static str {
|
|
|
|
|
|
"no messages\ntype below, Enter sends"
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-09-12 14:22:38 -04:00
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
|
|
// Delivery state (outbox)
|
|
|
|
|
|
//
|
|
|
|
|
|
// The outbox is the only source of per-message state: `Queued` / `Sending` /
|
|
|
|
|
|
// `Failed` rows are what `Node::outbox_pending` still holds, and a row is
|
|
|
|
|
|
// deleted the moment the send crosses the circuit — so an outbound message with
|
|
|
|
|
|
// no row is `Sent`. No parallel state model, no new wire prefix.
|
|
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
/// Longest short-form failure reason shown in a chat row.
|
|
|
|
|
|
pub const FAIL_REASON_BUDGET: usize = 24;
|
|
|
|
|
|
|
|
|
|
|
|
/// Marker glyph for one delivery state. ASCII chrome falls back to `ok` for the
|
|
|
|
|
|
/// wordless delivered state; `queued` / `sending` / `failed` already carry their
|
|
|
|
|
|
/// word, so their glyph is dropped rather than invented.
|
|
|
|
|
|
pub fn delivery_glyph(status: &OutboxStatus) -> &'static str {
|
|
|
|
|
|
let ascii = ascii_chrome();
|
|
|
|
|
|
match status {
|
|
|
|
|
|
OutboxStatus::Sent => {
|
|
|
|
|
|
if ascii {
|
|
|
|
|
|
"ok"
|
|
|
|
|
|
} else {
|
|
|
|
|
|
"✓"
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
OutboxStatus::Queued => {
|
|
|
|
|
|
if ascii {
|
|
|
|
|
|
""
|
|
|
|
|
|
} else {
|
|
|
|
|
|
"◷"
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
OutboxStatus::Sending => {
|
|
|
|
|
|
if ascii {
|
|
|
|
|
|
""
|
|
|
|
|
|
} else {
|
|
|
|
|
|
"»"
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
OutboxStatus::Failed(_) => {
|
|
|
|
|
|
if ascii {
|
|
|
|
|
|
""
|
|
|
|
|
|
} else {
|
|
|
|
|
|
"✗"
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// Next-attempt age for a queued row, from the absolute `next_attempt_at` the
|
|
|
|
|
|
/// outbox stores.
|
|
|
|
|
|
pub fn retry_in_text(next_in_secs: i64) -> String {
|
|
|
|
|
|
if next_in_secs <= 0 {
|
|
|
|
|
|
"retry now".to_string()
|
|
|
|
|
|
} else if next_in_secs < 60 {
|
|
|
|
|
|
format!("retry {next_in_secs}s")
|
|
|
|
|
|
} else {
|
|
|
|
|
|
format!("retry {}m", (next_in_secs + 59) / 60)
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// Transport failure text, short form: sanitized, tail of the `a: b: c` chain,
|
|
|
|
|
|
/// capped at `budget` cells so one peer's error cannot blow out the row.
|
|
|
|
|
|
pub fn short_send_reason(why: &str, budget: usize) -> String {
|
|
|
|
|
|
let clean = sanitize::display_text(why.as_bytes());
|
|
|
|
|
|
let tail = clean.rsplit(": ").next().unwrap_or("").trim();
|
|
|
|
|
|
let text = if tail.is_empty() { clean.trim() } else { tail };
|
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]>
2026-09-18 23:13:12 -04:00
|
|
|
|
fit_cells(text, budget)
|
2026-09-12 14:22:38 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// One row's delivery marker, straight from the outbox state.
|
|
|
|
|
|
pub fn delivery_tag(status: &OutboxStatus, attempts: u32, next_in_secs: i64) -> String {
|
|
|
|
|
|
let glyph = delivery_glyph(status);
|
|
|
|
|
|
let body = match status {
|
|
|
|
|
|
OutboxStatus::Sent => String::new(),
|
|
|
|
|
|
OutboxStatus::Queued => format!(
|
|
|
|
|
|
"queued (try {attempts}/{DEFAULT_MAX_ATTEMPTS}, {})",
|
|
|
|
|
|
retry_in_text(next_in_secs)
|
|
|
|
|
|
),
|
|
|
|
|
|
OutboxStatus::Sending => "sending".to_string(),
|
|
|
|
|
|
OutboxStatus::Failed(why) => {
|
|
|
|
|
|
format!("failed: {}", short_send_reason(why, FAIL_REASON_BUDGET))
|
|
|
|
|
|
}
|
|
|
|
|
|
};
|
|
|
|
|
|
match (glyph.is_empty(), body.is_empty()) {
|
|
|
|
|
|
(_, true) => glyph.to_string(),
|
|
|
|
|
|
(true, false) => body,
|
|
|
|
|
|
(false, false) => format!("{glyph} {body}"),
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// Footer summary derived from the outbox rows of the selected friend.
|
|
|
|
|
|
#[derive(Debug, Default, Clone, PartialEq, Eq)]
|
|
|
|
|
|
pub struct OutboxSummary {
|
|
|
|
|
|
/// `Queued` + `Sending`: rows the worker may still deliver.
|
|
|
|
|
|
pub queued: usize,
|
|
|
|
|
|
/// Terminal failures — these never retry.
|
|
|
|
|
|
pub failed: usize,
|
|
|
|
|
|
/// First terminal failure, for the fail-closed footer copy.
|
|
|
|
|
|
pub first_error: Option<String>,
|
2026-09-17 20:44:28 -04:00
|
|
|
|
/// Highest attempt count across outstanding rows (0 when nothing is
|
|
|
|
|
|
/// outstanding). With `DEFAULT_MAX_ATTEMPTS` this is the `n` in `(n/8)`.
|
|
|
|
|
|
pub attempts: u32,
|
|
|
|
|
|
/// Seconds until the earliest scheduled retry, relative to the render
|
|
|
|
|
|
/// `now`. `None` while nothing is outstanding.
|
|
|
|
|
|
pub next_in_secs: Option<i64>,
|
2026-09-12 14:22:38 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
impl OutboxSummary {
|
|
|
|
|
|
/// Footer note, or `None` when nothing is outstanding. Any terminal failure
|
|
|
|
|
|
/// keeps a `send failed` statement so the fail-closed copy stays visible.
|
2026-09-17 20:44:28 -04:00
|
|
|
|
///
|
|
|
|
|
|
/// An outstanding row is a reachability statement, not just a count: the
|
|
|
|
|
|
/// peer's onion did not answer *this* dial, so the note names that and the
|
|
|
|
|
|
/// retry it is waiting on (`peer unreachable, queued (n/8, retry 45s)`).
|
|
|
|
|
|
/// There is no mutual-online indicator to fall back on.
|
2026-09-12 14:22:38 -04:00
|
|
|
|
pub fn note(&self) -> Option<String> {
|
|
|
|
|
|
let reason = || {
|
|
|
|
|
|
short_send_reason(
|
|
|
|
|
|
self.first_error.as_deref().unwrap_or("unknown"),
|
|
|
|
|
|
FAIL_REASON_BUDGET,
|
|
|
|
|
|
)
|
|
|
|
|
|
};
|
2026-09-17 20:44:28 -04:00
|
|
|
|
let queued = || {
|
|
|
|
|
|
format!(
|
|
|
|
|
|
"peer unreachable, queued ({}/{DEFAULT_MAX_ATTEMPTS}, {})",
|
|
|
|
|
|
self.attempts,
|
|
|
|
|
|
retry_in_text(self.next_in_secs.unwrap_or(0))
|
|
|
|
|
|
)
|
|
|
|
|
|
};
|
2026-09-12 14:22:38 -04:00
|
|
|
|
match (self.queued, self.failed) {
|
|
|
|
|
|
(0, 0) => None,
|
|
|
|
|
|
(0, 1) => Some(format!("send failed: {}", reason())),
|
|
|
|
|
|
(0, failed) => Some(format!("send failed: {} ({failed} failed)", reason())),
|
2026-09-17 20:44:28 -04:00
|
|
|
|
(_, 0) => Some(queued()),
|
|
|
|
|
|
(_, _) => Some(format!("{}, send failed: {}", queued(), reason())),
|
2026-09-12 14:22:38 -04:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// Chat transcript with per-message delivery state, plus the footer summary.
|
|
|
|
|
|
///
|
2026-09-12 14:34:37 -04:00
|
|
|
|
/// Pending rows are joined to messages on `Message::id` /
|
|
|
|
|
|
/// `OutboxEntry::message_id` — never on the body. Two identical bodies are
|
|
|
|
|
|
/// distinct rows with distinct ids, so the marker always lands on the row that
|
|
|
|
|
|
/// actually owns the outbox entry.
|
2026-09-12 14:22:38 -04:00
|
|
|
|
pub fn chat_with_delivery(
|
|
|
|
|
|
msgs: &[Message],
|
|
|
|
|
|
pending: &[OutboxEntry],
|
|
|
|
|
|
now: i64,
|
|
|
|
|
|
) -> (Vec<String>, OutboxSummary) {
|
|
|
|
|
|
let mut summary = OutboxSummary::default();
|
|
|
|
|
|
for entry in pending {
|
|
|
|
|
|
match &entry.status {
|
|
|
|
|
|
OutboxStatus::Failed(why) => {
|
|
|
|
|
|
summary.failed += 1;
|
|
|
|
|
|
summary.first_error.get_or_insert_with(|| why.clone());
|
|
|
|
|
|
}
|
2026-09-17 20:44:28 -04:00
|
|
|
|
_ => {
|
|
|
|
|
|
summary.queued += 1;
|
|
|
|
|
|
// The note is the reachability statement for the selected
|
|
|
|
|
|
// friend: highest attempt count, soonest scheduled retry.
|
|
|
|
|
|
summary.attempts = summary.attempts.max(entry.attempts);
|
|
|
|
|
|
let secs = entry.next_attempt_at - now;
|
|
|
|
|
|
summary.next_in_secs = Some(match summary.next_in_secs {
|
|
|
|
|
|
Some(prev) => prev.min(secs),
|
|
|
|
|
|
None => secs,
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
2026-09-12 14:22:38 -04:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
if msgs.is_empty() {
|
|
|
|
|
|
return (
|
|
|
|
|
|
empty_friend_chat_text()
|
|
|
|
|
|
.lines()
|
|
|
|
|
|
.map(str::to_string)
|
|
|
|
|
|
.collect(),
|
|
|
|
|
|
summary,
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-09-12 14:34:37 -04:00
|
|
|
|
// One row per message in practice (a retry updates its row, not inserts a
|
|
|
|
|
|
// second), and `pending` is ordered by row id, so a hypothetical duplicate
|
|
|
|
|
|
// resolves to the newest — the same rule the store's own
|
|
|
|
|
|
// `outbox_status_of_message` uses.
|
|
|
|
|
|
let by_id: HashMap<i64, &OutboxEntry> =
|
|
|
|
|
|
pending.iter().map(|entry| (entry.message_id, entry)).collect();
|
2026-09-12 14:22:38 -04:00
|
|
|
|
let mut tags: Vec<Option<String>> = vec![None; msgs.len()];
|
2026-09-12 14:34:37 -04:00
|
|
|
|
for (i, msg) in msgs.iter().enumerate() {
|
2026-09-12 14:22:38 -04:00
|
|
|
|
if msg.dir != "out" {
|
|
|
|
|
|
continue;
|
|
|
|
|
|
}
|
2026-09-12 14:34:37 -04:00
|
|
|
|
if let Some(entry) = by_id.get(&msg.id) {
|
2026-09-12 14:22:38 -04:00
|
|
|
|
tags[i] = Some(delivery_tag(
|
|
|
|
|
|
&entry.status,
|
|
|
|
|
|
entry.attempts,
|
|
|
|
|
|
entry.next_attempt_at - now,
|
|
|
|
|
|
));
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
let lines = msgs
|
|
|
|
|
|
.iter()
|
|
|
|
|
|
.enumerate()
|
|
|
|
|
|
.map(|(i, msg)| {
|
|
|
|
|
|
let side = if msg.dir == "out" { "you" } else { "them" };
|
|
|
|
|
|
let body = sanitize::display_text(&msg.plaintext);
|
|
|
|
|
|
let tag = match tags[i].clone() {
|
|
|
|
|
|
Some(tag) => tag,
|
|
|
|
|
|
None if msg.dir == "out" => delivery_tag(&OutboxStatus::Sent, 0, 0),
|
|
|
|
|
|
None => String::new(),
|
|
|
|
|
|
};
|
|
|
|
|
|
if tag.is_empty() {
|
|
|
|
|
|
format!("{side}: {body}")
|
|
|
|
|
|
} else {
|
|
|
|
|
|
format!("{side}: {body} {tag}")
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
.collect();
|
|
|
|
|
|
(lines, summary)
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-09-12 00:54:16 -04:00
|
|
|
|
/// Paste overlay copy. Error keeps the resubmit hint.
|
|
|
|
|
|
pub fn paste_screen_text(buf: &str, err: Option<&str>) -> String {
|
|
|
|
|
|
let hint = match err {
|
|
|
|
|
|
Some(e) => format!("{e}\nEnter resubmits Esc back"),
|
|
|
|
|
|
None => "paste onionwire:v1 payload, Enter to submit".to_string(),
|
|
|
|
|
|
};
|
|
|
|
|
|
format!("{hint}\n\n{buf}")
|
2026-09-12 00:15:19 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
fn char_len(s: &str) -> usize {
|
|
|
|
|
|
s.chars().count()
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-09-15 17:29:26 -04:00
|
|
|
|
/// Terminal colour capability, detected from the environment.
|
|
|
|
|
|
///
|
|
|
|
|
|
/// `ColorMode::None` means “strip all colour” (e.g. `NO_COLOR`); the TUI then
|
|
|
|
|
|
/// falls back to ASCII chrome and a `! ` prefix on alerts so signal survives.
|
|
|
|
|
|
/// `Ansi16` is the 16-colour fallback for dumb / non-TTY output. `Rgb` is the
|
|
|
|
|
|
/// full-fidelity path.
|
|
|
|
|
|
///
|
|
|
|
|
|
/// The palette (`C_*`) is always defined. `tokens_for(mode)` projects it into a
|
|
|
|
|
|
/// concrete `TokenStyles` so that tests can assert on the resolved `Style`
|
|
|
|
|
|
/// without depending on the process environment.
|
|
|
|
|
|
#[derive(Clone, Copy, PartialEq, Eq, Debug)]
|
|
|
|
|
|
pub enum ColorMode {
|
|
|
|
|
|
Rgb,
|
|
|
|
|
|
Ansi16,
|
|
|
|
|
|
None,
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// Detect the terminal's colour capability from the environment.
|
|
|
|
|
|
///
|
|
|
|
|
|
/// - `NO_COLOR` is set → `ColorMode::None`.
|
|
|
|
|
|
/// - `TERM=dumb` or stdout is not a TTY → `ColorMode::Ansi16`.
|
|
|
|
|
|
/// - Otherwise → `ColorMode::Rgb`.
|
|
|
|
|
|
pub fn color_mode() -> ColorMode {
|
|
|
|
|
|
if std::env::var_os("NO_COLOR").is_some() {
|
|
|
|
|
|
ColorMode::None
|
|
|
|
|
|
} else if std::env::var("TERM").ok().as_deref() == Some("dumb") || !io::stdout().is_terminal() {
|
|
|
|
|
|
ColorMode::Ansi16
|
|
|
|
|
|
} else {
|
|
|
|
|
|
ColorMode::Rgb
|
2026-09-12 00:15:19 -04:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-09-15 17:29:26 -04:00
|
|
|
|
/// All UI styles resolved for a single `ColorMode`. Tests construct this
|
|
|
|
|
|
/// directly instead of calling `color_mode()`, because the latter reads the
|
|
|
|
|
|
/// process environment (which is non-deterministic in `cargo test`).
|
|
|
|
|
|
pub struct TokenStyles {
|
|
|
|
|
|
/// Primary text (names, message bodies).
|
|
|
|
|
|
pub text: Style,
|
|
|
|
|
|
/// Muted / secondary text (timestamps, hints).
|
|
|
|
|
|
pub dim: Style,
|
|
|
|
|
|
/// Accent: headers, focus ring, selected friend.
|
|
|
|
|
|
pub accent: Style,
|
|
|
|
|
|
/// Alert: failure / validation errors.
|
|
|
|
|
|
pub alert: Style,
|
|
|
|
|
|
/// Stale data (unconfirmed, timed out).
|
|
|
|
|
|
pub stale: Style,
|
|
|
|
|
|
/// Border / chrome lines.
|
|
|
|
|
|
pub border: Style,
|
|
|
|
|
|
/// Highlight block (selected list row).
|
|
|
|
|
|
pub highlight: Style,
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// Project the RGB palette constants into a concrete [`TokenStyles`] for the
|
|
|
|
|
|
/// given `ColorMode`. This is the single source of truth the `style_*` helpers
|
|
|
|
|
|
/// delegate to, and the only surface tests assert against.
|
|
|
|
|
|
pub fn tokens_for(mode: ColorMode) -> TokenStyles {
|
|
|
|
|
|
let rgb = |fg: Color, ansi: Color| match mode {
|
|
|
|
|
|
ColorMode::None => Style::default(),
|
|
|
|
|
|
ColorMode::Ansi16 => Style::default().fg(ansi),
|
|
|
|
|
|
ColorMode::Rgb => Style::default().fg(fg),
|
|
|
|
|
|
};
|
|
|
|
|
|
let accent = match mode {
|
2026-09-12 00:15:19 -04:00
|
|
|
|
ColorMode::None => Style::default().add_modifier(Modifier::BOLD),
|
|
|
|
|
|
ColorMode::Ansi16 => Style::default().fg(Color::Yellow),
|
|
|
|
|
|
ColorMode::Rgb => Style::default().fg(C_ACCENT),
|
2026-09-15 17:29:26 -04:00
|
|
|
|
};
|
|
|
|
|
|
let highlight = match mode {
|
|
|
|
|
|
ColorMode::None => Style::default().add_modifier(Modifier::BOLD | Modifier::REVERSED),
|
|
|
|
|
|
ColorMode::Ansi16 => Style::default()
|
|
|
|
|
|
.add_modifier(Modifier::REVERSED | Modifier::BOLD),
|
|
|
|
|
|
ColorMode::Rgb => Style::default()
|
|
|
|
|
|
.bg(C_HL_BG)
|
|
|
|
|
|
.fg(C_ACCENT)
|
|
|
|
|
|
.add_modifier(Modifier::BOLD),
|
|
|
|
|
|
};
|
|
|
|
|
|
TokenStyles {
|
|
|
|
|
|
text: rgb(C_TEXT, Color::White),
|
|
|
|
|
|
dim: rgb(C_DIM, Color::DarkGray),
|
|
|
|
|
|
accent,
|
|
|
|
|
|
alert: rgb(C_ALERT, Color::Red),
|
|
|
|
|
|
stale: rgb(C_STALE, Color::Yellow),
|
|
|
|
|
|
border: rgb(C_BORDER, Color::DarkGray),
|
|
|
|
|
|
highlight,
|
2026-09-12 00:15:19 -04:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-09-15 17:29:26 -04:00
|
|
|
|
|
|
|
|
|
|
fn style_accent() -> Style {
|
|
|
|
|
|
tokens_for(color_mode()).accent
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-09-12 00:15:19 -04:00
|
|
|
|
fn style_text() -> Style {
|
2026-09-15 17:29:26 -04:00
|
|
|
|
tokens_for(color_mode()).text
|
2026-09-12 00:15:19 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
fn style_dim() -> Style {
|
2026-09-15 17:29:26 -04:00
|
|
|
|
tokens_for(color_mode()).dim
|
2026-09-12 00:15:19 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
fn style_alert() -> Style {
|
2026-09-15 17:29:26 -04:00
|
|
|
|
tokens_for(color_mode()).alert
|
2026-09-12 00:15:19 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
fn style_stale() -> Style {
|
2026-09-15 17:29:26 -04:00
|
|
|
|
tokens_for(color_mode()).stale
|
2026-09-12 00:15:19 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
fn style_border() -> Style {
|
2026-09-15 17:29:26 -04:00
|
|
|
|
tokens_for(color_mode()).border
|
2026-09-12 00:15:19 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
fn style_highlight() -> Style {
|
2026-09-15 17:29:26 -04:00
|
|
|
|
tokens_for(color_mode()).highlight
|
2026-09-12 00:15:19 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
2026-09-11 22:33:55 -04:00
|
|
|
|
/// How long the TUI waits for a key before redrawing (so background send can update status).
|
|
|
|
|
|
pub const TUI_POLL: Duration = Duration::from_millis(100);
|
|
|
|
|
|
|
|
|
|
|
|
/// Non-blocking read of a background send/job status. Never waits on Tor.
|
|
|
|
|
|
pub fn take_job_result(rx: &mpsc::Receiver<String>) -> Option<String> {
|
|
|
|
|
|
match rx.try_recv() {
|
|
|
|
|
|
Ok(s) => Some(s),
|
|
|
|
|
|
Err(mpsc::TryRecvError::Empty) => None,
|
|
|
|
|
|
Err(mpsc::TryRecvError::Disconnected) => Some("send failed".into()),
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-09-10 02:07:40 -04:00
|
|
|
|
pub fn fingerprint_mismatch_banner() -> &'static str {
|
|
|
|
|
|
"fingerprint mismatch"
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-09-10 02:43:45 -04:00
|
|
|
|
pub fn rotate_screen_text() -> &'static str {
|
|
|
|
|
|
"Rotate onion address?\n\
|
|
|
|
|
|
Your identity key stays the same.\n\
|
|
|
|
|
|
Online friends get a signed location update.\n\
|
2026-09-10 16:53:03 -04:00
|
|
|
|
Offline friends CANNOT find you until they F3-paste your new invite.\n\
|
2026-09-10 02:43:45 -04:00
|
|
|
|
Type ROTATE to confirm Esc to cancel"
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-09-17 20:48:10 -04:00
|
|
|
|
/// F8. Hard cut like the locator rotate: the prekey is our Noise static and the
|
|
|
|
|
|
/// ratchet bootstrap is derived from the prekey DH, so nothing short of a fresh
|
|
|
|
|
|
/// invite re-syncs a friend.
|
|
|
|
|
|
pub fn prekey_screen_text() -> &'static str {
|
|
|
|
|
|
"Rotate prekey?\n\
|
|
|
|
|
|
Your identity and onion stay the same.\n\
|
|
|
|
|
|
Every friend must F3-paste your new invite to pick up the new prekey,\n\
|
|
|
|
|
|
or you cannot reach them and they cannot reach you.\n\
|
|
|
|
|
|
Type ROTATE to confirm Esc to cancel"
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-09-10 17:19:50 -04:00
|
|
|
|
pub fn quit_screen_text() -> &'static str {
|
|
|
|
|
|
"Quit OnionWire?\n\
|
|
|
|
|
|
Message history can be cleared; identity and friends stay.\n\
|
|
|
|
|
|
This is not /wipe-all.\n\
|
|
|
|
|
|
Type CLEAR then Enter to clear history and quit.\n\
|
|
|
|
|
|
Type QUIT then Enter to quit without clearing.\n\
|
|
|
|
|
|
Esc to cancel"
|
|
|
|
|
|
}
|
|
|
|
|
|
|
tui: ASCII onion chrome, themed panes, and real keyboard navigation
- Hand-written wordmark banner (<=80 cols, auto-collapses to a compact
mark below banner width) plus onion glyph and themed screen headings
- Color-palette consts, stateful pane titles, highlighted selection row
(accent + bg), context-sensitive footer that always keeps '? help'
- Pane focus model (roster/chat/composer) with Tab/Shift-Tab, 1/2/3,
j/k + arrows, g/G, and a '?' help overlay; Esc closes any overlay
- New tests/tui_chrome.rs: banner widths, help overlay bindings, real
footer helper at 80 and 120 cols, 80x24 draw smoke test
- README keybinding table updated to match
Locked helper strings (fingerprint_mismatch_banner, rotate_screen_text,
wipe_screen_text, parse_slash) unchanged; UI-only (src/tui.rs).
2026-09-10 13:01:40 -04:00
|
|
|
|
/// Full Main-screen wordmark. Every line is <= 80 ASCII characters.
|
|
|
|
|
|
pub fn wordmark_banner() -> &'static str {
|
|
|
|
|
|
"\
|
|
|
|
|
|
.-~~-. .-~~-. .-~~-. ONIONWIRE\n\
|
|
|
|
|
|
( o )( o )( o ) identity = pubkey onion = locator\n\
|
|
|
|
|
|
`-..-' `-..-' `-..-' tor messenger no server"
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// One-line fallback when the terminal is narrower than the wordmark.
|
|
|
|
|
|
pub fn compact_banner() -> &'static str {
|
|
|
|
|
|
"ONIONWIRE (o) tor"
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
pub fn onion_glyph() -> &'static str {
|
|
|
|
|
|
"\
|
|
|
|
|
|
.-.\n\
|
|
|
|
|
|
( o )\n\
|
|
|
|
|
|
'-'"
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
pub fn help_overlay_text() -> &'static str {
|
|
|
|
|
|
"\
|
|
|
|
|
|
OnionWire keys\n\
|
|
|
|
|
|
\n\
|
|
|
|
|
|
Tab / Shift-Tab cycle roster, chat, composer\n\
|
|
|
|
|
|
1 / 2 / 3 focus roster / chat / composer\n\
|
|
|
|
|
|
j k or Up Down move or scroll focused pane\n\
|
|
|
|
|
|
g / G jump to top / bottom\n\
|
2026-09-10 23:07:22 -04:00
|
|
|
|
Enter send chat to selected friend, or a /command\n\
|
tui: ASCII onion chrome, themed panes, and real keyboard navigation
- Hand-written wordmark banner (<=80 cols, auto-collapses to a compact
mark below banner width) plus onion glyph and themed screen headings
- Color-palette consts, stateful pane titles, highlighted selection row
(accent + bg), context-sensitive footer that always keeps '? help'
- Pane focus model (roster/chat/composer) with Tab/Shift-Tab, 1/2/3,
j/k + arrows, g/G, and a '?' help overlay; Esc closes any overlay
- New tests/tui_chrome.rs: banner widths, help overlay bindings, real
footer helper at 80 and 120 cols, 80x24 draw smoke test
- README keybinding table updated to match
Locked helper strings (fingerprint_mismatch_banner, rotate_screen_text,
wipe_screen_text, parse_slash) unchanged; UI-only (src/tui.rs).
2026-09-10 13:01:40 -04:00
|
|
|
|
Esc close overlay, go back, clear composer\n\
|
2026-09-10 16:53:03 -04:00
|
|
|
|
F2 share invite\n\
|
|
|
|
|
|
F3 paste invite\n\
|
tui: ASCII onion chrome, themed panes, and real keyboard navigation
- Hand-written wordmark banner (<=80 cols, auto-collapses to a compact
mark below banner width) plus onion glyph and themed screen headings
- Color-palette consts, stateful pane titles, highlighted selection row
(accent + bg), context-sensitive footer that always keeps '? help'
- Pane focus model (roster/chat/composer) with Tab/Shift-Tab, 1/2/3,
j/k + arrows, g/G, and a '?' help overlay; Esc closes any overlay
- New tests/tui_chrome.rs: banner widths, help overlay bindings, real
footer helper at 80 and 120 cols, 80x24 draw smoke test
- README keybinding table updated to match
Locked helper strings (fingerprint_mismatch_banner, rotate_screen_text,
wipe_screen_text, parse_slash) unchanged; UI-only (src/tui.rs).
2026-09-10 13:01:40 -04:00
|
|
|
|
F4 rotate onion locator\n\
|
2026-09-10 14:25:31 -04:00
|
|
|
|
F5 selected friend's profile (/who)\n\
|
2026-09-13 23:25:25 -04:00
|
|
|
|
F6 wallet (receive QR, create/import)\n\
|
2026-09-17 20:48:10 -04:00
|
|
|
|
F8 rotate prekey\n\
|
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
|
|
|
|
F9 wallets & settings menu\n\
|
2026-09-10 14:25:31 -04:00
|
|
|
|
/profile edit name, bio, Monero address\n\
|
2026-09-10 14:37:43 -04:00
|
|
|
|
/pay <xmr> [memo] invoice to receive\n\
|
|
|
|
|
|
/tip <xmr> [memo] pay selected friend\n\
|
2026-09-13 23:25:25 -04:00
|
|
|
|
/wallet create new spend wallet (seed shown once)\n\
|
|
|
|
|
|
/wallet import restore from existing seed\n\
|
2026-09-10 23:32:06 -04:00
|
|
|
|
/file /path send file to selected friend (1 MiB)\n\
|
2026-09-10 14:50:01 -04:00
|
|
|
|
/backup /path encrypted identity export\n\
|
|
|
|
|
|
/restore /path overwrite self keys\n\
|
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
|
|
|
|
/wipe wipe messages; identity and friends stay\n\
|
|
|
|
|
|
/wipe-all wipe identity too — you become a new person\n\
|
|
|
|
|
|
/settings wallets & settings menu\n\
|
tui: ASCII onion chrome, themed panes, and real keyboard navigation
- Hand-written wordmark banner (<=80 cols, auto-collapses to a compact
mark below banner width) plus onion glyph and themed screen headings
- Color-palette consts, stateful pane titles, highlighted selection row
(accent + bg), context-sensitive footer that always keeps '? help'
- Pane focus model (roster/chat/composer) with Tab/Shift-Tab, 1/2/3,
j/k + arrows, g/G, and a '?' help overlay; Esc closes any overlay
- New tests/tui_chrome.rs: banner widths, help overlay bindings, real
footer helper at 80 and 120 cols, 80x24 draw smoke test
- README keybinding table updated to match
Locked helper strings (fingerprint_mismatch_banner, rotate_screen_text,
wipe_screen_text, parse_slash) unchanged; UI-only (src/tui.rs).
2026-09-10 13:01:40 -04:00
|
|
|
|
? this help\n\
|
2026-09-10 17:19:50 -04:00
|
|
|
|
Ctrl-Q quit; type CLEAR or QUIT\n\
|
tui: ASCII onion chrome, themed panes, and real keyboard navigation
- Hand-written wordmark banner (<=80 cols, auto-collapses to a compact
mark below banner width) plus onion glyph and themed screen headings
- Color-palette consts, stateful pane titles, highlighted selection row
(accent + bg), context-sensitive footer that always keeps '? help'
- Pane focus model (roster/chat/composer) with Tab/Shift-Tab, 1/2/3,
j/k + arrows, g/G, and a '?' help overlay; Esc closes any overlay
- New tests/tui_chrome.rs: banner widths, help overlay bindings, real
footer helper at 80 and 120 cols, 80x24 draw smoke test
- README keybinding table updated to match
Locked helper strings (fingerprint_mismatch_banner, rotate_screen_text,
wipe_screen_text, parse_slash) unchanged; UI-only (src/tui.rs).
2026-09-10 13:01:40 -04:00
|
|
|
|
\n\
|
|
|
|
|
|
Esc closes this overlay"
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-09-10 14:25:31 -04:00
|
|
|
|
pub fn who_overlay_text(fingerprint: &str, onion: &str, profile: Option<&FriendProfile>) -> String {
|
|
|
|
|
|
match profile {
|
|
|
|
|
|
None => format!(
|
|
|
|
|
|
"friend profile\n\nfp {fingerprint}\nonion {onion}\n\nno profile yet\n\nEsc closes"
|
|
|
|
|
|
),
|
|
|
|
|
|
Some(p) => {
|
|
|
|
|
|
let name = if p.display_name.is_empty() {
|
|
|
|
|
|
"(none)"
|
|
|
|
|
|
} else {
|
|
|
|
|
|
p.display_name.as_str()
|
|
|
|
|
|
};
|
|
|
|
|
|
let bio = if p.bio.is_empty() {
|
|
|
|
|
|
"(none)"
|
|
|
|
|
|
} else {
|
|
|
|
|
|
p.bio.as_str()
|
|
|
|
|
|
};
|
|
|
|
|
|
let xmr = if p.xmr_addr.is_empty() {
|
|
|
|
|
|
"(none)"
|
|
|
|
|
|
} else {
|
|
|
|
|
|
p.xmr_addr.as_str()
|
|
|
|
|
|
};
|
|
|
|
|
|
format!(
|
|
|
|
|
|
"friend profile\n\nname {name}\nbio {bio}\nxmr {xmr}\nfp {fingerprint}\nonion {onion}\n\nEsc closes"
|
|
|
|
|
|
)
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
tui: ASCII onion chrome, themed panes, and real keyboard navigation
- Hand-written wordmark banner (<=80 cols, auto-collapses to a compact
mark below banner width) plus onion glyph and themed screen headings
- Color-palette consts, stateful pane titles, highlighted selection row
(accent + bg), context-sensitive footer that always keeps '? help'
- Pane focus model (roster/chat/composer) with Tab/Shift-Tab, 1/2/3,
j/k + arrows, g/G, and a '?' help overlay; Esc closes any overlay
- New tests/tui_chrome.rs: banner widths, help overlay bindings, real
footer helper at 80 and 120 cols, 80x24 draw smoke test
- README keybinding table updated to match
Locked helper strings (fingerprint_mismatch_banner, rotate_screen_text,
wipe_screen_text, parse_slash) unchanged; UI-only (src/tui.rs).
2026-09-10 13:01:40 -04:00
|
|
|
|
pub fn banner_for_width(width: u16) -> &'static str {
|
|
|
|
|
|
let full = wordmark_banner();
|
|
|
|
|
|
let max_line = full.lines().map(|l| l.chars().count()).max().unwrap_or(0);
|
|
|
|
|
|
if (width as usize) >= max_line {
|
|
|
|
|
|
full
|
|
|
|
|
|
} else {
|
|
|
|
|
|
compact_banner()
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-09-12 00:15:19 -04:00
|
|
|
|
/// One-line main-screen header. Do not use `banner_for_width(80)` here — that stays the wordmark.
|
|
|
|
|
|
pub fn main_header_line(width: u16, me_fp: &str, me_onion: &str) -> String {
|
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]>
2026-09-18 23:13:12 -04:00
|
|
|
|
main_header_line_phased(width, me_fp, me_onion, None)
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// One-line main-screen header carrying the Tor phase. `None` keeps the
|
|
|
|
|
|
/// historic string; `Some` puts the phase word and glyph between the app name
|
|
|
|
|
|
/// and the identity.
|
|
|
|
|
|
pub fn main_header_line_phased(
|
|
|
|
|
|
width: u16,
|
|
|
|
|
|
me_fp: &str,
|
|
|
|
|
|
me_onion: &str,
|
|
|
|
|
|
phase: Option<TorPhase>,
|
|
|
|
|
|
) -> String {
|
|
|
|
|
|
fit_cells(&header_plain(me_fp, me_onion, phase), width as usize)
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// The header text without a width: one place builds the string, so the styled
|
|
|
|
|
|
/// spans and the plain helper can never drift apart.
|
|
|
|
|
|
fn header_plain(me_fp: &str, me_onion: &str, phase: Option<TorPhase>) -> String {
|
2026-09-12 00:15:19 -04:00
|
|
|
|
let fp: String = me_fp.chars().take(8).collect();
|
|
|
|
|
|
let onion = if me_onion.is_empty() {
|
|
|
|
|
|
"unset".to_string()
|
|
|
|
|
|
} else {
|
|
|
|
|
|
me_onion.chars().take(8).collect()
|
|
|
|
|
|
};
|
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]>
2026-09-18 23:13:12 -04:00
|
|
|
|
let tor = match phase {
|
|
|
|
|
|
None => "tor".to_string(),
|
|
|
|
|
|
Some(p) => format!("{} tor {}", p.glyph(), p.word()),
|
|
|
|
|
|
};
|
|
|
|
|
|
format!("onionwire {tor} me:{fp} onion:{onion}")
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// The header as spans. The app name is plain text (not accent — the accent is
|
|
|
|
|
|
/// reserved for focus), the identity is muted, and only the phase carries a
|
|
|
|
|
|
/// semantic colour. Too narrow to lay out in parts, the line degrades to one
|
|
|
|
|
|
/// truncated muted span rather than clipping mid-field.
|
|
|
|
|
|
pub fn main_header_spans(
|
|
|
|
|
|
width: u16,
|
|
|
|
|
|
me_fp: &str,
|
|
|
|
|
|
me_onion: &str,
|
|
|
|
|
|
phase: Option<TorPhase>,
|
|
|
|
|
|
) -> Vec<Span<'static>> {
|
|
|
|
|
|
let plain = header_plain(me_fp, me_onion, phase);
|
|
|
|
|
|
if cell_width(&plain) > width as usize {
|
|
|
|
|
|
return vec![Span::raw(fit_cells(&plain, width as usize)).style(style_dim())];
|
|
|
|
|
|
}
|
2026-09-12 00:15:19 -04:00
|
|
|
|
let fp: String = me_fp.chars().take(8).collect();
|
|
|
|
|
|
let onion = if me_onion.is_empty() {
|
|
|
|
|
|
"unset".to_string()
|
|
|
|
|
|
} else {
|
|
|
|
|
|
me_onion.chars().take(8).collect()
|
|
|
|
|
|
};
|
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]>
2026-09-18 23:13:12 -04:00
|
|
|
|
let (tor_text, tor_style) = match phase {
|
|
|
|
|
|
None => ("tor".to_string(), style_dim()),
|
|
|
|
|
|
Some(p) => (format!("{} tor {}", p.glyph(), p.word()), p.style()),
|
|
|
|
|
|
};
|
|
|
|
|
|
vec![
|
|
|
|
|
|
Span::raw("onionwire").style(style_text().add_modifier(Modifier::BOLD)),
|
|
|
|
|
|
Span::raw(" "),
|
|
|
|
|
|
Span::raw(tor_text).style(tor_style),
|
|
|
|
|
|
Span::raw(format!(" me:{fp} onion:{onion}")).style(style_dim()),
|
|
|
|
|
|
]
|
2026-09-12 00:15:19 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// Roster column in cells: 22 at 80-wide, 28 at 120+.
|
|
|
|
|
|
pub fn roster_col_width(term_width: u16) -> u16 {
|
|
|
|
|
|
if term_width >= 120 { 28 } else { 22 }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
tui: ASCII onion chrome, themed panes, and real keyboard navigation
- Hand-written wordmark banner (<=80 cols, auto-collapses to a compact
mark below banner width) plus onion glyph and themed screen headings
- Color-palette consts, stateful pane titles, highlighted selection row
(accent + bg), context-sensitive footer that always keeps '? help'
- Pane focus model (roster/chat/composer) with Tab/Shift-Tab, 1/2/3,
j/k + arrows, g/G, and a '?' help overlay; Esc closes any overlay
- New tests/tui_chrome.rs: banner widths, help overlay bindings, real
footer helper at 80 and 120 cols, 80x24 draw smoke test
- README keybinding table updated to match
Locked helper strings (fingerprint_mismatch_banner, rotate_screen_text,
wipe_screen_text, parse_slash) unchanged; UI-only (src/tui.rs).
2026-09-10 13:01:40 -04:00
|
|
|
|
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
|
|
|
|
|
pub enum Pane {
|
|
|
|
|
|
Roster,
|
|
|
|
|
|
Chat,
|
|
|
|
|
|
Composer,
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
impl Pane {
|
|
|
|
|
|
pub fn next(self) -> Self {
|
|
|
|
|
|
match self {
|
|
|
|
|
|
Self::Roster => Self::Chat,
|
|
|
|
|
|
Self::Chat => Self::Composer,
|
|
|
|
|
|
Self::Composer => Self::Roster,
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
pub fn prev(self) -> Self {
|
|
|
|
|
|
match self {
|
|
|
|
|
|
Self::Roster => Self::Composer,
|
|
|
|
|
|
Self::Chat => Self::Roster,
|
|
|
|
|
|
Self::Composer => Self::Chat,
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-09-10 02:49:42 -04:00
|
|
|
|
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
|
|
|
|
|
pub enum WipeKind {
|
|
|
|
|
|
Messages,
|
|
|
|
|
|
All,
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-09-10 14:37:43 -04:00
|
|
|
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
2026-09-10 14:25:31 -04:00
|
|
|
|
pub enum SlashCmd {
|
|
|
|
|
|
Wipe(WipeKind),
|
|
|
|
|
|
Profile,
|
|
|
|
|
|
Who,
|
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
|
|
|
|
/// `/settings` — the WALLETS & SETTINGS menu (same screen as F9).
|
|
|
|
|
|
Settings,
|
2026-09-10 14:37:43 -04:00
|
|
|
|
Pay { atomic: String, memo: String },
|
|
|
|
|
|
Tip { atomic: String, memo: String },
|
2026-09-10 14:50:01 -04:00
|
|
|
|
Backup { path: String },
|
|
|
|
|
|
Restore { path: String },
|
2026-09-10 23:32:06 -04:00
|
|
|
|
File { path: String },
|
2026-09-13 23:25:25 -04:00
|
|
|
|
WalletCreate,
|
|
|
|
|
|
WalletImport,
|
2026-09-10 14:25:31 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
2026-09-10 23:07:22 -04:00
|
|
|
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
|
|
|
|
|
pub enum ComposerAction {
|
|
|
|
|
|
Cmd(SlashCmd),
|
|
|
|
|
|
Send(String),
|
|
|
|
|
|
UnknownSlash(String),
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// Enter in the composer: slash command, chat send, or unknown `/cmd`.
|
|
|
|
|
|
pub fn composer_enter(raw: &str) -> Option<ComposerAction> {
|
|
|
|
|
|
let s = raw.trim();
|
|
|
|
|
|
if s.is_empty() {
|
|
|
|
|
|
return None;
|
|
|
|
|
|
}
|
|
|
|
|
|
if let Some(cmd) = parse_cmd(raw) {
|
|
|
|
|
|
return Some(ComposerAction::Cmd(cmd));
|
|
|
|
|
|
}
|
|
|
|
|
|
if s.starts_with('/') {
|
|
|
|
|
|
return Some(ComposerAction::UnknownSlash(s.to_string()));
|
|
|
|
|
|
}
|
|
|
|
|
|
Some(ComposerAction::Send(s.to_string()))
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-09-10 14:25:31 -04:00
|
|
|
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
|
|
|
|
|
pub struct ProfileDraft {
|
|
|
|
|
|
pub display_name: String,
|
|
|
|
|
|
pub bio: String,
|
|
|
|
|
|
pub xmr_addr: String,
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#[derive(Debug, Clone)]
|
|
|
|
|
|
pub struct ProfileEditor {
|
|
|
|
|
|
name: String,
|
|
|
|
|
|
bio: String,
|
|
|
|
|
|
xmr: String,
|
|
|
|
|
|
field: usize,
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
impl ProfileEditor {
|
|
|
|
|
|
pub fn new(display_name: &str, bio: &str, xmr_addr: &str) -> Self {
|
|
|
|
|
|
Self {
|
|
|
|
|
|
name: display_name.to_string(),
|
|
|
|
|
|
bio: bio.to_string(),
|
|
|
|
|
|
xmr: xmr_addr.to_string(),
|
|
|
|
|
|
field: 0,
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
pub fn on_enter(&self) -> ProfileDraft {
|
|
|
|
|
|
ProfileDraft {
|
|
|
|
|
|
display_name: self.name.clone(),
|
|
|
|
|
|
bio: self.bio.clone(),
|
|
|
|
|
|
xmr_addr: self.xmr.clone(),
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
pub fn on_tab(&mut self) {
|
|
|
|
|
|
self.field = (self.field + 1) % 3;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
pub fn on_backtab(&mut self) {
|
|
|
|
|
|
self.field = (self.field + 2) % 3;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
pub fn on_char(&mut self, c: char) {
|
|
|
|
|
|
if c == '\n' {
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
self.field_mut().push(c);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
pub fn on_backspace(&mut self) {
|
|
|
|
|
|
self.field_mut().pop();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
pub fn field(&self) -> usize {
|
|
|
|
|
|
self.field
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
pub fn display_name(&self) -> &str {
|
|
|
|
|
|
&self.name
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
pub fn bio(&self) -> &str {
|
|
|
|
|
|
&self.bio
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
pub fn xmr_addr(&self) -> &str {
|
|
|
|
|
|
&self.xmr
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
fn field_mut(&mut self) -> &mut String {
|
|
|
|
|
|
match self.field {
|
|
|
|
|
|
0 => &mut self.name,
|
|
|
|
|
|
1 => &mut self.bio,
|
|
|
|
|
|
_ => &mut self.xmr,
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-09-10 02:49:42 -04:00
|
|
|
|
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
|
|
|
|
|
pub enum WipeDecision {
|
|
|
|
|
|
Pending,
|
|
|
|
|
|
Confirm,
|
|
|
|
|
|
Cancel,
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
|
|
|
|
|
pub enum AppExit {
|
|
|
|
|
|
Quit,
|
|
|
|
|
|
WipeAll,
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-09-10 14:25:31 -04:00
|
|
|
|
pub fn parse_cmd(raw: &str) -> Option<SlashCmd> {
|
2026-09-10 14:37:43 -04:00
|
|
|
|
let s = raw.trim();
|
|
|
|
|
|
match s {
|
|
|
|
|
|
"/wipe" => return Some(SlashCmd::Wipe(WipeKind::Messages)),
|
|
|
|
|
|
"/wipe-all" => return Some(SlashCmd::Wipe(WipeKind::All)),
|
|
|
|
|
|
"/profile" => return Some(SlashCmd::Profile),
|
|
|
|
|
|
"/who" => return Some(SlashCmd::Who),
|
|
|
|
|
|
_ => {}
|
|
|
|
|
|
}
|
|
|
|
|
|
if let Some(rest) = s.strip_prefix("/pay")
|
|
|
|
|
|
&& (rest.is_empty() || rest.starts_with(char::is_whitespace))
|
|
|
|
|
|
{
|
|
|
|
|
|
return parse_amount_cmd(rest).map(|(atomic, memo)| SlashCmd::Pay { atomic, memo });
|
|
|
|
|
|
}
|
|
|
|
|
|
if let Some(rest) = s.strip_prefix("/tip")
|
|
|
|
|
|
&& (rest.is_empty() || rest.starts_with(char::is_whitespace))
|
|
|
|
|
|
{
|
|
|
|
|
|
return parse_amount_cmd(rest).map(|(atomic, memo)| SlashCmd::Tip { atomic, memo });
|
|
|
|
|
|
}
|
2026-09-10 14:50:01 -04:00
|
|
|
|
if let Some(rest) = s.strip_prefix("/backup")
|
|
|
|
|
|
&& (rest.is_empty() || rest.starts_with(char::is_whitespace))
|
|
|
|
|
|
{
|
|
|
|
|
|
return parse_path_cmd(rest).map(|path| SlashCmd::Backup { path });
|
|
|
|
|
|
}
|
|
|
|
|
|
if let Some(rest) = s.strip_prefix("/restore")
|
|
|
|
|
|
&& (rest.is_empty() || rest.starts_with(char::is_whitespace))
|
|
|
|
|
|
{
|
|
|
|
|
|
return parse_path_cmd(rest).map(|path| SlashCmd::Restore { path });
|
|
|
|
|
|
}
|
2026-09-10 23:32:06 -04:00
|
|
|
|
if let Some(rest) = s.strip_prefix("/file")
|
|
|
|
|
|
&& (rest.is_empty() || rest.starts_with(char::is_whitespace))
|
|
|
|
|
|
{
|
|
|
|
|
|
return parse_path_cmd(rest).map(|path| SlashCmd::File { path });
|
|
|
|
|
|
}
|
2026-09-13 23:25:25 -04:00
|
|
|
|
match s {
|
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
|
|
|
|
"/settings" => return Some(SlashCmd::Settings),
|
2026-09-13 23:25:25 -04:00
|
|
|
|
"/wallet create" => return Some(SlashCmd::WalletCreate),
|
|
|
|
|
|
"/wallet import" => return Some(SlashCmd::WalletImport),
|
|
|
|
|
|
_ => {}
|
|
|
|
|
|
}
|
2026-09-10 14:37:43 -04:00
|
|
|
|
None
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-09-10 14:50:01 -04:00
|
|
|
|
fn parse_path_cmd(rest: &str) -> Option<String> {
|
|
|
|
|
|
let path = rest.trim();
|
|
|
|
|
|
if path.is_empty() {
|
|
|
|
|
|
None
|
|
|
|
|
|
} else {
|
|
|
|
|
|
Some(path.to_string())
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-09-10 14:37:43 -04:00
|
|
|
|
fn parse_amount_cmd(rest: &str) -> Option<(String, String)> {
|
|
|
|
|
|
let rest = rest.trim();
|
|
|
|
|
|
if rest.is_empty() {
|
|
|
|
|
|
return None;
|
2026-09-10 14:25:31 -04:00
|
|
|
|
}
|
2026-09-10 14:37:43 -04:00
|
|
|
|
let mut parts = rest.splitn(2, char::is_whitespace);
|
|
|
|
|
|
let amount = parts.next()?.trim();
|
|
|
|
|
|
let memo = parts.next().unwrap_or("").trim().to_string();
|
|
|
|
|
|
let atomic = crate::pay::xmr_to_atomic(amount).ok()?;
|
|
|
|
|
|
Some((atomic, memo))
|
2026-09-10 14:25:31 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
pub fn parse_slash(raw: &str) -> Option<WipeKind> {
|
|
|
|
|
|
match parse_cmd(raw) {
|
|
|
|
|
|
Some(SlashCmd::Wipe(k)) => Some(k),
|
2026-09-10 02:49:42 -04:00
|
|
|
|
_ => None,
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
pub fn wipe_screen_text(kind: WipeKind) -> &'static str {
|
|
|
|
|
|
match kind {
|
|
|
|
|
|
WipeKind::Messages => {
|
2026-09-10 20:22:31 -04:00
|
|
|
|
"Wipe chat and payments history?\n\
|
2026-09-10 02:49:42 -04:00
|
|
|
|
Identity key and friends stay.\n\
|
2026-09-10 20:22:31 -04:00
|
|
|
|
Not a forensic erase.\n\
|
2026-09-10 02:49:42 -04:00
|
|
|
|
Type WIPE to confirm Esc to cancel"
|
|
|
|
|
|
}
|
|
|
|
|
|
WipeKind::All => {
|
|
|
|
|
|
"Wipe ALL local data?\n\
|
|
|
|
|
|
This deletes your identity key. You become a new person.\n\
|
|
|
|
|
|
Type WIPEALL to confirm Esc to cancel"
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#[derive(Debug)]
|
|
|
|
|
|
pub struct WipePrompt {
|
|
|
|
|
|
expected: &'static str,
|
|
|
|
|
|
buf: String,
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
impl WipePrompt {
|
|
|
|
|
|
pub fn messages() -> Self {
|
|
|
|
|
|
Self {
|
|
|
|
|
|
expected: "WIPE",
|
|
|
|
|
|
buf: String::new(),
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
pub fn all() -> Self {
|
|
|
|
|
|
Self {
|
|
|
|
|
|
expected: "WIPEALL",
|
|
|
|
|
|
buf: String::new(),
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
pub fn on_esc(&self) -> WipeDecision {
|
|
|
|
|
|
WipeDecision::Cancel
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
pub fn on_char(&mut self, c: char) -> WipeDecision {
|
|
|
|
|
|
if c == '\n' {
|
|
|
|
|
|
return WipeDecision::Pending;
|
|
|
|
|
|
}
|
|
|
|
|
|
if c == '\u{8}' {
|
|
|
|
|
|
self.buf.pop();
|
|
|
|
|
|
return WipeDecision::Pending;
|
|
|
|
|
|
}
|
|
|
|
|
|
if !c.is_ascii_alphabetic() {
|
|
|
|
|
|
return WipeDecision::Pending;
|
|
|
|
|
|
}
|
|
|
|
|
|
self.buf.push(c);
|
|
|
|
|
|
if self.buf == self.expected {
|
|
|
|
|
|
WipeDecision::Confirm
|
|
|
|
|
|
} else {
|
|
|
|
|
|
WipeDecision::Pending
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
pub fn typed(&self) -> &str {
|
|
|
|
|
|
&self.buf
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-09-10 02:43:45 -04:00
|
|
|
|
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
|
|
|
|
|
pub enum RotateDecision {
|
|
|
|
|
|
Pending,
|
|
|
|
|
|
Confirm,
|
|
|
|
|
|
Cancel,
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#[derive(Debug, Default)]
|
|
|
|
|
|
pub struct RotatePrompt {
|
|
|
|
|
|
buf: String,
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
impl RotatePrompt {
|
|
|
|
|
|
pub fn new() -> Self {
|
|
|
|
|
|
Self::default()
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
pub fn on_esc(&self) -> RotateDecision {
|
|
|
|
|
|
RotateDecision::Cancel
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
pub fn on_char(&mut self, c: char) -> RotateDecision {
|
|
|
|
|
|
if c == '\n' {
|
|
|
|
|
|
return RotateDecision::Pending;
|
|
|
|
|
|
}
|
|
|
|
|
|
if c == '\u{8}' {
|
|
|
|
|
|
self.buf.pop();
|
|
|
|
|
|
return RotateDecision::Pending;
|
|
|
|
|
|
}
|
|
|
|
|
|
if !c.is_ascii_alphabetic() {
|
|
|
|
|
|
return RotateDecision::Pending;
|
|
|
|
|
|
}
|
|
|
|
|
|
self.buf.push(c);
|
|
|
|
|
|
if self.buf == "ROTATE" {
|
|
|
|
|
|
RotateDecision::Confirm
|
|
|
|
|
|
} else {
|
|
|
|
|
|
RotateDecision::Pending
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
pub fn typed(&self) -> &str {
|
|
|
|
|
|
&self.buf
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-09-10 17:19:50 -04:00
|
|
|
|
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
|
|
|
|
|
pub enum QuitDecision {
|
|
|
|
|
|
Pending,
|
|
|
|
|
|
ClearAndQuit,
|
|
|
|
|
|
Quit,
|
|
|
|
|
|
Cancel,
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#[derive(Debug, Default)]
|
|
|
|
|
|
pub struct QuitPrompt {
|
|
|
|
|
|
buf: String,
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
impl QuitPrompt {
|
|
|
|
|
|
pub fn new() -> Self {
|
|
|
|
|
|
Self::default()
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
pub fn on_esc(&self) -> QuitDecision {
|
|
|
|
|
|
QuitDecision::Cancel
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
pub fn on_char(&mut self, c: char) -> QuitDecision {
|
|
|
|
|
|
if c == '\n' {
|
|
|
|
|
|
return match self.buf.as_str() {
|
|
|
|
|
|
"CLEAR" => QuitDecision::ClearAndQuit,
|
|
|
|
|
|
"QUIT" => QuitDecision::Quit,
|
|
|
|
|
|
_ => QuitDecision::Pending,
|
|
|
|
|
|
};
|
|
|
|
|
|
}
|
|
|
|
|
|
if c == '\u{8}' {
|
|
|
|
|
|
self.buf.pop();
|
|
|
|
|
|
return QuitDecision::Pending;
|
|
|
|
|
|
}
|
|
|
|
|
|
if !c.is_ascii_alphabetic() {
|
|
|
|
|
|
return QuitDecision::Pending;
|
|
|
|
|
|
}
|
|
|
|
|
|
self.buf.push(c);
|
|
|
|
|
|
QuitDecision::Pending
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
pub fn typed(&self) -> &str {
|
|
|
|
|
|
&self.buf
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-09-10 14:50:01 -04:00
|
|
|
|
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
|
|
|
|
|
pub enum BackupKind {
|
|
|
|
|
|
Backup,
|
|
|
|
|
|
Restore,
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
|
|
|
|
|
pub enum BackupDecision {
|
|
|
|
|
|
Pending,
|
|
|
|
|
|
Confirm,
|
|
|
|
|
|
Cancel,
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#[derive(Debug)]
|
|
|
|
|
|
pub struct BackupPrompt {
|
|
|
|
|
|
expected: &'static str,
|
|
|
|
|
|
buf: String,
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
impl BackupPrompt {
|
|
|
|
|
|
pub fn backup() -> Self {
|
|
|
|
|
|
Self {
|
|
|
|
|
|
expected: "BACKUP",
|
|
|
|
|
|
buf: String::new(),
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
pub fn restore() -> Self {
|
|
|
|
|
|
Self {
|
|
|
|
|
|
expected: "RESTORE",
|
|
|
|
|
|
buf: String::new(),
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
pub fn on_esc(&self) -> BackupDecision {
|
|
|
|
|
|
BackupDecision::Cancel
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
pub fn on_char(&mut self, c: char) -> BackupDecision {
|
|
|
|
|
|
if c == '\n' {
|
|
|
|
|
|
return BackupDecision::Pending;
|
|
|
|
|
|
}
|
|
|
|
|
|
if c == '\u{8}' {
|
|
|
|
|
|
self.buf.pop();
|
|
|
|
|
|
return BackupDecision::Pending;
|
|
|
|
|
|
}
|
|
|
|
|
|
if !c.is_ascii_alphabetic() {
|
|
|
|
|
|
return BackupDecision::Pending;
|
|
|
|
|
|
}
|
|
|
|
|
|
self.buf.push(c);
|
|
|
|
|
|
if self.buf == self.expected {
|
|
|
|
|
|
BackupDecision::Confirm
|
|
|
|
|
|
} else {
|
|
|
|
|
|
BackupDecision::Pending
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
pub fn typed(&self) -> &str {
|
|
|
|
|
|
&self.buf
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-09-12 14:06:20 -04:00
|
|
|
|
/// The in-progress passphrase on the backup/restore screen: the hidden buffer
|
|
|
|
|
|
/// plus the first entry, kept across the second prompt of the backup flow.
|
|
|
|
|
|
///
|
|
|
|
|
|
/// Both are `Zeroizing<String>`, so the passphrase does not sit in a plain
|
|
|
|
|
|
/// heap `String` for the life of the screen; `close()` wipes eagerly on every
|
|
|
|
|
|
/// exit path (submit, mismatch, cancel) instead of waiting for the screen
|
|
|
|
|
|
/// value to be dropped, and the wrapper covers the paths that cannot call it
|
|
|
|
|
|
/// (Ctrl-Q, a panic).
|
|
|
|
|
|
pub struct PassphraseEntry {
|
|
|
|
|
|
first: Option<Zeroizing<String>>,
|
|
|
|
|
|
buf: Zeroizing<String>,
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
impl Default for PassphraseEntry {
|
|
|
|
|
|
fn default() -> Self {
|
|
|
|
|
|
Self {
|
|
|
|
|
|
first: None,
|
|
|
|
|
|
buf: Zeroizing::new(String::new()),
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
impl PassphraseEntry {
|
|
|
|
|
|
pub fn new() -> Self {
|
|
|
|
|
|
Self::default()
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// Second prompt of the backup flow: the first passphrase was already typed.
|
|
|
|
|
|
pub fn with_first(first: &str) -> Self {
|
|
|
|
|
|
Self {
|
|
|
|
|
|
first: Some(Zeroizing::new(first.to_string())),
|
|
|
|
|
|
..Self::default()
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
pub fn push(&mut self, c: char) {
|
|
|
|
|
|
self.buf.push(c);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
pub fn backspace(&mut self) {
|
|
|
|
|
|
self.buf.pop();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// What the screen echoes back — the passphrase itself is not drawn.
|
|
|
|
|
|
pub fn buf(&self) -> &str {
|
|
|
|
|
|
self.buf.as_str()
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
pub fn first(&self) -> Option<&str> {
|
|
|
|
|
|
self.first.as_deref().map(String::as_str)
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// Take the typed passphrase for submission, leaving this entry empty.
|
|
|
|
|
|
pub fn take_buf(&mut self) -> Zeroizing<String> {
|
|
|
|
|
|
std::mem::replace(&mut self.buf, Zeroizing::new(String::new()))
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// Take the first-passphrase copy for the confirm comparison.
|
|
|
|
|
|
pub fn take_first(&mut self) -> Option<Zeroizing<String>> {
|
|
|
|
|
|
self.first.take()
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// Wipe both buffers: the screen is done with them.
|
|
|
|
|
|
pub fn close(&mut self) {
|
|
|
|
|
|
self.buf.zeroize();
|
|
|
|
|
|
if let Some(first) = self.first.as_mut() {
|
|
|
|
|
|
first.zeroize();
|
|
|
|
|
|
}
|
|
|
|
|
|
self.first = None;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-09-10 14:50:01 -04:00
|
|
|
|
pub fn backup_screen_text() -> &'static str {
|
|
|
|
|
|
"Write encrypted identity backup?\n\
|
|
|
|
|
|
This file is your identity secret. Treat it like the database.\n\
|
|
|
|
|
|
Onion (locator) is not included.\n\
|
|
|
|
|
|
Type BACKUP to confirm Esc to cancel"
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
pub fn restore_screen_text() -> &'static str {
|
|
|
|
|
|
"Restore identity from backup?\n\
|
|
|
|
|
|
This overwrites your self keys. It does not rewrite the roster.\n\
|
|
|
|
|
|
You may become a different person with old friends.\n\
|
|
|
|
|
|
Type RESTORE to confirm Esc to cancel"
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
pub fn restore_terminal() {
|
|
|
|
|
|
ratatui::restore();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-09-10 02:49:42 -04:00
|
|
|
|
pub fn run(node: Arc<Node>, rt: tokio::runtime::Handle) -> Result<AppExit, String> {
|
2026-09-10 14:50:01 -04:00
|
|
|
|
let prev = std::panic::take_hook();
|
|
|
|
|
|
std::panic::set_hook(Box::new(move |info| {
|
|
|
|
|
|
restore_terminal();
|
|
|
|
|
|
prev(info);
|
|
|
|
|
|
}));
|
2026-09-10 02:43:45 -04:00
|
|
|
|
let mut app = App::new(node, rt)?;
|
2026-09-10 01:54:19 -04:00
|
|
|
|
let mut terminal = ratatui::init();
|
|
|
|
|
|
let result = app.run(&mut terminal);
|
2026-09-10 14:50:01 -04:00
|
|
|
|
restore_terminal();
|
2026-09-10 01:54:19 -04:00
|
|
|
|
result
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
struct App {
|
2026-09-10 02:43:45 -04:00
|
|
|
|
node: Arc<Node>,
|
|
|
|
|
|
rt: tokio::runtime::Handle,
|
2026-09-10 01:54:19 -04:00
|
|
|
|
screen: Screen,
|
|
|
|
|
|
friends: Vec<Friend>,
|
|
|
|
|
|
selected: usize,
|
|
|
|
|
|
me_fp: String,
|
|
|
|
|
|
me_onion: String,
|
2026-09-10 02:07:40 -04:00
|
|
|
|
alert: Option<String>,
|
2026-09-10 02:43:45 -04:00
|
|
|
|
status_note: Option<String>,
|
2026-09-10 02:49:42 -04:00
|
|
|
|
composer: String,
|
tui: ASCII onion chrome, themed panes, and real keyboard navigation
- Hand-written wordmark banner (<=80 cols, auto-collapses to a compact
mark below banner width) plus onion glyph and themed screen headings
- Color-palette consts, stateful pane titles, highlighted selection row
(accent + bg), context-sensitive footer that always keeps '? help'
- Pane focus model (roster/chat/composer) with Tab/Shift-Tab, 1/2/3,
j/k + arrows, g/G, and a '?' help overlay; Esc closes any overlay
- New tests/tui_chrome.rs: banner widths, help overlay bindings, real
footer helper at 80 and 120 cols, 80x24 draw smoke test
- README keybinding table updated to match
Locked helper strings (fingerprint_mismatch_banner, rotate_screen_text,
wipe_screen_text, parse_slash) unchanged; UI-only (src/tui.rs).
2026-09-10 13:01:40 -04:00
|
|
|
|
focus: Pane,
|
|
|
|
|
|
help_open: bool,
|
2026-09-10 14:25:31 -04:00
|
|
|
|
who_open: bool,
|
tui: ASCII onion chrome, themed panes, and real keyboard navigation
- Hand-written wordmark banner (<=80 cols, auto-collapses to a compact
mark below banner width) plus onion glyph and themed screen headings
- Color-palette consts, stateful pane titles, highlighted selection row
(accent + bg), context-sensitive footer that always keeps '? help'
- Pane focus model (roster/chat/composer) with Tab/Shift-Tab, 1/2/3,
j/k + arrows, g/G, and a '?' help overlay; Esc closes any overlay
- New tests/tui_chrome.rs: banner widths, help overlay bindings, real
footer helper at 80 and 120 cols, 80x24 draw smoke test
- README keybinding table updated to match
Locked helper strings (fingerprint_mismatch_banner, rotate_screen_text,
wipe_screen_text, parse_slash) unchanged; UI-only (src/tui.rs).
2026-09-10 13:01:40 -04:00
|
|
|
|
chat_scroll: u16,
|
2026-09-11 22:33:55 -04:00
|
|
|
|
job_rx: Option<mpsc::Receiver<String>>,
|
2026-09-10 01:54:19 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
enum Screen {
|
|
|
|
|
|
Main,
|
2026-09-10 14:50:01 -04:00
|
|
|
|
Share {
|
|
|
|
|
|
payload: String,
|
|
|
|
|
|
},
|
|
|
|
|
|
Paste {
|
|
|
|
|
|
buf: String,
|
|
|
|
|
|
err: Option<String>,
|
|
|
|
|
|
},
|
|
|
|
|
|
Approve {
|
|
|
|
|
|
payload: QrPayload,
|
|
|
|
|
|
},
|
|
|
|
|
|
Rotate {
|
|
|
|
|
|
prompt: RotatePrompt,
|
|
|
|
|
|
},
|
2026-09-17 20:48:10 -04:00
|
|
|
|
RotatePrekey {
|
|
|
|
|
|
prompt: RotatePrompt,
|
|
|
|
|
|
},
|
2026-09-10 14:50:01 -04:00
|
|
|
|
Wipe {
|
|
|
|
|
|
kind: WipeKind,
|
|
|
|
|
|
prompt: WipePrompt,
|
|
|
|
|
|
},
|
|
|
|
|
|
Profile {
|
|
|
|
|
|
editor: ProfileEditor,
|
|
|
|
|
|
},
|
|
|
|
|
|
ConfirmKeys {
|
|
|
|
|
|
kind: BackupKind,
|
|
|
|
|
|
path: String,
|
|
|
|
|
|
prompt: BackupPrompt,
|
|
|
|
|
|
},
|
|
|
|
|
|
Passphrase {
|
|
|
|
|
|
kind: BackupKind,
|
|
|
|
|
|
path: String,
|
2026-09-12 14:06:20 -04:00
|
|
|
|
entry: PassphraseEntry,
|
2026-09-10 14:50:01 -04:00
|
|
|
|
},
|
2026-09-12 22:53:58 -04:00
|
|
|
|
Wallet {
|
|
|
|
|
|
receive_addr: String,
|
|
|
|
|
|
balance: String,
|
|
|
|
|
|
transfers: Vec<wallet::TransferRow>,
|
|
|
|
|
|
qr_modal: Option<QrModal>,
|
|
|
|
|
|
},
|
2026-09-13 23:25:25 -04:00
|
|
|
|
WalletSetup(WalletSetup),
|
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
|
|
|
|
/// F9 / `/settings`: the WALLETS & SETTINGS discovery menu. Holds the
|
|
|
|
|
|
/// snapshot, not a pre-rendered body, so a resize re-fits and nothing stale
|
|
|
|
|
|
/// survives a repaint.
|
|
|
|
|
|
WalletsSettings {
|
|
|
|
|
|
state: WalletMenuState,
|
|
|
|
|
|
},
|
tui: peer payment history behind the F9 `payments` row (key p)
The F9 / `/settings` menu's only payment row showed the wallet's own transfer
list (`Node::wallet_recent_transfers`, F6). The signed `/pay` invoices and
`/tip` receipts a peer sent live in the `payments` table and had no path from
the TUI, so they were invisible. `Node::list_payments` (PR #119) closes that
gap; this wires it into a screen.
- `Screen::PeerPayments { state }` + `PeerPaymentsState` /
`PeerPaymentRow`, built by `PeerPaymentsState::from_payments` from
`Node::list_payments`' rows (newest first: the store returns `payments.id`
ascending, the screen windows the vector).
- Key handler: `p` on the F9 screen opens it (`open_peer_payments`); `up`/`down`
(or `k`/`j`) move the selection, `Esc` goes back, `F9` reopens the menu.
- Rows carry direction, kind, amount (`pay::atomic_to_xmr_str`, the same
piconero formatter the chat lines use), memo (sanitized at draw time) and the
receipt's `verified` / `unverified` word; the focused row is marked with `>`
and bold. The selected row's txid and address sit under the rows — the
address wrapped over two lines rather than clipped.
- States: populated, `no payments with {peer}`, `could not read payments`, and
a menu row that refuses when no friend is selected. An empty history is a
state, never an error.
- Menu: the wallet's own list is retitled `transfers` (F6, unchanged), and the
new `payments` row (key `p`) names the peer and the count. Two histories, two
rows, no ambiguity.
- Widths are measured in cells (`Span::width`); trailing columns are dropped
before they can wrap, so the body fits 80x24 (20 inner rows of 21) as well as
120x40 and 200x60.
Tests: new `tests/tui_payments.rs` (11 tests) dumps and asserts the screen at
80x24, 120x40 and 200x60 including the empty history, asserts a memo carrying
ESC/BEL/C1/bidi/newline bytes never reaches the frame buffer, and asserts the
window/column invariants for every width from 20 to 200.
Also relaxes one width assertion in `tests/tui_spec.rs`: `fit_cells` was
asserted to start with `"abcdef"`, which only holds when another test's
in-flight `ONIONWIRE_ASCII` mutation is not visible — the suite mutates env vars
without a global lock, so that test flaked (it also fails on an unmodified tree,
1 run in 2). It now accepts either chrome's cut point, which is what the comment
already claimed.
Docs: `docs/TUI.md` gains the screen's section, the retitled/replaced rows and
the updated row count; the "peer payment history" gap entry is closed.
2026-09-18 23:53:10 -04:00
|
|
|
|
/// F9 → `payments`: the peer-scoped history from `Node::list_payments`.
|
|
|
|
|
|
/// Holds the same kind of snapshot as the menu (a resize re-fits it), so a
|
|
|
|
|
|
/// repaint never re-reads the store mid-frame.
|
|
|
|
|
|
PeerPayments {
|
|
|
|
|
|
state: PeerPaymentsState,
|
|
|
|
|
|
},
|
2026-09-10 17:19:50 -04:00
|
|
|
|
Quit {
|
|
|
|
|
|
prompt: QuitPrompt,
|
|
|
|
|
|
},
|
2026-09-10 01:54:19 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
2026-09-13 23:25:25 -04:00
|
|
|
|
enum WalletSetup {
|
|
|
|
|
|
CreateWarn { typed: String },
|
|
|
|
|
|
CreatePass { entry: PassphraseEntry },
|
|
|
|
|
|
CreateSeed { seed: Zeroizing<String>, typed: String },
|
|
|
|
|
|
ImportSeed { buf: Zeroizing<String> },
|
|
|
|
|
|
ImportPass { seed: Zeroizing<String>, entry: PassphraseEntry },
|
|
|
|
|
|
}
|
|
|
|
|
|
|
tui: F9 works on the peer-payments screen, and frames dump the real footer
Review round 1 on the F9 `payments` row found two false affordances.
1. `footer_hints(Screen::PeerPayments)` prints `F9 menu`, and docs/TUI.md says
F9 reopens the menu, but the `KeyCode::F(9)` arm opened it only from
`Screen::Main`, so pressing F9 on the peer history did nothing.
The function keys are now routed through one table, `function_key_for(screen,
code)`, and the F9 arm no longer has the Main-only guard: it opens (or
reopens) the menu from `Main`, `WalletsSettings` and `PeerPayments`. A screen
that names a key has to answer it while it is open — that is what the table
encodes, and `mod function_key_tests` locks it, including a test that reads
the screen's own hint and asserts every `F<n>` it names is answered there.
2. The PR's frame dumps passed `"Esc back up/down select ? help"` to
`status_footer` by hand, so every dumped frame showed a footer the app never
renders. `peer_payments_footer_hint()` is now the single source both
`footer_hints` and the fixture read, and
`peer_payments_frame_shows_the_shipped_footer` pins the dumped frame's last
line to the shipped one.
Also restores the rustfmt-only reflow of unrelated tests in `tests/tui_spec.rs`
(`queued_row`, a `failed_row` call, `rgb_tokens_…`, `alert_line_…`), keeping this
card's real edits there.
Presentation only: no wire, store, session, send-path or `Node` change.
2026-09-19 00:31:42 -04:00
|
|
|
|
/// A function key the TUI answers before the per-screen `match`; the screen's
|
|
|
|
|
|
/// own key handler never sees it.
|
|
|
|
|
|
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
|
|
|
|
|
enum FunctionKey {
|
|
|
|
|
|
Share,
|
|
|
|
|
|
Paste,
|
|
|
|
|
|
Rotate,
|
|
|
|
|
|
Who,
|
|
|
|
|
|
Wallet,
|
|
|
|
|
|
RotatePrekey,
|
|
|
|
|
|
OpenMenu,
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// The function key `screen` answers, or `None` when the key belongs to the
|
|
|
|
|
|
/// per-screen handler.
|
|
|
|
|
|
///
|
|
|
|
|
|
/// The function keys stay live on every screen that names one — in its footer
|
|
|
|
|
|
/// or in its body: a shortcut the user can read has to work while that screen
|
|
|
|
|
|
/// is open.
|
|
|
|
|
|
fn function_key_for(screen: &Screen, code: KeyCode) -> Option<FunctionKey> {
|
|
|
|
|
|
if !matches!(
|
|
|
|
|
|
screen,
|
|
|
|
|
|
Screen::Main | Screen::WalletsSettings { .. } | Screen::PeerPayments { .. }
|
|
|
|
|
|
) {
|
|
|
|
|
|
return None;
|
|
|
|
|
|
}
|
|
|
|
|
|
match code {
|
|
|
|
|
|
KeyCode::F(2) => Some(FunctionKey::Share),
|
|
|
|
|
|
KeyCode::F(3) => Some(FunctionKey::Paste),
|
|
|
|
|
|
KeyCode::F(4) => Some(FunctionKey::Rotate),
|
|
|
|
|
|
KeyCode::F(5) => Some(FunctionKey::Who),
|
|
|
|
|
|
KeyCode::F(6) => Some(FunctionKey::Wallet),
|
|
|
|
|
|
KeyCode::F(8) => Some(FunctionKey::RotatePrekey),
|
|
|
|
|
|
KeyCode::F(9) => Some(FunctionKey::OpenMenu),
|
|
|
|
|
|
_ => None,
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-09-10 01:54:19 -04:00
|
|
|
|
impl App {
|
2026-09-10 02:43:45 -04:00
|
|
|
|
fn new(node: Arc<Node>, rt: tokio::runtime::Handle) -> Result<Self, String> {
|
|
|
|
|
|
let friends = node.list_friends()?;
|
2026-09-10 01:54:19 -04:00
|
|
|
|
Ok(Self {
|
2026-09-10 02:43:45 -04:00
|
|
|
|
me_fp: to_hex(&node.identity_pk()),
|
|
|
|
|
|
me_onion: node.onion(),
|
|
|
|
|
|
node,
|
|
|
|
|
|
rt,
|
2026-09-10 01:54:19 -04:00
|
|
|
|
screen: Screen::Main,
|
|
|
|
|
|
friends,
|
|
|
|
|
|
selected: 0,
|
2026-09-10 02:07:40 -04:00
|
|
|
|
alert: None,
|
2026-09-10 02:43:45 -04:00
|
|
|
|
status_note: None,
|
2026-09-10 02:49:42 -04:00
|
|
|
|
composer: String::new(),
|
tui: ASCII onion chrome, themed panes, and real keyboard navigation
- Hand-written wordmark banner (<=80 cols, auto-collapses to a compact
mark below banner width) plus onion glyph and themed screen headings
- Color-palette consts, stateful pane titles, highlighted selection row
(accent + bg), context-sensitive footer that always keeps '? help'
- Pane focus model (roster/chat/composer) with Tab/Shift-Tab, 1/2/3,
j/k + arrows, g/G, and a '?' help overlay; Esc closes any overlay
- New tests/tui_chrome.rs: banner widths, help overlay bindings, real
footer helper at 80 and 120 cols, 80x24 draw smoke test
- README keybinding table updated to match
Locked helper strings (fingerprint_mismatch_banner, rotate_screen_text,
wipe_screen_text, parse_slash) unchanged; UI-only (src/tui.rs).
2026-09-10 13:01:40 -04:00
|
|
|
|
focus: Pane::Composer,
|
|
|
|
|
|
help_open: false,
|
2026-09-10 14:25:31 -04:00
|
|
|
|
who_open: false,
|
tui: ASCII onion chrome, themed panes, and real keyboard navigation
- Hand-written wordmark banner (<=80 cols, auto-collapses to a compact
mark below banner width) plus onion glyph and themed screen headings
- Color-palette consts, stateful pane titles, highlighted selection row
(accent + bg), context-sensitive footer that always keeps '? help'
- Pane focus model (roster/chat/composer) with Tab/Shift-Tab, 1/2/3,
j/k + arrows, g/G, and a '?' help overlay; Esc closes any overlay
- New tests/tui_chrome.rs: banner widths, help overlay bindings, real
footer helper at 80 and 120 cols, 80x24 draw smoke test
- README keybinding table updated to match
Locked helper strings (fingerprint_mismatch_banner, rotate_screen_text,
wipe_screen_text, parse_slash) unchanged; UI-only (src/tui.rs).
2026-09-10 13:01:40 -04:00
|
|
|
|
chat_scroll: 0,
|
2026-09-11 22:33:55 -04:00
|
|
|
|
job_rx: None,
|
2026-09-10 01:54:19 -04:00
|
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-09-10 02:49:42 -04:00
|
|
|
|
fn run(&mut self, terminal: &mut DefaultTerminal) -> Result<AppExit, String> {
|
2026-09-10 01:54:19 -04:00
|
|
|
|
loop {
|
2026-09-11 22:33:55 -04:00
|
|
|
|
self.drain_job();
|
2026-09-10 01:54:19 -04:00
|
|
|
|
terminal.draw(|f| self.draw(f)).map_err(|e| e.to_string())?;
|
2026-09-11 22:33:55 -04:00
|
|
|
|
if !event::poll(TUI_POLL).map_err(io_err)? {
|
|
|
|
|
|
continue;
|
|
|
|
|
|
}
|
2026-09-10 01:54:19 -04:00
|
|
|
|
let Event::Key(key) = event::read().map_err(io_err)? else {
|
|
|
|
|
|
continue;
|
|
|
|
|
|
};
|
|
|
|
|
|
if key.kind != KeyEventKind::Press {
|
|
|
|
|
|
continue;
|
|
|
|
|
|
}
|
|
|
|
|
|
if key.code == KeyCode::Char('q') && key.modifiers.contains(KeyModifiers::CONTROL) {
|
2026-09-10 17:19:50 -04:00
|
|
|
|
if !matches!(self.screen, Screen::Quit { .. }) {
|
|
|
|
|
|
self.screen = Screen::Quit {
|
|
|
|
|
|
prompt: QuitPrompt::new(),
|
|
|
|
|
|
};
|
|
|
|
|
|
}
|
|
|
|
|
|
continue;
|
2026-09-10 02:49:42 -04:00
|
|
|
|
}
|
|
|
|
|
|
if let Some(exit) = self.handle_key(key)? {
|
|
|
|
|
|
return Ok(exit);
|
2026-09-10 01:54:19 -04:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-09-10 02:49:42 -04:00
|
|
|
|
fn handle_key(&mut self, key: KeyEvent) -> Result<Option<AppExit>, String> {
|
tui: ASCII onion chrome, themed panes, and real keyboard navigation
- Hand-written wordmark banner (<=80 cols, auto-collapses to a compact
mark below banner width) plus onion glyph and themed screen headings
- Color-palette consts, stateful pane titles, highlighted selection row
(accent + bg), context-sensitive footer that always keeps '? help'
- Pane focus model (roster/chat/composer) with Tab/Shift-Tab, 1/2/3,
j/k + arrows, g/G, and a '?' help overlay; Esc closes any overlay
- New tests/tui_chrome.rs: banner widths, help overlay bindings, real
footer helper at 80 and 120 cols, 80x24 draw smoke test
- README keybinding table updated to match
Locked helper strings (fingerprint_mismatch_banner, rotate_screen_text,
wipe_screen_text, parse_slash) unchanged; UI-only (src/tui.rs).
2026-09-10 13:01:40 -04:00
|
|
|
|
if self.help_open {
|
|
|
|
|
|
match key.code {
|
|
|
|
|
|
KeyCode::Esc | KeyCode::Char('?') => self.help_open = false,
|
|
|
|
|
|
_ => {}
|
|
|
|
|
|
}
|
|
|
|
|
|
return Ok(None);
|
|
|
|
|
|
}
|
2026-09-10 14:25:31 -04:00
|
|
|
|
if self.who_open {
|
|
|
|
|
|
match key.code {
|
|
|
|
|
|
KeyCode::Esc | KeyCode::F(5) => self.who_open = false,
|
|
|
|
|
|
KeyCode::Char('?') => {
|
|
|
|
|
|
self.who_open = false;
|
|
|
|
|
|
self.help_open = true;
|
|
|
|
|
|
}
|
|
|
|
|
|
_ => {}
|
|
|
|
|
|
}
|
|
|
|
|
|
return Ok(None);
|
|
|
|
|
|
}
|
tui: ASCII onion chrome, themed panes, and real keyboard navigation
- Hand-written wordmark banner (<=80 cols, auto-collapses to a compact
mark below banner width) plus onion glyph and themed screen headings
- Color-palette consts, stateful pane titles, highlighted selection row
(accent + bg), context-sensitive footer that always keeps '? help'
- Pane focus model (roster/chat/composer) with Tab/Shift-Tab, 1/2/3,
j/k + arrows, g/G, and a '?' help overlay; Esc closes any overlay
- New tests/tui_chrome.rs: banner widths, help overlay bindings, real
footer helper at 80 and 120 cols, 80x24 draw smoke test
- README keybinding table updated to match
Locked helper strings (fingerprint_mismatch_banner, rotate_screen_text,
wipe_screen_text, parse_slash) unchanged; UI-only (src/tui.rs).
2026-09-10 13:01:40 -04:00
|
|
|
|
if key.code == KeyCode::Char('?') && !matches!(self.screen, Screen::Paste { .. }) {
|
|
|
|
|
|
self.help_open = true;
|
|
|
|
|
|
return Ok(None);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-09-10 02:49:42 -04:00
|
|
|
|
let mut wipe_confirm = None;
|
2026-09-10 17:19:50 -04:00
|
|
|
|
let mut quit_clear = None;
|
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
|
|
|
|
let mut copy_addr = false;
|
2026-09-10 14:25:31 -04:00
|
|
|
|
let mut profile_save = None;
|
|
|
|
|
|
let mut open_profile = false;
|
2026-09-10 14:37:43 -04:00
|
|
|
|
let mut pay_cmd = None;
|
|
|
|
|
|
let mut tip_cmd = None;
|
2026-09-10 23:32:06 -04:00
|
|
|
|
let mut file_cmd = None;
|
2026-09-10 23:07:22 -04:00
|
|
|
|
let mut chat_send = None;
|
2026-09-12 14:06:20 -04:00
|
|
|
|
let mut pass_submit = None;
|
tui: peer payment history behind the F9 `payments` row (key p)
The F9 / `/settings` menu's only payment row showed the wallet's own transfer
list (`Node::wallet_recent_transfers`, F6). The signed `/pay` invoices and
`/tip` receipts a peer sent live in the `payments` table and had no path from
the TUI, so they were invisible. `Node::list_payments` (PR #119) closes that
gap; this wires it into a screen.
- `Screen::PeerPayments { state }` + `PeerPaymentsState` /
`PeerPaymentRow`, built by `PeerPaymentsState::from_payments` from
`Node::list_payments`' rows (newest first: the store returns `payments.id`
ascending, the screen windows the vector).
- Key handler: `p` on the F9 screen opens it (`open_peer_payments`); `up`/`down`
(or `k`/`j`) move the selection, `Esc` goes back, `F9` reopens the menu.
- Rows carry direction, kind, amount (`pay::atomic_to_xmr_str`, the same
piconero formatter the chat lines use), memo (sanitized at draw time) and the
receipt's `verified` / `unverified` word; the focused row is marked with `>`
and bold. The selected row's txid and address sit under the rows — the
address wrapped over two lines rather than clipped.
- States: populated, `no payments with {peer}`, `could not read payments`, and
a menu row that refuses when no friend is selected. An empty history is a
state, never an error.
- Menu: the wallet's own list is retitled `transfers` (F6, unchanged), and the
new `payments` row (key `p`) names the peer and the count. Two histories, two
rows, no ambiguity.
- Widths are measured in cells (`Span::width`); trailing columns are dropped
before they can wrap, so the body fits 80x24 (20 inner rows of 21) as well as
120x40 and 200x60.
Tests: new `tests/tui_payments.rs` (11 tests) dumps and asserts the screen at
80x24, 120x40 and 200x60 including the empty history, asserts a memo carrying
ESC/BEL/C1/bidi/newline bytes never reaches the frame buffer, and asserts the
window/column invariants for every width from 20 to 200.
Also relaxes one width assertion in `tests/tui_spec.rs`: `fit_cells` was
asserted to start with `"abcdef"`, which only holds when another test's
in-flight `ONIONWIRE_ASCII` mutation is not visible — the suite mutates env vars
without a global lock, so that test flaked (it also fails on an unmodified tree,
1 run in 2). It now accepts either chrome's cut point, which is what the comment
already claimed.
Docs: `docs/TUI.md` gains the screen's section, the retitled/replaced rows and
the updated row count; the "peer payment history" gap entry is closed.
2026-09-18 23:53:10 -04:00
|
|
|
|
let mut open_payments = false;
|
|
|
|
|
|
let mut payments_back = false;
|
|
|
|
|
|
let mut payments_move = 0i32;
|
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
|
|
|
|
|
|
|
|
|
|
// The function-key shortcuts stay live on the WALLETS & SETTINGS screen
|
tui: F9 works on the peer-payments screen, and frames dump the real footer
Review round 1 on the F9 `payments` row found two false affordances.
1. `footer_hints(Screen::PeerPayments)` prints `F9 menu`, and docs/TUI.md says
F9 reopens the menu, but the `KeyCode::F(9)` arm opened it only from
`Screen::Main`, so pressing F9 on the peer history did nothing.
The function keys are now routed through one table, `function_key_for(screen,
code)`, and the F9 arm no longer has the Main-only guard: it opens (or
reopens) the menu from `Main`, `WalletsSettings` and `PeerPayments`. A screen
that names a key has to answer it while it is open — that is what the table
encodes, and `mod function_key_tests` locks it, including a test that reads
the screen's own hint and asserts every `F<n>` it names is answered there.
2. The PR's frame dumps passed `"Esc back up/down select ? help"` to
`status_footer` by hand, so every dumped frame showed a footer the app never
renders. `peer_payments_footer_hint()` is now the single source both
`footer_hints` and the fixture read, and
`peer_payments_frame_shows_the_shipped_footer` pins the dumped frame's last
line to the shipped one.
Also restores the rustfmt-only reflow of unrelated tests in `tests/tui_spec.rs`
(`queued_row`, a `failed_row` call, `rgb_tokens_…`, `alert_line_…`), keeping this
card's real edits there.
Presentation only: no wire, store, session, send-path or `Node` change.
2026-09-19 00:31:42 -04:00
|
|
|
|
// and the peer history too: the settings screen's whole point is naming
|
|
|
|
|
|
// the key that fires each row, and the history's footer names `F9
|
|
|
|
|
|
// menu`, so a key a screen names has to work while it is open.
|
|
|
|
|
|
if let Some(fk) = function_key_for(&self.screen, key.code) {
|
|
|
|
|
|
match fk {
|
|
|
|
|
|
FunctionKey::Share => self.open_share()?,
|
|
|
|
|
|
FunctionKey::Paste => {
|
2026-09-10 01:54:19 -04:00
|
|
|
|
self.screen = Screen::Paste {
|
|
|
|
|
|
buf: String::new(),
|
|
|
|
|
|
err: None,
|
|
|
|
|
|
};
|
|
|
|
|
|
}
|
tui: F9 works on the peer-payments screen, and frames dump the real footer
Review round 1 on the F9 `payments` row found two false affordances.
1. `footer_hints(Screen::PeerPayments)` prints `F9 menu`, and docs/TUI.md says
F9 reopens the menu, but the `KeyCode::F(9)` arm opened it only from
`Screen::Main`, so pressing F9 on the peer history did nothing.
The function keys are now routed through one table, `function_key_for(screen,
code)`, and the F9 arm no longer has the Main-only guard: it opens (or
reopens) the menu from `Main`, `WalletsSettings` and `PeerPayments`. A screen
that names a key has to answer it while it is open — that is what the table
encodes, and `mod function_key_tests` locks it, including a test that reads
the screen's own hint and asserts every `F<n>` it names is answered there.
2. The PR's frame dumps passed `"Esc back up/down select ? help"` to
`status_footer` by hand, so every dumped frame showed a footer the app never
renders. `peer_payments_footer_hint()` is now the single source both
`footer_hints` and the fixture read, and
`peer_payments_frame_shows_the_shipped_footer` pins the dumped frame's last
line to the shipped one.
Also restores the rustfmt-only reflow of unrelated tests in `tests/tui_spec.rs`
(`queued_row`, a `failed_row` call, `rgb_tokens_…`, `alert_line_…`), keeping this
card's real edits there.
Presentation only: no wire, store, session, send-path or `Node` change.
2026-09-19 00:31:42 -04:00
|
|
|
|
FunctionKey::Rotate => {
|
2026-09-10 02:43:45 -04:00
|
|
|
|
self.screen = Screen::Rotate {
|
|
|
|
|
|
prompt: RotatePrompt::new(),
|
|
|
|
|
|
};
|
|
|
|
|
|
}
|
tui: F9 works on the peer-payments screen, and frames dump the real footer
Review round 1 on the F9 `payments` row found two false affordances.
1. `footer_hints(Screen::PeerPayments)` prints `F9 menu`, and docs/TUI.md says
F9 reopens the menu, but the `KeyCode::F(9)` arm opened it only from
`Screen::Main`, so pressing F9 on the peer history did nothing.
The function keys are now routed through one table, `function_key_for(screen,
code)`, and the F9 arm no longer has the Main-only guard: it opens (or
reopens) the menu from `Main`, `WalletsSettings` and `PeerPayments`. A screen
that names a key has to answer it while it is open — that is what the table
encodes, and `mod function_key_tests` locks it, including a test that reads
the screen's own hint and asserts every `F<n>` it names is answered there.
2. The PR's frame dumps passed `"Esc back up/down select ? help"` to
`status_footer` by hand, so every dumped frame showed a footer the app never
renders. `peer_payments_footer_hint()` is now the single source both
`footer_hints` and the fixture read, and
`peer_payments_frame_shows_the_shipped_footer` pins the dumped frame's last
line to the shipped one.
Also restores the rustfmt-only reflow of unrelated tests in `tests/tui_spec.rs`
(`queued_row`, a `failed_row` call, `rgb_tokens_…`, `alert_line_…`), keeping this
card's real edits there.
Presentation only: no wire, store, session, send-path or `Node` change.
2026-09-19 00:31:42 -04:00
|
|
|
|
FunctionKey::Who => self.who_open = true,
|
|
|
|
|
|
FunctionKey::Wallet => self.open_wallet()?,
|
|
|
|
|
|
FunctionKey::RotatePrekey => {
|
2026-09-17 20:48:10 -04:00
|
|
|
|
self.screen = Screen::RotatePrekey {
|
|
|
|
|
|
prompt: RotatePrompt::new(),
|
|
|
|
|
|
};
|
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
|
|
|
|
}
|
tui: F9 works on the peer-payments screen, and frames dump the real footer
Review round 1 on the F9 `payments` row found two false affordances.
1. `footer_hints(Screen::PeerPayments)` prints `F9 menu`, and docs/TUI.md says
F9 reopens the menu, but the `KeyCode::F(9)` arm opened it only from
`Screen::Main`, so pressing F9 on the peer history did nothing.
The function keys are now routed through one table, `function_key_for(screen,
code)`, and the F9 arm no longer has the Main-only guard: it opens (or
reopens) the menu from `Main`, `WalletsSettings` and `PeerPayments`. A screen
that names a key has to answer it while it is open — that is what the table
encodes, and `mod function_key_tests` locks it, including a test that reads
the screen's own hint and asserts every `F<n>` it names is answered there.
2. The PR's frame dumps passed `"Esc back up/down select ? help"` to
`status_footer` by hand, so every dumped frame showed a footer the app never
renders. `peer_payments_footer_hint()` is now the single source both
`footer_hints` and the fixture read, and
`peer_payments_frame_shows_the_shipped_footer` pins the dumped frame's last
line to the shipped one.
Also restores the rustfmt-only reflow of unrelated tests in `tests/tui_spec.rs`
(`queued_row`, a `failed_row` call, `rgb_tokens_…`, `alert_line_…`), keeping this
card's real edits there.
Presentation only: no wire, store, session, send-path or `Node` change.
2026-09-19 00:31:42 -04:00
|
|
|
|
// One level above the screen it is pressed on: F9 from Main
|
|
|
|
|
|
// opens the menu, and from the menu or the peer history it
|
|
|
|
|
|
// reopens it rather than silently doing nothing.
|
|
|
|
|
|
FunctionKey::OpenMenu => self.open_wallets_settings()?,
|
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
|
|
|
|
}
|
tui: F9 works on the peer-payments screen, and frames dump the real footer
Review round 1 on the F9 `payments` row found two false affordances.
1. `footer_hints(Screen::PeerPayments)` prints `F9 menu`, and docs/TUI.md says
F9 reopens the menu, but the `KeyCode::F(9)` arm opened it only from
`Screen::Main`, so pressing F9 on the peer history did nothing.
The function keys are now routed through one table, `function_key_for(screen,
code)`, and the F9 arm no longer has the Main-only guard: it opens (or
reopens) the menu from `Main`, `WalletsSettings` and `PeerPayments`. A screen
that names a key has to answer it while it is open — that is what the table
encodes, and `mod function_key_tests` locks it, including a test that reads
the screen's own hint and asserts every `F<n>` it names is answered there.
2. The PR's frame dumps passed `"Esc back up/down select ? help"` to
`status_footer` by hand, so every dumped frame showed a footer the app never
renders. `peer_payments_footer_hint()` is now the single source both
`footer_hints` and the fixture read, and
`peer_payments_frame_shows_the_shipped_footer` pins the dumped frame's last
line to the shipped one.
Also restores the rustfmt-only reflow of unrelated tests in `tests/tui_spec.rs`
(`queued_row`, a `failed_row` call, `rgb_tokens_…`, `alert_line_…`), keeping this
card's real edits there.
Presentation only: no wire, store, session, send-path or `Node` change.
2026-09-19 00:31:42 -04:00
|
|
|
|
return Ok(None);
|
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
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
match &mut self.screen {
|
|
|
|
|
|
Screen::Main => match key.code {
|
|
|
|
|
|
KeyCode::Tab => self.focus = self.focus.next(),
|
|
|
|
|
|
KeyCode::BackTab => self.focus = self.focus.prev(),
|
|
|
|
|
|
KeyCode::Up => self.nav_up(),
|
|
|
|
|
|
KeyCode::Down => self.nav_down(),
|
2026-09-10 02:49:42 -04:00
|
|
|
|
KeyCode::Esc => self.composer.clear(),
|
|
|
|
|
|
KeyCode::Backspace => {
|
tui: ASCII onion chrome, themed panes, and real keyboard navigation
- Hand-written wordmark banner (<=80 cols, auto-collapses to a compact
mark below banner width) plus onion glyph and themed screen headings
- Color-palette consts, stateful pane titles, highlighted selection row
(accent + bg), context-sensitive footer that always keeps '? help'
- Pane focus model (roster/chat/composer) with Tab/Shift-Tab, 1/2/3,
j/k + arrows, g/G, and a '?' help overlay; Esc closes any overlay
- New tests/tui_chrome.rs: banner widths, help overlay bindings, real
footer helper at 80 and 120 cols, 80x24 draw smoke test
- README keybinding table updated to match
Locked helper strings (fingerprint_mismatch_banner, rotate_screen_text,
wipe_screen_text, parse_slash) unchanged; UI-only (src/tui.rs).
2026-09-10 13:01:40 -04:00
|
|
|
|
if self.focus == Pane::Composer {
|
|
|
|
|
|
self.composer.pop();
|
|
|
|
|
|
}
|
2026-09-10 02:49:42 -04:00
|
|
|
|
}
|
2026-09-10 23:07:22 -04:00
|
|
|
|
KeyCode::Enter => match composer_enter(&self.composer) {
|
|
|
|
|
|
Some(ComposerAction::Cmd(SlashCmd::Wipe(kind))) => {
|
2026-09-10 02:49:42 -04:00
|
|
|
|
self.composer.clear();
|
|
|
|
|
|
let prompt = match kind {
|
|
|
|
|
|
WipeKind::Messages => WipePrompt::messages(),
|
|
|
|
|
|
WipeKind::All => WipePrompt::all(),
|
|
|
|
|
|
};
|
|
|
|
|
|
self.screen = Screen::Wipe { kind, prompt };
|
|
|
|
|
|
}
|
2026-09-10 23:07:22 -04:00
|
|
|
|
Some(ComposerAction::Cmd(SlashCmd::Profile)) => {
|
2026-09-10 14:25:31 -04:00
|
|
|
|
self.composer.clear();
|
|
|
|
|
|
open_profile = true;
|
|
|
|
|
|
}
|
2026-09-10 23:07:22 -04:00
|
|
|
|
Some(ComposerAction::Cmd(SlashCmd::Who)) => {
|
2026-09-10 14:25:31 -04:00
|
|
|
|
self.composer.clear();
|
|
|
|
|
|
self.who_open = true;
|
|
|
|
|
|
}
|
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
|
|
|
|
Some(ComposerAction::Cmd(SlashCmd::Settings)) => {
|
|
|
|
|
|
self.composer.clear();
|
|
|
|
|
|
self.open_wallets_settings()?;
|
|
|
|
|
|
}
|
2026-09-10 23:07:22 -04:00
|
|
|
|
Some(ComposerAction::Cmd(SlashCmd::Pay { atomic, memo })) => {
|
2026-09-10 14:37:43 -04:00
|
|
|
|
self.composer.clear();
|
|
|
|
|
|
pay_cmd = Some((atomic, memo));
|
|
|
|
|
|
}
|
2026-09-10 23:07:22 -04:00
|
|
|
|
Some(ComposerAction::Cmd(SlashCmd::Tip { atomic, memo })) => {
|
2026-09-10 14:37:43 -04:00
|
|
|
|
self.composer.clear();
|
|
|
|
|
|
tip_cmd = Some((atomic, memo));
|
|
|
|
|
|
}
|
2026-09-10 23:07:22 -04:00
|
|
|
|
Some(ComposerAction::Cmd(SlashCmd::Backup { path })) => {
|
2026-09-10 14:50:01 -04:00
|
|
|
|
self.composer.clear();
|
|
|
|
|
|
self.screen = Screen::ConfirmKeys {
|
|
|
|
|
|
kind: BackupKind::Backup,
|
|
|
|
|
|
path,
|
|
|
|
|
|
prompt: BackupPrompt::backup(),
|
|
|
|
|
|
};
|
|
|
|
|
|
}
|
2026-09-10 23:07:22 -04:00
|
|
|
|
Some(ComposerAction::Cmd(SlashCmd::Restore { path })) => {
|
2026-09-10 14:50:01 -04:00
|
|
|
|
self.composer.clear();
|
|
|
|
|
|
self.screen = Screen::ConfirmKeys {
|
|
|
|
|
|
kind: BackupKind::Restore,
|
|
|
|
|
|
path,
|
|
|
|
|
|
prompt: BackupPrompt::restore(),
|
|
|
|
|
|
};
|
|
|
|
|
|
}
|
2026-09-10 23:32:06 -04:00
|
|
|
|
Some(ComposerAction::Cmd(SlashCmd::File { path })) => {
|
|
|
|
|
|
self.composer.clear();
|
|
|
|
|
|
file_cmd = Some(path);
|
|
|
|
|
|
}
|
2026-09-13 23:25:25 -04:00
|
|
|
|
Some(ComposerAction::Cmd(SlashCmd::WalletCreate)) => {
|
|
|
|
|
|
self.composer.clear();
|
|
|
|
|
|
self.screen = Screen::WalletSetup(WalletSetup::CreateWarn {
|
|
|
|
|
|
typed: String::new(),
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
Some(ComposerAction::Cmd(SlashCmd::WalletImport)) => {
|
|
|
|
|
|
self.composer.clear();
|
|
|
|
|
|
self.screen = Screen::WalletSetup(WalletSetup::ImportSeed {
|
|
|
|
|
|
buf: Zeroizing::new(String::new()),
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
2026-09-10 23:07:22 -04:00
|
|
|
|
Some(ComposerAction::Send(text)) => {
|
|
|
|
|
|
self.composer.clear();
|
|
|
|
|
|
chat_send = Some(text);
|
|
|
|
|
|
}
|
|
|
|
|
|
Some(ComposerAction::UnknownSlash(cmd)) => {
|
|
|
|
|
|
self.composer.clear();
|
|
|
|
|
|
self.status_note = Some(format!("unknown command {cmd}"));
|
|
|
|
|
|
}
|
2026-09-10 14:25:31 -04:00
|
|
|
|
None => {}
|
|
|
|
|
|
},
|
2026-09-10 02:49:42 -04:00
|
|
|
|
KeyCode::Char(c) if !key.modifiers.contains(KeyModifiers::CONTROL) => {
|
tui: ASCII onion chrome, themed panes, and real keyboard navigation
- Hand-written wordmark banner (<=80 cols, auto-collapses to a compact
mark below banner width) plus onion glyph and themed screen headings
- Color-palette consts, stateful pane titles, highlighted selection row
(accent + bg), context-sensitive footer that always keeps '? help'
- Pane focus model (roster/chat/composer) with Tab/Shift-Tab, 1/2/3,
j/k + arrows, g/G, and a '?' help overlay; Esc closes any overlay
- New tests/tui_chrome.rs: banner widths, help overlay bindings, real
footer helper at 80 and 120 cols, 80x24 draw smoke test
- README keybinding table updated to match
Locked helper strings (fingerprint_mismatch_banner, rotate_screen_text,
wipe_screen_text, parse_slash) unchanged; UI-only (src/tui.rs).
2026-09-10 13:01:40 -04:00
|
|
|
|
self.handle_main_char(c);
|
2026-09-10 02:49:42 -04:00
|
|
|
|
}
|
2026-09-10 01:54:19 -04:00
|
|
|
|
_ => {}
|
|
|
|
|
|
},
|
|
|
|
|
|
Screen::Share { .. } => {
|
|
|
|
|
|
if key.code == KeyCode::Esc {
|
|
|
|
|
|
self.screen = Screen::Main;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
Screen::Paste { buf, err } => match key.code {
|
|
|
|
|
|
KeyCode::Esc => self.screen = Screen::Main,
|
|
|
|
|
|
KeyCode::Enter => {
|
|
|
|
|
|
let raw = buf.clone();
|
|
|
|
|
|
self.submit_paste(&raw)?;
|
|
|
|
|
|
}
|
|
|
|
|
|
KeyCode::Backspace => {
|
|
|
|
|
|
buf.pop();
|
|
|
|
|
|
*err = None;
|
|
|
|
|
|
}
|
|
|
|
|
|
KeyCode::Char(c) if !key.modifiers.contains(KeyModifiers::CONTROL) => {
|
|
|
|
|
|
buf.push(c);
|
|
|
|
|
|
*err = None;
|
|
|
|
|
|
}
|
|
|
|
|
|
_ => {}
|
|
|
|
|
|
},
|
|
|
|
|
|
Screen::Approve { payload } => match key.code {
|
|
|
|
|
|
KeyCode::Char('y') | KeyCode::Enter => {
|
|
|
|
|
|
let p = payload.clone();
|
|
|
|
|
|
self.accept_friend(&p)?;
|
|
|
|
|
|
}
|
|
|
|
|
|
KeyCode::Char('n') | KeyCode::Esc => self.screen = Screen::Main,
|
|
|
|
|
|
_ => {}
|
|
|
|
|
|
},
|
2026-09-10 02:43:45 -04:00
|
|
|
|
Screen::Rotate { prompt } => match key.code {
|
|
|
|
|
|
KeyCode::Esc => self.screen = Screen::Main,
|
|
|
|
|
|
KeyCode::Char(c) if !key.modifiers.contains(KeyModifiers::CONTROL) => {
|
|
|
|
|
|
if prompt.on_char(c) == RotateDecision::Confirm {
|
|
|
|
|
|
self.confirm_rotate()?;
|
|
|
|
|
|
}
|
2026-09-10 01:54:19 -04:00
|
|
|
|
}
|
2026-09-10 02:43:45 -04:00
|
|
|
|
KeyCode::Backspace => {
|
|
|
|
|
|
prompt.on_char('\u{8}');
|
|
|
|
|
|
}
|
|
|
|
|
|
_ => {}
|
|
|
|
|
|
},
|
2026-09-17 20:48:10 -04:00
|
|
|
|
Screen::RotatePrekey { prompt } => match key.code {
|
|
|
|
|
|
KeyCode::Esc => self.screen = Screen::Main,
|
|
|
|
|
|
KeyCode::Char(c) if !key.modifiers.contains(KeyModifiers::CONTROL) => {
|
|
|
|
|
|
if prompt.on_char(c) == RotateDecision::Confirm {
|
|
|
|
|
|
self.confirm_rotate_prekey()?;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
KeyCode::Backspace => {
|
|
|
|
|
|
prompt.on_char('\u{8}');
|
|
|
|
|
|
}
|
|
|
|
|
|
_ => {}
|
|
|
|
|
|
},
|
2026-09-10 02:49:42 -04:00
|
|
|
|
Screen::Wipe { kind, prompt } => {
|
|
|
|
|
|
let kind = *kind;
|
|
|
|
|
|
match key.code {
|
|
|
|
|
|
KeyCode::Esc => self.screen = Screen::Main,
|
|
|
|
|
|
KeyCode::Char(c) if !key.modifiers.contains(KeyModifiers::CONTROL) => {
|
|
|
|
|
|
if prompt.on_char(c) == WipeDecision::Confirm {
|
|
|
|
|
|
wipe_confirm = Some(kind);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
KeyCode::Backspace => {
|
|
|
|
|
|
prompt.on_char('\u{8}');
|
|
|
|
|
|
}
|
|
|
|
|
|
_ => {}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2026-09-10 14:25:31 -04:00
|
|
|
|
Screen::Profile { editor } => match key.code {
|
|
|
|
|
|
KeyCode::Esc => self.screen = Screen::Main,
|
|
|
|
|
|
KeyCode::Tab => editor.on_tab(),
|
|
|
|
|
|
KeyCode::BackTab => editor.on_backtab(),
|
|
|
|
|
|
KeyCode::Backspace => editor.on_backspace(),
|
|
|
|
|
|
KeyCode::Enter => profile_save = Some(editor.on_enter()),
|
|
|
|
|
|
KeyCode::Char(c) if !key.modifiers.contains(KeyModifiers::CONTROL) => {
|
|
|
|
|
|
editor.on_char(c);
|
|
|
|
|
|
}
|
|
|
|
|
|
_ => {}
|
|
|
|
|
|
},
|
2026-09-10 14:50:01 -04:00
|
|
|
|
Screen::ConfirmKeys { kind, path, prompt } => {
|
|
|
|
|
|
let kind = *kind;
|
|
|
|
|
|
match key.code {
|
|
|
|
|
|
KeyCode::Esc => self.screen = Screen::Main,
|
|
|
|
|
|
KeyCode::Char(c) if !key.modifiers.contains(KeyModifiers::CONTROL) => {
|
|
|
|
|
|
if prompt.on_char(c) == BackupDecision::Confirm {
|
|
|
|
|
|
self.screen = Screen::Passphrase {
|
|
|
|
|
|
kind,
|
|
|
|
|
|
path: path.clone(),
|
2026-09-12 14:06:20 -04:00
|
|
|
|
entry: PassphraseEntry::new(),
|
2026-09-10 14:50:01 -04:00
|
|
|
|
};
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
KeyCode::Backspace => {
|
|
|
|
|
|
prompt.on_char('\u{8}');
|
|
|
|
|
|
}
|
|
|
|
|
|
_ => {}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2026-09-12 14:06:20 -04:00
|
|
|
|
Screen::Passphrase { kind, path, entry } => match key.code {
|
|
|
|
|
|
KeyCode::Esc => {
|
|
|
|
|
|
entry.close();
|
|
|
|
|
|
self.screen = Screen::Main;
|
2026-09-10 14:50:01 -04:00
|
|
|
|
}
|
2026-09-12 14:06:20 -04:00
|
|
|
|
KeyCode::Backspace => entry.backspace(),
|
2026-09-10 14:50:01 -04:00
|
|
|
|
KeyCode::Enter => {
|
2026-09-12 14:06:20 -04:00
|
|
|
|
pass_submit = Some((*kind, path.clone(), entry.take_first(), entry.take_buf()));
|
2026-09-10 14:50:01 -04:00
|
|
|
|
}
|
|
|
|
|
|
KeyCode::Char(c) if !key.modifiers.contains(KeyModifiers::CONTROL) => {
|
2026-09-12 14:06:20 -04:00
|
|
|
|
entry.push(c);
|
2026-09-10 14:50:01 -04:00
|
|
|
|
}
|
|
|
|
|
|
_ => {}
|
|
|
|
|
|
},
|
2026-09-12 22:53:58 -04:00
|
|
|
|
Screen::Wallet { .. } => match key.code {
|
|
|
|
|
|
KeyCode::Esc => self.screen = Screen::Main,
|
|
|
|
|
|
KeyCode::Char('r') | KeyCode::Enter => self.wallet_toggle_qr(),
|
2026-09-18 09:28:11 -04:00
|
|
|
|
KeyCode::Char('s') => self.wallet_child_start(),
|
|
|
|
|
|
KeyCode::Char('x') => self.wallet_child_stop(),
|
|
|
|
|
|
KeyCode::Char('p') => self.wallet_child_probe(),
|
2026-09-13 23:25:25 -04:00
|
|
|
|
KeyCode::Char('c') => {
|
|
|
|
|
|
self.screen = Screen::WalletSetup(WalletSetup::CreateWarn {
|
|
|
|
|
|
typed: String::new(),
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
KeyCode::Char('i') => {
|
|
|
|
|
|
self.screen = Screen::WalletSetup(WalletSetup::ImportSeed {
|
|
|
|
|
|
buf: Zeroizing::new(String::new()),
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
2026-09-12 22:53:58 -04:00
|
|
|
|
_ => {}
|
|
|
|
|
|
},
|
2026-09-13 23:25:25 -04:00
|
|
|
|
Screen::WalletSetup(_) => self.handle_wallet_setup(key)?,
|
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
|
|
|
|
Screen::WalletsSettings { .. } => match key.code {
|
|
|
|
|
|
KeyCode::Esc => self.screen = Screen::Main,
|
|
|
|
|
|
KeyCode::Char('c') => copy_addr = true,
|
tui: peer payment history behind the F9 `payments` row (key p)
The F9 / `/settings` menu's only payment row showed the wallet's own transfer
list (`Node::wallet_recent_transfers`, F6). The signed `/pay` invoices and
`/tip` receipts a peer sent live in the `payments` table and had no path from
the TUI, so they were invisible. `Node::list_payments` (PR #119) closes that
gap; this wires it into a screen.
- `Screen::PeerPayments { state }` + `PeerPaymentsState` /
`PeerPaymentRow`, built by `PeerPaymentsState::from_payments` from
`Node::list_payments`' rows (newest first: the store returns `payments.id`
ascending, the screen windows the vector).
- Key handler: `p` on the F9 screen opens it (`open_peer_payments`); `up`/`down`
(or `k`/`j`) move the selection, `Esc` goes back, `F9` reopens the menu.
- Rows carry direction, kind, amount (`pay::atomic_to_xmr_str`, the same
piconero formatter the chat lines use), memo (sanitized at draw time) and the
receipt's `verified` / `unverified` word; the focused row is marked with `>`
and bold. The selected row's txid and address sit under the rows — the
address wrapped over two lines rather than clipped.
- States: populated, `no payments with {peer}`, `could not read payments`, and
a menu row that refuses when no friend is selected. An empty history is a
state, never an error.
- Menu: the wallet's own list is retitled `transfers` (F6, unchanged), and the
new `payments` row (key `p`) names the peer and the count. Two histories, two
rows, no ambiguity.
- Widths are measured in cells (`Span::width`); trailing columns are dropped
before they can wrap, so the body fits 80x24 (20 inner rows of 21) as well as
120x40 and 200x60.
Tests: new `tests/tui_payments.rs` (11 tests) dumps and asserts the screen at
80x24, 120x40 and 200x60 including the empty history, asserts a memo carrying
ESC/BEL/C1/bidi/newline bytes never reaches the frame buffer, and asserts the
window/column invariants for every width from 20 to 200.
Also relaxes one width assertion in `tests/tui_spec.rs`: `fit_cells` was
asserted to start with `"abcdef"`, which only holds when another test's
in-flight `ONIONWIRE_ASCII` mutation is not visible — the suite mutates env vars
without a global lock, so that test flaked (it also fails on an unmodified tree,
1 run in 2). It now accepts either chrome's cut point, which is what the comment
already claimed.
Docs: `docs/TUI.md` gains the screen's section, the retitled/replaced rows and
the updated row count; the "peer payment history" gap entry is closed.
2026-09-18 23:53:10 -04:00
|
|
|
|
// `p` is the key the menu's `payments` row prints.
|
|
|
|
|
|
KeyCode::Char('p') => open_payments = true,
|
|
|
|
|
|
_ => {}
|
|
|
|
|
|
},
|
|
|
|
|
|
Screen::PeerPayments { .. } => match key.code {
|
|
|
|
|
|
KeyCode::Esc => payments_back = true,
|
|
|
|
|
|
KeyCode::Up | KeyCode::Char('k') => payments_move = -1,
|
|
|
|
|
|
KeyCode::Down | KeyCode::Char('j') => payments_move = 1,
|
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
|
|
|
|
_ => {}
|
|
|
|
|
|
},
|
2026-09-10 17:19:50 -04:00
|
|
|
|
Screen::Quit { prompt } => match key.code {
|
|
|
|
|
|
KeyCode::Esc => self.screen = Screen::Main,
|
|
|
|
|
|
KeyCode::Enter => match prompt.on_char('\n') {
|
|
|
|
|
|
QuitDecision::ClearAndQuit => quit_clear = Some(true),
|
|
|
|
|
|
QuitDecision::Quit => quit_clear = Some(false),
|
|
|
|
|
|
_ => {}
|
|
|
|
|
|
},
|
|
|
|
|
|
KeyCode::Backspace => {
|
|
|
|
|
|
prompt.on_char('\u{8}');
|
|
|
|
|
|
}
|
|
|
|
|
|
KeyCode::Char(c) if !key.modifiers.contains(KeyModifiers::CONTROL) => {
|
|
|
|
|
|
prompt.on_char(c);
|
|
|
|
|
|
}
|
|
|
|
|
|
_ => {}
|
|
|
|
|
|
},
|
2026-09-10 02:49:42 -04:00
|
|
|
|
}
|
|
|
|
|
|
if let Some(kind) = wipe_confirm {
|
|
|
|
|
|
return self.confirm_wipe(kind);
|
|
|
|
|
|
}
|
tui: peer payment history behind the F9 `payments` row (key p)
The F9 / `/settings` menu's only payment row showed the wallet's own transfer
list (`Node::wallet_recent_transfers`, F6). The signed `/pay` invoices and
`/tip` receipts a peer sent live in the `payments` table and had no path from
the TUI, so they were invisible. `Node::list_payments` (PR #119) closes that
gap; this wires it into a screen.
- `Screen::PeerPayments { state }` + `PeerPaymentsState` /
`PeerPaymentRow`, built by `PeerPaymentsState::from_payments` from
`Node::list_payments`' rows (newest first: the store returns `payments.id`
ascending, the screen windows the vector).
- Key handler: `p` on the F9 screen opens it (`open_peer_payments`); `up`/`down`
(or `k`/`j`) move the selection, `Esc` goes back, `F9` reopens the menu.
- Rows carry direction, kind, amount (`pay::atomic_to_xmr_str`, the same
piconero formatter the chat lines use), memo (sanitized at draw time) and the
receipt's `verified` / `unverified` word; the focused row is marked with `>`
and bold. The selected row's txid and address sit under the rows — the
address wrapped over two lines rather than clipped.
- States: populated, `no payments with {peer}`, `could not read payments`, and
a menu row that refuses when no friend is selected. An empty history is a
state, never an error.
- Menu: the wallet's own list is retitled `transfers` (F6, unchanged), and the
new `payments` row (key `p`) names the peer and the count. Two histories, two
rows, no ambiguity.
- Widths are measured in cells (`Span::width`); trailing columns are dropped
before they can wrap, so the body fits 80x24 (20 inner rows of 21) as well as
120x40 and 200x60.
Tests: new `tests/tui_payments.rs` (11 tests) dumps and asserts the screen at
80x24, 120x40 and 200x60 including the empty history, asserts a memo carrying
ESC/BEL/C1/bidi/newline bytes never reaches the frame buffer, and asserts the
window/column invariants for every width from 20 to 200.
Also relaxes one width assertion in `tests/tui_spec.rs`: `fit_cells` was
asserted to start with `"abcdef"`, which only holds when another test's
in-flight `ONIONWIRE_ASCII` mutation is not visible — the suite mutates env vars
without a global lock, so that test flaked (it also fails on an unmodified tree,
1 run in 2). It now accepts either chrome's cut point, which is what the comment
already claimed.
Docs: `docs/TUI.md` gains the screen's section, the retitled/replaced rows and
the updated row count; the "peer payment history" gap entry is closed.
2026-09-18 23:53:10 -04:00
|
|
|
|
if payments_move != 0
|
|
|
|
|
|
&& let Screen::PeerPayments { state } = &mut self.screen
|
|
|
|
|
|
{
|
|
|
|
|
|
if payments_move < 0 {
|
|
|
|
|
|
state.select_prev();
|
|
|
|
|
|
} else {
|
|
|
|
|
|
state.select_next();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
if payments_back {
|
|
|
|
|
|
self.screen = Screen::Main;
|
|
|
|
|
|
}
|
|
|
|
|
|
if open_payments {
|
|
|
|
|
|
self.open_peer_payments()?;
|
|
|
|
|
|
}
|
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
|
|
|
|
if copy_addr {
|
|
|
|
|
|
self.copy_receive_address();
|
|
|
|
|
|
}
|
2026-09-10 17:19:50 -04:00
|
|
|
|
if let Some(clear) = quit_clear {
|
|
|
|
|
|
if clear {
|
|
|
|
|
|
self.node.wipe_messages()?;
|
|
|
|
|
|
}
|
|
|
|
|
|
return Ok(Some(AppExit::Quit));
|
|
|
|
|
|
}
|
2026-09-10 14:25:31 -04:00
|
|
|
|
if open_profile {
|
|
|
|
|
|
self.open_profile()?;
|
|
|
|
|
|
}
|
|
|
|
|
|
if let Some(draft) = profile_save {
|
|
|
|
|
|
self.save_profile(draft)?;
|
|
|
|
|
|
}
|
2026-09-10 14:37:43 -04:00
|
|
|
|
if let Some((atomic, memo)) = pay_cmd {
|
|
|
|
|
|
self.send_pay(&atomic, &memo)?;
|
|
|
|
|
|
}
|
|
|
|
|
|
if let Some((atomic, memo)) = tip_cmd {
|
|
|
|
|
|
self.send_tip(&atomic, &memo)?;
|
|
|
|
|
|
}
|
2026-09-10 23:32:06 -04:00
|
|
|
|
if let Some(path) = file_cmd {
|
|
|
|
|
|
self.send_file(&path)?;
|
|
|
|
|
|
}
|
2026-09-10 23:07:22 -04:00
|
|
|
|
if let Some(text) = chat_send {
|
|
|
|
|
|
self.send_chat(&text)?;
|
|
|
|
|
|
}
|
2026-09-12 14:06:20 -04:00
|
|
|
|
if let Some((kind, path, first, pass)) = pass_submit {
|
|
|
|
|
|
self.submit_passphrase(kind, &path, first.as_deref().map(String::as_str), &pass)?;
|
|
|
|
|
|
}
|
2026-09-10 02:49:42 -04:00
|
|
|
|
Ok(None)
|
|
|
|
|
|
}
|
|
|
|
|
|
|
tui: ASCII onion chrome, themed panes, and real keyboard navigation
- Hand-written wordmark banner (<=80 cols, auto-collapses to a compact
mark below banner width) plus onion glyph and themed screen headings
- Color-palette consts, stateful pane titles, highlighted selection row
(accent + bg), context-sensitive footer that always keeps '? help'
- Pane focus model (roster/chat/composer) with Tab/Shift-Tab, 1/2/3,
j/k + arrows, g/G, and a '?' help overlay; Esc closes any overlay
- New tests/tui_chrome.rs: banner widths, help overlay bindings, real
footer helper at 80 and 120 cols, 80x24 draw smoke test
- README keybinding table updated to match
Locked helper strings (fingerprint_mismatch_banner, rotate_screen_text,
wipe_screen_text, parse_slash) unchanged; UI-only (src/tui.rs).
2026-09-10 13:01:40 -04:00
|
|
|
|
fn handle_main_char(&mut self, c: char) {
|
|
|
|
|
|
if self.focus != Pane::Composer {
|
|
|
|
|
|
match c {
|
|
|
|
|
|
'1' => self.focus = Pane::Roster,
|
|
|
|
|
|
'2' => self.focus = Pane::Chat,
|
|
|
|
|
|
'3' => self.focus = Pane::Composer,
|
|
|
|
|
|
'j' => self.nav_down(),
|
|
|
|
|
|
'k' => self.nav_up(),
|
|
|
|
|
|
'g' => self.nav_top(),
|
|
|
|
|
|
'G' => self.nav_bottom(),
|
|
|
|
|
|
_ => {}
|
|
|
|
|
|
}
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
self.composer.push(c);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
fn nav_up(&mut self) {
|
|
|
|
|
|
match self.focus {
|
|
|
|
|
|
Pane::Roster => {
|
|
|
|
|
|
self.selected = self.selected.saturating_sub(1);
|
|
|
|
|
|
self.chat_scroll = u16::MAX;
|
|
|
|
|
|
}
|
|
|
|
|
|
Pane::Chat => {
|
|
|
|
|
|
self.chat_scroll = self.chat_scroll.saturating_sub(1);
|
|
|
|
|
|
}
|
|
|
|
|
|
Pane::Composer => {}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
fn nav_down(&mut self) {
|
|
|
|
|
|
match self.focus {
|
|
|
|
|
|
Pane::Roster => {
|
|
|
|
|
|
if !self.friends.is_empty() {
|
|
|
|
|
|
self.selected = (self.selected + 1).min(self.friends.len() - 1);
|
|
|
|
|
|
self.chat_scroll = u16::MAX;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
Pane::Chat => {
|
|
|
|
|
|
self.chat_scroll = self.chat_scroll.saturating_add(1);
|
|
|
|
|
|
}
|
|
|
|
|
|
Pane::Composer => {}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
fn nav_top(&mut self) {
|
|
|
|
|
|
match self.focus {
|
|
|
|
|
|
Pane::Roster => {
|
|
|
|
|
|
self.selected = 0;
|
|
|
|
|
|
self.chat_scroll = u16::MAX;
|
|
|
|
|
|
}
|
|
|
|
|
|
Pane::Chat => self.chat_scroll = 0,
|
|
|
|
|
|
Pane::Composer => {}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
fn nav_bottom(&mut self) {
|
|
|
|
|
|
match self.focus {
|
|
|
|
|
|
Pane::Roster => {
|
|
|
|
|
|
if !self.friends.is_empty() {
|
|
|
|
|
|
self.selected = self.friends.len() - 1;
|
|
|
|
|
|
self.chat_scroll = u16::MAX;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
Pane::Chat => self.chat_scroll = u16::MAX,
|
|
|
|
|
|
Pane::Composer => {}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-09-10 02:49:42 -04:00
|
|
|
|
fn confirm_wipe(&mut self, kind: WipeKind) -> Result<Option<AppExit>, String> {
|
|
|
|
|
|
match kind {
|
|
|
|
|
|
WipeKind::Messages => {
|
|
|
|
|
|
self.node.wipe_messages()?;
|
|
|
|
|
|
self.status_note = Some("wiped messages".into());
|
|
|
|
|
|
self.screen = Screen::Main;
|
|
|
|
|
|
Ok(None)
|
|
|
|
|
|
}
|
|
|
|
|
|
WipeKind::All => Ok(Some(AppExit::WipeAll)),
|
2026-09-10 01:54:19 -04:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-09-10 14:50:01 -04:00
|
|
|
|
fn submit_passphrase(
|
|
|
|
|
|
&mut self,
|
|
|
|
|
|
kind: BackupKind,
|
|
|
|
|
|
path: &str,
|
|
|
|
|
|
first: Option<&str>,
|
|
|
|
|
|
pass: &str,
|
|
|
|
|
|
) -> Result<(), String> {
|
|
|
|
|
|
match kind {
|
|
|
|
|
|
BackupKind::Backup => {
|
|
|
|
|
|
if let Some(first) = first {
|
|
|
|
|
|
if first != pass {
|
|
|
|
|
|
self.alert = Some("passphrases do not match".into());
|
|
|
|
|
|
self.screen = Screen::Main;
|
|
|
|
|
|
return Ok(());
|
|
|
|
|
|
}
|
|
|
|
|
|
match self.node.write_backup(path, pass) {
|
|
|
|
|
|
Ok(()) => {
|
|
|
|
|
|
self.status_note = Some(format!("backup written {path}"));
|
|
|
|
|
|
self.screen = Screen::Main;
|
|
|
|
|
|
}
|
|
|
|
|
|
Err(e) => {
|
|
|
|
|
|
self.alert = Some(e);
|
|
|
|
|
|
self.screen = Screen::Main;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
} else {
|
|
|
|
|
|
self.screen = Screen::Passphrase {
|
|
|
|
|
|
kind,
|
|
|
|
|
|
path: path.to_string(),
|
2026-09-12 14:06:20 -04:00
|
|
|
|
entry: PassphraseEntry::with_first(pass),
|
2026-09-10 14:50:01 -04:00
|
|
|
|
};
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
BackupKind::Restore => match self.node.restore_backup(path, pass) {
|
|
|
|
|
|
Ok(()) => {
|
|
|
|
|
|
self.me_fp = to_hex(&self.node.identity_pk());
|
|
|
|
|
|
self.status_note = Some("identity restored — roster unchanged".into());
|
|
|
|
|
|
self.screen = Screen::Main;
|
|
|
|
|
|
}
|
|
|
|
|
|
Err(e) => {
|
|
|
|
|
|
self.alert = Some(e);
|
|
|
|
|
|
self.screen = Screen::Main;
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
}
|
|
|
|
|
|
Ok(())
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-09-10 02:43:45 -04:00
|
|
|
|
fn confirm_rotate(&mut self) -> Result<(), String> {
|
|
|
|
|
|
let node = Arc::clone(&self.node);
|
|
|
|
|
|
match self.rt.block_on(node.rotate()) {
|
|
|
|
|
|
Ok(outcome) => {
|
|
|
|
|
|
self.me_onion = node.onion();
|
|
|
|
|
|
self.status_note = Some(format!(
|
|
|
|
|
|
"rotated · notified {}/{} friends",
|
|
|
|
|
|
outcome.notified, outcome.friends
|
|
|
|
|
|
));
|
|
|
|
|
|
self.open_share()
|
|
|
|
|
|
}
|
|
|
|
|
|
Err(e) => {
|
|
|
|
|
|
self.alert = Some(e);
|
|
|
|
|
|
self.screen = Screen::Main;
|
|
|
|
|
|
Ok(())
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-09-17 20:48:10 -04:00
|
|
|
|
/// F8. Local and synchronous: nothing is pushed to peers — the new prekey
|
|
|
|
|
|
/// only travels inside a fresh signed invite — so the screen goes straight
|
|
|
|
|
|
/// to that invite (the F2 share path) for the user to hand out.
|
|
|
|
|
|
fn confirm_rotate_prekey(&mut self) -> Result<(), String> {
|
|
|
|
|
|
match self.node.rotate_prekey() {
|
|
|
|
|
|
Ok(_) => {
|
|
|
|
|
|
self.status_note =
|
|
|
|
|
|
Some("prekey rotated · friends must F3-paste your new invite".into());
|
|
|
|
|
|
self.open_share()
|
|
|
|
|
|
}
|
|
|
|
|
|
Err(e) => {
|
|
|
|
|
|
self.alert = Some(e);
|
|
|
|
|
|
self.screen = Screen::Main;
|
|
|
|
|
|
Ok(())
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-09-10 01:54:19 -04:00
|
|
|
|
fn open_share(&mut self) -> Result<(), String> {
|
2026-09-10 02:43:45 -04:00
|
|
|
|
let payload = self.node.qr_payload()?;
|
2026-09-10 16:53:03 -04:00
|
|
|
|
self.screen = Screen::Share { payload };
|
2026-09-10 01:54:19 -04:00
|
|
|
|
Ok(())
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-09-12 22:53:58 -04:00
|
|
|
|
fn open_wallet(&mut self) -> Result<(), String> {
|
2026-09-13 15:34:39 -04:00
|
|
|
|
let addr = self.rt.block_on(self.node.wallet_receive_address())?;
|
2026-09-12 22:53:58 -04:00
|
|
|
|
let balance = self.rt.block_on(self.node.wallet_balance());
|
2026-09-13 15:34:39 -04:00
|
|
|
|
let transfers = self.rt.block_on(self.node.wallet_recent_transfers(8)).unwrap_or_default();
|
2026-09-12 22:53:58 -04:00
|
|
|
|
self.screen = Screen::Wallet {
|
|
|
|
|
|
receive_addr: addr,
|
|
|
|
|
|
balance,
|
|
|
|
|
|
transfers,
|
|
|
|
|
|
qr_modal: None,
|
|
|
|
|
|
};
|
|
|
|
|
|
Ok(())
|
|
|
|
|
|
}
|
|
|
|
|
|
|
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
|
|
|
|
/// F9 / `/settings`: snapshot the state the WALLETS & SETTINGS menu shows.
|
|
|
|
|
|
///
|
|
|
|
|
|
/// Credential-free by construction: it reads `Node`'s status/label getters
|
|
|
|
|
|
/// only — never `WalletConfig::rpc_login`, `secret()`, a seed, or a
|
|
|
|
|
|
/// passphrase — so nothing on the screen can leak one.
|
|
|
|
|
|
///
|
|
|
|
|
|
/// It blocks on the same three wallet calls the F6 screen already blocks on
|
|
|
|
|
|
/// (address, balance, recent transfers); `wallet_status` and
|
|
|
|
|
|
/// `wallet_child_status` are lock-only reads and never dial.
|
|
|
|
|
|
fn open_wallets_settings(&mut self) -> Result<(), String> {
|
|
|
|
|
|
let wstat = self.node.wallet_status();
|
|
|
|
|
|
let child = self.node.wallet_child_status();
|
|
|
|
|
|
let balance = self.rt.block_on(self.node.wallet_balance());
|
|
|
|
|
|
let receive_addr = self
|
|
|
|
|
|
.rt
|
|
|
|
|
|
.block_on(self.node.wallet_receive_address())
|
|
|
|
|
|
.unwrap_or_default();
|
|
|
|
|
|
let transfers = self
|
|
|
|
|
|
.rt
|
|
|
|
|
|
.block_on(self.node.wallet_recent_transfers(8))
|
|
|
|
|
|
.map(|rows| rows.len())
|
|
|
|
|
|
.unwrap_or(0);
|
|
|
|
|
|
let profile = self.node.self_profile().ok();
|
|
|
|
|
|
let nickname = profile
|
|
|
|
|
|
.as_ref()
|
|
|
|
|
|
.and_then(|p| (!p.display_name.is_empty()).then(|| p.display_name.clone()));
|
|
|
|
|
|
let bio_set = profile.as_ref().is_some_and(|p| !p.bio.is_empty());
|
|
|
|
|
|
let xmr_set = profile.as_ref().is_some_and(|p| !p.xmr_addr.is_empty());
|
tui: peer payment history behind the F9 `payments` row (key p)
The F9 / `/settings` menu's only payment row showed the wallet's own transfer
list (`Node::wallet_recent_transfers`, F6). The signed `/pay` invoices and
`/tip` receipts a peer sent live in the `payments` table and had no path from
the TUI, so they were invisible. `Node::list_payments` (PR #119) closes that
gap; this wires it into a screen.
- `Screen::PeerPayments { state }` + `PeerPaymentsState` /
`PeerPaymentRow`, built by `PeerPaymentsState::from_payments` from
`Node::list_payments`' rows (newest first: the store returns `payments.id`
ascending, the screen windows the vector).
- Key handler: `p` on the F9 screen opens it (`open_peer_payments`); `up`/`down`
(or `k`/`j`) move the selection, `Esc` goes back, `F9` reopens the menu.
- Rows carry direction, kind, amount (`pay::atomic_to_xmr_str`, the same
piconero formatter the chat lines use), memo (sanitized at draw time) and the
receipt's `verified` / `unverified` word; the focused row is marked with `>`
and bold. The selected row's txid and address sit under the rows — the
address wrapped over two lines rather than clipped.
- States: populated, `no payments with {peer}`, `could not read payments`, and
a menu row that refuses when no friend is selected. An empty history is a
state, never an error.
- Menu: the wallet's own list is retitled `transfers` (F6, unchanged), and the
new `payments` row (key `p`) names the peer and the count. Two histories, two
rows, no ambiguity.
- Widths are measured in cells (`Span::width`); trailing columns are dropped
before they can wrap, so the body fits 80x24 (20 inner rows of 21) as well as
120x40 and 200x60.
Tests: new `tests/tui_payments.rs` (11 tests) dumps and asserts the screen at
80x24, 120x40 and 200x60 including the empty history, asserts a memo carrying
ESC/BEL/C1/bidi/newline bytes never reaches the frame buffer, and asserts the
window/column invariants for every width from 20 to 200.
Also relaxes one width assertion in `tests/tui_spec.rs`: `fit_cells` was
asserted to start with `"abcdef"`, which only holds when another test's
in-flight `ONIONWIRE_ASCII` mutation is not visible — the suite mutates env vars
without a global lock, so that test flaked (it also fails on an unmodified tree,
1 run in 2). It now accepts either chrome's cut point, which is what the comment
already claimed.
Docs: `docs/TUI.md` gains the screen's section, the retitled/replaced rows and
the updated row count; the "peer payment history" gap entry is closed.
2026-09-18 23:53:10 -04:00
|
|
|
|
// The friend the rest of the TUI acts on is the chat's selected friend.
|
|
|
|
|
|
// `list_payments` is a lock-only read: no dial, no RPC, so this snapshot
|
|
|
|
|
|
// stays cheap and works while Tor is still bootstrapping.
|
|
|
|
|
|
let friend = self.friends.get(self.selected);
|
|
|
|
|
|
let peer = friend
|
|
|
|
|
|
.map(|f| f.petname.clone().unwrap_or_else(|| f.fingerprint.clone()))
|
|
|
|
|
|
.unwrap_or_default();
|
|
|
|
|
|
let peer_payments = friend.and_then(|f| {
|
|
|
|
|
|
self.node
|
|
|
|
|
|
.list_payments(&f.pubkey)
|
|
|
|
|
|
.ok()
|
|
|
|
|
|
.map(|rows| rows.len())
|
|
|
|
|
|
});
|
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
|
|
|
|
self.screen = Screen::WalletsSettings {
|
|
|
|
|
|
state: WalletMenuState {
|
|
|
|
|
|
configured: wstat.configured,
|
|
|
|
|
|
connected: wstat.connected,
|
|
|
|
|
|
wallet_error: wstat.last_error,
|
|
|
|
|
|
receive_addr,
|
|
|
|
|
|
balance,
|
|
|
|
|
|
transfers,
|
|
|
|
|
|
child_state: child.state.as_str().to_string(),
|
|
|
|
|
|
child_source: child.chain_source,
|
|
|
|
|
|
child_error: child.last_error,
|
|
|
|
|
|
nickname,
|
|
|
|
|
|
bio_set,
|
|
|
|
|
|
xmr_set,
|
|
|
|
|
|
me_fp: self.me_fp.clone(),
|
tui: peer payment history behind the F9 `payments` row (key p)
The F9 / `/settings` menu's only payment row showed the wallet's own transfer
list (`Node::wallet_recent_transfers`, F6). The signed `/pay` invoices and
`/tip` receipts a peer sent live in the `payments` table and had no path from
the TUI, so they were invisible. `Node::list_payments` (PR #119) closes that
gap; this wires it into a screen.
- `Screen::PeerPayments { state }` + `PeerPaymentsState` /
`PeerPaymentRow`, built by `PeerPaymentsState::from_payments` from
`Node::list_payments`' rows (newest first: the store returns `payments.id`
ascending, the screen windows the vector).
- Key handler: `p` on the F9 screen opens it (`open_peer_payments`); `up`/`down`
(or `k`/`j`) move the selection, `Esc` goes back, `F9` reopens the menu.
- Rows carry direction, kind, amount (`pay::atomic_to_xmr_str`, the same
piconero formatter the chat lines use), memo (sanitized at draw time) and the
receipt's `verified` / `unverified` word; the focused row is marked with `>`
and bold. The selected row's txid and address sit under the rows — the
address wrapped over two lines rather than clipped.
- States: populated, `no payments with {peer}`, `could not read payments`, and
a menu row that refuses when no friend is selected. An empty history is a
state, never an error.
- Menu: the wallet's own list is retitled `transfers` (F6, unchanged), and the
new `payments` row (key `p`) names the peer and the count. Two histories, two
rows, no ambiguity.
- Widths are measured in cells (`Span::width`); trailing columns are dropped
before they can wrap, so the body fits 80x24 (20 inner rows of 21) as well as
120x40 and 200x60.
Tests: new `tests/tui_payments.rs` (11 tests) dumps and asserts the screen at
80x24, 120x40 and 200x60 including the empty history, asserts a memo carrying
ESC/BEL/C1/bidi/newline bytes never reaches the frame buffer, and asserts the
window/column invariants for every width from 20 to 200.
Also relaxes one width assertion in `tests/tui_spec.rs`: `fit_cells` was
asserted to start with `"abcdef"`, which only holds when another test's
in-flight `ONIONWIRE_ASCII` mutation is not visible — the suite mutates env vars
without a global lock, so that test flaked (it also fails on an unmodified tree,
1 run in 2). It now accepts either chrome's cut point, which is what the comment
already claimed.
Docs: `docs/TUI.md` gains the screen's section, the retitled/replaced rows and
the updated row count; the "peer payment history" gap entry is closed.
2026-09-18 23:53:10 -04:00
|
|
|
|
peer,
|
|
|
|
|
|
peer_payments,
|
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
|
|
|
|
},
|
|
|
|
|
|
};
|
|
|
|
|
|
Ok(())
|
|
|
|
|
|
}
|
|
|
|
|
|
|
tui: peer payment history behind the F9 `payments` row (key p)
The F9 / `/settings` menu's only payment row showed the wallet's own transfer
list (`Node::wallet_recent_transfers`, F6). The signed `/pay` invoices and
`/tip` receipts a peer sent live in the `payments` table and had no path from
the TUI, so they were invisible. `Node::list_payments` (PR #119) closes that
gap; this wires it into a screen.
- `Screen::PeerPayments { state }` + `PeerPaymentsState` /
`PeerPaymentRow`, built by `PeerPaymentsState::from_payments` from
`Node::list_payments`' rows (newest first: the store returns `payments.id`
ascending, the screen windows the vector).
- Key handler: `p` on the F9 screen opens it (`open_peer_payments`); `up`/`down`
(or `k`/`j`) move the selection, `Esc` goes back, `F9` reopens the menu.
- Rows carry direction, kind, amount (`pay::atomic_to_xmr_str`, the same
piconero formatter the chat lines use), memo (sanitized at draw time) and the
receipt's `verified` / `unverified` word; the focused row is marked with `>`
and bold. The selected row's txid and address sit under the rows — the
address wrapped over two lines rather than clipped.
- States: populated, `no payments with {peer}`, `could not read payments`, and
a menu row that refuses when no friend is selected. An empty history is a
state, never an error.
- Menu: the wallet's own list is retitled `transfers` (F6, unchanged), and the
new `payments` row (key `p`) names the peer and the count. Two histories, two
rows, no ambiguity.
- Widths are measured in cells (`Span::width`); trailing columns are dropped
before they can wrap, so the body fits 80x24 (20 inner rows of 21) as well as
120x40 and 200x60.
Tests: new `tests/tui_payments.rs` (11 tests) dumps and asserts the screen at
80x24, 120x40 and 200x60 including the empty history, asserts a memo carrying
ESC/BEL/C1/bidi/newline bytes never reaches the frame buffer, and asserts the
window/column invariants for every width from 20 to 200.
Also relaxes one width assertion in `tests/tui_spec.rs`: `fit_cells` was
asserted to start with `"abcdef"`, which only holds when another test's
in-flight `ONIONWIRE_ASCII` mutation is not visible — the suite mutates env vars
without a global lock, so that test flaked (it also fails on an unmodified tree,
1 run in 2). It now accepts either chrome's cut point, which is what the comment
already claimed.
Docs: `docs/TUI.md` gains the screen's section, the retitled/replaced rows and
the updated row count; the "peer payment history" gap entry is closed.
2026-09-18 23:53:10 -04:00
|
|
|
|
/// The F9 menu's `payments` row: the selected friend's payment history from
|
|
|
|
|
|
/// `Node::list_payments`.
|
|
|
|
|
|
///
|
|
|
|
|
|
/// Read-only and fail-closed: the call takes the store lock and nothing
|
|
|
|
|
|
/// else, so it never dials and is safe while offline. A friend with no rows
|
|
|
|
|
|
/// is `Ok(vec![])` — an empty history, not an error.
|
|
|
|
|
|
fn open_peer_payments(&mut self) -> Result<(), String> {
|
|
|
|
|
|
let Some(friend) = self.friends.get(self.selected) else {
|
|
|
|
|
|
self.status_note = Some("no friend selected".into());
|
|
|
|
|
|
return Ok(());
|
|
|
|
|
|
};
|
|
|
|
|
|
let peer = friend
|
|
|
|
|
|
.petname
|
|
|
|
|
|
.clone()
|
|
|
|
|
|
.unwrap_or_else(|| friend.fingerprint.clone());
|
|
|
|
|
|
let pk = friend.pubkey.clone();
|
|
|
|
|
|
let state = match self.node.list_payments(&pk) {
|
|
|
|
|
|
Ok(rows) => PeerPaymentsState::from_payments(peer, &rows),
|
|
|
|
|
|
Err(e) => PeerPaymentsState::error(peer, e),
|
|
|
|
|
|
};
|
|
|
|
|
|
self.screen = Screen::PeerPayments { state };
|
|
|
|
|
|
Ok(())
|
|
|
|
|
|
}
|
|
|
|
|
|
|
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
|
|
|
|
/// `c` on the WALLETS & SETTINGS menu: copy the receive address through the
|
|
|
|
|
|
/// terminal's own clipboard (OSC 52 — no crate, and it survives SSH). The
|
|
|
|
|
|
/// address never touches a file.
|
|
|
|
|
|
fn copy_receive_address(&mut self) {
|
|
|
|
|
|
let addr = match &self.screen {
|
|
|
|
|
|
Screen::WalletsSettings { state } => state.receive_addr.clone(),
|
|
|
|
|
|
_ => return,
|
|
|
|
|
|
};
|
|
|
|
|
|
if addr.is_empty() {
|
|
|
|
|
|
self.status_note = Some("no receive address to copy".into());
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
let seq = osc52_copy_sequence(&addr);
|
|
|
|
|
|
let wrote = {
|
|
|
|
|
|
let mut out = io::stdout();
|
|
|
|
|
|
out.write_all(seq.as_bytes()).is_ok() && out.flush().is_ok()
|
|
|
|
|
|
};
|
|
|
|
|
|
self.status_note = Some(if wrote {
|
|
|
|
|
|
"copied receive address".into()
|
|
|
|
|
|
} else {
|
|
|
|
|
|
"could not write the clipboard sequence".into()
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-09-18 09:28:11 -04:00
|
|
|
|
/// The core's pay/tip readiness guard, refused before any dial when the
|
|
|
|
|
|
/// wallet is unconfigured, view-only (for a tip), or not answering. `true`
|
|
|
|
|
|
/// when the send may proceed; the reason is already in the status note when
|
|
|
|
|
|
/// it is not.
|
|
|
|
|
|
fn wallet_ready(&mut self, is_tip: bool) -> bool {
|
|
|
|
|
|
match self
|
|
|
|
|
|
.rt
|
|
|
|
|
|
.block_on(self.node.wallet_readiness(is_tip))
|
|
|
|
|
|
.refusal()
|
|
|
|
|
|
{
|
|
|
|
|
|
Some(refusal) => {
|
|
|
|
|
|
self.status_note = Some(refusal.to_string());
|
|
|
|
|
|
false
|
|
|
|
|
|
}
|
|
|
|
|
|
None => true,
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
wallet: land the in-process Cuprate chain source on main
`ChainSource::InProcessCuprate { datadir }` is the fourth chain source: P2P,
consensus and RandomX run inside the OnionWire process instead of as a spawned
`monerod`. The wallet layer does not move — the daemon binds the same loopback
unrestricted RPC (`127.0.0.1:18081`) that `WalletChild::daemon_address` already
returns for a local source, so `wallet_rpc_argv`, the RPC client, the payment
frames and the receipt-verification path are untouched.
- Cargo.toml: `cuprated` (git, rev 4f8fcd1b) + `toml`, both optional, behind the
`cuprate-daemon` feature, OFF by default. `cuprated`'s own `arti` feature is
disabled (`default-features = false`): its arti-client 0.44 cannot unify with
this crate's 0.46, and the in-process daemon is clearnet-only. One Tor stack in
the process. `Cargo.lock` gains the graph; a default build's
`cargo tree --locked -e normal -i cuprated` still says "did not match any
packages", and only `arti-client v0.46.0` is in the lock.
- src/cuprate.rs (new): `CuprateNode` builds the cuprated config as TOML
(testnet, unrestricted RPC on loopback, restricted RPC disabled, inbound P2P
off), launches it on a runtime it owns, and owns the node. `launch` is
synchronous on purpose: `WalletChild::start` is sync (the TUI calls it from its
blocking thread, UniFFI calls it from an async context) and a runtime cannot be
started from inside a runtime, so the launch runs on a thread of its own and
the node + its runtime come back over a channel. Dropping the value asks the
node to shut down and `shutdown_background`s the runtime, which is the only
exit that cannot panic when the value is dropped inside another runtime.
The type exists in every build (feature off: `launch` fails with the feature
name), so the chain-source type, its stored record and its copy do not fork on
a cargo feature.
- src/wallet.rs: the variant, its label (`in-process node`), and the chain-daemon
client the wallet line carried (typed `WalletError`, de-chunked HTTP,
`get_height` over the URI endpoint, an above-the-tip height as one typed
error). Cuprate answers those three differently from monerod and the
in-process source is what makes them the *local* case.
- src/wallet_child.rs: launches/holds/stops the node, `chain_datadir` for the
free-space/ownership question, the honest `chain_copy` line, `kind =
"cuprate"` in the sealed record, and `ChildConfig::validate` for it.
- src/tui.rs: the wallet screen's chain line carries the testnet caveat when the
configured source is the in-process one. It computes the line at draw time, so
`Screen::Wallet`'s shape (which tests construct) does not change.
- docs/WALLET.md, docs/THREAT_MODEL.md, docs/cuprate-android-spike.md: the
feature flag and how to enable it, where the (fjall) chain store lives, the
**measured** +11.8 MiB delta, the pre-production/testnet caveat, and the
in-repo aarch64-linux-android proof with exit codes.
Scope deviations, stated plainly:
- `src/cuprate.rs` and its one `src/lib.rs` module line are not in the card's
allowed list; the card's own deliverable describes the module's behaviour.
- `crates/onionwire-sdk/src/lib.rs` is forbidden, but adding a variant to a
`pub enum` that the SDK matches exhaustively breaks the SDK workspace, and the
root CI `sdk` job runs on every PR. One variant plus two match arms land here
so the SDK keeps compiling (`cargo test --locked` + clippy clean); the SDK card
owns the rest — feature passthrough, the config field's semantics, the label
and its tests, and the Android check.
- `tests/wallet.rs` carries the launch test. `tests/tui_frames.rs` is untouched:
main has no `ChainChoice` to pin (the chain-source picker is the unmerged F7
work, and `docs/WALLET.md` says so rather than describing a picker that does
not exist).
Proof (all on this tree):
- Default build: `cargo test --locked --target x86_64-unknown-linux-gnu` → 345
passed / 0 failed across 33 suites, exit 0; `cargo clippy --locked
--all-targets --target x86_64-unknown-linux-gnu -- -D warnings` exit 0.
- Feature on: `cargo test --locked --features cuprate-daemon --target
x86_64-unknown-linux-gnu` → 347 passed / 0 failed, exit 0; same clippy with
`--features cuprate-daemon` exit 0. The two extra tests are the real thing:
`wallet_child::tests::in_process_source_launches_a_daemon_and_stop_shuts_it_down`
and `tests/wallet.rs::an_in_process_cuprate_node_answers_the_typed_daemon_client`
— the latter launches the node, drives `get_info` / `get_height` / `get_block`
through the typed client, checks the above-the-tip 500 maps to
`DaemonHeightOutOfRange`, checks the chain store is under the chain datadir,
and checks the listener dies with the node.
- aarch64: `cargo check --locked --release --target aarch64-linux-android
--features cuprate-daemon` exit 0 (1m 50s), and the full link exit 0
(`cargo rustc ... --bin onionwire -- <NDK C++ runtime / compiler-rt link
args>`) producing `ELF 64-bit LSB pie executable, ARM aarch64, for Android 26,
built by NDK r28c`.
- Size: stripped aarch64 release binary, 24,725,704 bytes without the feature and
37,053,472 with it — +12,327,768 bytes (≈ +11.8 MiB), the figure
`docs/WALLET.md` now quotes.
2026-09-18 13:45:59 -04:00
|
|
|
|
/// The wallet screen's chain-source line: the child status, plus the
|
|
|
|
|
|
/// caveat the configured source carries.
|
|
|
|
|
|
///
|
|
|
|
|
|
/// The in-process daemon is **testnet only** in this build, and this line is
|
|
|
|
|
|
/// the only place the wallet screen names the configured chain source (the
|
|
|
|
|
|
/// source itself is a stored setting), so the caveat travels with it — a
|
|
|
|
|
|
/// user who reads it as a mainnet node would be misled.
|
|
|
|
|
|
fn wallet_child_screen_line(&self) -> String {
|
|
|
|
|
|
let mut line = self.node.wallet_child_line();
|
|
|
|
|
|
if matches!(
|
|
|
|
|
|
self.node.wallet_child_config().source,
|
|
|
|
|
|
ChainSource::InProcessCuprate { .. }
|
|
|
|
|
|
) {
|
|
|
|
|
|
if !line.is_empty() {
|
|
|
|
|
|
line.push_str(" · ");
|
|
|
|
|
|
}
|
|
|
|
|
|
line.push_str(crate::cuprate::TESTNET_ONLY);
|
|
|
|
|
|
}
|
|
|
|
|
|
line
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-09-18 09:28:11 -04:00
|
|
|
|
/// Key `s` on the wallet screen: start the app-owned wallet child. The
|
|
|
|
|
|
/// balance/address readouts refresh on the next F6 — the child's RPC is not
|
|
|
|
|
|
/// answering in the same breath — so this reports the state it reached.
|
|
|
|
|
|
fn wallet_child_start(&mut self) {
|
|
|
|
|
|
self.status_note = Some(match self.node.start_wallet_child() {
|
|
|
|
|
|
Ok(()) => self.wallet_child_note(),
|
|
|
|
|
|
Err(e) => format!("wallet child: {e}"),
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// Key `x`: stop the child (idempotent) and drop back to the stored/env
|
|
|
|
|
|
/// wallet config.
|
|
|
|
|
|
fn wallet_child_stop(&mut self) {
|
|
|
|
|
|
self.status_note = Some(match self.node.stop_wallet_child() {
|
|
|
|
|
|
Ok(()) => "wallet child stopped".into(),
|
|
|
|
|
|
Err(e) => format!("wallet child: {e}"),
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// Key `p`: one probe of the running child — is its RPC answering, and is
|
|
|
|
|
|
/// the chain at the tip? The only thing that can report `ready`.
|
|
|
|
|
|
fn wallet_child_probe(&mut self) {
|
|
|
|
|
|
self.status_note = Some(self.wallet_child_note());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// The child status line, or the copy that names what is missing.
|
|
|
|
|
|
fn wallet_child_note(&mut self) -> String {
|
|
|
|
|
|
let line = self.rt.block_on(self.node.wallet_child_refresh()).line();
|
|
|
|
|
|
if line.is_empty() {
|
|
|
|
|
|
"no wallet child configured — set a chain source first".into()
|
|
|
|
|
|
} else {
|
|
|
|
|
|
line
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-09-12 22:53:58 -04:00
|
|
|
|
fn wallet_toggle_qr(&mut self) {
|
|
|
|
|
|
let Screen::Wallet {
|
|
|
|
|
|
ref mut qr_modal,
|
|
|
|
|
|
ref receive_addr,
|
|
|
|
|
|
..
|
|
|
|
|
|
} = self.screen
|
|
|
|
|
|
else {
|
|
|
|
|
|
return;
|
|
|
|
|
|
};
|
|
|
|
|
|
if let Some(modal) = qr_modal {
|
|
|
|
|
|
*qr_modal = if modal.closed {
|
|
|
|
|
|
qr_modal.take()
|
|
|
|
|
|
} else {
|
|
|
|
|
|
None
|
|
|
|
|
|
};
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
let uri = if receive_addr.starts_with('4') || receive_addr.starts_with('8') {
|
|
|
|
|
|
format!("monero:{receive_addr}")
|
|
|
|
|
|
} else {
|
|
|
|
|
|
receive_addr.clone()
|
|
|
|
|
|
};
|
|
|
|
|
|
let m = match qrcode::QrCode::new(uri.as_bytes()) {
|
|
|
|
|
|
Ok(m) => m,
|
|
|
|
|
|
Err(_) => {
|
|
|
|
|
|
qr_modal.replace(QrModal {
|
|
|
|
|
|
closed: false,
|
|
|
|
|
|
matrix_rows: Vec::new(),
|
|
|
|
|
|
uri: receive_addr.clone(),
|
|
|
|
|
|
});
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
};
|
|
|
|
|
|
let cols = m.to_colors();
|
|
|
|
|
|
let w = m.width();
|
|
|
|
|
|
let rows: Vec<String> = (0..w)
|
|
|
|
|
|
.map(|y| {
|
|
|
|
|
|
(0..w)
|
|
|
|
|
|
.map(|x| {
|
|
|
|
|
|
cols[y * w + x].select('█', ' ')
|
|
|
|
|
|
})
|
|
|
|
|
|
.collect()
|
|
|
|
|
|
})
|
|
|
|
|
|
.collect();
|
|
|
|
|
|
qr_modal.replace(QrModal {
|
|
|
|
|
|
closed: false,
|
|
|
|
|
|
matrix_rows: rows,
|
|
|
|
|
|
uri: receive_addr.clone(),
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-09-13 23:25:25 -04:00
|
|
|
|
fn handle_wallet_setup(&mut self, key: KeyEvent) -> Result<(), String> {
|
|
|
|
|
|
let Screen::WalletSetup(setup) = &mut self.screen else {
|
|
|
|
|
|
return Ok(());
|
|
|
|
|
|
};
|
|
|
|
|
|
if key.code == KeyCode::Esc {
|
|
|
|
|
|
match setup {
|
|
|
|
|
|
WalletSetup::CreatePass { entry } | WalletSetup::ImportPass { entry, .. } => {
|
|
|
|
|
|
entry.close();
|
|
|
|
|
|
}
|
|
|
|
|
|
WalletSetup::CreateSeed { seed, .. } => seed.zeroize(),
|
|
|
|
|
|
WalletSetup::ImportSeed { buf } => buf.zeroize(),
|
|
|
|
|
|
WalletSetup::CreateWarn { .. } => {}
|
|
|
|
|
|
}
|
|
|
|
|
|
self.screen = Screen::Main;
|
|
|
|
|
|
return Ok(());
|
|
|
|
|
|
}
|
|
|
|
|
|
match setup {
|
|
|
|
|
|
WalletSetup::CreateWarn { typed } => match key.code {
|
|
|
|
|
|
KeyCode::Char(c) if c.is_ascii_alphabetic() => {
|
|
|
|
|
|
typed.push(c);
|
|
|
|
|
|
if typed.eq_ignore_ascii_case("SPEND") {
|
|
|
|
|
|
self.screen = Screen::WalletSetup(WalletSetup::CreatePass {
|
|
|
|
|
|
entry: PassphraseEntry::new(),
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
KeyCode::Backspace => {
|
|
|
|
|
|
typed.pop();
|
|
|
|
|
|
}
|
|
|
|
|
|
_ => {}
|
|
|
|
|
|
},
|
|
|
|
|
|
WalletSetup::CreatePass { entry } => match key.code {
|
|
|
|
|
|
KeyCode::Backspace => entry.backspace(),
|
|
|
|
|
|
KeyCode::Char(c) if !key.modifiers.contains(KeyModifiers::CONTROL) => {
|
|
|
|
|
|
entry.push(c);
|
|
|
|
|
|
}
|
|
|
|
|
|
KeyCode::Enter => {
|
|
|
|
|
|
let first = entry.take_first();
|
|
|
|
|
|
let pass = entry.take_buf();
|
|
|
|
|
|
if let Some(first) = first {
|
|
|
|
|
|
if first.as_str() != pass.as_str() {
|
|
|
|
|
|
entry.close();
|
|
|
|
|
|
self.alert = Some("passphrases do not match".into());
|
|
|
|
|
|
self.screen = Screen::Main;
|
|
|
|
|
|
return Ok(());
|
|
|
|
|
|
}
|
|
|
|
|
|
match self.rt.block_on(self.node.wallet_create(pass.as_str())) {
|
|
|
|
|
|
Ok(seed) => {
|
|
|
|
|
|
self.screen = Screen::WalletSetup(WalletSetup::CreateSeed {
|
|
|
|
|
|
seed: Zeroizing::new(seed),
|
|
|
|
|
|
typed: String::new(),
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
Err(e) => {
|
|
|
|
|
|
self.alert = Some(e);
|
|
|
|
|
|
self.screen = Screen::Main;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
} else {
|
|
|
|
|
|
self.screen = Screen::WalletSetup(WalletSetup::CreatePass {
|
|
|
|
|
|
entry: PassphraseEntry::with_first(pass.as_str()),
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
_ => {}
|
|
|
|
|
|
},
|
|
|
|
|
|
WalletSetup::CreateSeed { typed, seed } => match key.code {
|
|
|
|
|
|
KeyCode::Char(c) if c.is_ascii_alphabetic() => {
|
|
|
|
|
|
typed.push(c);
|
|
|
|
|
|
if typed.eq_ignore_ascii_case("SEEN") {
|
|
|
|
|
|
seed.zeroize();
|
|
|
|
|
|
self.status_note = Some("wallet created — seed shown once".into());
|
|
|
|
|
|
return self.open_wallet();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
KeyCode::Backspace => {
|
|
|
|
|
|
typed.pop();
|
|
|
|
|
|
}
|
|
|
|
|
|
_ => {}
|
|
|
|
|
|
},
|
|
|
|
|
|
WalletSetup::ImportSeed { buf } => match key.code {
|
|
|
|
|
|
KeyCode::Backspace => {
|
|
|
|
|
|
buf.pop();
|
|
|
|
|
|
}
|
|
|
|
|
|
KeyCode::Char(c) if !key.modifiers.contains(KeyModifiers::CONTROL) => {
|
|
|
|
|
|
buf.push(c);
|
|
|
|
|
|
}
|
|
|
|
|
|
KeyCode::Enter => {
|
|
|
|
|
|
let seed = std::mem::replace(buf, Zeroizing::new(String::new()));
|
|
|
|
|
|
if seed.trim().is_empty() {
|
|
|
|
|
|
self.alert = Some("seed required to import a wallet".into());
|
|
|
|
|
|
self.screen = Screen::Main;
|
|
|
|
|
|
return Ok(());
|
|
|
|
|
|
}
|
|
|
|
|
|
self.screen = Screen::WalletSetup(WalletSetup::ImportPass {
|
|
|
|
|
|
seed,
|
|
|
|
|
|
entry: PassphraseEntry::new(),
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
_ => {}
|
|
|
|
|
|
},
|
|
|
|
|
|
WalletSetup::ImportPass { entry, seed } => match key.code {
|
|
|
|
|
|
KeyCode::Backspace => entry.backspace(),
|
|
|
|
|
|
KeyCode::Char(c) if !key.modifiers.contains(KeyModifiers::CONTROL) => {
|
|
|
|
|
|
entry.push(c);
|
|
|
|
|
|
}
|
|
|
|
|
|
KeyCode::Enter => {
|
|
|
|
|
|
let first = entry.take_first();
|
|
|
|
|
|
let pass = entry.take_buf();
|
|
|
|
|
|
if let Some(first) = first {
|
|
|
|
|
|
if first.as_str() != pass.as_str() {
|
|
|
|
|
|
entry.close();
|
|
|
|
|
|
seed.zeroize();
|
|
|
|
|
|
self.alert = Some("passphrases do not match".into());
|
|
|
|
|
|
self.screen = Screen::Main;
|
|
|
|
|
|
return Ok(());
|
|
|
|
|
|
}
|
|
|
|
|
|
let result = self
|
|
|
|
|
|
.rt
|
|
|
|
|
|
.block_on(self.node.wallet_restore(pass.as_str(), seed.as_str()));
|
|
|
|
|
|
seed.zeroize();
|
|
|
|
|
|
match result {
|
|
|
|
|
|
Ok(()) => {
|
|
|
|
|
|
self.status_note = Some("wallet imported".into());
|
|
|
|
|
|
return self.open_wallet();
|
|
|
|
|
|
}
|
|
|
|
|
|
Err(e) => {
|
|
|
|
|
|
self.alert = Some(e);
|
|
|
|
|
|
self.screen = Screen::Main;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
} else {
|
|
|
|
|
|
let seed = std::mem::replace(seed, Zeroizing::new(String::new()));
|
|
|
|
|
|
self.screen = Screen::WalletSetup(WalletSetup::ImportPass {
|
|
|
|
|
|
seed,
|
|
|
|
|
|
entry: PassphraseEntry::with_first(pass.as_str()),
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
_ => {}
|
|
|
|
|
|
},
|
|
|
|
|
|
}
|
|
|
|
|
|
Ok(())
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-09-10 01:54:19 -04:00
|
|
|
|
fn submit_paste(&mut self, raw: &str) -> Result<(), String> {
|
|
|
|
|
|
match qr::decode(raw.trim()) {
|
|
|
|
|
|
Err(e) => {
|
|
|
|
|
|
self.screen = Screen::Paste {
|
|
|
|
|
|
buf: raw.to_string(),
|
|
|
|
|
|
err: Some(e.to_string()),
|
|
|
|
|
|
};
|
|
|
|
|
|
}
|
|
|
|
|
|
Ok(payload) => {
|
2026-09-10 02:43:45 -04:00
|
|
|
|
let known = self.node.get_friend(&payload.pubkey)?.is_some();
|
2026-09-10 01:54:19 -04:00
|
|
|
|
if known {
|
|
|
|
|
|
self.accept_friend(&payload)?;
|
|
|
|
|
|
} else {
|
|
|
|
|
|
self.screen = Screen::Approve { payload };
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
Ok(())
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
fn accept_friend(&mut self, payload: &QrPayload) -> Result<(), String> {
|
2026-09-10 02:43:45 -04:00
|
|
|
|
self.node.add_friend_payload(payload)?;
|
2026-09-10 01:54:19 -04:00
|
|
|
|
self.reload_friends()?;
|
|
|
|
|
|
self.screen = Screen::Main;
|
|
|
|
|
|
Ok(())
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
fn reload_friends(&mut self) -> Result<(), String> {
|
2026-09-10 02:43:45 -04:00
|
|
|
|
self.friends = self.node.list_friends()?;
|
2026-09-10 01:54:19 -04:00
|
|
|
|
if self.friends.is_empty() {
|
|
|
|
|
|
self.selected = 0;
|
|
|
|
|
|
} else {
|
|
|
|
|
|
self.selected = self.selected.min(self.friends.len() - 1);
|
|
|
|
|
|
}
|
tui: ASCII onion chrome, themed panes, and real keyboard navigation
- Hand-written wordmark banner (<=80 cols, auto-collapses to a compact
mark below banner width) plus onion glyph and themed screen headings
- Color-palette consts, stateful pane titles, highlighted selection row
(accent + bg), context-sensitive footer that always keeps '? help'
- Pane focus model (roster/chat/composer) with Tab/Shift-Tab, 1/2/3,
j/k + arrows, g/G, and a '?' help overlay; Esc closes any overlay
- New tests/tui_chrome.rs: banner widths, help overlay bindings, real
footer helper at 80 and 120 cols, 80x24 draw smoke test
- README keybinding table updated to match
Locked helper strings (fingerprint_mismatch_banner, rotate_screen_text,
wipe_screen_text, parse_slash) unchanged; UI-only (src/tui.rs).
2026-09-10 13:01:40 -04:00
|
|
|
|
self.chat_scroll = u16::MAX;
|
2026-09-10 01:54:19 -04:00
|
|
|
|
Ok(())
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-09-10 14:25:31 -04:00
|
|
|
|
fn open_profile(&mut self) -> Result<(), String> {
|
|
|
|
|
|
let p = self.node.self_profile()?;
|
|
|
|
|
|
self.screen = Screen::Profile {
|
|
|
|
|
|
editor: ProfileEditor::new(&p.display_name, &p.bio, &p.xmr_addr),
|
|
|
|
|
|
};
|
|
|
|
|
|
Ok(())
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
fn save_profile(&mut self, draft: ProfileDraft) -> Result<(), String> {
|
|
|
|
|
|
if let Err(e) = self
|
|
|
|
|
|
.node
|
|
|
|
|
|
.set_self_profile(&draft.display_name, &draft.bio, &draft.xmr_addr)
|
|
|
|
|
|
{
|
|
|
|
|
|
self.alert = Some(e);
|
|
|
|
|
|
return Ok(());
|
|
|
|
|
|
}
|
|
|
|
|
|
self.screen = Screen::Main;
|
|
|
|
|
|
if let Some(friend) = self.friends.get(self.selected) {
|
|
|
|
|
|
let pk = friend.pubkey.clone();
|
|
|
|
|
|
match self.rt.block_on(self.node.push_self_profile(&pk)) {
|
|
|
|
|
|
Ok(()) => self.status_note = Some("profile saved · sent".into()),
|
|
|
|
|
|
Err(e) => self.status_note = Some(format!("profile send failed: {e}")),
|
|
|
|
|
|
}
|
|
|
|
|
|
} else {
|
|
|
|
|
|
self.status_note = Some("profile saved".into());
|
|
|
|
|
|
}
|
|
|
|
|
|
Ok(())
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-09-10 14:37:43 -04:00
|
|
|
|
fn send_pay(&mut self, atomic: &str, memo: &str) -> Result<(), String> {
|
|
|
|
|
|
let Some(friend) = self.friends.get(self.selected) else {
|
|
|
|
|
|
self.status_note = Some("no friend selected".into());
|
|
|
|
|
|
return Ok(());
|
|
|
|
|
|
};
|
|
|
|
|
|
let pk = friend.pubkey.clone();
|
2026-09-18 09:28:11 -04:00
|
|
|
|
if !self.wallet_ready(false) {
|
|
|
|
|
|
return Ok(());
|
|
|
|
|
|
}
|
2026-09-10 14:37:43 -04:00
|
|
|
|
match self.rt.block_on(self.node.pay_invoice(&pk, atomic, memo)) {
|
|
|
|
|
|
Ok(()) => self.status_note = Some("invoice sent".into()),
|
|
|
|
|
|
Err(e) => self.status_note = Some(e),
|
|
|
|
|
|
}
|
|
|
|
|
|
Ok(())
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
fn send_tip(&mut self, atomic: &str, memo: &str) -> Result<(), String> {
|
|
|
|
|
|
let Some(friend) = self.friends.get(self.selected) else {
|
|
|
|
|
|
self.status_note = Some("no friend selected".into());
|
|
|
|
|
|
return Ok(());
|
|
|
|
|
|
};
|
|
|
|
|
|
let pk = friend.pubkey.clone();
|
2026-09-18 09:28:11 -04:00
|
|
|
|
if !self.wallet_ready(true) {
|
|
|
|
|
|
return Ok(());
|
|
|
|
|
|
}
|
2026-09-10 14:37:43 -04:00
|
|
|
|
match self.rt.block_on(self.node.tip(&pk, atomic, memo)) {
|
|
|
|
|
|
Ok(()) => self.status_note = Some("tip sent".into()),
|
|
|
|
|
|
Err(e) => self.status_note = Some(e),
|
|
|
|
|
|
}
|
|
|
|
|
|
Ok(())
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-09-10 23:32:06 -04:00
|
|
|
|
fn send_file(&mut self, path: &str) -> Result<(), String> {
|
|
|
|
|
|
let Some(friend) = self.friends.get(self.selected) else {
|
|
|
|
|
|
self.status_note = Some("no friend selected".into());
|
|
|
|
|
|
return Ok(());
|
|
|
|
|
|
};
|
|
|
|
|
|
let pk = friend.pubkey.clone();
|
|
|
|
|
|
self.status_note = Some("sending".into());
|
|
|
|
|
|
match self
|
|
|
|
|
|
.rt
|
|
|
|
|
|
.block_on(self.node.send_file(&pk, std::path::Path::new(path)))
|
|
|
|
|
|
{
|
|
|
|
|
|
Ok(name) => self.status_note = Some(format!("sent file {name}")),
|
|
|
|
|
|
Err(e) => self.status_note = Some(format!("send failed: {e}")),
|
|
|
|
|
|
}
|
|
|
|
|
|
Ok(())
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-09-10 23:07:22 -04:00
|
|
|
|
fn send_chat(&mut self, text: &str) -> Result<(), String> {
|
|
|
|
|
|
let Some(friend) = self.friends.get(self.selected) else {
|
|
|
|
|
|
self.status_note = Some("no friend selected".into());
|
|
|
|
|
|
return Ok(());
|
|
|
|
|
|
};
|
2026-09-11 22:33:55 -04:00
|
|
|
|
if self.job_rx.is_some() {
|
|
|
|
|
|
self.status_note = Some("already sending".into());
|
|
|
|
|
|
return Ok(());
|
2026-09-10 23:07:22 -04:00
|
|
|
|
}
|
2026-09-11 22:33:55 -04:00
|
|
|
|
let pk = friend.pubkey.clone();
|
|
|
|
|
|
let body = text.as_bytes().to_vec();
|
|
|
|
|
|
let node = Arc::clone(&self.node);
|
|
|
|
|
|
let (tx, rx) = mpsc::channel();
|
|
|
|
|
|
self.status_note = Some("sending".into());
|
2026-09-12 22:53:58 -04:00
|
|
|
|
let _j = self.rt.spawn(async move {
|
2026-09-12 14:22:38 -04:00
|
|
|
|
// `send()` reports `Sent` when the circuit took it and `Queued` when
|
|
|
|
|
|
// the peer's onion is unreachable. The footer then reads the real
|
|
|
|
|
|
// row count from the outbox, so this note is only the first word.
|
2026-09-11 22:33:55 -04:00
|
|
|
|
let note = match node.send(&pk, &body).await {
|
2026-09-12 14:22:38 -04:00
|
|
|
|
Ok(OutboxStatus::Sent) => "sent".to_string(),
|
|
|
|
|
|
Ok(_) => "queued".to_string(),
|
|
|
|
|
|
Err(e) => format!("send failed: {}", short_send_reason(&e, FAIL_REASON_BUDGET)),
|
2026-09-11 22:33:55 -04:00
|
|
|
|
};
|
|
|
|
|
|
let _ = tx.send(note);
|
2026-09-12 22:53:58 -04:00
|
|
|
|
});
|
2026-09-11 22:33:55 -04:00
|
|
|
|
self.job_rx = Some(rx);
|
2026-09-10 23:07:22 -04:00
|
|
|
|
Ok(())
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-09-11 22:33:55 -04:00
|
|
|
|
fn drain_job(&mut self) {
|
|
|
|
|
|
let Some(note) = self.job_rx.as_ref().and_then(take_job_result) else {
|
|
|
|
|
|
return;
|
|
|
|
|
|
};
|
|
|
|
|
|
self.status_note = Some(note);
|
|
|
|
|
|
self.job_rx = None;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-09-10 14:25:31 -04:00
|
|
|
|
fn who_body(&self) -> String {
|
|
|
|
|
|
let Some(friend) = self.friends.get(self.selected) else {
|
|
|
|
|
|
return "no friend selected\n\nEsc closes".into();
|
|
|
|
|
|
};
|
|
|
|
|
|
let profile = self.node.friend_profile(&friend.pubkey).ok().flatten();
|
|
|
|
|
|
who_overlay_text(&friend.fingerprint, &friend.onion, profile.as_ref())
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-09-10 01:54:19 -04:00
|
|
|
|
fn draw(&self, f: &mut Frame) {
|
|
|
|
|
|
match &self.screen {
|
|
|
|
|
|
Screen::Main => self.draw_main(f),
|
2026-09-10 16:53:03 -04:00
|
|
|
|
Screen::Share { payload } => draw_share(f, payload),
|
2026-09-10 01:54:19 -04:00
|
|
|
|
Screen::Paste { buf, err } => draw_paste(f, buf, err.as_deref()),
|
|
|
|
|
|
Screen::Approve { payload } => draw_approve(f, payload),
|
2026-09-10 02:43:45 -04:00
|
|
|
|
Screen::Rotate { prompt } => draw_rotate(f, prompt.typed()),
|
2026-09-17 20:48:10 -04:00
|
|
|
|
Screen::RotatePrekey { prompt } => draw_rotate_prekey(f, prompt.typed()),
|
2026-09-10 02:49:42 -04:00
|
|
|
|
Screen::Wipe { kind, prompt } => draw_wipe(f, *kind, prompt.typed()),
|
2026-09-10 14:25:31 -04:00
|
|
|
|
Screen::Profile { editor } => draw_profile(f, editor),
|
2026-09-10 14:50:01 -04:00
|
|
|
|
Screen::ConfirmKeys { kind, prompt, .. } => draw_confirm_keys(f, *kind, prompt.typed()),
|
2026-09-12 14:06:20 -04:00
|
|
|
|
Screen::Passphrase { kind, entry, .. } => {
|
|
|
|
|
|
draw_passphrase(f, *kind, entry.first().is_some(), entry.buf())
|
|
|
|
|
|
}
|
2026-09-10 17:19:50 -04:00
|
|
|
|
Screen::Quit { prompt } => draw_quit(f, prompt.typed()),
|
2026-09-18 09:28:11 -04:00
|
|
|
|
Screen::Wallet {
|
|
|
|
|
|
receive_addr,
|
|
|
|
|
|
balance,
|
|
|
|
|
|
transfers,
|
|
|
|
|
|
qr_modal,
|
|
|
|
|
|
} => {
|
wallet: land the in-process Cuprate chain source on main
`ChainSource::InProcessCuprate { datadir }` is the fourth chain source: P2P,
consensus and RandomX run inside the OnionWire process instead of as a spawned
`monerod`. The wallet layer does not move — the daemon binds the same loopback
unrestricted RPC (`127.0.0.1:18081`) that `WalletChild::daemon_address` already
returns for a local source, so `wallet_rpc_argv`, the RPC client, the payment
frames and the receipt-verification path are untouched.
- Cargo.toml: `cuprated` (git, rev 4f8fcd1b) + `toml`, both optional, behind the
`cuprate-daemon` feature, OFF by default. `cuprated`'s own `arti` feature is
disabled (`default-features = false`): its arti-client 0.44 cannot unify with
this crate's 0.46, and the in-process daemon is clearnet-only. One Tor stack in
the process. `Cargo.lock` gains the graph; a default build's
`cargo tree --locked -e normal -i cuprated` still says "did not match any
packages", and only `arti-client v0.46.0` is in the lock.
- src/cuprate.rs (new): `CuprateNode` builds the cuprated config as TOML
(testnet, unrestricted RPC on loopback, restricted RPC disabled, inbound P2P
off), launches it on a runtime it owns, and owns the node. `launch` is
synchronous on purpose: `WalletChild::start` is sync (the TUI calls it from its
blocking thread, UniFFI calls it from an async context) and a runtime cannot be
started from inside a runtime, so the launch runs on a thread of its own and
the node + its runtime come back over a channel. Dropping the value asks the
node to shut down and `shutdown_background`s the runtime, which is the only
exit that cannot panic when the value is dropped inside another runtime.
The type exists in every build (feature off: `launch` fails with the feature
name), so the chain-source type, its stored record and its copy do not fork on
a cargo feature.
- src/wallet.rs: the variant, its label (`in-process node`), and the chain-daemon
client the wallet line carried (typed `WalletError`, de-chunked HTTP,
`get_height` over the URI endpoint, an above-the-tip height as one typed
error). Cuprate answers those three differently from monerod and the
in-process source is what makes them the *local* case.
- src/wallet_child.rs: launches/holds/stops the node, `chain_datadir` for the
free-space/ownership question, the honest `chain_copy` line, `kind =
"cuprate"` in the sealed record, and `ChildConfig::validate` for it.
- src/tui.rs: the wallet screen's chain line carries the testnet caveat when the
configured source is the in-process one. It computes the line at draw time, so
`Screen::Wallet`'s shape (which tests construct) does not change.
- docs/WALLET.md, docs/THREAT_MODEL.md, docs/cuprate-android-spike.md: the
feature flag and how to enable it, where the (fjall) chain store lives, the
**measured** +11.8 MiB delta, the pre-production/testnet caveat, and the
in-repo aarch64-linux-android proof with exit codes.
Scope deviations, stated plainly:
- `src/cuprate.rs` and its one `src/lib.rs` module line are not in the card's
allowed list; the card's own deliverable describes the module's behaviour.
- `crates/onionwire-sdk/src/lib.rs` is forbidden, but adding a variant to a
`pub enum` that the SDK matches exhaustively breaks the SDK workspace, and the
root CI `sdk` job runs on every PR. One variant plus two match arms land here
so the SDK keeps compiling (`cargo test --locked` + clippy clean); the SDK card
owns the rest — feature passthrough, the config field's semantics, the label
and its tests, and the Android check.
- `tests/wallet.rs` carries the launch test. `tests/tui_frames.rs` is untouched:
main has no `ChainChoice` to pin (the chain-source picker is the unmerged F7
work, and `docs/WALLET.md` says so rather than describing a picker that does
not exist).
Proof (all on this tree):
- Default build: `cargo test --locked --target x86_64-unknown-linux-gnu` → 345
passed / 0 failed across 33 suites, exit 0; `cargo clippy --locked
--all-targets --target x86_64-unknown-linux-gnu -- -D warnings` exit 0.
- Feature on: `cargo test --locked --features cuprate-daemon --target
x86_64-unknown-linux-gnu` → 347 passed / 0 failed, exit 0; same clippy with
`--features cuprate-daemon` exit 0. The two extra tests are the real thing:
`wallet_child::tests::in_process_source_launches_a_daemon_and_stop_shuts_it_down`
and `tests/wallet.rs::an_in_process_cuprate_node_answers_the_typed_daemon_client`
— the latter launches the node, drives `get_info` / `get_height` / `get_block`
through the typed client, checks the above-the-tip 500 maps to
`DaemonHeightOutOfRange`, checks the chain store is under the chain datadir,
and checks the listener dies with the node.
- aarch64: `cargo check --locked --release --target aarch64-linux-android
--features cuprate-daemon` exit 0 (1m 50s), and the full link exit 0
(`cargo rustc ... --bin onionwire -- <NDK C++ runtime / compiler-rt link
args>`) producing `ELF 64-bit LSB pie executable, ARM aarch64, for Android 26,
built by NDK r28c`.
- Size: stripped aarch64 release binary, 24,725,704 bytes without the feature and
37,053,472 with it — +12,327,768 bytes (≈ +11.8 MiB), the figure
`docs/WALLET.md` now quotes.
2026-09-18 13:45:59 -04:00
|
|
|
|
let child = self.wallet_child_screen_line();
|
2026-09-18 09:28:11 -04:00
|
|
|
|
draw_wallet(
|
|
|
|
|
|
f,
|
|
|
|
|
|
receive_addr,
|
|
|
|
|
|
balance,
|
|
|
|
|
|
transfers,
|
|
|
|
|
|
qr_modal.as_ref(),
|
|
|
|
|
|
&child,
|
|
|
|
|
|
)
|
2026-09-12 22:53:58 -04:00
|
|
|
|
}
|
2026-09-13 23:25:25 -04:00
|
|
|
|
Screen::WalletSetup(setup) => draw_wallet_setup(f, setup),
|
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
|
|
|
|
Screen::WalletsSettings { state } => {
|
|
|
|
|
|
// The one status line the screen carries: same `status_footer`
|
|
|
|
|
|
// shape as Main, so TOR / identity / the copy confirmation read
|
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]>
2026-09-18 23:13:12 -04:00
|
|
|
|
// in the same place on every screen — including the phase.
|
|
|
|
|
|
let footer = status_footer_phased(
|
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
|
|
|
|
f.area().width,
|
|
|
|
|
|
&self.me_fp,
|
|
|
|
|
|
&self.me_onion,
|
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]>
2026-09-18 23:13:12 -04:00
|
|
|
|
Some(TorPhase::of(self.node.tor_state())),
|
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
|
|
|
|
self.status_note.as_deref(),
|
|
|
|
|
|
footer_hints(&self.screen),
|
|
|
|
|
|
);
|
|
|
|
|
|
draw_wallets_settings(f, state, &footer)
|
|
|
|
|
|
}
|
tui: peer payment history behind the F9 `payments` row (key p)
The F9 / `/settings` menu's only payment row showed the wallet's own transfer
list (`Node::wallet_recent_transfers`, F6). The signed `/pay` invoices and
`/tip` receipts a peer sent live in the `payments` table and had no path from
the TUI, so they were invisible. `Node::list_payments` (PR #119) closes that
gap; this wires it into a screen.
- `Screen::PeerPayments { state }` + `PeerPaymentsState` /
`PeerPaymentRow`, built by `PeerPaymentsState::from_payments` from
`Node::list_payments`' rows (newest first: the store returns `payments.id`
ascending, the screen windows the vector).
- Key handler: `p` on the F9 screen opens it (`open_peer_payments`); `up`/`down`
(or `k`/`j`) move the selection, `Esc` goes back, `F9` reopens the menu.
- Rows carry direction, kind, amount (`pay::atomic_to_xmr_str`, the same
piconero formatter the chat lines use), memo (sanitized at draw time) and the
receipt's `verified` / `unverified` word; the focused row is marked with `>`
and bold. The selected row's txid and address sit under the rows — the
address wrapped over two lines rather than clipped.
- States: populated, `no payments with {peer}`, `could not read payments`, and
a menu row that refuses when no friend is selected. An empty history is a
state, never an error.
- Menu: the wallet's own list is retitled `transfers` (F6, unchanged), and the
new `payments` row (key `p`) names the peer and the count. Two histories, two
rows, no ambiguity.
- Widths are measured in cells (`Span::width`); trailing columns are dropped
before they can wrap, so the body fits 80x24 (20 inner rows of 21) as well as
120x40 and 200x60.
Tests: new `tests/tui_payments.rs` (11 tests) dumps and asserts the screen at
80x24, 120x40 and 200x60 including the empty history, asserts a memo carrying
ESC/BEL/C1/bidi/newline bytes never reaches the frame buffer, and asserts the
window/column invariants for every width from 20 to 200.
Also relaxes one width assertion in `tests/tui_spec.rs`: `fit_cells` was
asserted to start with `"abcdef"`, which only holds when another test's
in-flight `ONIONWIRE_ASCII` mutation is not visible — the suite mutates env vars
without a global lock, so that test flaked (it also fails on an unmodified tree,
1 run in 2). It now accepts either chrome's cut point, which is what the comment
already claimed.
Docs: `docs/TUI.md` gains the screen's section, the retitled/replaced rows and
the updated row count; the "peer payment history" gap entry is closed.
2026-09-18 23:53:10 -04:00
|
|
|
|
Screen::PeerPayments { state } => {
|
|
|
|
|
|
let footer = status_footer(
|
|
|
|
|
|
f.area().width,
|
|
|
|
|
|
&self.me_fp,
|
|
|
|
|
|
&self.me_onion,
|
|
|
|
|
|
self.status_note.as_deref(),
|
|
|
|
|
|
footer_hints(&self.screen),
|
|
|
|
|
|
);
|
|
|
|
|
|
draw_peer_payments(f, state, &footer)
|
|
|
|
|
|
}
|
2026-09-10 01:54:19 -04:00
|
|
|
|
}
|
tui: ASCII onion chrome, themed panes, and real keyboard navigation
- Hand-written wordmark banner (<=80 cols, auto-collapses to a compact
mark below banner width) plus onion glyph and themed screen headings
- Color-palette consts, stateful pane titles, highlighted selection row
(accent + bg), context-sensitive footer that always keeps '? help'
- Pane focus model (roster/chat/composer) with Tab/Shift-Tab, 1/2/3,
j/k + arrows, g/G, and a '?' help overlay; Esc closes any overlay
- New tests/tui_chrome.rs: banner widths, help overlay bindings, real
footer helper at 80 and 120 cols, 80x24 draw smoke test
- README keybinding table updated to match
Locked helper strings (fingerprint_mismatch_banner, rotate_screen_text,
wipe_screen_text, parse_slash) unchanged; UI-only (src/tui.rs).
2026-09-10 13:01:40 -04:00
|
|
|
|
if self.help_open {
|
2026-09-10 14:25:31 -04:00
|
|
|
|
draw_text_overlay(f, "? help", help_overlay_text());
|
|
|
|
|
|
} else if self.who_open {
|
|
|
|
|
|
draw_text_overlay(f, "/who", &self.who_body());
|
tui: ASCII onion chrome, themed panes, and real keyboard navigation
- Hand-written wordmark banner (<=80 cols, auto-collapses to a compact
mark below banner width) plus onion glyph and themed screen headings
- Color-palette consts, stateful pane titles, highlighted selection row
(accent + bg), context-sensitive footer that always keeps '? help'
- Pane focus model (roster/chat/composer) with Tab/Shift-Tab, 1/2/3,
j/k + arrows, g/G, and a '?' help overlay; Esc closes any overlay
- New tests/tui_chrome.rs: banner widths, help overlay bindings, real
footer helper at 80 and 120 cols, 80x24 draw smoke test
- README keybinding table updated to match
Locked helper strings (fingerprint_mismatch_banner, rotate_screen_text,
wipe_screen_text, parse_slash) unchanged; UI-only (src/tui.rs).
2026-09-10 13:01:40 -04:00
|
|
|
|
}
|
2026-09-10 01:54:19 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
fn draw_main(&self, f: &mut Frame) {
|
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]>
2026-09-18 23:13:12 -04:00
|
|
|
|
let phase = Some(TorPhase::of(self.node.tor_state()));
|
|
|
|
|
|
let (chat_lines, summary, chat_style) = self.chat_view(phase);
|
|
|
|
|
|
let rows: Vec<FriendRow> = self.friends.iter().map(friend_row).collect();
|
2026-09-12 14:22:38 -04:00
|
|
|
|
let chat_name = self.friends.get(self.selected).map(|friend| {
|
|
|
|
|
|
friend
|
|
|
|
|
|
.petname
|
|
|
|
|
|
.as_deref()
|
|
|
|
|
|
.unwrap_or(&friend.fingerprint)
|
|
|
|
|
|
.to_string()
|
|
|
|
|
|
});
|
|
|
|
|
|
// The outbox is the source of truth while anything is outstanding; the
|
|
|
|
|
|
// transient note still covers "sending", "sent file x", "invoice sent".
|
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]>
2026-09-18 23:13:12 -04:00
|
|
|
|
let mut note = summary.note().or_else(|| self.status_note.clone());
|
|
|
|
|
|
// The alert row above the panes is the error channel. When it already
|
|
|
|
|
|
// carries the same sentence, drop it from the footer: one statement of a
|
|
|
|
|
|
// failure, in the place the eye goes for errors.
|
|
|
|
|
|
if note.as_deref() == self.alert.as_deref() {
|
|
|
|
|
|
note = None;
|
|
|
|
|
|
}
|
|
|
|
|
|
let view = MainView {
|
|
|
|
|
|
me_fp: &self.me_fp,
|
|
|
|
|
|
me_onion: &self.me_onion,
|
|
|
|
|
|
phase,
|
|
|
|
|
|
friends: &rows,
|
|
|
|
|
|
selected: self.selected,
|
|
|
|
|
|
focus: self.focus,
|
|
|
|
|
|
chat_lines: &chat_lines,
|
|
|
|
|
|
chat_style,
|
|
|
|
|
|
chat_name: chat_name.as_deref(),
|
|
|
|
|
|
chat_scroll: self.chat_scroll,
|
|
|
|
|
|
composer: &self.composer,
|
|
|
|
|
|
alert: self.alert.as_deref(),
|
|
|
|
|
|
note: note.as_deref(),
|
|
|
|
|
|
};
|
|
|
|
|
|
draw_main_chrome(f, &view);
|
tui: ASCII onion chrome, themed panes, and real keyboard navigation
- Hand-written wordmark banner (<=80 cols, auto-collapses to a compact
mark below banner width) plus onion glyph and themed screen headings
- Color-palette consts, stateful pane titles, highlighted selection row
(accent + bg), context-sensitive footer that always keeps '? help'
- Pane focus model (roster/chat/composer) with Tab/Shift-Tab, 1/2/3,
j/k + arrows, g/G, and a '?' help overlay; Esc closes any overlay
- New tests/tui_chrome.rs: banner widths, help overlay bindings, real
footer helper at 80 and 120 cols, 80x24 draw smoke test
- README keybinding table updated to match
Locked helper strings (fingerprint_mismatch_banner, rotate_screen_text,
wipe_screen_text, parse_slash) unchanged; UI-only (src/tui.rs).
2026-09-10 13:01:40 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
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]>
2026-09-18 23:13:12 -04:00
|
|
|
|
/// Transcript, outbox summary, and how the rows should be styled. State copy
|
|
|
|
|
|
/// is flagged here — the render path never guesses from the text.
|
|
|
|
|
|
fn chat_view(&self, phase: Option<TorPhase>) -> (Vec<String>, OutboxSummary, ChatRowStyle) {
|
tui: ASCII onion chrome, themed panes, and real keyboard navigation
- Hand-written wordmark banner (<=80 cols, auto-collapses to a compact
mark below banner width) plus onion glyph and themed screen headings
- Color-palette consts, stateful pane titles, highlighted selection row
(accent + bg), context-sensitive footer that always keeps '? help'
- Pane focus model (roster/chat/composer) with Tab/Shift-Tab, 1/2/3,
j/k + arrows, g/G, and a '?' help overlay; Esc closes any overlay
- New tests/tui_chrome.rs: banner widths, help overlay bindings, real
footer helper at 80 and 120 cols, 80x24 draw smoke test
- README keybinding table updated to match
Locked helper strings (fingerprint_mismatch_banner, rotate_screen_text,
wipe_screen_text, parse_slash) unchanged; UI-only (src/tui.rs).
2026-09-10 13:01:40 -04:00
|
|
|
|
let Some(friend) = self.friends.get(self.selected) else {
|
2026-09-12 14:22:38 -04:00
|
|
|
|
return (
|
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]>
2026-09-18 23:13:12 -04:00
|
|
|
|
chat_no_friends_lines(phase),
|
2026-09-12 14:22:38 -04:00
|
|
|
|
OutboxSummary::default(),
|
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]>
2026-09-18 23:13:12 -04:00
|
|
|
|
ChatRowStyle::State,
|
2026-09-12 14:22:38 -04:00
|
|
|
|
);
|
tui: ASCII onion chrome, themed panes, and real keyboard navigation
- Hand-written wordmark banner (<=80 cols, auto-collapses to a compact
mark below banner width) plus onion glyph and themed screen headings
- Color-palette consts, stateful pane titles, highlighted selection row
(accent + bg), context-sensitive footer that always keeps '? help'
- Pane focus model (roster/chat/composer) with Tab/Shift-Tab, 1/2/3,
j/k + arrows, g/G, and a '?' help overlay; Esc closes any overlay
- New tests/tui_chrome.rs: banner widths, help overlay bindings, real
footer helper at 80 and 120 cols, 80x24 draw smoke test
- README keybinding table updated to match
Locked helper strings (fingerprint_mismatch_banner, rotate_screen_text,
wipe_screen_text, parse_slash) unchanged; UI-only (src/tui.rs).
2026-09-10 13:01:40 -04:00
|
|
|
|
};
|
|
|
|
|
|
match self.node.list_messages(&friend.pubkey) {
|
2026-09-12 14:22:38 -04:00
|
|
|
|
Ok(msgs) => {
|
|
|
|
|
|
let pending = self.node.outbox_pending(&friend.pubkey).unwrap_or_default();
|
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]>
2026-09-18 23:13:12 -04:00
|
|
|
|
let (lines, summary) = chat_with_delivery(&msgs, &pending, unix_now_secs());
|
|
|
|
|
|
let style = if msgs.is_empty() {
|
|
|
|
|
|
ChatRowStyle::State
|
|
|
|
|
|
} else {
|
|
|
|
|
|
ChatRowStyle::Text
|
|
|
|
|
|
};
|
|
|
|
|
|
(lines, summary, style)
|
2026-09-12 14:22:38 -04:00
|
|
|
|
}
|
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]>
2026-09-18 23:13:12 -04:00
|
|
|
|
Err(e) => (vec![e], OutboxSummary::default(), ChatRowStyle::Error),
|
tui: ASCII onion chrome, themed panes, and real keyboard navigation
- Hand-written wordmark banner (<=80 cols, auto-collapses to a compact
mark below banner width) plus onion glyph and themed screen headings
- Color-palette consts, stateful pane titles, highlighted selection row
(accent + bg), context-sensitive footer that always keeps '? help'
- Pane focus model (roster/chat/composer) with Tab/Shift-Tab, 1/2/3,
j/k + arrows, g/G, and a '?' help overlay; Esc closes any overlay
- New tests/tui_chrome.rs: banner widths, help overlay bindings, real
footer helper at 80 and 120 cols, 80x24 draw smoke test
- README keybinding table updated to match
Locked helper strings (fingerprint_mismatch_banner, rotate_screen_text,
wipe_screen_text, parse_slash) unchanged; UI-only (src/tui.rs).
2026-09-10 13:01:40 -04:00
|
|
|
|
}
|
|
|
|
|
|
}
|
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]>
2026-09-18 23:13:12 -04:00
|
|
|
|
}
|
tui: ASCII onion chrome, themed panes, and real keyboard navigation
- Hand-written wordmark banner (<=80 cols, auto-collapses to a compact
mark below banner width) plus onion glyph and themed screen headings
- Color-palette consts, stateful pane titles, highlighted selection row
(accent + bg), context-sensitive footer that always keeps '? help'
- Pane focus model (roster/chat/composer) with Tab/Shift-Tab, 1/2/3,
j/k + arrows, g/G, and a '?' help overlay; Esc closes any overlay
- New tests/tui_chrome.rs: banner widths, help overlay bindings, real
footer helper at 80 and 120 cols, 80x24 draw smoke test
- README keybinding table updated to match
Locked helper strings (fingerprint_mismatch_banner, rotate_screen_text,
wipe_screen_text, parse_slash) unchanged; UI-only (src/tui.rs).
2026-09-10 13:01:40 -04:00
|
|
|
|
|
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]>
2026-09-18 23:13:12 -04:00
|
|
|
|
/// One roster row: the label, the fingerprint, and the word `stale` when the
|
|
|
|
|
|
/// last dial did not answer. Colour is what the row is (text vs stale), never a
|
|
|
|
|
|
/// decoration — the word carries the state on a monochrome terminal.
|
|
|
|
|
|
pub fn roster_line(row: &FriendRow, inner_width: u16) -> Line<'static> {
|
|
|
|
|
|
let text = roster_row_text(row, inner_width);
|
|
|
|
|
|
let style = if row.stale { style_stale() } else { style_text() };
|
|
|
|
|
|
Line::from(Span::raw(text).style(style))
|
tui: ASCII onion chrome, themed panes, and real keyboard navigation
- Hand-written wordmark banner (<=80 cols, auto-collapses to a compact
mark below banner width) plus onion glyph and themed screen headings
- Color-palette consts, stateful pane titles, highlighted selection row
(accent + bg), context-sensitive footer that always keeps '? help'
- Pane focus model (roster/chat/composer) with Tab/Shift-Tab, 1/2/3,
j/k + arrows, g/G, and a '?' help overlay; Esc closes any overlay
- New tests/tui_chrome.rs: banner widths, help overlay bindings, real
footer helper at 80 and 120 cols, 80x24 draw smoke test
- README keybinding table updated to match
Locked helper strings (fingerprint_mismatch_banner, rotate_screen_text,
wipe_screen_text, parse_slash) unchanged; UI-only (src/tui.rs).
2026-09-10 13:01:40 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
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]>
2026-09-18 23:13:12 -04:00
|
|
|
|
/// How one chat row is styled.
|
|
|
|
|
|
#[derive(Clone, Copy, PartialEq, Eq, Debug)]
|
|
|
|
|
|
pub enum ChatRowStyle {
|
|
|
|
|
|
/// Transcript rows: our own messages and the peer's.
|
|
|
|
|
|
Text,
|
|
|
|
|
|
/// Empty / loading copy that stands in for a transcript.
|
|
|
|
|
|
State,
|
|
|
|
|
|
/// The pane could not read the transcript at all.
|
|
|
|
|
|
Error,
|
tui: ASCII onion chrome, themed panes, and real keyboard navigation
- Hand-written wordmark banner (<=80 cols, auto-collapses to a compact
mark below banner width) plus onion glyph and themed screen headings
- Color-palette consts, stateful pane titles, highlighted selection row
(accent + bg), context-sensitive footer that always keeps '? help'
- Pane focus model (roster/chat/composer) with Tab/Shift-Tab, 1/2/3,
j/k + arrows, g/G, and a '?' help overlay; Esc closes any overlay
- New tests/tui_chrome.rs: banner widths, help overlay bindings, real
footer helper at 80 and 120 cols, 80x24 draw smoke test
- README keybinding table updated to match
Locked helper strings (fingerprint_mismatch_banner, rotate_screen_text,
wipe_screen_text, parse_slash) unchanged; UI-only (src/tui.rs).
2026-09-10 13:01:40 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
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]>
2026-09-18 23:13:12 -04:00
|
|
|
|
/// The main screen: one header line, one primary pane, one status line, one
|
|
|
|
|
|
/// footer hint line.
|
|
|
|
|
|
///
|
|
|
|
|
|
/// Every field is plain data, so the render path has no `Node` in it and
|
|
|
|
|
|
/// `tests/tui_frames.rs` dumps the real chrome at 80x24, 120x40 and 200x60.
|
|
|
|
|
|
pub struct MainView<'a> {
|
|
|
|
|
|
pub me_fp: &'a str,
|
|
|
|
|
|
pub me_onion: &'a str,
|
|
|
|
|
|
/// Tor phase, or `None` to keep the phase-free `TOR` token.
|
|
|
|
|
|
pub phase: Option<TorPhase>,
|
|
|
|
|
|
pub friends: &'a [FriendRow],
|
|
|
|
|
|
pub selected: usize,
|
|
|
|
|
|
/// Which pane owns the keyboard. Drives the marker, the bold title, the
|
|
|
|
|
|
/// accented border, and the footer hints.
|
|
|
|
|
|
pub focus: Pane,
|
|
|
|
|
|
pub chat_lines: &'a [String],
|
|
|
|
|
|
pub chat_style: ChatRowStyle,
|
|
|
|
|
|
pub chat_name: Option<&'a str>,
|
|
|
|
|
|
pub chat_scroll: u16,
|
|
|
|
|
|
pub composer: &'a str,
|
|
|
|
|
|
/// Fail-closed one-liner: `send failed: …`, `fingerprint mismatch`, or a
|
|
|
|
|
|
/// validation message. Rendered above the panes, never truncated mid-word.
|
|
|
|
|
|
pub alert: Option<&'a str>,
|
|
|
|
|
|
/// Footer note: outbox summary or the last status message.
|
|
|
|
|
|
pub note: Option<&'a str>,
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// Draw the main screen. The only chrome that reads colour is `pane_block_for`
|
|
|
|
|
|
/// (focus), `roster_line` (state), and the header's phase token.
|
|
|
|
|
|
pub fn draw_main_chrome(f: &mut Frame, view: &MainView<'_>) {
|
|
|
|
|
|
let area = f.area();
|
|
|
|
|
|
let alert_h = u16::from(view.alert.is_some());
|
|
|
|
|
|
let cols = Layout::vertical([
|
|
|
|
|
|
Constraint::Length(1),
|
|
|
|
|
|
Constraint::Length(alert_h),
|
|
|
|
|
|
Constraint::Min(3),
|
|
|
|
|
|
Constraint::Length(3),
|
|
|
|
|
|
Constraint::Length(1),
|
|
|
|
|
|
])
|
|
|
|
|
|
.split(area);
|
|
|
|
|
|
|
|
|
|
|
|
f.render_widget(
|
|
|
|
|
|
Paragraph::new(Line::from(main_header_spans(
|
|
|
|
|
|
area.width,
|
|
|
|
|
|
view.me_fp,
|
|
|
|
|
|
view.me_onion,
|
|
|
|
|
|
view.phase,
|
|
|
|
|
|
))),
|
|
|
|
|
|
cols[0],
|
|
|
|
|
|
);
|
|
|
|
|
|
if let Some(msg) = view.alert {
|
|
|
|
|
|
let text = alert_line(msg, area.width);
|
|
|
|
|
|
f.render_widget(Paragraph::new(text).style(style_alert()), cols[1]);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
let roster_w = roster_col_width(area.width).min(cols[2].width.saturating_sub(10));
|
|
|
|
|
|
let panes =
|
|
|
|
|
|
Layout::horizontal([Constraint::Length(roster_w), Constraint::Min(10)]).split(cols[2]);
|
|
|
|
|
|
let inner_roster = panes[0].width.saturating_sub(2);
|
|
|
|
|
|
|
|
|
|
|
|
let stale_n = view.friends.iter().filter(|fr| fr.stale).count();
|
|
|
|
|
|
let roster_title = if view.friends.is_empty() {
|
|
|
|
|
|
"roster 0".to_string()
|
|
|
|
|
|
} else if stale_n > 0 {
|
|
|
|
|
|
format!("roster {} {stale_n} stale", view.friends.len())
|
|
|
|
|
|
} else {
|
|
|
|
|
|
format!("roster {}", view.friends.len())
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
let items: Vec<ListItem> = if view.friends.is_empty() {
|
|
|
|
|
|
empty_roster_lines()
|
|
|
|
|
|
.iter()
|
|
|
|
|
|
.map(|l| ListItem::new(*l).style(style_dim()))
|
|
|
|
|
|
.collect()
|
|
|
|
|
|
} else {
|
|
|
|
|
|
view.friends
|
|
|
|
|
|
.iter()
|
|
|
|
|
|
.map(|row| ListItem::new(roster_line(row, inner_roster)))
|
|
|
|
|
|
.collect()
|
|
|
|
|
|
};
|
|
|
|
|
|
let roster = List::new(items)
|
|
|
|
|
|
.highlight_style(style_highlight())
|
|
|
|
|
|
.highlight_symbol("> ")
|
|
|
|
|
|
.block(pane_block_for(&roster_title, view.focus == Pane::Roster));
|
|
|
|
|
|
let mut roster_state = ListState::default();
|
|
|
|
|
|
if !view.friends.is_empty() {
|
|
|
|
|
|
roster_state.select(Some(view.selected));
|
|
|
|
|
|
}
|
|
|
|
|
|
f.render_stateful_widget(roster, panes[0], &mut roster_state);
|
|
|
|
|
|
|
|
|
|
|
|
let chat = chat_lines_for(view.chat_lines, view.chat_style);
|
|
|
|
|
|
draw_chat_lines(
|
|
|
|
|
|
f,
|
|
|
|
|
|
panes[1],
|
|
|
|
|
|
&chat,
|
|
|
|
|
|
view.chat_name,
|
|
|
|
|
|
view.focus == Pane::Chat,
|
|
|
|
|
|
view.chat_scroll,
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
// Composer: no frame. `> ` plus bold while it owns the keyboard, `message`
|
|
|
|
|
|
// as a muted placeholder when it is empty. The 3-row slot stays so a
|
|
|
|
|
|
// wrapped line is not clipped.
|
|
|
|
|
|
let focused = view.focus == Pane::Composer;
|
|
|
|
|
|
let mark = if focused { "> " } else { " " };
|
|
|
|
|
|
let (cmd, cmd_style) = if view.composer.is_empty() {
|
|
|
|
|
|
(format!("{mark}message"), style_dim())
|
|
|
|
|
|
} else if focused {
|
|
|
|
|
|
(
|
|
|
|
|
|
format!("{mark}{}", view.composer),
|
|
|
|
|
|
style_text().add_modifier(Modifier::BOLD),
|
|
|
|
|
|
)
|
|
|
|
|
|
} else {
|
|
|
|
|
|
(format!("{mark}{}", view.composer), style_text())
|
|
|
|
|
|
};
|
|
|
|
|
|
f.render_widget(
|
|
|
|
|
|
Paragraph::new(cmd)
|
|
|
|
|
|
.style(cmd_style)
|
|
|
|
|
|
.wrap(Wrap { trim: false }),
|
|
|
|
|
|
cols[3],
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
let footer = status_footer_compact(
|
|
|
|
|
|
area.width,
|
|
|
|
|
|
view.me_fp,
|
|
|
|
|
|
view.phase,
|
|
|
|
|
|
view.note,
|
|
|
|
|
|
pane_footer_hints(view.focus),
|
|
|
|
|
|
);
|
|
|
|
|
|
f.render_widget(Paragraph::new(footer).style(style_dim()), cols[4]);
|
|
|
|
|
|
}
|
2026-09-12 14:22:38 -04:00
|
|
|
|
fn pane_block_for(title: &str, focused: bool) -> Block<'_> {
|
|
|
|
|
|
let border = if focused {
|
|
|
|
|
|
style_accent()
|
|
|
|
|
|
} else {
|
|
|
|
|
|
style_border()
|
|
|
|
|
|
};
|
|
|
|
|
|
let title_style = if focused {
|
|
|
|
|
|
style_accent().add_modifier(Modifier::BOLD)
|
|
|
|
|
|
} else {
|
|
|
|
|
|
style_dim()
|
|
|
|
|
|
};
|
|
|
|
|
|
apply_chrome_borders(Block::default())
|
|
|
|
|
|
.border_style(border)
|
|
|
|
|
|
.title(title)
|
|
|
|
|
|
.title_style(title_style)
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
fn unix_now_secs() -> i64 {
|
|
|
|
|
|
SystemTime::now()
|
|
|
|
|
|
.duration_since(UNIX_EPOCH)
|
|
|
|
|
|
.map(|d| d.as_secs() as i64)
|
|
|
|
|
|
.unwrap_or(0)
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// Real chat-pane renderer: `App::draw_main` calls this, so width, wrap and
|
|
|
|
|
|
/// delivery-marker behaviour are testable without constructing a `Node`.
|
|
|
|
|
|
pub fn draw_chat(
|
|
|
|
|
|
f: &mut Frame,
|
|
|
|
|
|
area: Rect,
|
|
|
|
|
|
lines: &[String],
|
|
|
|
|
|
name: Option<&str>,
|
|
|
|
|
|
focused: bool,
|
|
|
|
|
|
scroll: u16,
|
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]>
2026-09-18 23:13:12 -04:00
|
|
|
|
) {
|
|
|
|
|
|
let styled = chat_lines_for(lines, ChatRowStyle::Text);
|
|
|
|
|
|
draw_chat_lines(f, area, &styled, name, focused, scroll);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// Transcript rows, styled. The style is a caller decision, never inferred from
|
|
|
|
|
|
/// the text: a peer message body must not be able to pick its own colour by
|
|
|
|
|
|
/// starting with the word `no`.
|
|
|
|
|
|
pub fn chat_lines_for(lines: &[String], style: ChatRowStyle) -> Vec<Line<'static>> {
|
|
|
|
|
|
let style = match style {
|
|
|
|
|
|
ChatRowStyle::Text => style_text(),
|
|
|
|
|
|
ChatRowStyle::State => style_dim(),
|
|
|
|
|
|
ChatRowStyle::Error => style_alert(),
|
|
|
|
|
|
};
|
|
|
|
|
|
lines
|
|
|
|
|
|
.iter()
|
|
|
|
|
|
.map(|l| Line::from(Span::raw(l.clone()).style(style)))
|
|
|
|
|
|
.collect()
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// The chat pane itself. Same renderer for transcript rows and state copy; the
|
|
|
|
|
|
/// only difference is the style the caller baked into each `Line`.
|
|
|
|
|
|
pub fn draw_chat_lines(
|
|
|
|
|
|
f: &mut Frame,
|
|
|
|
|
|
area: Rect,
|
|
|
|
|
|
lines: &[Line<'static>],
|
|
|
|
|
|
name: Option<&str>,
|
|
|
|
|
|
focused: bool,
|
|
|
|
|
|
scroll: u16,
|
2026-09-12 14:22:38 -04:00
|
|
|
|
) {
|
|
|
|
|
|
let inner_h = area.height.saturating_sub(2);
|
|
|
|
|
|
let nlines = lines.len();
|
|
|
|
|
|
let max_scroll = nlines.saturating_sub(inner_h as usize) as u16;
|
|
|
|
|
|
let scroll = scroll.min(max_scroll);
|
|
|
|
|
|
let overflow = nlines > inner_h as usize && inner_h > 0;
|
|
|
|
|
|
let mut title = match name {
|
|
|
|
|
|
Some(n) => format!("chat {n}"),
|
|
|
|
|
|
None => "chat".to_string(),
|
|
|
|
|
|
};
|
|
|
|
|
|
if overflow {
|
|
|
|
|
|
let end = (scroll as usize + inner_h as usize).min(nlines);
|
|
|
|
|
|
title.push_str(&format!(" {}-{end}/{nlines}", scroll as usize + 1));
|
|
|
|
|
|
}
|
|
|
|
|
|
let mark = if focused { "> " } else { " " };
|
|
|
|
|
|
let title = format!("{mark}{title}");
|
|
|
|
|
|
f.render_widget(
|
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]>
2026-09-18 23:13:12 -04:00
|
|
|
|
Paragraph::new(lines.to_vec())
|
2026-09-12 14:22:38 -04:00
|
|
|
|
.wrap(Wrap { trim: false })
|
|
|
|
|
|
.scroll((scroll, 0))
|
|
|
|
|
|
.block(pane_block_for(&title, focused)),
|
|
|
|
|
|
area,
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
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]>
2026-09-18 23:13:12 -04:00
|
|
|
|
/// Chat-pane copy when no friend is selected. States after the base two rows
|
|
|
|
|
|
/// say which phase the node is actually in, so an empty roster during first
|
|
|
|
|
|
/// publish does not read as a broken app.
|
|
|
|
|
|
pub fn chat_no_friends_lines(phase: Option<TorPhase>) -> Vec<String> {
|
|
|
|
|
|
let mut lines = vec![
|
|
|
|
|
|
"no friends yet".to_string(),
|
|
|
|
|
|
"F3 paste an invite to add one".to_string(),
|
|
|
|
|
|
];
|
|
|
|
|
|
let state = match phase {
|
|
|
|
|
|
None => None,
|
|
|
|
|
|
Some(TorPhase::Connecting) => {
|
|
|
|
|
|
Some("tor connecting — first publish takes a few minutes")
|
|
|
|
|
|
}
|
|
|
|
|
|
Some(TorPhase::Degraded) => Some("tor degraded — reachable, still settling"),
|
|
|
|
|
|
Some(TorPhase::Off) => Some("tor off — no onion service is running"),
|
|
|
|
|
|
Some(TorPhase::Ready) => None,
|
|
|
|
|
|
};
|
|
|
|
|
|
if let Some(note) = state {
|
|
|
|
|
|
lines.push(String::new());
|
|
|
|
|
|
lines.push(note.to_string());
|
|
|
|
|
|
}
|
|
|
|
|
|
lines
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// Roster-pane copy when the friend list is empty. Two rows, so the pane reads
|
|
|
|
|
|
/// as an empty state instead of a blank box.
|
|
|
|
|
|
pub fn empty_roster_lines() -> [&'static str; 2] {
|
|
|
|
|
|
["no friends", "F3 adds one"]
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// One friend, as the roster draws it.
|
|
|
|
|
|
///
|
|
|
|
|
|
/// Built by `App` from `store::Friend`; the render path never touches the store
|
|
|
|
|
|
/// type, which is what lets `tests/tui_frames.rs` draw the real chrome.
|
|
|
|
|
|
#[derive(Clone, Debug, PartialEq, Eq)]
|
|
|
|
|
|
pub struct FriendRow {
|
|
|
|
|
|
/// Display name: petname when set, fingerprint otherwise, already sanitized.
|
|
|
|
|
|
pub label: String,
|
|
|
|
|
|
/// Full fingerprint hex; the row fits it to the pane.
|
|
|
|
|
|
pub fingerprint: String,
|
|
|
|
|
|
/// Last dial to this peer's onion did not answer.
|
|
|
|
|
|
pub stale: bool,
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// The roster row for one friend, fitted to the pane's inner width in cells.
|
|
|
|
|
|
pub fn friend_row(friend: &Friend) -> FriendRow {
|
|
|
|
|
|
let raw = friend.petname.as_deref().unwrap_or(&friend.fingerprint);
|
|
|
|
|
|
FriendRow {
|
|
|
|
|
|
label: sanitize::display_text(raw.as_bytes()).to_string(),
|
|
|
|
|
|
fingerprint: friend.fingerprint.clone(),
|
|
|
|
|
|
stale: !friend.last_connect_ok,
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// Tor lifecycle as the chrome shows it: one word plus one glyph, so the phase
|
|
|
|
|
|
/// survives `NO_COLOR`, a 16-colour terminal, and a monochrome dump.
|
|
|
|
|
|
///
|
|
|
|
|
|
/// Read from `Node::tor_state()`. `Connecting` is the long first publish (HsDir
|
|
|
|
|
|
/// descriptor upload), `Ready` is a published descriptor, `Degraded` is
|
|
|
|
|
|
/// reachable while Arti still reports the service broken — usable, and not the
|
|
|
|
|
|
/// same statement as ready — and `Off` is a stopped node.
|
|
|
|
|
|
#[derive(Clone, Copy, PartialEq, Eq, Debug)]
|
|
|
|
|
|
pub enum TorPhase {
|
|
|
|
|
|
Connecting,
|
|
|
|
|
|
Ready,
|
|
|
|
|
|
Degraded,
|
|
|
|
|
|
Off,
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
impl TorPhase {
|
|
|
|
|
|
/// Project `hs::TorState`. This is the only place that knows the mapping.
|
|
|
|
|
|
pub fn of(state: TorState) -> Self {
|
|
|
|
|
|
match state {
|
|
|
|
|
|
TorState::Published => Self::Ready,
|
|
|
|
|
|
TorState::DegradedReachable => Self::Degraded,
|
|
|
|
|
|
TorState::Stopped => Self::Off,
|
|
|
|
|
|
TorState::Bootstrapping => Self::Connecting,
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// The word a reader sees. Never abbreviated: `ok`/`up` would be ambiguous
|
|
|
|
|
|
/// with the delivery markers.
|
|
|
|
|
|
pub fn word(self) -> &'static str {
|
|
|
|
|
|
match self {
|
|
|
|
|
|
Self::Connecting => "connecting",
|
|
|
|
|
|
Self::Ready => "ready",
|
|
|
|
|
|
Self::Degraded => "degraded",
|
|
|
|
|
|
Self::Off => "off",
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// Marker glyph, paired with [`Self::word`]. ASCII chrome falls back to
|
|
|
|
|
|
/// `...` / `ok` rather than dropping the marker.
|
|
|
|
|
|
pub fn glyph(self) -> &'static str {
|
|
|
|
|
|
let ascii = ascii_chrome();
|
|
|
|
|
|
match self {
|
|
|
|
|
|
Self::Connecting => {
|
|
|
|
|
|
if ascii {
|
|
|
|
|
|
"..."
|
|
|
|
|
|
} else {
|
|
|
|
|
|
"…"
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
Self::Ready => {
|
|
|
|
|
|
if ascii {
|
|
|
|
|
|
"ok"
|
|
|
|
|
|
} else {
|
|
|
|
|
|
"✓"
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
Self::Degraded => "!",
|
|
|
|
|
|
Self::Off => "x",
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// Semantic style: colour answers "what is this", never "what mood".
|
|
|
|
|
|
/// Ready is the unremarkable state, so it takes the plain text token.
|
|
|
|
|
|
pub fn style(self) -> Style {
|
|
|
|
|
|
match self {
|
|
|
|
|
|
Self::Connecting => style_dim(),
|
|
|
|
|
|
Self::Ready => style_text(),
|
|
|
|
|
|
Self::Degraded => style_stale(),
|
|
|
|
|
|
Self::Off => style_alert(),
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// The footer's `TOR` cluster. `None` keeps the bare `TOR` the chrome tests
|
|
|
|
|
|
/// lock; `Some` adds the phase glyph and word.
|
|
|
|
|
|
pub fn tor_token(phase: Option<TorPhase>) -> String {
|
|
|
|
|
|
match phase {
|
|
|
|
|
|
None => "TOR".to_string(),
|
|
|
|
|
|
Some(p) => format!("{} TOR {}", p.glyph(), p.word()),
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-09-12 00:15:19 -04:00
|
|
|
|
/// Status bar: never drop a non-empty `status_note`. Always keep `TOR`, `me:`, `? help`.
|
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]>
2026-09-18 23:13:12 -04:00
|
|
|
|
///
|
|
|
|
|
|
/// Phase-free twin of [`status_footer_phased`], kept because the chrome tests
|
|
|
|
|
|
/// and the reconstructed dumps call it directly.
|
tui: ASCII onion chrome, themed panes, and real keyboard navigation
- Hand-written wordmark banner (<=80 cols, auto-collapses to a compact
mark below banner width) plus onion glyph and themed screen headings
- Color-palette consts, stateful pane titles, highlighted selection row
(accent + bg), context-sensitive footer that always keeps '? help'
- Pane focus model (roster/chat/composer) with Tab/Shift-Tab, 1/2/3,
j/k + arrows, g/G, and a '?' help overlay; Esc closes any overlay
- New tests/tui_chrome.rs: banner widths, help overlay bindings, real
footer helper at 80 and 120 cols, 80x24 draw smoke test
- README keybinding table updated to match
Locked helper strings (fingerprint_mismatch_banner, rotate_screen_text,
wipe_screen_text, parse_slash) unchanged; UI-only (src/tui.rs).
2026-09-10 13:01:40 -04:00
|
|
|
|
pub fn status_footer(
|
|
|
|
|
|
width: u16,
|
|
|
|
|
|
me_fp: &str,
|
|
|
|
|
|
me_onion: &str,
|
|
|
|
|
|
status_note: Option<&str>,
|
|
|
|
|
|
hints: &str,
|
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]>
2026-09-18 23:13:12 -04:00
|
|
|
|
) -> String {
|
|
|
|
|
|
status_footer_phased(width, me_fp, me_onion, None, status_note, hints)
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// Status bar with the Tor phase folded into the `TOR` cluster.
|
|
|
|
|
|
///
|
|
|
|
|
|
/// Every width here is in terminal **cells** (`fit_cells` / `cell_width`), not
|
|
|
|
|
|
/// `chars().count()`: the phase glyph and any peer-supplied note text must not
|
|
|
|
|
|
/// be able to push the line past the frame.
|
|
|
|
|
|
pub fn status_footer_phased(
|
|
|
|
|
|
width: u16,
|
|
|
|
|
|
me_fp: &str,
|
|
|
|
|
|
me_onion: &str,
|
|
|
|
|
|
phase: Option<TorPhase>,
|
|
|
|
|
|
status_note: Option<&str>,
|
|
|
|
|
|
hints: &str,
|
|
|
|
|
|
) -> String {
|
|
|
|
|
|
status_footer_inner(width, me_fp, Some(me_onion), phase, status_note, hints)
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// Footer for a screen whose header already prints the identity.
|
|
|
|
|
|
///
|
|
|
|
|
|
/// The main screen's header carries `me:` and `onion:`, so repeating the onion
|
|
|
|
|
|
/// in the footer costs 20+ cells and buys nothing; those cells go to the hints
|
|
|
|
|
|
/// instead. `TOR` and `me:` stay — `tests/tui_chrome.rs` locks both.
|
|
|
|
|
|
pub fn status_footer_compact(
|
|
|
|
|
|
width: u16,
|
|
|
|
|
|
me_fp: &str,
|
|
|
|
|
|
phase: Option<TorPhase>,
|
|
|
|
|
|
status_note: Option<&str>,
|
|
|
|
|
|
hints: &str,
|
|
|
|
|
|
) -> String {
|
|
|
|
|
|
status_footer_inner(width, me_fp, None, phase, status_note, hints)
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
fn status_footer_inner(
|
|
|
|
|
|
width: u16,
|
|
|
|
|
|
me_fp: &str,
|
|
|
|
|
|
me_onion: Option<&str>,
|
|
|
|
|
|
phase: Option<TorPhase>,
|
|
|
|
|
|
status_note: Option<&str>,
|
|
|
|
|
|
hints: &str,
|
tui: ASCII onion chrome, themed panes, and real keyboard navigation
- Hand-written wordmark banner (<=80 cols, auto-collapses to a compact
mark below banner width) plus onion glyph and themed screen headings
- Color-palette consts, stateful pane titles, highlighted selection row
(accent + bg), context-sensitive footer that always keeps '? help'
- Pane focus model (roster/chat/composer) with Tab/Shift-Tab, 1/2/3,
j/k + arrows, g/G, and a '?' help overlay; Esc closes any overlay
- New tests/tui_chrome.rs: banner widths, help overlay bindings, real
footer helper at 80 and 120 cols, 80x24 draw smoke test
- README keybinding table updated to match
Locked helper strings (fingerprint_mismatch_banner, rotate_screen_text,
wipe_screen_text, parse_slash) unchanged; UI-only (src/tui.rs).
2026-09-10 13:01:40 -04:00
|
|
|
|
) -> String {
|
|
|
|
|
|
let w = width as usize;
|
2026-09-12 00:15:19 -04:00
|
|
|
|
let gap = if w >= 120 { " " } else { " " };
|
|
|
|
|
|
let help = "? help";
|
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]>
2026-09-18 23:13:12 -04:00
|
|
|
|
let me = format!("{} me:{}", tor_token(phase), truncate_fp(me_fp));
|
2026-09-12 00:15:19 -04:00
|
|
|
|
let mut note = status_note.unwrap_or("").trim().to_string();
|
|
|
|
|
|
if !note.is_empty()
|
|
|
|
|
|
&& color_mode() == ColorMode::None
|
2026-09-12 14:22:38 -04:00
|
|
|
|
&& (note.contains("send failed") || note == "fingerprint mismatch")
|
2026-09-12 00:15:19 -04:00
|
|
|
|
&& !note.starts_with("! ")
|
|
|
|
|
|
{
|
|
|
|
|
|
note = format!("! {note}");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if !note.is_empty() {
|
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]>
2026-09-18 23:13:12 -04:00
|
|
|
|
let fixed = cell_width(&me) + cell_width(help) + 2 * cell_width(gap);
|
2026-09-12 00:15:19 -04:00
|
|
|
|
let budget = w.saturating_sub(fixed);
|
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]>
2026-09-18 23:13:12 -04:00
|
|
|
|
if cell_width(¬e) > budget {
|
|
|
|
|
|
note = fit_cells(¬e, budget.max(12));
|
2026-09-12 00:15:19 -04:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
let mut parts: Vec<String> = Vec::new();
|
|
|
|
|
|
if !note.is_empty() {
|
|
|
|
|
|
parts.push(note);
|
|
|
|
|
|
}
|
|
|
|
|
|
parts.push(me);
|
|
|
|
|
|
|
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]>
2026-09-18 23:13:12 -04:00
|
|
|
|
if let Some(onion) = me_onion {
|
|
|
|
|
|
let onion_full = if onion.is_empty() {
|
|
|
|
|
|
"unset".to_string()
|
|
|
|
|
|
} else {
|
|
|
|
|
|
onion.to_string()
|
|
|
|
|
|
};
|
|
|
|
|
|
let onion_short = if onion.is_empty() {
|
|
|
|
|
|
"unset".to_string()
|
|
|
|
|
|
} else {
|
|
|
|
|
|
truncate_fp(onion)
|
|
|
|
|
|
};
|
|
|
|
|
|
let onion_full_part = format!("onion:{onion_full}");
|
|
|
|
|
|
let onion_short_part = format!("onion:{onion_short}");
|
|
|
|
|
|
let try_full = width >= 110;
|
|
|
|
|
|
if try_full && footer_fits(&parts, &[&onion_full_part], help, gap, w) {
|
|
|
|
|
|
parts.push(onion_full_part);
|
|
|
|
|
|
} else if footer_fits(&parts, &[&onion_short_part], help, gap, w) {
|
|
|
|
|
|
parts.push(onion_short_part);
|
|
|
|
|
|
}
|
2026-09-12 00:15:19 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
tui: ASCII onion chrome, themed panes, and real keyboard navigation
- Hand-written wordmark banner (<=80 cols, auto-collapses to a compact
mark below banner width) plus onion glyph and themed screen headings
- Color-palette consts, stateful pane titles, highlighted selection row
(accent + bg), context-sensitive footer that always keeps '? help'
- Pane focus model (roster/chat/composer) with Tab/Shift-Tab, 1/2/3,
j/k + arrows, g/G, and a '?' help overlay; Esc closes any overlay
- New tests/tui_chrome.rs: banner widths, help overlay bindings, real
footer helper at 80 and 120 cols, 80x24 draw smoke test
- README keybinding table updated to match
Locked helper strings (fingerprint_mismatch_banner, rotate_screen_text,
wipe_screen_text, parse_slash) unchanged; UI-only (src/tui.rs).
2026-09-10 13:01:40 -04:00
|
|
|
|
let extra = hints.replace("? help", "");
|
2026-09-12 00:15:19 -04:00
|
|
|
|
let mut hint_tokens: Vec<&str> = extra.split_whitespace().collect();
|
|
|
|
|
|
while !hint_tokens.is_empty() {
|
|
|
|
|
|
let hint_str = hint_tokens.join(" ");
|
|
|
|
|
|
if footer_fits(&parts, &[&hint_str], help, gap, w) {
|
|
|
|
|
|
parts.push(hint_str);
|
|
|
|
|
|
break;
|
tui: ASCII onion chrome, themed panes, and real keyboard navigation
- Hand-written wordmark banner (<=80 cols, auto-collapses to a compact
mark below banner width) plus onion glyph and themed screen headings
- Color-palette consts, stateful pane titles, highlighted selection row
(accent + bg), context-sensitive footer that always keeps '? help'
- Pane focus model (roster/chat/composer) with Tab/Shift-Tab, 1/2/3,
j/k + arrows, g/G, and a '?' help overlay; Esc closes any overlay
- New tests/tui_chrome.rs: banner widths, help overlay bindings, real
footer helper at 80 and 120 cols, 80x24 draw smoke test
- README keybinding table updated to match
Locked helper strings (fingerprint_mismatch_banner, rotate_screen_text,
wipe_screen_text, parse_slash) unchanged; UI-only (src/tui.rs).
2026-09-10 13:01:40 -04:00
|
|
|
|
}
|
2026-09-12 00:15:19 -04:00
|
|
|
|
hint_tokens.remove(0);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
parts.push(help.to_string());
|
|
|
|
|
|
let line = parts.join(gap);
|
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]>
2026-09-18 23:13:12 -04:00
|
|
|
|
if cell_width(&line) <= w {
|
2026-09-12 00:15:19 -04:00
|
|
|
|
line
|
|
|
|
|
|
} else {
|
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]>
2026-09-18 23:13:12 -04:00
|
|
|
|
fit_cells(&line, w)
|
tui: ASCII onion chrome, themed panes, and real keyboard navigation
- Hand-written wordmark banner (<=80 cols, auto-collapses to a compact
mark below banner width) plus onion glyph and themed screen headings
- Color-palette consts, stateful pane titles, highlighted selection row
(accent + bg), context-sensitive footer that always keeps '? help'
- Pane focus model (roster/chat/composer) with Tab/Shift-Tab, 1/2/3,
j/k + arrows, g/G, and a '?' help overlay; Esc closes any overlay
- New tests/tui_chrome.rs: banner widths, help overlay bindings, real
footer helper at 80 and 120 cols, 80x24 draw smoke test
- README keybinding table updated to match
Locked helper strings (fingerprint_mismatch_banner, rotate_screen_text,
wipe_screen_text, parse_slash) unchanged; UI-only (src/tui.rs).
2026-09-10 13:01:40 -04:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-09-12 00:15:19 -04:00
|
|
|
|
fn footer_fits(parts: &[String], extra: &[&str], help: &str, gap: &str, w: usize) -> bool {
|
|
|
|
|
|
let mut all: Vec<&str> = parts.iter().map(String::as_str).collect();
|
|
|
|
|
|
all.extend(extra.iter().copied());
|
|
|
|
|
|
all.push(help);
|
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]>
2026-09-18 23:13:12 -04:00
|
|
|
|
cell_width(&all.join(gap)) <= w
|
tui: ASCII onion chrome, themed panes, and real keyboard navigation
- Hand-written wordmark banner (<=80 cols, auto-collapses to a compact
mark below banner width) plus onion glyph and themed screen headings
- Color-palette consts, stateful pane titles, highlighted selection row
(accent + bg), context-sensitive footer that always keeps '? help'
- Pane focus model (roster/chat/composer) with Tab/Shift-Tab, 1/2/3,
j/k + arrows, g/G, and a '?' help overlay; Esc closes any overlay
- New tests/tui_chrome.rs: banner widths, help overlay bindings, real
footer helper at 80 and 120 cols, 80x24 draw smoke test
- README keybinding table updated to match
Locked helper strings (fingerprint_mismatch_banner, rotate_screen_text,
wipe_screen_text, parse_slash) unchanged; UI-only (src/tui.rs).
2026-09-10 13:01:40 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
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
|
|
|
|
/// Main-screen key hints. `F6` (wallet) and `F9` (wallets & settings) are named
|
|
|
|
|
|
/// here on purpose: the menu is the discoverable surface, and the footer is how
|
|
|
|
|
|
/// a user finds the menu in the first place. Kept short so width 80 still shows
|
|
|
|
|
|
/// TOR + identity + `? help`.
|
tui: ASCII onion chrome, themed panes, and real keyboard navigation
- Hand-written wordmark banner (<=80 cols, auto-collapses to a compact
mark below banner width) plus onion glyph and themed screen headings
- Color-palette consts, stateful pane titles, highlighted selection row
(accent + bg), context-sensitive footer that always keeps '? help'
- Pane focus model (roster/chat/composer) with Tab/Shift-Tab, 1/2/3,
j/k + arrows, g/G, and a '?' help overlay; Esc closes any overlay
- New tests/tui_chrome.rs: banner widths, help overlay bindings, real
footer helper at 80 and 120 cols, 80x24 draw smoke test
- README keybinding table updated to match
Locked helper strings (fingerprint_mismatch_banner, rotate_screen_text,
wipe_screen_text, parse_slash) unchanged; UI-only (src/tui.rs).
2026-09-10 13:01:40 -04:00
|
|
|
|
pub fn main_footer_hints() -> &'static str {
|
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
|
|
|
|
"Tab F2 F3 F4 F5 F6 F9 ? help Ctrl-Q"
|
tui: ASCII onion chrome, themed panes, and real keyboard navigation
- Hand-written wordmark banner (<=80 cols, auto-collapses to a compact
mark below banner width) plus onion glyph and themed screen headings
- Color-palette consts, stateful pane titles, highlighted selection row
(accent + bg), context-sensitive footer that always keeps '? help'
- Pane focus model (roster/chat/composer) with Tab/Shift-Tab, 1/2/3,
j/k + arrows, g/G, and a '?' help overlay; Esc closes any overlay
- New tests/tui_chrome.rs: banner widths, help overlay bindings, real
footer helper at 80 and 120 cols, 80x24 draw smoke test
- README keybinding table updated to match
Locked helper strings (fingerprint_mismatch_banner, rotate_screen_text,
wipe_screen_text, parse_slash) unchanged; UI-only (src/tui.rs).
2026-09-10 13:01:40 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
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]>
2026-09-18 23:13:12 -04:00
|
|
|
|
/// Footer hints for one focused main pane.
|
|
|
|
|
|
///
|
|
|
|
|
|
/// The footer is the only place the keys are visible without opening `?`, so it
|
|
|
|
|
|
/// changes with the pane you are actually in — and every variant keeps `F9`
|
|
|
|
|
|
/// (the discoverable menu) and `? help`, which `tests/tui_chrome.rs` asserts are
|
|
|
|
|
|
/// reachable from the footer at 80, 120 and 200.
|
|
|
|
|
|
pub fn pane_footer_hints(pane: Pane) -> &'static str {
|
|
|
|
|
|
match pane {
|
|
|
|
|
|
Pane::Roster => "j k select F3 add F6 wallet F9 settings ? help",
|
|
|
|
|
|
Pane::Chat => "j k scroll g G ends F4 rotate F9 settings ? help",
|
|
|
|
|
|
Pane::Composer => "Enter send / commands F9 settings ? help",
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
tui: ASCII onion chrome, themed panes, and real keyboard navigation
- Hand-written wordmark banner (<=80 cols, auto-collapses to a compact
mark below banner width) plus onion glyph and themed screen headings
- Color-palette consts, stateful pane titles, highlighted selection row
(accent + bg), context-sensitive footer that always keeps '? help'
- Pane focus model (roster/chat/composer) with Tab/Shift-Tab, 1/2/3,
j/k + arrows, g/G, and a '?' help overlay; Esc closes any overlay
- New tests/tui_chrome.rs: banner widths, help overlay bindings, real
footer helper at 80 and 120 cols, 80x24 draw smoke test
- README keybinding table updated to match
Locked helper strings (fingerprint_mismatch_banner, rotate_screen_text,
wipe_screen_text, parse_slash) unchanged; UI-only (src/tui.rs).
2026-09-10 13:01:40 -04:00
|
|
|
|
fn footer_hints(screen: &Screen) -> &'static str {
|
2026-09-12 22:53:58 -04:00
|
|
|
|
match screen {
|
|
|
|
|
|
Screen::Main => main_footer_hints(),
|
|
|
|
|
|
Screen::Share { .. } => "Esc back ? help",
|
|
|
|
|
|
Screen::Paste { .. } => "Enter submit Esc back ? help",
|
|
|
|
|
|
Screen::Approve { .. } => "y accept n reject ? help",
|
|
|
|
|
|
Screen::Rotate { .. } => "type ROTATE Esc cancel ? help",
|
2026-09-17 20:48:10 -04:00
|
|
|
|
Screen::RotatePrekey { .. } => "type ROTATE Esc cancel ? help",
|
2026-09-12 22:53:58 -04:00
|
|
|
|
Screen::Wipe { kind, .. } => match kind {
|
|
|
|
|
|
WipeKind::Messages => "type WIPE Esc cancel ? help",
|
|
|
|
|
|
WipeKind::All => "type WIPEALL Esc cancel ? help",
|
|
|
|
|
|
},
|
|
|
|
|
|
Screen::Profile { .. } => "Enter save Tab field Esc cancel ? help",
|
|
|
|
|
|
Screen::ConfirmKeys { kind, .. } => match kind {
|
|
|
|
|
|
BackupKind::Backup => "type BACKUP Esc cancel ? help",
|
|
|
|
|
|
BackupKind::Restore => "type RESTORE Esc cancel ? help",
|
|
|
|
|
|
},
|
|
|
|
|
|
Screen::Passphrase { .. } => "Enter submit Esc cancel ? help",
|
2026-09-18 09:28:11 -04:00
|
|
|
|
Screen::Wallet { .. } => "c create i import r qr s/x child Esc back ? help",
|
2026-09-13 23:25:25 -04:00
|
|
|
|
Screen::WalletSetup(WalletSetup::CreateWarn { .. }) => "type SPEND Esc cancel ? help",
|
|
|
|
|
|
Screen::WalletSetup(WalletSetup::CreatePass { .. } | WalletSetup::ImportPass { .. }) => {
|
|
|
|
|
|
"Enter submit Esc cancel ? help"
|
|
|
|
|
|
}
|
|
|
|
|
|
Screen::WalletSetup(WalletSetup::CreateSeed { .. }) => "type SEEN Esc cancel ? help",
|
|
|
|
|
|
Screen::WalletSetup(WalletSetup::ImportSeed { .. }) => "paste seed Enter Esc ? help",
|
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
|
|
|
|
Screen::WalletsSettings { .. } => "Esc back c copy ? help",
|
tui: F9 works on the peer-payments screen, and frames dump the real footer
Review round 1 on the F9 `payments` row found two false affordances.
1. `footer_hints(Screen::PeerPayments)` prints `F9 menu`, and docs/TUI.md says
F9 reopens the menu, but the `KeyCode::F(9)` arm opened it only from
`Screen::Main`, so pressing F9 on the peer history did nothing.
The function keys are now routed through one table, `function_key_for(screen,
code)`, and the F9 arm no longer has the Main-only guard: it opens (or
reopens) the menu from `Main`, `WalletsSettings` and `PeerPayments`. A screen
that names a key has to answer it while it is open — that is what the table
encodes, and `mod function_key_tests` locks it, including a test that reads
the screen's own hint and asserts every `F<n>` it names is answered there.
2. The PR's frame dumps passed `"Esc back up/down select ? help"` to
`status_footer` by hand, so every dumped frame showed a footer the app never
renders. `peer_payments_footer_hint()` is now the single source both
`footer_hints` and the fixture read, and
`peer_payments_frame_shows_the_shipped_footer` pins the dumped frame's last
line to the shipped one.
Also restores the rustfmt-only reflow of unrelated tests in `tests/tui_spec.rs`
(`queued_row`, a `failed_row` call, `rgb_tokens_…`, `alert_line_…`), keeping this
card's real edits there.
Presentation only: no wire, store, session, send-path or `Node` change.
2026-09-19 00:31:42 -04:00
|
|
|
|
Screen::PeerPayments { .. } => peer_payments_footer_hint(),
|
2026-09-12 22:53:58 -04:00
|
|
|
|
Screen::Quit { .. } => "CLEAR or QUIT then Enter Esc cancel ? help",
|
|
|
|
|
|
}
|
2026-09-10 01:54:19 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
tui: F9 works on the peer-payments screen, and frames dump the real footer
Review round 1 on the F9 `payments` row found two false affordances.
1. `footer_hints(Screen::PeerPayments)` prints `F9 menu`, and docs/TUI.md says
F9 reopens the menu, but the `KeyCode::F(9)` arm opened it only from
`Screen::Main`, so pressing F9 on the peer history did nothing.
The function keys are now routed through one table, `function_key_for(screen,
code)`, and the F9 arm no longer has the Main-only guard: it opens (or
reopens) the menu from `Main`, `WalletsSettings` and `PeerPayments`. A screen
that names a key has to answer it while it is open — that is what the table
encodes, and `mod function_key_tests` locks it, including a test that reads
the screen's own hint and asserts every `F<n>` it names is answered there.
2. The PR's frame dumps passed `"Esc back up/down select ? help"` to
`status_footer` by hand, so every dumped frame showed a footer the app never
renders. `peer_payments_footer_hint()` is now the single source both
`footer_hints` and the fixture read, and
`peer_payments_frame_shows_the_shipped_footer` pins the dumped frame's last
line to the shipped one.
Also restores the rustfmt-only reflow of unrelated tests in `tests/tui_spec.rs`
(`queued_row`, a `failed_row` call, `rgb_tokens_…`, `alert_line_…`), keeping this
card's real edits there.
Presentation only: no wire, store, session, send-path or `Node` change.
2026-09-19 00:31:42 -04:00
|
|
|
|
/// The hint line the peer-payment-history screen prints. One source only: the
|
|
|
|
|
|
/// screen's frame tests build their fixture from this, so a dumped frame can
|
|
|
|
|
|
/// never show a footer the app does not render.
|
|
|
|
|
|
pub fn peer_payments_footer_hint() -> &'static str {
|
|
|
|
|
|
PEER_PAYMENTS_FOOTER_HINT
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const PEER_PAYMENTS_FOOTER_HINT: &str = "Esc back up/down select F9 menu ? help";
|
|
|
|
|
|
|
2026-09-12 00:54:16 -04:00
|
|
|
|
fn apply_chrome_borders(block: Block<'_>) -> Block<'_> {
|
|
|
|
|
|
let block = block.borders(Borders::ALL);
|
|
|
|
|
|
if ascii_chrome() {
|
|
|
|
|
|
block.border_set(ASCII_BORDERS)
|
|
|
|
|
|
} else {
|
|
|
|
|
|
block
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
tui: ASCII onion chrome, themed panes, and real keyboard navigation
- Hand-written wordmark banner (<=80 cols, auto-collapses to a compact
mark below banner width) plus onion glyph and themed screen headings
- Color-palette consts, stateful pane titles, highlighted selection row
(accent + bg), context-sensitive footer that always keeps '? help'
- Pane focus model (roster/chat/composer) with Tab/Shift-Tab, 1/2/3,
j/k + arrows, g/G, and a '?' help overlay; Esc closes any overlay
- New tests/tui_chrome.rs: banner widths, help overlay bindings, real
footer helper at 80 and 120 cols, 80x24 draw smoke test
- README keybinding table updated to match
Locked helper strings (fingerprint_mismatch_banner, rotate_screen_text,
wipe_screen_text, parse_slash) unchanged; UI-only (src/tui.rs).
2026-09-10 13:01:40 -04:00
|
|
|
|
fn themed_block(title: &str) -> Block<'_> {
|
2026-09-12 00:54:16 -04:00
|
|
|
|
apply_chrome_borders(Block::default())
|
2026-09-12 00:15:19 -04:00
|
|
|
|
.border_style(style_accent())
|
tui: ASCII onion chrome, themed panes, and real keyboard navigation
- Hand-written wordmark banner (<=80 cols, auto-collapses to a compact
mark below banner width) plus onion glyph and themed screen headings
- Color-palette consts, stateful pane titles, highlighted selection row
(accent + bg), context-sensitive footer that always keeps '? help'
- Pane focus model (roster/chat/composer) with Tab/Shift-Tab, 1/2/3,
j/k + arrows, g/G, and a '?' help overlay; Esc closes any overlay
- New tests/tui_chrome.rs: banner widths, help overlay bindings, real
footer helper at 80 and 120 cols, 80x24 draw smoke test
- README keybinding table updated to match
Locked helper strings (fingerprint_mismatch_banner, rotate_screen_text,
wipe_screen_text, parse_slash) unchanged; UI-only (src/tui.rs).
2026-09-10 13:01:40 -04:00
|
|
|
|
.title(title)
|
2026-09-12 00:15:19 -04:00
|
|
|
|
.title_style(style_accent().add_modifier(Modifier::BOLD))
|
tui: ASCII onion chrome, themed panes, and real keyboard navigation
- Hand-written wordmark banner (<=80 cols, auto-collapses to a compact
mark below banner width) plus onion glyph and themed screen headings
- Color-palette consts, stateful pane titles, highlighted selection row
(accent + bg), context-sensitive footer that always keeps '? help'
- Pane focus model (roster/chat/composer) with Tab/Shift-Tab, 1/2/3,
j/k + arrows, g/G, and a '?' help overlay; Esc closes any overlay
- New tests/tui_chrome.rs: banner widths, help overlay bindings, real
footer helper at 80 and 120 cols, 80x24 draw smoke test
- README keybinding table updated to match
Locked helper strings (fingerprint_mismatch_banner, rotate_screen_text,
wipe_screen_text, parse_slash) unchanged; UI-only (src/tui.rs).
2026-09-10 13:01:40 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
2026-09-10 16:53:03 -04:00
|
|
|
|
pub fn draw_share(f: &mut Frame, payload: &str) {
|
|
|
|
|
|
let (fp, onion) = match qr::decode(payload) {
|
|
|
|
|
|
Ok(p) => (truncate_fp(&to_hex(&p.pubkey)), p.onion),
|
|
|
|
|
|
Err(_) => ("?".into(), "?".into()),
|
|
|
|
|
|
};
|
2026-09-12 00:54:16 -04:00
|
|
|
|
let inner = f.area().width.saturating_sub(2) as usize;
|
|
|
|
|
|
let invite = wrap_invite(payload, inner.max(1));
|
2026-09-10 16:53:03 -04:00
|
|
|
|
let body = format!(
|
2026-09-12 00:54:16 -04:00
|
|
|
|
"give this string to a friend; they F3 paste it\n\nfp {fp}\nonion {onion}\n\n{invite}"
|
2026-09-10 16:53:03 -04:00
|
|
|
|
);
|
2026-09-10 01:54:19 -04:00
|
|
|
|
f.render_widget(
|
|
|
|
|
|
Paragraph::new(body)
|
2026-09-12 00:15:19 -04:00
|
|
|
|
.style(style_text())
|
2026-09-10 01:54:19 -04:00
|
|
|
|
.wrap(Wrap { trim: false })
|
2026-09-10 16:53:03 -04:00
|
|
|
|
.block(themed_block("(o) invite")),
|
2026-09-10 01:54:19 -04:00
|
|
|
|
f.area(),
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
fn draw_paste(f: &mut Frame, buf: &str, err: Option<&str>) {
|
2026-09-12 00:54:16 -04:00
|
|
|
|
let inner = f.area().width.saturating_sub(2) as usize;
|
|
|
|
|
|
let shown = wrap_invite(buf, inner.max(1));
|
|
|
|
|
|
let body = paste_screen_text(&shown, err);
|
tui: ASCII onion chrome, themed panes, and real keyboard navigation
- Hand-written wordmark banner (<=80 cols, auto-collapses to a compact
mark below banner width) plus onion glyph and themed screen headings
- Color-palette consts, stateful pane titles, highlighted selection row
(accent + bg), context-sensitive footer that always keeps '? help'
- Pane focus model (roster/chat/composer) with Tab/Shift-Tab, 1/2/3,
j/k + arrows, g/G, and a '?' help overlay; Esc closes any overlay
- New tests/tui_chrome.rs: banner widths, help overlay bindings, real
footer helper at 80 and 120 cols, 80x24 draw smoke test
- README keybinding table updated to match
Locked helper strings (fingerprint_mismatch_banner, rotate_screen_text,
wipe_screen_text, parse_slash) unchanged; UI-only (src/tui.rs).
2026-09-10 13:01:40 -04:00
|
|
|
|
let style = if err.is_some() {
|
2026-09-12 00:15:19 -04:00
|
|
|
|
style_alert()
|
tui: ASCII onion chrome, themed panes, and real keyboard navigation
- Hand-written wordmark banner (<=80 cols, auto-collapses to a compact
mark below banner width) plus onion glyph and themed screen headings
- Color-palette consts, stateful pane titles, highlighted selection row
(accent + bg), context-sensitive footer that always keeps '? help'
- Pane focus model (roster/chat/composer) with Tab/Shift-Tab, 1/2/3,
j/k + arrows, g/G, and a '?' help overlay; Esc closes any overlay
- New tests/tui_chrome.rs: banner widths, help overlay bindings, real
footer helper at 80 and 120 cols, 80x24 draw smoke test
- README keybinding table updated to match
Locked helper strings (fingerprint_mismatch_banner, rotate_screen_text,
wipe_screen_text, parse_slash) unchanged; UI-only (src/tui.rs).
2026-09-10 13:01:40 -04:00
|
|
|
|
} else {
|
2026-09-12 00:15:19 -04:00
|
|
|
|
style_text()
|
tui: ASCII onion chrome, themed panes, and real keyboard navigation
- Hand-written wordmark banner (<=80 cols, auto-collapses to a compact
mark below banner width) plus onion glyph and themed screen headings
- Color-palette consts, stateful pane titles, highlighted selection row
(accent + bg), context-sensitive footer that always keeps '? help'
- Pane focus model (roster/chat/composer) with Tab/Shift-Tab, 1/2/3,
j/k + arrows, g/G, and a '?' help overlay; Esc closes any overlay
- New tests/tui_chrome.rs: banner widths, help overlay bindings, real
footer helper at 80 and 120 cols, 80x24 draw smoke test
- README keybinding table updated to match
Locked helper strings (fingerprint_mismatch_banner, rotate_screen_text,
wipe_screen_text, parse_slash) unchanged; UI-only (src/tui.rs).
2026-09-10 13:01:40 -04:00
|
|
|
|
};
|
2026-09-10 01:54:19 -04:00
|
|
|
|
f.render_widget(
|
|
|
|
|
|
Paragraph::new(body)
|
tui: ASCII onion chrome, themed panes, and real keyboard navigation
- Hand-written wordmark banner (<=80 cols, auto-collapses to a compact
mark below banner width) plus onion glyph and themed screen headings
- Color-palette consts, stateful pane titles, highlighted selection row
(accent + bg), context-sensitive footer that always keeps '? help'
- Pane focus model (roster/chat/composer) with Tab/Shift-Tab, 1/2/3,
j/k + arrows, g/G, and a '?' help overlay; Esc closes any overlay
- New tests/tui_chrome.rs: banner widths, help overlay bindings, real
footer helper at 80 and 120 cols, 80x24 draw smoke test
- README keybinding table updated to match
Locked helper strings (fingerprint_mismatch_banner, rotate_screen_text,
wipe_screen_text, parse_slash) unchanged; UI-only (src/tui.rs).
2026-09-10 13:01:40 -04:00
|
|
|
|
.style(style)
|
2026-09-10 01:54:19 -04:00
|
|
|
|
.wrap(Wrap { trim: false })
|
2026-09-10 16:53:03 -04:00
|
|
|
|
.block(themed_block("(o) paste invite")),
|
2026-09-10 01:54:19 -04:00
|
|
|
|
f.area(),
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
fn draw_approve(f: &mut Frame, payload: &QrPayload) {
|
|
|
|
|
|
let fp = to_hex(&payload.pubkey);
|
|
|
|
|
|
let body = format!(
|
|
|
|
|
|
"Unknown key. Add this friend?\n\nfp {}\nonion {}\n\ny accept n / Esc reject",
|
|
|
|
|
|
truncate_fp(&fp),
|
|
|
|
|
|
payload.onion
|
|
|
|
|
|
);
|
|
|
|
|
|
f.render_widget(
|
tui: ASCII onion chrome, themed panes, and real keyboard navigation
- Hand-written wordmark banner (<=80 cols, auto-collapses to a compact
mark below banner width) plus onion glyph and themed screen headings
- Color-palette consts, stateful pane titles, highlighted selection row
(accent + bg), context-sensitive footer that always keeps '? help'
- Pane focus model (roster/chat/composer) with Tab/Shift-Tab, 1/2/3,
j/k + arrows, g/G, and a '?' help overlay; Esc closes any overlay
- New tests/tui_chrome.rs: banner widths, help overlay bindings, real
footer helper at 80 and 120 cols, 80x24 draw smoke test
- README keybinding table updated to match
Locked helper strings (fingerprint_mismatch_banner, rotate_screen_text,
wipe_screen_text, parse_slash) unchanged; UI-only (src/tui.rs).
2026-09-10 13:01:40 -04:00
|
|
|
|
Paragraph::new(body)
|
2026-09-12 00:15:19 -04:00
|
|
|
|
.style(style_text())
|
tui: ASCII onion chrome, themed panes, and real keyboard navigation
- Hand-written wordmark banner (<=80 cols, auto-collapses to a compact
mark below banner width) plus onion glyph and themed screen headings
- Color-palette consts, stateful pane titles, highlighted selection row
(accent + bg), context-sensitive footer that always keeps '? help'
- Pane focus model (roster/chat/composer) with Tab/Shift-Tab, 1/2/3,
j/k + arrows, g/G, and a '?' help overlay; Esc closes any overlay
- New tests/tui_chrome.rs: banner widths, help overlay bindings, real
footer helper at 80 and 120 cols, 80x24 draw smoke test
- README keybinding table updated to match
Locked helper strings (fingerprint_mismatch_banner, rotate_screen_text,
wipe_screen_text, parse_slash) unchanged; UI-only (src/tui.rs).
2026-09-10 13:01:40 -04:00
|
|
|
|
.block(themed_block("(o) approve")),
|
2026-09-10 01:54:19 -04:00
|
|
|
|
f.area(),
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-09-10 02:43:45 -04:00
|
|
|
|
fn draw_rotate(f: &mut Frame, typed: &str) {
|
|
|
|
|
|
let body = format!("{}\n\n{typed}", rotate_screen_text());
|
2026-09-10 01:54:19 -04:00
|
|
|
|
f.render_widget(
|
|
|
|
|
|
Paragraph::new(body)
|
2026-09-12 00:15:19 -04:00
|
|
|
|
.style(style_text())
|
2026-09-10 01:54:19 -04:00
|
|
|
|
.wrap(Wrap { trim: false })
|
tui: ASCII onion chrome, themed panes, and real keyboard navigation
- Hand-written wordmark banner (<=80 cols, auto-collapses to a compact
mark below banner width) plus onion glyph and themed screen headings
- Color-palette consts, stateful pane titles, highlighted selection row
(accent + bg), context-sensitive footer that always keeps '? help'
- Pane focus model (roster/chat/composer) with Tab/Shift-Tab, 1/2/3,
j/k + arrows, g/G, and a '?' help overlay; Esc closes any overlay
- New tests/tui_chrome.rs: banner widths, help overlay bindings, real
footer helper at 80 and 120 cols, 80x24 draw smoke test
- README keybinding table updated to match
Locked helper strings (fingerprint_mismatch_banner, rotate_screen_text,
wipe_screen_text, parse_slash) unchanged; UI-only (src/tui.rs).
2026-09-10 13:01:40 -04:00
|
|
|
|
.block(themed_block("(o) rotate locator")),
|
2026-09-10 01:54:19 -04:00
|
|
|
|
f.area(),
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-09-17 20:48:10 -04:00
|
|
|
|
fn draw_rotate_prekey(f: &mut Frame, typed: &str) {
|
|
|
|
|
|
let body = format!("{}\n\n{typed}", prekey_screen_text());
|
|
|
|
|
|
f.render_widget(
|
|
|
|
|
|
Paragraph::new(body)
|
|
|
|
|
|
.style(style_text())
|
|
|
|
|
|
.wrap(Wrap { trim: false })
|
|
|
|
|
|
.block(themed_block("(o) rotate prekey")),
|
|
|
|
|
|
f.area(),
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-09-10 02:49:42 -04:00
|
|
|
|
fn draw_wipe(f: &mut Frame, kind: WipeKind, typed: &str) {
|
|
|
|
|
|
let title = match kind {
|
tui: ASCII onion chrome, themed panes, and real keyboard navigation
- Hand-written wordmark banner (<=80 cols, auto-collapses to a compact
mark below banner width) plus onion glyph and themed screen headings
- Color-palette consts, stateful pane titles, highlighted selection row
(accent + bg), context-sensitive footer that always keeps '? help'
- Pane focus model (roster/chat/composer) with Tab/Shift-Tab, 1/2/3,
j/k + arrows, g/G, and a '?' help overlay; Esc closes any overlay
- New tests/tui_chrome.rs: banner widths, help overlay bindings, real
footer helper at 80 and 120 cols, 80x24 draw smoke test
- README keybinding table updated to match
Locked helper strings (fingerprint_mismatch_banner, rotate_screen_text,
wipe_screen_text, parse_slash) unchanged; UI-only (src/tui.rs).
2026-09-10 13:01:40 -04:00
|
|
|
|
WipeKind::Messages => "(o) wipe",
|
|
|
|
|
|
WipeKind::All => "(o) wipe all",
|
2026-09-10 02:49:42 -04:00
|
|
|
|
};
|
|
|
|
|
|
let body = format!("{}\n\n{typed}", wipe_screen_text(kind));
|
|
|
|
|
|
f.render_widget(
|
|
|
|
|
|
Paragraph::new(body)
|
2026-09-12 00:15:19 -04:00
|
|
|
|
.style(style_text())
|
2026-09-10 02:49:42 -04:00
|
|
|
|
.wrap(Wrap { trim: false })
|
tui: ASCII onion chrome, themed panes, and real keyboard navigation
- Hand-written wordmark banner (<=80 cols, auto-collapses to a compact
mark below banner width) plus onion glyph and themed screen headings
- Color-palette consts, stateful pane titles, highlighted selection row
(accent + bg), context-sensitive footer that always keeps '? help'
- Pane focus model (roster/chat/composer) with Tab/Shift-Tab, 1/2/3,
j/k + arrows, g/G, and a '?' help overlay; Esc closes any overlay
- New tests/tui_chrome.rs: banner widths, help overlay bindings, real
footer helper at 80 and 120 cols, 80x24 draw smoke test
- README keybinding table updated to match
Locked helper strings (fingerprint_mismatch_banner, rotate_screen_text,
wipe_screen_text, parse_slash) unchanged; UI-only (src/tui.rs).
2026-09-10 13:01:40 -04:00
|
|
|
|
.block(themed_block(title)),
|
2026-09-10 02:49:42 -04:00
|
|
|
|
f.area(),
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-09-10 17:19:50 -04:00
|
|
|
|
fn draw_quit(f: &mut Frame, typed: &str) {
|
|
|
|
|
|
let body = format!("{}\n\n{typed}", quit_screen_text());
|
|
|
|
|
|
f.render_widget(
|
|
|
|
|
|
Paragraph::new(body)
|
2026-09-12 00:15:19 -04:00
|
|
|
|
.style(style_text())
|
2026-09-10 17:19:50 -04:00
|
|
|
|
.wrap(Wrap { trim: false })
|
|
|
|
|
|
.block(themed_block("(o) quit")),
|
|
|
|
|
|
f.area(),
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-09-10 14:25:31 -04:00
|
|
|
|
fn draw_profile(f: &mut Frame, editor: &ProfileEditor) {
|
|
|
|
|
|
let labels = ["name", "bio", "xmr"];
|
|
|
|
|
|
let values = [editor.display_name(), editor.bio(), editor.xmr_addr()];
|
|
|
|
|
|
let mut body = String::from(
|
|
|
|
|
|
"Your profile (friend-visible)\nEnter saves Esc cancels Tab next field\n",
|
|
|
|
|
|
);
|
|
|
|
|
|
for (i, (label, value)) in labels.iter().zip(values).enumerate() {
|
|
|
|
|
|
let mark = if editor.field() == i { ">" } else { " " };
|
|
|
|
|
|
body.push_str(&format!("\n{mark} {label}: {value}"));
|
|
|
|
|
|
}
|
|
|
|
|
|
f.render_widget(
|
|
|
|
|
|
Paragraph::new(body)
|
2026-09-12 00:15:19 -04:00
|
|
|
|
.style(style_text())
|
2026-09-10 14:25:31 -04:00
|
|
|
|
.wrap(Wrap { trim: false })
|
|
|
|
|
|
.block(themed_block("(o) profile")),
|
|
|
|
|
|
f.area(),
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-09-10 14:50:01 -04:00
|
|
|
|
fn draw_confirm_keys(f: &mut Frame, kind: BackupKind, typed: &str) {
|
|
|
|
|
|
let (title, text) = match kind {
|
|
|
|
|
|
BackupKind::Backup => ("(o) backup", backup_screen_text()),
|
|
|
|
|
|
BackupKind::Restore => ("(o) restore", restore_screen_text()),
|
|
|
|
|
|
};
|
|
|
|
|
|
let body = format!("{text}\n\n{typed}");
|
|
|
|
|
|
f.render_widget(
|
|
|
|
|
|
Paragraph::new(body)
|
2026-09-12 00:15:19 -04:00
|
|
|
|
.style(style_text())
|
2026-09-10 14:50:01 -04:00
|
|
|
|
.wrap(Wrap { trim: false })
|
|
|
|
|
|
.block(themed_block(title)),
|
|
|
|
|
|
f.area(),
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
fn draw_passphrase(f: &mut Frame, kind: BackupKind, second: bool, buf: &str) {
|
|
|
|
|
|
let stars: String = buf.chars().map(|_| '*').collect();
|
|
|
|
|
|
let hint = match (kind, second) {
|
|
|
|
|
|
(BackupKind::Backup, false) => "Enter passphrase",
|
|
|
|
|
|
(BackupKind::Backup, true) => "Re-enter passphrase",
|
|
|
|
|
|
(BackupKind::Restore, _) => "Enter passphrase",
|
|
|
|
|
|
};
|
|
|
|
|
|
let body = format!("{hint}\n\n{stars}\n\nEnter submit Esc cancel");
|
|
|
|
|
|
f.render_widget(
|
|
|
|
|
|
Paragraph::new(body)
|
2026-09-12 00:15:19 -04:00
|
|
|
|
.style(style_text())
|
2026-09-10 14:50:01 -04:00
|
|
|
|
.wrap(Wrap { trim: false })
|
|
|
|
|
|
.block(themed_block("(o) passphrase")),
|
|
|
|
|
|
f.area(),
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
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]>
2026-09-18 23:13:12 -04:00
|
|
|
|
/// A centered popup over a cleared screen: title, body, wrap, scroll to the
|
|
|
|
|
|
/// tail. Every modal goes through this one, so a popup can never punch through
|
|
|
|
|
|
/// the chrome underneath it and can never be wider than the frame.
|
|
|
|
|
|
///
|
|
|
|
|
|
/// Width always keeps a one-cell margin on each side. Height keeps the margin
|
|
|
|
|
|
/// only when the frame can afford it: a 22-line body on a 24-row terminal needs
|
|
|
|
|
|
/// the rows more than it needs symmetry, and the scroll below still lands the
|
|
|
|
|
|
/// last line on screen.
|
2026-09-12 00:15:19 -04:00
|
|
|
|
pub fn draw_text_overlay(f: &mut Frame, title: &str, text: &str) {
|
tui: ASCII onion chrome, themed panes, and real keyboard navigation
- Hand-written wordmark banner (<=80 cols, auto-collapses to a compact
mark below banner width) plus onion glyph and themed screen headings
- Color-palette consts, stateful pane titles, highlighted selection row
(accent + bg), context-sensitive footer that always keeps '? help'
- Pane focus model (roster/chat/composer) with Tab/Shift-Tab, 1/2/3,
j/k + arrows, g/G, and a '?' help overlay; Esc closes any overlay
- New tests/tui_chrome.rs: banner widths, help overlay bindings, real
footer helper at 80 and 120 cols, 80x24 draw smoke test
- README keybinding table updated to match
Locked helper strings (fingerprint_mismatch_banner, rotate_screen_text,
wipe_screen_text, parse_slash) unchanged; UI-only (src/tui.rs).
2026-09-10 13:01:40 -04:00
|
|
|
|
let area = f.area();
|
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]>
2026-09-18 23:13:12 -04:00
|
|
|
|
let wanted_w = text
|
|
|
|
|
|
.lines()
|
|
|
|
|
|
.map(cell_width)
|
|
|
|
|
|
.max()
|
|
|
|
|
|
.unwrap_or(40)
|
|
|
|
|
|
.saturating_add(4);
|
|
|
|
|
|
let wanted_h = text.lines().count() as u16 + 2;
|
|
|
|
|
|
let max_w = area.width.saturating_sub(2).max(10);
|
|
|
|
|
|
let width = (wanted_w as u16).clamp(10, max_w.max(10)).min(area.width);
|
|
|
|
|
|
let height = if wanted_h >= area.height.saturating_sub(1) {
|
|
|
|
|
|
area.height
|
2026-09-12 00:15:19 -04:00
|
|
|
|
} else {
|
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]>
2026-09-18 23:13:12 -04:00
|
|
|
|
wanted_h.clamp(3, area.height)
|
|
|
|
|
|
};
|
|
|
|
|
|
let popup = Rect {
|
|
|
|
|
|
x: area.x + (area.width.saturating_sub(width)) / 2,
|
|
|
|
|
|
y: area.y + (area.height.saturating_sub(height)) / 2,
|
|
|
|
|
|
width,
|
|
|
|
|
|
height,
|
tui: ASCII onion chrome, themed panes, and real keyboard navigation
- Hand-written wordmark banner (<=80 cols, auto-collapses to a compact
mark below banner width) plus onion glyph and themed screen headings
- Color-palette consts, stateful pane titles, highlighted selection row
(accent + bg), context-sensitive footer that always keeps '? help'
- Pane focus model (roster/chat/composer) with Tab/Shift-Tab, 1/2/3,
j/k + arrows, g/G, and a '?' help overlay; Esc closes any overlay
- New tests/tui_chrome.rs: banner widths, help overlay bindings, real
footer helper at 80 and 120 cols, 80x24 draw smoke test
- README keybinding table updated to match
Locked helper strings (fingerprint_mismatch_banner, rotate_screen_text,
wipe_screen_text, parse_slash) unchanged; UI-only (src/tui.rs).
2026-09-10 13:01:40 -04:00
|
|
|
|
};
|
2026-09-12 00:15:19 -04:00
|
|
|
|
f.render_widget(Clear, area);
|
tui: ASCII onion chrome, themed panes, and real keyboard navigation
- Hand-written wordmark banner (<=80 cols, auto-collapses to a compact
mark below banner width) plus onion glyph and themed screen headings
- Color-palette consts, stateful pane titles, highlighted selection row
(accent + bg), context-sensitive footer that always keeps '? help'
- Pane focus model (roster/chat/composer) with Tab/Shift-Tab, 1/2/3,
j/k + arrows, g/G, and a '?' help overlay; Esc closes any overlay
- New tests/tui_chrome.rs: banner widths, help overlay bindings, real
footer helper at 80 and 120 cols, 80x24 draw smoke test
- README keybinding table updated to match
Locked helper strings (fingerprint_mismatch_banner, rotate_screen_text,
wipe_screen_text, parse_slash) unchanged; UI-only (src/tui.rs).
2026-09-10 13:01:40 -04:00
|
|
|
|
f.render_widget(Clear, popup);
|
2026-09-12 00:15:19 -04:00
|
|
|
|
let inner_w = popup.width.saturating_sub(2).max(1);
|
|
|
|
|
|
let inner_h = popup.height.saturating_sub(2);
|
|
|
|
|
|
let wrapped: u16 = text
|
|
|
|
|
|
.lines()
|
|
|
|
|
|
.map(|l| {
|
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]>
2026-09-18 23:13:12 -04:00
|
|
|
|
let n = cell_width(l) as u16;
|
|
|
|
|
|
if n == 0 {
|
|
|
|
|
|
1
|
|
|
|
|
|
} else {
|
|
|
|
|
|
n.div_ceil(inner_w)
|
|
|
|
|
|
}
|
2026-09-12 00:15:19 -04:00
|
|
|
|
})
|
|
|
|
|
|
.sum();
|
|
|
|
|
|
let scroll = wrapped.saturating_sub(inner_h);
|
tui: ASCII onion chrome, themed panes, and real keyboard navigation
- Hand-written wordmark banner (<=80 cols, auto-collapses to a compact
mark below banner width) plus onion glyph and themed screen headings
- Color-palette consts, stateful pane titles, highlighted selection row
(accent + bg), context-sensitive footer that always keeps '? help'
- Pane focus model (roster/chat/composer) with Tab/Shift-Tab, 1/2/3,
j/k + arrows, g/G, and a '?' help overlay; Esc closes any overlay
- New tests/tui_chrome.rs: banner widths, help overlay bindings, real
footer helper at 80 and 120 cols, 80x24 draw smoke test
- README keybinding table updated to match
Locked helper strings (fingerprint_mismatch_banner, rotate_screen_text,
wipe_screen_text, parse_slash) unchanged; UI-only (src/tui.rs).
2026-09-10 13:01:40 -04:00
|
|
|
|
f.render_widget(
|
|
|
|
|
|
Paragraph::new(text)
|
2026-09-12 00:15:19 -04:00
|
|
|
|
.style(style_text())
|
|
|
|
|
|
.wrap(Wrap { trim: false })
|
|
|
|
|
|
.scroll((scroll, 0))
|
2026-09-10 14:25:31 -04:00
|
|
|
|
.block(themed_block(title)),
|
tui: ASCII onion chrome, themed panes, and real keyboard navigation
- Hand-written wordmark banner (<=80 cols, auto-collapses to a compact
mark below banner width) plus onion glyph and themed screen headings
- Color-palette consts, stateful pane titles, highlighted selection row
(accent + bg), context-sensitive footer that always keeps '? help'
- Pane focus model (roster/chat/composer) with Tab/Shift-Tab, 1/2/3,
j/k + arrows, g/G, and a '?' help overlay; Esc closes any overlay
- New tests/tui_chrome.rs: banner widths, help overlay bindings, real
footer helper at 80 and 120 cols, 80x24 draw smoke test
- README keybinding table updated to match
Locked helper strings (fingerprint_mismatch_banner, rotate_screen_text,
wipe_screen_text, parse_slash) unchanged; UI-only (src/tui.rs).
2026-09-10 13:01:40 -04:00
|
|
|
|
popup,
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
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
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
|
|
// WALLETS & SETTINGS menu (F9 / `/settings`)
|
|
|
|
|
|
//
|
|
|
|
|
|
// One screen that names every wallet and settings capability the TUI can
|
|
|
|
|
|
// actually reach, together with the key or command that fires each one. It is a
|
|
|
|
|
|
// discoverability layer over the existing shortcuts, not a replacement: F2, F3,
|
|
|
|
|
|
// F4, F5, F6 and F8 keep working, and they stay live *on this screen* so no row
|
|
|
|
|
|
// can name a key that does nothing here.
|
|
|
|
|
|
//
|
|
|
|
|
|
// Copy, never credentials. `WalletMenuState` carries booleans, labels and
|
|
|
|
|
|
// display-ready error strings from `Node`'s getters; it has no field that can
|
|
|
|
|
|
// hold `WalletConfig::rpc_login`, `secret()`, a seed, or a passphrase.
|
|
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
/// Label column in cells. Every label is short ASCII, so this is also its
|
|
|
|
|
|
/// character count.
|
|
|
|
|
|
const MENU_LABEL_W: usize = 9;
|
|
|
|
|
|
/// Key column in cells: the widest key string the menu emits.
|
|
|
|
|
|
const MENU_KEYS_W: usize = 12;
|
|
|
|
|
|
|
|
|
|
|
|
/// State the WALLETS & SETTINGS menu draws. Built once by the caller from
|
|
|
|
|
|
/// `Node`'s getters and carried raw (un-sanitized) — the render path strips
|
|
|
|
|
|
/// control/bidi characters and truncates in cells.
|
|
|
|
|
|
#[derive(Clone, Debug, Default)]
|
|
|
|
|
|
pub struct WalletMenuState {
|
|
|
|
|
|
/// A wallet endpoint resolved to a usable wallet (stored or env config).
|
|
|
|
|
|
pub configured: bool,
|
|
|
|
|
|
/// The last probe answered. Never inferred from `configured`.
|
|
|
|
|
|
pub connected: bool,
|
|
|
|
|
|
/// `WalletStatus::last_error`, display-ready.
|
|
|
|
|
|
pub wallet_error: Option<String>,
|
|
|
|
|
|
/// Receive address; empty when the wallet is unreachable.
|
|
|
|
|
|
pub receive_addr: String,
|
|
|
|
|
|
/// Human-readable balance, or `off` / `err` from `Node::wallet_balance`.
|
|
|
|
|
|
pub balance: String,
|
|
|
|
|
|
/// How many recent transfers `Node::wallet_recent_transfers` returned.
|
|
|
|
|
|
pub transfers: usize,
|
|
|
|
|
|
/// `WalletChildState` display word: off / connecting / syncing / ready /
|
|
|
|
|
|
/// exited.
|
|
|
|
|
|
pub child_state: String,
|
|
|
|
|
|
/// Chain-source label: `receive-only` / `local node` / `remote daemon`.
|
|
|
|
|
|
pub child_source: String,
|
|
|
|
|
|
/// `WalletChildStatus::last_error`, display-ready.
|
|
|
|
|
|
pub child_error: Option<String>,
|
|
|
|
|
|
/// Self-profile display name, if one is set.
|
|
|
|
|
|
pub nickname: Option<String>,
|
|
|
|
|
|
pub bio_set: bool,
|
|
|
|
|
|
pub xmr_set: bool,
|
|
|
|
|
|
/// Our own fingerprint (identity = pubkey), full hex.
|
|
|
|
|
|
pub me_fp: String,
|
tui: peer payment history behind the F9 `payments` row (key p)
The F9 / `/settings` menu's only payment row showed the wallet's own transfer
list (`Node::wallet_recent_transfers`, F6). The signed `/pay` invoices and
`/tip` receipts a peer sent live in the `payments` table and had no path from
the TUI, so they were invisible. `Node::list_payments` (PR #119) closes that
gap; this wires it into a screen.
- `Screen::PeerPayments { state }` + `PeerPaymentsState` /
`PeerPaymentRow`, built by `PeerPaymentsState::from_payments` from
`Node::list_payments`' rows (newest first: the store returns `payments.id`
ascending, the screen windows the vector).
- Key handler: `p` on the F9 screen opens it (`open_peer_payments`); `up`/`down`
(or `k`/`j`) move the selection, `Esc` goes back, `F9` reopens the menu.
- Rows carry direction, kind, amount (`pay::atomic_to_xmr_str`, the same
piconero formatter the chat lines use), memo (sanitized at draw time) and the
receipt's `verified` / `unverified` word; the focused row is marked with `>`
and bold. The selected row's txid and address sit under the rows — the
address wrapped over two lines rather than clipped.
- States: populated, `no payments with {peer}`, `could not read payments`, and
a menu row that refuses when no friend is selected. An empty history is a
state, never an error.
- Menu: the wallet's own list is retitled `transfers` (F6, unchanged), and the
new `payments` row (key `p`) names the peer and the count. Two histories, two
rows, no ambiguity.
- Widths are measured in cells (`Span::width`); trailing columns are dropped
before they can wrap, so the body fits 80x24 (20 inner rows of 21) as well as
120x40 and 200x60.
Tests: new `tests/tui_payments.rs` (11 tests) dumps and asserts the screen at
80x24, 120x40 and 200x60 including the empty history, asserts a memo carrying
ESC/BEL/C1/bidi/newline bytes never reaches the frame buffer, and asserts the
window/column invariants for every width from 20 to 200.
Also relaxes one width assertion in `tests/tui_spec.rs`: `fit_cells` was
asserted to start with `"abcdef"`, which only holds when another test's
in-flight `ONIONWIRE_ASCII` mutation is not visible — the suite mutates env vars
without a global lock, so that test flaked (it also fails on an unmodified tree,
1 run in 2). It now accepts either chrome's cut point, which is what the comment
already claimed.
Docs: `docs/TUI.md` gains the screen's section, the retitled/replaced rows and
the updated row count; the "peer payment history" gap entry is closed.
2026-09-18 23:53:10 -04:00
|
|
|
|
/// Display name of the friend the F9 screen's friend-scoped rows act on (the
|
|
|
|
|
|
/// chat's selected friend), or empty when there is none.
|
|
|
|
|
|
pub peer: String,
|
|
|
|
|
|
/// `Some(rows)` when `Node::list_payments` answered for that friend;
|
|
|
|
|
|
/// `None` when the read itself failed (which is not "no history").
|
|
|
|
|
|
pub peer_payments: Option<usize>,
|
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
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// Width of `s` in terminal **cells**, measured by ratatui's own text type.
|
|
|
|
|
|
///
|
|
|
|
|
|
/// `unicode-width` is not a direct dependency of this crate, so this goes
|
|
|
|
|
|
/// through `Span::width` — the same measurement the renderer truncates with —
|
|
|
|
|
|
/// rather than `chars().count()`: CJK and emoji are double-width, combining
|
|
|
|
|
|
/// marks zero-width, and a char count gets both wrong.
|
|
|
|
|
|
pub fn cell_width(s: &str) -> usize {
|
|
|
|
|
|
ratatui::text::Span::raw(s).width()
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// Truncate `s` to at most `max` cells, closed with the chrome's ellipsis.
|
|
|
|
|
|
pub fn fit_cells(s: &str, max: usize) -> String {
|
|
|
|
|
|
if cell_width(s) <= max {
|
|
|
|
|
|
return s.to_string();
|
|
|
|
|
|
}
|
|
|
|
|
|
let e = ellipsis();
|
|
|
|
|
|
let el = cell_width(e);
|
|
|
|
|
|
if max <= el {
|
|
|
|
|
|
return e.chars().take(max).collect();
|
|
|
|
|
|
}
|
|
|
|
|
|
let budget = max - el;
|
|
|
|
|
|
let mut out = String::new();
|
|
|
|
|
|
let mut used = 0;
|
|
|
|
|
|
for ch in s.chars() {
|
|
|
|
|
|
let w = cell_width(&ch.to_string());
|
|
|
|
|
|
if used + w > budget {
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
used += w;
|
|
|
|
|
|
out.push(ch);
|
|
|
|
|
|
}
|
|
|
|
|
|
format!("{out}{e}")
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// One row of untrusted text, made safe to place in a single line: control and
|
|
|
|
|
|
/// bidi characters stripped (newlines and tabs included, or they would break
|
|
|
|
|
|
/// the row) and the rest left to `fit_cells`.
|
|
|
|
|
|
fn menu_cell_text(raw: &str) -> String {
|
|
|
|
|
|
sanitize::display_text(raw.as_bytes())
|
|
|
|
|
|
.chars()
|
|
|
|
|
|
.filter(|c| !matches!(c, '\n' | '\r' | '\t'))
|
|
|
|
|
|
.collect()
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
fn menu_yn(set: bool) -> &'static str {
|
|
|
|
|
|
if set { "set" } else { "unset" }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// Which `style_*` token a row's value carries. Colour is never the only
|
|
|
|
|
|
/// signal: every value also spells its state out in words.
|
|
|
|
|
|
#[derive(Clone, Copy, PartialEq, Eq)]
|
|
|
|
|
|
enum MenuTone {
|
|
|
|
|
|
Normal,
|
|
|
|
|
|
Dim,
|
|
|
|
|
|
Alert,
|
|
|
|
|
|
Stale,
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
struct MenuRow {
|
|
|
|
|
|
label: &'static str,
|
|
|
|
|
|
value: String,
|
|
|
|
|
|
keys: &'static str,
|
|
|
|
|
|
tone: MenuTone,
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
impl MenuRow {
|
|
|
|
|
|
fn new(label: &'static str, value: String, keys: &'static str, tone: MenuTone) -> Self {
|
|
|
|
|
|
Self {
|
|
|
|
|
|
label,
|
|
|
|
|
|
value,
|
|
|
|
|
|
keys,
|
|
|
|
|
|
tone,
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// The two groups, in the order the card fixes: WALLET, then SETTINGS.
|
|
|
|
|
|
///
|
tui: peer payment history behind the F9 `payments` row (key p)
The F9 / `/settings` menu's only payment row showed the wallet's own transfer
list (`Node::wallet_recent_transfers`, F6). The signed `/pay` invoices and
`/tip` receipts a peer sent live in the `payments` table and had no path from
the TUI, so they were invisible. `Node::list_payments` (PR #119) closes that
gap; this wires it into a screen.
- `Screen::PeerPayments { state }` + `PeerPaymentsState` /
`PeerPaymentRow`, built by `PeerPaymentsState::from_payments` from
`Node::list_payments`' rows (newest first: the store returns `payments.id`
ascending, the screen windows the vector).
- Key handler: `p` on the F9 screen opens it (`open_peer_payments`); `up`/`down`
(or `k`/`j`) move the selection, `Esc` goes back, `F9` reopens the menu.
- Rows carry direction, kind, amount (`pay::atomic_to_xmr_str`, the same
piconero formatter the chat lines use), memo (sanitized at draw time) and the
receipt's `verified` / `unverified` word; the focused row is marked with `>`
and bold. The selected row's txid and address sit under the rows — the
address wrapped over two lines rather than clipped.
- States: populated, `no payments with {peer}`, `could not read payments`, and
a menu row that refuses when no friend is selected. An empty history is a
state, never an error.
- Menu: the wallet's own list is retitled `transfers` (F6, unchanged), and the
new `payments` row (key `p`) names the peer and the count. Two histories, two
rows, no ambiguity.
- Widths are measured in cells (`Span::width`); trailing columns are dropped
before they can wrap, so the body fits 80x24 (20 inner rows of 21) as well as
120x40 and 200x60.
Tests: new `tests/tui_payments.rs` (11 tests) dumps and asserts the screen at
80x24, 120x40 and 200x60 including the empty history, asserts a memo carrying
ESC/BEL/C1/bidi/newline bytes never reaches the frame buffer, and asserts the
window/column invariants for every width from 20 to 200.
Also relaxes one width assertion in `tests/tui_spec.rs`: `fit_cells` was
asserted to start with `"abcdef"`, which only holds when another test's
in-flight `ONIONWIRE_ASCII` mutation is not visible — the suite mutates env vars
without a global lock, so that test flaked (it also fails on an unmodified tree,
1 run in 2). It now accepts either chrome's cut point, which is what the comment
already claimed.
Docs: `docs/TUI.md` gains the screen's section, the retitled/replaced rows and
the updated row count; the "peer payment history" gap entry is closed.
2026-09-18 23:53:10 -04:00
|
|
|
|
/// Two payment-ish rows, and they are not the same thing: `transfers` is the
|
|
|
|
|
|
/// wallet's own list (F6, `wallet_recent_transfers`), `payments` is the
|
|
|
|
|
|
/// peer-scoped history (`Node::list_payments`) opened by `p`.
|
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
|
|
|
|
fn menu_groups(s: &WalletMenuState) -> (Vec<MenuRow>, Vec<MenuRow>) {
|
|
|
|
|
|
let endpoint_word = if !s.configured {
|
|
|
|
|
|
"not configured · receive-only"
|
|
|
|
|
|
} else if s.connected {
|
|
|
|
|
|
"configured · connected"
|
|
|
|
|
|
} else {
|
|
|
|
|
|
"configured · not connected"
|
|
|
|
|
|
};
|
|
|
|
|
|
let endpoint_tone = if s.wallet_error.is_some() {
|
|
|
|
|
|
MenuTone::Alert
|
|
|
|
|
|
} else if !s.configured {
|
|
|
|
|
|
MenuTone::Dim
|
|
|
|
|
|
} else if s.connected {
|
|
|
|
|
|
MenuTone::Normal
|
|
|
|
|
|
} else {
|
|
|
|
|
|
MenuTone::Stale
|
|
|
|
|
|
};
|
|
|
|
|
|
let endpoint_value = match &s.wallet_error {
|
|
|
|
|
|
Some(e) => format!("{endpoint_word} · {}", menu_cell_text(e)),
|
|
|
|
|
|
None => endpoint_word.to_string(),
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
let running = matches!(s.child_state.as_str(), "connecting" | "syncing" | "ready");
|
|
|
|
|
|
let child_value = format!(
|
|
|
|
|
|
"{} · {}",
|
|
|
|
|
|
menu_cell_text(&s.child_source),
|
|
|
|
|
|
if running { "running" } else { "not started" }
|
|
|
|
|
|
);
|
|
|
|
|
|
let (sync_word, sync_tone) = match s.child_state.as_str() {
|
|
|
|
|
|
"ready" => ("chain at tip · wallet answering", MenuTone::Normal),
|
|
|
|
|
|
"syncing" => ("wallet answering · chain not at tip", MenuTone::Stale),
|
|
|
|
|
|
"connecting" => ("wallet RPC not answering yet", MenuTone::Stale),
|
|
|
|
|
|
"exited" => ("child exited", MenuTone::Alert),
|
|
|
|
|
|
_ => ("not probing · no chain source", MenuTone::Dim),
|
|
|
|
|
|
};
|
|
|
|
|
|
let sync_value = match &s.child_error {
|
|
|
|
|
|
Some(e) => format!("{sync_word} · {}", menu_cell_text(e)),
|
|
|
|
|
|
None => sync_word.to_string(),
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
let receive_empty = s.receive_addr.is_empty();
|
|
|
|
|
|
let wallet = vec![
|
|
|
|
|
|
MenuRow::new("endpoint", endpoint_value, "", endpoint_tone),
|
|
|
|
|
|
MenuRow::new("child", child_value, "F6 s/x", MenuTone::Normal),
|
|
|
|
|
|
MenuRow::new("sync", sync_value, "F6 p", sync_tone),
|
|
|
|
|
|
MenuRow::new(
|
|
|
|
|
|
"receive",
|
|
|
|
|
|
if receive_empty {
|
|
|
|
|
|
"no address yet · wallet unreachable".to_string()
|
|
|
|
|
|
} else {
|
|
|
|
|
|
menu_cell_text(&s.receive_addr)
|
|
|
|
|
|
},
|
|
|
|
|
|
if receive_empty { "" } else { "c copy F6 r" },
|
|
|
|
|
|
if receive_empty {
|
|
|
|
|
|
MenuTone::Dim
|
|
|
|
|
|
} else {
|
|
|
|
|
|
MenuTone::Normal
|
|
|
|
|
|
},
|
|
|
|
|
|
),
|
|
|
|
|
|
MenuRow::new(
|
|
|
|
|
|
"balance",
|
|
|
|
|
|
menu_cell_text(&s.balance),
|
|
|
|
|
|
"F6",
|
|
|
|
|
|
match s.balance.as_str() {
|
|
|
|
|
|
"err" => MenuTone::Alert,
|
|
|
|
|
|
"off" | "" => MenuTone::Dim,
|
|
|
|
|
|
_ => MenuTone::Normal,
|
|
|
|
|
|
},
|
|
|
|
|
|
),
|
|
|
|
|
|
MenuRow::new(
|
tui: peer payment history behind the F9 `payments` row (key p)
The F9 / `/settings` menu's only payment row showed the wallet's own transfer
list (`Node::wallet_recent_transfers`, F6). The signed `/pay` invoices and
`/tip` receipts a peer sent live in the `payments` table and had no path from
the TUI, so they were invisible. `Node::list_payments` (PR #119) closes that
gap; this wires it into a screen.
- `Screen::PeerPayments { state }` + `PeerPaymentsState` /
`PeerPaymentRow`, built by `PeerPaymentsState::from_payments` from
`Node::list_payments`' rows (newest first: the store returns `payments.id`
ascending, the screen windows the vector).
- Key handler: `p` on the F9 screen opens it (`open_peer_payments`); `up`/`down`
(or `k`/`j`) move the selection, `Esc` goes back, `F9` reopens the menu.
- Rows carry direction, kind, amount (`pay::atomic_to_xmr_str`, the same
piconero formatter the chat lines use), memo (sanitized at draw time) and the
receipt's `verified` / `unverified` word; the focused row is marked with `>`
and bold. The selected row's txid and address sit under the rows — the
address wrapped over two lines rather than clipped.
- States: populated, `no payments with {peer}`, `could not read payments`, and
a menu row that refuses when no friend is selected. An empty history is a
state, never an error.
- Menu: the wallet's own list is retitled `transfers` (F6, unchanged), and the
new `payments` row (key `p`) names the peer and the count. Two histories, two
rows, no ambiguity.
- Widths are measured in cells (`Span::width`); trailing columns are dropped
before they can wrap, so the body fits 80x24 (20 inner rows of 21) as well as
120x40 and 200x60.
Tests: new `tests/tui_payments.rs` (11 tests) dumps and asserts the screen at
80x24, 120x40 and 200x60 including the empty history, asserts a memo carrying
ESC/BEL/C1/bidi/newline bytes never reaches the frame buffer, and asserts the
window/column invariants for every width from 20 to 200.
Also relaxes one width assertion in `tests/tui_spec.rs`: `fit_cells` was
asserted to start with `"abcdef"`, which only holds when another test's
in-flight `ONIONWIRE_ASCII` mutation is not visible — the suite mutates env vars
without a global lock, so that test flaked (it also fails on an unmodified tree,
1 run in 2). It now accepts either chrome's cut point, which is what the comment
already claimed.
Docs: `docs/TUI.md` gains the screen's section, the retitled/replaced rows and
the updated row count; the "peer payment history" gap entry is closed.
2026-09-18 23:53:10 -04:00
|
|
|
|
"transfers",
|
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
|
|
|
|
if s.transfers == 0 {
|
|
|
|
|
|
"no transfers yet".to_string()
|
|
|
|
|
|
} else {
|
|
|
|
|
|
format!("{} recent", s.transfers)
|
|
|
|
|
|
},
|
|
|
|
|
|
"F6",
|
|
|
|
|
|
if s.transfers == 0 {
|
|
|
|
|
|
MenuTone::Dim
|
|
|
|
|
|
} else {
|
|
|
|
|
|
MenuTone::Normal
|
|
|
|
|
|
},
|
|
|
|
|
|
),
|
tui: peer payment history behind the F9 `payments` row (key p)
The F9 / `/settings` menu's only payment row showed the wallet's own transfer
list (`Node::wallet_recent_transfers`, F6). The signed `/pay` invoices and
`/tip` receipts a peer sent live in the `payments` table and had no path from
the TUI, so they were invisible. `Node::list_payments` (PR #119) closes that
gap; this wires it into a screen.
- `Screen::PeerPayments { state }` + `PeerPaymentsState` /
`PeerPaymentRow`, built by `PeerPaymentsState::from_payments` from
`Node::list_payments`' rows (newest first: the store returns `payments.id`
ascending, the screen windows the vector).
- Key handler: `p` on the F9 screen opens it (`open_peer_payments`); `up`/`down`
(or `k`/`j`) move the selection, `Esc` goes back, `F9` reopens the menu.
- Rows carry direction, kind, amount (`pay::atomic_to_xmr_str`, the same
piconero formatter the chat lines use), memo (sanitized at draw time) and the
receipt's `verified` / `unverified` word; the focused row is marked with `>`
and bold. The selected row's txid and address sit under the rows — the
address wrapped over two lines rather than clipped.
- States: populated, `no payments with {peer}`, `could not read payments`, and
a menu row that refuses when no friend is selected. An empty history is a
state, never an error.
- Menu: the wallet's own list is retitled `transfers` (F6, unchanged), and the
new `payments` row (key `p`) names the peer and the count. Two histories, two
rows, no ambiguity.
- Widths are measured in cells (`Span::width`); trailing columns are dropped
before they can wrap, so the body fits 80x24 (20 inner rows of 21) as well as
120x40 and 200x60.
Tests: new `tests/tui_payments.rs` (11 tests) dumps and asserts the screen at
80x24, 120x40 and 200x60 including the empty history, asserts a memo carrying
ESC/BEL/C1/bidi/newline bytes never reaches the frame buffer, and asserts the
window/column invariants for every width from 20 to 200.
Also relaxes one width assertion in `tests/tui_spec.rs`: `fit_cells` was
asserted to start with `"abcdef"`, which only holds when another test's
in-flight `ONIONWIRE_ASCII` mutation is not visible — the suite mutates env vars
without a global lock, so that test flaked (it also fails on an unmodified tree,
1 run in 2). It now accepts either chrome's cut point, which is what the comment
already claimed.
Docs: `docs/TUI.md` gains the screen's section, the retitled/replaced rows and
the updated row count; the "peer payment history" gap entry is closed.
2026-09-18 23:53:10 -04:00
|
|
|
|
// The peer-scoped history: signed `/pay` invoices and `/tip` receipts
|
|
|
|
|
|
// that peer sent. Distinct from the wallet's own transfer list above,
|
|
|
|
|
|
// and labelled so — `Payments` here means `payments` rows, not the
|
|
|
|
|
|
// wallet's `transfers`.
|
|
|
|
|
|
MenuRow::new(
|
|
|
|
|
|
"payments",
|
|
|
|
|
|
if s.peer.is_empty() {
|
|
|
|
|
|
"no friend selected".to_string()
|
|
|
|
|
|
} else {
|
|
|
|
|
|
let peer = menu_cell_text(&s.peer);
|
|
|
|
|
|
match s.peer_payments {
|
|
|
|
|
|
None => format!("history unreadable {}{peer}", "\u{b7} "),
|
|
|
|
|
|
Some(0) => format!("no history with {peer}"),
|
|
|
|
|
|
Some(n) => format!("{n} with {peer}"),
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
if s.peer.is_empty() { "" } else { "p" },
|
|
|
|
|
|
if s.peer.is_empty() || s.peer_payments == Some(0) {
|
|
|
|
|
|
MenuTone::Dim
|
|
|
|
|
|
} else {
|
|
|
|
|
|
MenuTone::Normal
|
|
|
|
|
|
},
|
|
|
|
|
|
),
|
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
|
|
|
|
MenuRow::new(
|
|
|
|
|
|
"create",
|
|
|
|
|
|
"/wallet create · seed shown once".to_string(),
|
|
|
|
|
|
"F6 c",
|
|
|
|
|
|
MenuTone::Normal,
|
|
|
|
|
|
),
|
|
|
|
|
|
MenuRow::new(
|
|
|
|
|
|
"import",
|
|
|
|
|
|
"/wallet import · 25-word seed".to_string(),
|
|
|
|
|
|
"F6 i",
|
|
|
|
|
|
MenuTone::Normal,
|
|
|
|
|
|
),
|
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
|
|
let settings = vec![
|
|
|
|
|
|
MenuRow::new(
|
|
|
|
|
|
"nickname",
|
|
|
|
|
|
match &s.nickname {
|
|
|
|
|
|
Some(n) => menu_cell_text(n),
|
|
|
|
|
|
None => "(none)".to_string(),
|
|
|
|
|
|
},
|
|
|
|
|
|
"/profile",
|
|
|
|
|
|
if s.nickname.is_some() {
|
|
|
|
|
|
MenuTone::Normal
|
|
|
|
|
|
} else {
|
|
|
|
|
|
MenuTone::Dim
|
|
|
|
|
|
},
|
|
|
|
|
|
),
|
|
|
|
|
|
MenuRow::new(
|
|
|
|
|
|
"profile",
|
|
|
|
|
|
format!("bio {} · xmr {}", menu_yn(s.bio_set), menu_yn(s.xmr_set)),
|
|
|
|
|
|
"/profile",
|
|
|
|
|
|
if s.bio_set || s.xmr_set {
|
|
|
|
|
|
MenuTone::Normal
|
|
|
|
|
|
} else {
|
|
|
|
|
|
MenuTone::Dim
|
|
|
|
|
|
},
|
|
|
|
|
|
),
|
|
|
|
|
|
MenuRow::new(
|
|
|
|
|
|
"identity",
|
|
|
|
|
|
format!("{} · identity = pubkey", truncate_fp(&s.me_fp)),
|
|
|
|
|
|
"F2",
|
|
|
|
|
|
MenuTone::Normal,
|
|
|
|
|
|
),
|
|
|
|
|
|
MenuRow::new(
|
|
|
|
|
|
"colour",
|
|
|
|
|
|
"auto · follows NO_COLOR / TERM".to_string(),
|
|
|
|
|
|
"",
|
|
|
|
|
|
MenuTone::Dim,
|
|
|
|
|
|
),
|
|
|
|
|
|
MenuRow::new(
|
|
|
|
|
|
"backup",
|
|
|
|
|
|
"encrypted identity export".to_string(),
|
|
|
|
|
|
"/backup",
|
|
|
|
|
|
MenuTone::Normal,
|
|
|
|
|
|
),
|
|
|
|
|
|
MenuRow::new(
|
|
|
|
|
|
"restore",
|
|
|
|
|
|
"overwrite self keys from a backup".to_string(),
|
|
|
|
|
|
"/restore",
|
|
|
|
|
|
MenuTone::Normal,
|
|
|
|
|
|
),
|
|
|
|
|
|
MenuRow::new(
|
|
|
|
|
|
"wipe",
|
|
|
|
|
|
"messages · identity and friends stay".to_string(),
|
|
|
|
|
|
"/wipe",
|
|
|
|
|
|
MenuTone::Normal,
|
|
|
|
|
|
),
|
|
|
|
|
|
MenuRow::new(
|
|
|
|
|
|
"wipe-all",
|
|
|
|
|
|
"deletes your identity key · new person".to_string(),
|
|
|
|
|
|
"/wipe-all",
|
|
|
|
|
|
MenuTone::Normal,
|
|
|
|
|
|
),
|
|
|
|
|
|
];
|
|
|
|
|
|
(wallet, settings)
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
fn menu_tone_style(tone: MenuTone) -> Style {
|
|
|
|
|
|
match tone {
|
|
|
|
|
|
MenuTone::Normal => style_text(),
|
|
|
|
|
|
MenuTone::Dim => style_dim(),
|
|
|
|
|
|
MenuTone::Alert => style_alert(),
|
|
|
|
|
|
MenuTone::Stale => style_stale(),
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// Section header: the title in the accent, ruled off in the dim tone. The rule
|
|
|
|
|
|
/// glyph degrades to `-` under `ONIONWIRE_ASCII` / `NO_COLOR`.
|
|
|
|
|
|
fn menu_section_line(width: usize, title: &str) -> Line<'static> {
|
|
|
|
|
|
let used = cell_width(title) + 1;
|
|
|
|
|
|
let rule = if ascii_chrome() { "-" } else { "─" };
|
|
|
|
|
|
Line::from(vec![
|
|
|
|
|
|
Span::styled(
|
|
|
|
|
|
format!("{title} "),
|
|
|
|
|
|
style_accent().add_modifier(Modifier::BOLD),
|
|
|
|
|
|
),
|
|
|
|
|
|
Span::styled(rule.repeat(width.saturating_sub(used)), style_dim()),
|
|
|
|
|
|
])
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// One row, padded out to exactly `width` cells: ` label value … keys`.
|
|
|
|
|
|
///
|
|
|
|
|
|
/// The key column is right-aligned so the eye can run down it, and the value is
|
|
|
|
|
|
/// truncated (never allowed to push the key off the row) so no row can wrap,
|
|
|
|
|
|
/// clip or scroll at 80 columns.
|
|
|
|
|
|
fn menu_row_line(width: usize, row: &MenuRow) -> Line<'static> {
|
|
|
|
|
|
let head = format!(" {:<w$} ", row.label, w = MENU_LABEL_W);
|
|
|
|
|
|
let head_w = cell_width(&head);
|
|
|
|
|
|
let keys = fit_cells(row.keys, MENU_KEYS_W);
|
|
|
|
|
|
// A terminal narrower than the fixed columns drops the key column instead of
|
|
|
|
|
|
// wrapping the row; 80 columns is the floor anyway, and 200x60 must not
|
|
|
|
|
|
// break above it.
|
|
|
|
|
|
let keys_w = cell_width(&keys);
|
|
|
|
|
|
let keys = if width < head_w + keys_w + 2 {
|
|
|
|
|
|
String::new()
|
|
|
|
|
|
} else {
|
|
|
|
|
|
keys
|
|
|
|
|
|
};
|
|
|
|
|
|
let keys_w = cell_width(&keys);
|
|
|
|
|
|
let tail = if keys_w == 0 { 0 } else { keys_w + 1 };
|
|
|
|
|
|
let value = fit_cells(
|
|
|
|
|
|
&menu_cell_text(&row.value),
|
|
|
|
|
|
width.saturating_sub(head_w + tail).max(1),
|
|
|
|
|
|
);
|
|
|
|
|
|
let used = head_w + cell_width(&value) + tail;
|
|
|
|
|
|
let pad = " ".repeat(width.saturating_sub(used));
|
|
|
|
|
|
let mut spans = vec![
|
|
|
|
|
|
Span::styled(head, style_dim()),
|
|
|
|
|
|
Span::styled(value, menu_tone_style(row.tone)),
|
|
|
|
|
|
];
|
|
|
|
|
|
if keys_w == 0 {
|
|
|
|
|
|
spans.push(Span::raw(pad));
|
|
|
|
|
|
} else {
|
|
|
|
|
|
spans.push(Span::raw(format!("{pad} ")));
|
|
|
|
|
|
spans.push(Span::styled(keys, style_accent()));
|
|
|
|
|
|
}
|
|
|
|
|
|
Line::from(spans)
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// The menu body as styled lines sized for `width` **inner** cells (the width
|
|
|
|
|
|
/// inside the block's borders).
|
|
|
|
|
|
pub fn wallets_settings_menu_lines(width: u16, s: &WalletMenuState) -> Vec<Line<'static>> {
|
|
|
|
|
|
let w = width as usize;
|
|
|
|
|
|
let (wallet, settings) = menu_groups(s);
|
|
|
|
|
|
let mut out = vec![menu_section_line(w, "WALLET")];
|
|
|
|
|
|
out.extend(wallet.iter().map(|row| menu_row_line(w, row)));
|
|
|
|
|
|
out.push(Line::default());
|
|
|
|
|
|
out.push(menu_section_line(w, "SETTINGS"));
|
|
|
|
|
|
out.extend(settings.iter().map(|row| menu_row_line(w, row)));
|
|
|
|
|
|
out
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// The menu body as plain text, for width/needle assertions.
|
|
|
|
|
|
pub fn wallets_settings_menu_text(width: u16, s: &WalletMenuState) -> String {
|
|
|
|
|
|
wallets_settings_menu_lines(width, s)
|
|
|
|
|
|
.iter()
|
|
|
|
|
|
.map(|line| {
|
|
|
|
|
|
line.spans
|
|
|
|
|
|
.iter()
|
|
|
|
|
|
.map(|span| span.content.as_ref())
|
|
|
|
|
|
.collect::<String>()
|
|
|
|
|
|
})
|
|
|
|
|
|
.collect::<Vec<_>>()
|
|
|
|
|
|
.join("\n")
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// WALLETS & SETTINGS: a full screen, never a popup — body plus the one status
|
|
|
|
|
|
/// line every other screen shares. `footer` is an already-built `status_footer`
|
|
|
|
|
|
/// line, so the caller owns TOR / identity / the transient note.
|
|
|
|
|
|
pub fn draw_wallets_settings(f: &mut Frame, state: &WalletMenuState, footer: &str) {
|
|
|
|
|
|
let area = f.area();
|
|
|
|
|
|
let rows = Layout::vertical([Constraint::Min(3), Constraint::Length(1)]).split(area);
|
|
|
|
|
|
let inner = rows[0].width.saturating_sub(2);
|
|
|
|
|
|
f.render_widget(
|
|
|
|
|
|
Paragraph::new(wallets_settings_menu_lines(inner, state))
|
|
|
|
|
|
.block(themed_block("(o) wallets & settings")),
|
|
|
|
|
|
rows[0],
|
|
|
|
|
|
);
|
|
|
|
|
|
f.render_widget(
|
|
|
|
|
|
Paragraph::new(fit_cells(footer, area.width as usize)).style(style_dim()),
|
|
|
|
|
|
rows[1],
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
tui: peer payment history behind the F9 `payments` row (key p)
The F9 / `/settings` menu's only payment row showed the wallet's own transfer
list (`Node::wallet_recent_transfers`, F6). The signed `/pay` invoices and
`/tip` receipts a peer sent live in the `payments` table and had no path from
the TUI, so they were invisible. `Node::list_payments` (PR #119) closes that
gap; this wires it into a screen.
- `Screen::PeerPayments { state }` + `PeerPaymentsState` /
`PeerPaymentRow`, built by `PeerPaymentsState::from_payments` from
`Node::list_payments`' rows (newest first: the store returns `payments.id`
ascending, the screen windows the vector).
- Key handler: `p` on the F9 screen opens it (`open_peer_payments`); `up`/`down`
(or `k`/`j`) move the selection, `Esc` goes back, `F9` reopens the menu.
- Rows carry direction, kind, amount (`pay::atomic_to_xmr_str`, the same
piconero formatter the chat lines use), memo (sanitized at draw time) and the
receipt's `verified` / `unverified` word; the focused row is marked with `>`
and bold. The selected row's txid and address sit under the rows — the
address wrapped over two lines rather than clipped.
- States: populated, `no payments with {peer}`, `could not read payments`, and
a menu row that refuses when no friend is selected. An empty history is a
state, never an error.
- Menu: the wallet's own list is retitled `transfers` (F6, unchanged), and the
new `payments` row (key `p`) names the peer and the count. Two histories, two
rows, no ambiguity.
- Widths are measured in cells (`Span::width`); trailing columns are dropped
before they can wrap, so the body fits 80x24 (20 inner rows of 21) as well as
120x40 and 200x60.
Tests: new `tests/tui_payments.rs` (11 tests) dumps and asserts the screen at
80x24, 120x40 and 200x60 including the empty history, asserts a memo carrying
ESC/BEL/C1/bidi/newline bytes never reaches the frame buffer, and asserts the
window/column invariants for every width from 20 to 200.
Also relaxes one width assertion in `tests/tui_spec.rs`: `fit_cells` was
asserted to start with `"abcdef"`, which only holds when another test's
in-flight `ONIONWIRE_ASCII` mutation is not visible — the suite mutates env vars
without a global lock, so that test flaked (it also fails on an unmodified tree,
1 run in 2). It now accepts either chrome's cut point, which is what the comment
already claimed.
Docs: `docs/TUI.md` gains the screen's section, the retitled/replaced rows and
the updated row count; the "peer payment history" gap entry is closed.
2026-09-18 23:53:10 -04:00
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
|
|
// Peer payment history: the F9 menu's `payments` row.
|
|
|
|
|
|
//
|
|
|
|
|
|
// This is the *other* history. The F6 screen shows the wallet's own transfer
|
|
|
|
|
|
// list (`Node::wallet_recent_transfers`); this one shows the peer-scoped rows
|
|
|
|
|
|
// `Node::list_payments` returns — the signed `/pay` invoices and `/tip`
|
|
|
|
|
|
// receipts that peer sent, which never appear in the wallet's own transfers.
|
|
|
|
|
|
//
|
|
|
|
|
|
// Everything here is display data: `memo` is peer-signed text returned as
|
|
|
|
|
|
// stored, so it goes through `menu_cell_text` (control + bidi stripped, no
|
|
|
|
|
|
// newlines) and `fit_cells` (truncated in cells) before it can reach a frame.
|
|
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
/// Direction column in cells: `in` / `out`.
|
|
|
|
|
|
const PAY_DIR_W: usize = 3;
|
|
|
|
|
|
/// Kind column in cells: `invoice` / `receipt` / `tip`.
|
|
|
|
|
|
const PAY_KIND_W: usize = 7;
|
|
|
|
|
|
/// Amount column in cells, right-aligned: `0.025000000000` is 14, so 15 holds
|
|
|
|
|
|
/// every XMR string `pay::atomic_to_xmr_str` can produce from a u128 piconero.
|
|
|
|
|
|
const PAY_AMOUNT_W: usize = 15;
|
|
|
|
|
|
/// Receipt flag column in cells: `unverified` is the widest word.
|
|
|
|
|
|
const PAY_FLAG_W: usize = 10;
|
|
|
|
|
|
|
|
|
|
|
|
/// One payment row, display-ready except for `memo`/`txid`/`address`, which the
|
|
|
|
|
|
/// render path sanitizes.
|
|
|
|
|
|
#[derive(Clone, Debug, Default)]
|
|
|
|
|
|
pub struct PeerPaymentRow {
|
|
|
|
|
|
/// `"in"` or `"out"` — the peer's direction, not ours.
|
|
|
|
|
|
pub dir: String,
|
|
|
|
|
|
/// `"invoice"`, `"receipt"` or `"tip"`.
|
|
|
|
|
|
pub kind: String,
|
|
|
|
|
|
/// `pay::atomic_to_xmr_str(amount_atomic)` — the same formatter the chat
|
|
|
|
|
|
/// lines use, not a second piconero formatter.
|
|
|
|
|
|
pub amount_xmr: String,
|
|
|
|
|
|
/// Peer-signed memo, as stored. Sanitized at draw time.
|
|
|
|
|
|
pub memo: String,
|
|
|
|
|
|
/// Chain txid, when the payment has one.
|
|
|
|
|
|
pub txid: Option<String>,
|
|
|
|
|
|
/// Destination address.
|
|
|
|
|
|
pub address: String,
|
|
|
|
|
|
/// Receipt signature check. Only receipts carry a meaningful flag.
|
|
|
|
|
|
pub verified: bool,
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// What the peer payment screen draws. Rows are **newest first** — the store
|
|
|
|
|
|
/// returns `payments.id` ascending, so `from_payments` reverses them here and
|
|
|
|
|
|
/// the render path windows the result. `error` is display-ready and only set
|
|
|
|
|
|
/// when the store read itself failed; an empty history is not an error.
|
|
|
|
|
|
#[derive(Clone, Debug, Default)]
|
|
|
|
|
|
pub struct PeerPaymentsState {
|
|
|
|
|
|
/// Display name of the peer this history belongs to.
|
|
|
|
|
|
pub peer: String,
|
|
|
|
|
|
pub rows: Vec<PeerPaymentRow>,
|
|
|
|
|
|
pub error: Option<String>,
|
|
|
|
|
|
/// Index into `rows` (display order, 0 = newest).
|
|
|
|
|
|
pub selected: usize,
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
impl PeerPaymentsState {
|
|
|
|
|
|
/// Build the screen state from `Node::list_payments`' rows.
|
|
|
|
|
|
pub fn from_payments(peer: String, rows: &[Payment]) -> Self {
|
|
|
|
|
|
let mut out: Vec<PeerPaymentRow> = rows
|
|
|
|
|
|
.iter()
|
|
|
|
|
|
.map(|p| PeerPaymentRow {
|
|
|
|
|
|
dir: p.dir.clone(),
|
|
|
|
|
|
kind: p.kind.clone(),
|
|
|
|
|
|
amount_xmr: crate::pay::atomic_to_xmr_str(&p.amount_atomic),
|
|
|
|
|
|
memo: p.memo.clone(),
|
|
|
|
|
|
txid: p.txid.clone(),
|
|
|
|
|
|
address: p.address.clone(),
|
|
|
|
|
|
verified: p.verified,
|
|
|
|
|
|
})
|
|
|
|
|
|
.collect();
|
|
|
|
|
|
// `payments.id` ascending is oldest first; a history reads newest first.
|
|
|
|
|
|
out.reverse();
|
|
|
|
|
|
Self {
|
|
|
|
|
|
peer,
|
|
|
|
|
|
rows: out,
|
|
|
|
|
|
error: None,
|
|
|
|
|
|
selected: 0,
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// The read failed. The screen says so instead of pretending "no history".
|
|
|
|
|
|
pub fn error(peer: String, why: String) -> Self {
|
|
|
|
|
|
Self {
|
|
|
|
|
|
peer,
|
|
|
|
|
|
rows: Vec::new(),
|
|
|
|
|
|
error: Some(why),
|
|
|
|
|
|
selected: 0,
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
pub fn select_next(&mut self) {
|
|
|
|
|
|
if !self.rows.is_empty() {
|
|
|
|
|
|
self.selected = (self.selected + 1).min(self.rows.len() - 1);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
pub fn select_prev(&mut self) {
|
|
|
|
|
|
self.selected = self.selected.saturating_sub(1);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// Pad `s` out to `cells` terminal cells on the right.
|
|
|
|
|
|
fn pad_right(s: &str, cells: usize) -> String {
|
|
|
|
|
|
let mut out = s.to_string();
|
|
|
|
|
|
let w = cell_width(&out);
|
|
|
|
|
|
if w < cells {
|
|
|
|
|
|
out.push_str(&" ".repeat(cells - w));
|
|
|
|
|
|
}
|
|
|
|
|
|
out
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// Pad `s` out to `cells` terminal cells on the left (numbers line up).
|
|
|
|
|
|
fn pad_left(s: &str, cells: usize) -> String {
|
|
|
|
|
|
let w = cell_width(s);
|
|
|
|
|
|
if w >= cells {
|
|
|
|
|
|
return s.to_string();
|
|
|
|
|
|
}
|
|
|
|
|
|
let mut out = " ".repeat(cells - w);
|
|
|
|
|
|
out.push_str(s);
|
|
|
|
|
|
out
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// Split `s` into a prefix of at most `max` cells and the (possibly empty)
|
|
|
|
|
|
/// remainder, so a long display value can be wrapped instead of clipped.
|
|
|
|
|
|
fn split_cells(s: &str, max: usize) -> (String, String) {
|
|
|
|
|
|
let mut head = String::new();
|
|
|
|
|
|
let mut used = 0;
|
|
|
|
|
|
for (i, ch) in s.char_indices() {
|
|
|
|
|
|
let w = cell_width(&ch.to_string());
|
|
|
|
|
|
if used + w > max {
|
|
|
|
|
|
return (head, s[i..].to_string());
|
|
|
|
|
|
}
|
|
|
|
|
|
used += w;
|
|
|
|
|
|
head.push(ch);
|
|
|
|
|
|
}
|
|
|
|
|
|
(head, String::new())
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// Which style a laid-out span carries.
|
|
|
|
|
|
#[derive(Clone, Copy, PartialEq, Eq)]
|
|
|
|
|
|
enum PaySlot {
|
|
|
|
|
|
Head,
|
|
|
|
|
|
Amount,
|
|
|
|
|
|
Flag,
|
|
|
|
|
|
Memo,
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// Lay out one payment line for `w` cells: `head`, then the amount, the receipt
|
|
|
|
|
|
/// flag and a flexible memo. Trailing columns are **dropped** when the pane is
|
|
|
|
|
|
/// too narrow, so no row can ever wrap or overrun — the 80-column floor holds
|
|
|
|
|
|
/// even if a terminal is smaller than the floor.
|
|
|
|
|
|
fn pay_columns(
|
|
|
|
|
|
w: usize,
|
|
|
|
|
|
head: &str,
|
|
|
|
|
|
amount: &str,
|
|
|
|
|
|
flag: &str,
|
|
|
|
|
|
memo: &str,
|
|
|
|
|
|
) -> Vec<(PaySlot, String)> {
|
|
|
|
|
|
let mut out: Vec<(PaySlot, String)> = Vec::new();
|
|
|
|
|
|
let head = if cell_width(head) > w {
|
|
|
|
|
|
fit_cells(head, w)
|
|
|
|
|
|
} else {
|
|
|
|
|
|
head.to_string()
|
|
|
|
|
|
};
|
|
|
|
|
|
let mut used = cell_width(&head);
|
|
|
|
|
|
out.push((PaySlot::Head, head));
|
|
|
|
|
|
|
|
|
|
|
|
if !amount.is_empty() && w >= used + 2 + PAY_AMOUNT_W {
|
|
|
|
|
|
let amount = fit_cells(amount, PAY_AMOUNT_W);
|
|
|
|
|
|
out.push((PaySlot::Head, " ".to_string()));
|
|
|
|
|
|
out.push((PaySlot::Amount, pad_left(&amount, PAY_AMOUNT_W)));
|
|
|
|
|
|
used += 2 + PAY_AMOUNT_W;
|
|
|
|
|
|
}
|
|
|
|
|
|
if !flag.is_empty() && w >= used + 2 + PAY_FLAG_W {
|
|
|
|
|
|
let flag = fit_cells(flag, PAY_FLAG_W);
|
|
|
|
|
|
out.push((PaySlot::Head, " ".to_string()));
|
|
|
|
|
|
out.push((PaySlot::Flag, pad_right(&flag, PAY_FLAG_W)));
|
|
|
|
|
|
used += 2 + PAY_FLAG_W;
|
|
|
|
|
|
}
|
|
|
|
|
|
if w > used + 2 {
|
|
|
|
|
|
let memo = fit_cells(memo, w - used - 2);
|
|
|
|
|
|
if !memo.is_empty() {
|
|
|
|
|
|
out.push((PaySlot::Head, " ".to_string()));
|
|
|
|
|
|
out.push((PaySlot::Memo, memo));
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
out
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// The column header, so an `in`/`out` and a `receipt`/`invoice` need no legend
|
|
|
|
|
|
/// and the XMR unit is stated once instead of on every row.
|
|
|
|
|
|
fn payment_header_line(w: usize) -> Line<'static> {
|
|
|
|
|
|
let head = format!(
|
|
|
|
|
|
"{} {}",
|
|
|
|
|
|
pad_right("dir", PAY_DIR_W),
|
|
|
|
|
|
pad_right("kind", PAY_KIND_W)
|
|
|
|
|
|
);
|
|
|
|
|
|
let mut spans = vec![Span::raw(" ".to_string())];
|
|
|
|
|
|
spans.extend(
|
|
|
|
|
|
pay_columns(w.saturating_sub(2), &head, "amount XMR", "receipt", "memo")
|
|
|
|
|
|
.into_iter()
|
|
|
|
|
|
.map(|(_, text)| Span::styled(text, style_dim())),
|
|
|
|
|
|
);
|
|
|
|
|
|
Line::from(spans)
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// One payment row. The focused row is marked with `>` **and** bold, so focus
|
|
|
|
|
|
/// survives a monochrome terminal; an unverified receipt says `unverified` as
|
|
|
|
|
|
/// well as taking the warn tone, so the state is never colour-only.
|
|
|
|
|
|
fn payment_row_line(w: usize, row: &PeerPaymentRow, selected: bool) -> Line<'static> {
|
|
|
|
|
|
let dir = fit_cells(&menu_cell_text(&row.dir), PAY_DIR_W);
|
|
|
|
|
|
let kind = fit_cells(&menu_cell_text(&row.kind), PAY_KIND_W);
|
|
|
|
|
|
let head = format!(
|
|
|
|
|
|
"{} {}",
|
|
|
|
|
|
pad_right(&dir, PAY_DIR_W),
|
|
|
|
|
|
pad_right(&kind, PAY_KIND_W)
|
|
|
|
|
|
);
|
|
|
|
|
|
let amount = menu_cell_text(&row.amount_xmr);
|
|
|
|
|
|
let (flag, flag_tone) = if row.kind == "receipt" {
|
|
|
|
|
|
if row.verified {
|
|
|
|
|
|
("verified".to_string(), style_text())
|
|
|
|
|
|
} else {
|
|
|
|
|
|
("unverified".to_string(), style_stale())
|
|
|
|
|
|
}
|
|
|
|
|
|
} else {
|
|
|
|
|
|
// A blank flag column, not an absent one: the memo column has to line
|
|
|
|
|
|
// up down the pane or the rows read as ragged.
|
|
|
|
|
|
(" ".repeat(PAY_FLAG_W), style_text())
|
|
|
|
|
|
};
|
|
|
|
|
|
let memo = menu_cell_text(&row.memo);
|
|
|
|
|
|
|
|
|
|
|
|
let mark_style = if selected {
|
|
|
|
|
|
style_accent().add_modifier(Modifier::BOLD)
|
|
|
|
|
|
} else {
|
|
|
|
|
|
style_dim()
|
|
|
|
|
|
};
|
|
|
|
|
|
let mut spans = vec![Span::styled(
|
|
|
|
|
|
if selected { "> " } else { " " }.to_string(),
|
|
|
|
|
|
mark_style,
|
|
|
|
|
|
)];
|
|
|
|
|
|
for (slot, text) in pay_columns(w.saturating_sub(2), &head, &amount, &flag, &memo) {
|
|
|
|
|
|
let style = match slot {
|
|
|
|
|
|
PaySlot::Head => style_dim(),
|
|
|
|
|
|
PaySlot::Amount => style_text(),
|
|
|
|
|
|
PaySlot::Flag => flag_tone,
|
|
|
|
|
|
PaySlot::Memo => {
|
|
|
|
|
|
if selected {
|
|
|
|
|
|
style_text()
|
|
|
|
|
|
} else {
|
|
|
|
|
|
style_dim()
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
};
|
|
|
|
|
|
let style = if selected {
|
|
|
|
|
|
style.add_modifier(Modifier::BOLD)
|
|
|
|
|
|
} else {
|
|
|
|
|
|
style
|
|
|
|
|
|
};
|
|
|
|
|
|
spans.push(Span::styled(text, style));
|
|
|
|
|
|
}
|
|
|
|
|
|
Line::from(spans)
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// The peer payment body as styled lines for a `width` × `height` **inner**
|
|
|
|
|
|
/// pane. `height` matters: the window is sized so the selected row and the tx /
|
|
|
|
|
|
/// address strip always fit, and the rows that fall outside it are counted in
|
|
|
|
|
|
/// an explicit `… N older` / `… N newer` line rather than silently dropped.
|
|
|
|
|
|
pub fn peer_payments_lines(width: u16, height: u16, s: &PeerPaymentsState) -> Vec<Line<'static>> {
|
|
|
|
|
|
let w = width as usize;
|
|
|
|
|
|
let h = height as usize;
|
|
|
|
|
|
if let Some(err) = &s.error {
|
|
|
|
|
|
return vec![
|
|
|
|
|
|
Line::from(vec![Span::styled(
|
|
|
|
|
|
" could not read payments",
|
|
|
|
|
|
style_alert(),
|
|
|
|
|
|
)]),
|
|
|
|
|
|
Line::from(vec![Span::styled(
|
|
|
|
|
|
fit_cells(&format!(" {}", menu_cell_text(err)), w.max(1)),
|
|
|
|
|
|
style_dim(),
|
|
|
|
|
|
)]),
|
|
|
|
|
|
];
|
|
|
|
|
|
}
|
|
|
|
|
|
let peer = menu_cell_text(&s.peer);
|
|
|
|
|
|
if s.rows.is_empty() {
|
|
|
|
|
|
return vec![
|
|
|
|
|
|
Line::from(vec![Span::styled(
|
|
|
|
|
|
fit_cells(&format!(" no payments with {peer}"), w.max(1)),
|
|
|
|
|
|
style_dim(),
|
|
|
|
|
|
)]),
|
|
|
|
|
|
Line::from(vec![Span::styled(
|
|
|
|
|
|
fit_cells(
|
|
|
|
|
|
" invoices, receipts and tips from this peer land here",
|
|
|
|
|
|
w.max(1),
|
|
|
|
|
|
),
|
|
|
|
|
|
style_dim(),
|
|
|
|
|
|
)]),
|
|
|
|
|
|
];
|
|
|
|
|
|
}
|
|
|
|
|
|
if h < 3 {
|
|
|
|
|
|
// Degenerate pane: the header alone is still an honest frame.
|
|
|
|
|
|
return vec![payment_header_line(w)];
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
let total = s.rows.len();
|
|
|
|
|
|
let selected = s.selected.min(total - 1);
|
|
|
|
|
|
// The selected row's detail: the txid, and the address wrapped over at most
|
|
|
|
|
|
// two lines so a 95-character base58 address is readable at 80 columns
|
|
|
|
|
|
// instead of clipped to a prefix.
|
|
|
|
|
|
let txid = s.rows[selected]
|
|
|
|
|
|
.txid
|
|
|
|
|
|
.as_deref()
|
|
|
|
|
|
.map(menu_cell_text)
|
|
|
|
|
|
.unwrap_or_else(|| "(no txid yet)".to_string());
|
|
|
|
|
|
let addr = menu_cell_text(&s.rows[selected].address);
|
|
|
|
|
|
let (addr_head, addr_rest) = {
|
|
|
|
|
|
let budget = w.saturating_sub(8).max(1);
|
|
|
|
|
|
if cell_width(&addr) > budget {
|
|
|
|
|
|
let (head, rest) = split_cells(&addr, budget);
|
|
|
|
|
|
(head, fit_cells(&rest, budget))
|
|
|
|
|
|
} else {
|
|
|
|
|
|
(addr, String::new())
|
|
|
|
|
|
}
|
|
|
|
|
|
};
|
|
|
|
|
|
let detail = w >= 40 && h >= 8;
|
|
|
|
|
|
let detail_h = if detail {
|
|
|
|
|
|
3 + usize::from(!addr_rest.is_empty())
|
|
|
|
|
|
} else {
|
|
|
|
|
|
0
|
|
|
|
|
|
};
|
|
|
|
|
|
let budget0 = h - (1 + detail_h);
|
|
|
|
|
|
let windowed = total > budget0 && budget0 >= 3;
|
|
|
|
|
|
let budget = if windowed { budget0 - 2 } else { budget0 };
|
|
|
|
|
|
let visible = budget.max(1).min(total);
|
|
|
|
|
|
let start = if total <= visible {
|
|
|
|
|
|
0
|
|
|
|
|
|
} else {
|
|
|
|
|
|
selected.saturating_sub(visible - 1).min(total - visible)
|
|
|
|
|
|
};
|
|
|
|
|
|
let end = (start + visible).min(total);
|
|
|
|
|
|
|
|
|
|
|
|
let mut out: Vec<Line<'static>> = vec![payment_header_line(w)];
|
|
|
|
|
|
if windowed && start > 0 {
|
|
|
|
|
|
out.push(Line::from(vec![Span::styled(
|
|
|
|
|
|
fit_cells(&format!(" {} {start} newer", ellipsis()), w.max(1)),
|
|
|
|
|
|
style_dim(),
|
|
|
|
|
|
)]));
|
|
|
|
|
|
}
|
|
|
|
|
|
for (i, row) in s.rows.iter().enumerate().take(end).skip(start) {
|
|
|
|
|
|
out.push(payment_row_line(w, row, i == selected));
|
|
|
|
|
|
}
|
|
|
|
|
|
if windowed && end < total {
|
|
|
|
|
|
out.push(Line::from(vec![Span::styled(
|
|
|
|
|
|
fit_cells(&format!(" {} {} older", ellipsis(), total - end), w.max(1)),
|
|
|
|
|
|
style_dim(),
|
|
|
|
|
|
)]));
|
|
|
|
|
|
}
|
|
|
|
|
|
if detail {
|
|
|
|
|
|
out.push(Line::default());
|
|
|
|
|
|
out.push(Line::from(vec![Span::styled(
|
|
|
|
|
|
fit_cells(&format!(" tx {txid}"), w.max(1)),
|
|
|
|
|
|
style_dim(),
|
|
|
|
|
|
)]));
|
|
|
|
|
|
out.push(Line::from(vec![Span::styled(
|
|
|
|
|
|
fit_cells(&format!(" addr {addr_head}"), w.max(1)),
|
|
|
|
|
|
style_dim(),
|
|
|
|
|
|
)]));
|
|
|
|
|
|
if !addr_rest.is_empty() {
|
|
|
|
|
|
out.push(Line::from(vec![Span::styled(
|
|
|
|
|
|
fit_cells(&format!(" {addr_rest}"), w.max(1)),
|
|
|
|
|
|
style_dim(),
|
|
|
|
|
|
)]));
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
out
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// The body as plain text, for width/needle assertions.
|
|
|
|
|
|
pub fn peer_payments_text(width: u16, height: u16, s: &PeerPaymentsState) -> String {
|
|
|
|
|
|
peer_payments_lines(width, height, s)
|
|
|
|
|
|
.iter()
|
|
|
|
|
|
.map(|line| {
|
|
|
|
|
|
line.spans
|
|
|
|
|
|
.iter()
|
|
|
|
|
|
.map(|span| span.content.as_ref())
|
|
|
|
|
|
.collect::<String>()
|
|
|
|
|
|
})
|
|
|
|
|
|
.collect::<Vec<_>>()
|
|
|
|
|
|
.join("\n")
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// Block title: the screen is peer-scoped, so the peer is named in the frame
|
|
|
|
|
|
/// itself and not only in the rows.
|
|
|
|
|
|
pub fn peer_payments_title(s: &PeerPaymentsState) -> String {
|
|
|
|
|
|
let peer = menu_cell_text(&s.peer);
|
|
|
|
|
|
if peer.is_empty() {
|
|
|
|
|
|
"(o) payments".to_string()
|
|
|
|
|
|
} else {
|
|
|
|
|
|
format!("(o) payments {}{peer}", "\u{b7} ")
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// Peer payment history: a full screen like the F9 menu, with the same single
|
|
|
|
|
|
/// status line. `footer` is an already-built `status_footer` row.
|
|
|
|
|
|
pub fn draw_peer_payments(f: &mut Frame, state: &PeerPaymentsState, footer: &str) {
|
|
|
|
|
|
let area = f.area();
|
|
|
|
|
|
let rows = Layout::vertical([Constraint::Min(3), Constraint::Length(1)]).split(area);
|
|
|
|
|
|
f.render_widget(
|
|
|
|
|
|
Paragraph::new(peer_payments_lines(
|
|
|
|
|
|
rows[0].width.saturating_sub(2),
|
|
|
|
|
|
rows[0].height.saturating_sub(2),
|
|
|
|
|
|
state,
|
|
|
|
|
|
))
|
|
|
|
|
|
.block(themed_block(&peer_payments_title(state))),
|
|
|
|
|
|
rows[0],
|
|
|
|
|
|
);
|
|
|
|
|
|
f.render_widget(
|
|
|
|
|
|
Paragraph::new(fit_cells(footer, area.width as usize)).style(style_dim()),
|
|
|
|
|
|
rows[1],
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
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
|
|
|
|
/// OSC 52 clipboard write for `text`: the terminal copies it, so no crate and
|
|
|
|
|
|
/// no clipboard daemon are involved and it still works over SSH. A terminal
|
|
|
|
|
|
/// that does not implement OSC 52 ignores the sequence.
|
|
|
|
|
|
pub fn osc52_copy_sequence(text: &str) -> String {
|
|
|
|
|
|
let clean = menu_cell_text(text);
|
|
|
|
|
|
let trimmed = clean.trim();
|
|
|
|
|
|
format!("\x1b]52;c;{}\x07", base64_encode(trimmed.as_bytes()))
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// Plain RFC 4648 base64 (standard alphabet, `=` padded). Hand-rolled because
|
|
|
|
|
|
/// this crate has no base64 dependency and the menu needs exactly one call site.
|
|
|
|
|
|
fn base64_encode(bytes: &[u8]) -> String {
|
|
|
|
|
|
const ALPHABET: &[u8; 64] =
|
|
|
|
|
|
b"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
|
|
|
|
let mut out = String::with_capacity(bytes.len().div_ceil(3) * 4);
|
|
|
|
|
|
for chunk in bytes.chunks(3) {
|
|
|
|
|
|
let b0 = chunk[0] as u32;
|
|
|
|
|
|
let b1 = *chunk.get(1).unwrap_or(&0) as u32;
|
|
|
|
|
|
let b2 = *chunk.get(2).unwrap_or(&0) as u32;
|
|
|
|
|
|
let n = (b0 << 16) | (b1 << 8) | b2;
|
|
|
|
|
|
out.push(ALPHABET[((n >> 18) & 63) as usize] as char);
|
|
|
|
|
|
out.push(ALPHABET[((n >> 12) & 63) as usize] as char);
|
|
|
|
|
|
out.push(if chunk.len() > 1 {
|
|
|
|
|
|
ALPHABET[((n >> 6) & 63) as usize] as char
|
|
|
|
|
|
} else {
|
|
|
|
|
|
'='
|
|
|
|
|
|
});
|
|
|
|
|
|
out.push(if chunk.len() > 2 {
|
|
|
|
|
|
ALPHABET[(n & 63) as usize] as char
|
|
|
|
|
|
} else {
|
|
|
|
|
|
'='
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
out
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-09-10 01:54:19 -04:00
|
|
|
|
fn truncate_fp(fp: &str) -> String {
|
|
|
|
|
|
let s: String = fp.chars().take(8).collect();
|
2026-09-12 00:15:19 -04:00
|
|
|
|
format!("{s}{}", ellipsis())
|
|
|
|
|
|
}
|
|
|
|
|
|
|
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]>
2026-09-18 23:13:12 -04:00
|
|
|
|
fn roster_row_text(row: &FriendRow, inner_width: u16) -> String {
|
2026-09-12 00:15:19 -04:00
|
|
|
|
let budget = (inner_width as usize).saturating_sub(2);
|
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]>
2026-09-18 23:13:12 -04:00
|
|
|
|
let stale_s = if row.stale { " stale" } else { "" };
|
|
|
|
|
|
let avail = budget.saturating_sub(cell_width(stale_s));
|
|
|
|
|
|
// The name is what the reader is looking for. The fingerprint only
|
|
|
|
|
|
// disambiguates two friends with the same petname, so it gets what is left
|
|
|
|
|
|
// and is dropped entirely when the pane is too narrow to show a usable
|
|
|
|
|
|
// prefix — a row that reads `bob-the-sta… stale` beats one that reads
|
|
|
|
|
|
// `… bbbbbbbb… stale`.
|
|
|
|
|
|
let name_share = cell_width(&row.label).min((avail / 2).max(6)).min(avail);
|
|
|
|
|
|
let fp_share = avail.saturating_sub(name_share);
|
|
|
|
|
|
let (shown, fp_part) = if fp_share >= 8 {
|
|
|
|
|
|
(
|
|
|
|
|
|
fit_cells(&row.label, name_share),
|
|
|
|
|
|
format!(" {}", fit_cells(&truncate_fp(&row.fingerprint), fp_share - 2)),
|
|
|
|
|
|
)
|
2026-09-12 00:15:19 -04:00
|
|
|
|
} else {
|
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]>
2026-09-18 23:13:12 -04:00
|
|
|
|
(fit_cells(&row.label, avail), String::new())
|
2026-09-12 00:15:19 -04:00
|
|
|
|
};
|
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]>
2026-09-18 23:13:12 -04:00
|
|
|
|
fit_cells(&format!("{shown}{fp_part}{stale_s}"), budget)
|
2026-09-10 01:54:19 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
fn to_hex(bytes: &[u8]) -> String {
|
|
|
|
|
|
bytes.iter().map(|b| format!("{b:02x}")).collect()
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-09-12 22:53:58 -04:00
|
|
|
|
#[derive(Clone, Debug)]
|
|
|
|
|
|
struct QrModal {
|
|
|
|
|
|
closed: bool,
|
|
|
|
|
|
matrix_rows: Vec<String>,
|
|
|
|
|
|
#[allow(dead_code)]
|
|
|
|
|
|
uri: String,
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
fn draw_wallet(
|
|
|
|
|
|
f: &mut Frame,
|
|
|
|
|
|
receive_addr: &str,
|
|
|
|
|
|
balance: &str,
|
|
|
|
|
|
transfers: &[wallet::TransferRow],
|
|
|
|
|
|
modal: Option<&QrModal>,
|
2026-09-18 09:28:11 -04:00
|
|
|
|
child: &str,
|
2026-09-12 22:53:58 -04:00
|
|
|
|
) {
|
|
|
|
|
|
let area = f.area();
|
|
|
|
|
|
if let Some(m) = modal {
|
|
|
|
|
|
// Clear behind the popup so the body does not bleed through.
|
|
|
|
|
|
f.render_widget(Clear, area);
|
|
|
|
|
|
let inner_w = area.width.saturating_sub(2).max(1);
|
|
|
|
|
|
let inner_h = area.height.saturating_sub(2).max(1);
|
|
|
|
|
|
let rows = m.matrix_rows.len().max(1);
|
|
|
|
|
|
let content_h = rows.min(inner_h as usize);
|
|
|
|
|
|
let popup_h = content_h as u16 + 2;
|
|
|
|
|
|
let popup_w = inner_w.max(6);
|
|
|
|
|
|
let x = area.x + (area.width.saturating_sub(popup_w)) / 2;
|
|
|
|
|
|
let y = area.y + (area.height.saturating_sub(popup_h)) / 2;
|
|
|
|
|
|
let popup = Rect {
|
|
|
|
|
|
x,
|
|
|
|
|
|
y,
|
|
|
|
|
|
width: popup_w,
|
|
|
|
|
|
height: popup_h,
|
|
|
|
|
|
};
|
|
|
|
|
|
f.render_widget(Clear, popup);
|
|
|
|
|
|
let mut body = String::from("receive address\nEsc or R closes\n\n");
|
|
|
|
|
|
if m.matrix_rows.is_empty() {
|
|
|
|
|
|
body.push_str("(qr error)");
|
|
|
|
|
|
} else {
|
|
|
|
|
|
for row in m.matrix_rows.iter().take(content_h) {
|
|
|
|
|
|
body.push_str(row);
|
|
|
|
|
|
body.push('\n');
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
f.render_widget(
|
|
|
|
|
|
Paragraph::new(body)
|
|
|
|
|
|
.style(style_text())
|
|
|
|
|
|
.wrap(Wrap { trim: false })
|
|
|
|
|
|
.block(
|
|
|
|
|
|
apply_chrome_borders(Block::default())
|
|
|
|
|
|
.border_style(style_accent())
|
|
|
|
|
|
.title("qr — monero:receive"),
|
|
|
|
|
|
),
|
|
|
|
|
|
popup,
|
|
|
|
|
|
);
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
let cols = Layout::vertical([
|
|
|
|
|
|
Constraint::Length(2),
|
|
|
|
|
|
Constraint::Min(4),
|
|
|
|
|
|
Constraint::Length(2),
|
|
|
|
|
|
Constraint::Length(3),
|
|
|
|
|
|
Constraint::Length(1),
|
|
|
|
|
|
])
|
|
|
|
|
|
.split(area);
|
|
|
|
|
|
|
|
|
|
|
|
f.render_widget(
|
|
|
|
|
|
Paragraph::new("wallet")
|
|
|
|
|
|
.style(style_accent())
|
|
|
|
|
|
.block(pane_block_for("wallet", true)),
|
|
|
|
|
|
cols[0],
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
let addr_line = if receive_addr.is_empty() {
|
|
|
|
|
|
"no address".into()
|
|
|
|
|
|
} else {
|
|
|
|
|
|
receive_addr.to_string()
|
|
|
|
|
|
};
|
|
|
|
|
|
let body = format!(
|
|
|
|
|
|
"address
|
|
|
|
|
|
{addr_line}
|
|
|
|
|
|
|
|
|
|
|
|
balance
|
|
|
|
|
|
{balance}
|
|
|
|
|
|
"
|
|
|
|
|
|
);
|
2026-09-18 09:28:11 -04:00
|
|
|
|
let mut lines: Vec<String> = body.lines().map(str::to_string).collect();
|
|
|
|
|
|
// Only rendered when a chain source is configured or a child was started, so
|
|
|
|
|
|
// an unconfigured install shows the same screen it always did.
|
|
|
|
|
|
if !child.is_empty() {
|
|
|
|
|
|
lines.push(String::new());
|
|
|
|
|
|
lines.push(format!(" {child}"));
|
|
|
|
|
|
}
|
|
|
|
|
|
lines.push(String::new());
|
|
|
|
|
|
lines.push("recent transfers".into());
|
2026-09-12 22:53:58 -04:00
|
|
|
|
if transfers.is_empty() {
|
|
|
|
|
|
lines.push(" (none)".into());
|
|
|
|
|
|
} else {
|
|
|
|
|
|
for t in transfers.iter().take(5) {
|
|
|
|
|
|
let xmr = crate::pay::atomic_to_xmr_str(&t.amount);
|
|
|
|
|
|
lines.push(format!(" {} {} XMR", t.txid.chars().take(16).collect::<String>(), xmr));
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2026-09-18 09:28:11 -04:00
|
|
|
|
let help = "s start child x stop child p probe c create i import r qr Esc back";
|
2026-09-12 22:53:58 -04:00
|
|
|
|
lines.push("".into());
|
|
|
|
|
|
f.render_widget(
|
|
|
|
|
|
Paragraph::new(lines.join("\n"))
|
|
|
|
|
|
.style(style_text())
|
|
|
|
|
|
.wrap(Wrap { trim: false })
|
|
|
|
|
|
.block(apply_chrome_borders(Block::default()).border_style(style_border())),
|
|
|
|
|
|
cols[2],
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
f.render_widget(Paragraph::new(help).style(style_dim()), cols[3]);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-09-13 23:25:25 -04:00
|
|
|
|
fn draw_wallet_setup(f: &mut Frame, setup: &WalletSetup) {
|
|
|
|
|
|
let (title, body) = match setup {
|
|
|
|
|
|
WalletSetup::CreateWarn { typed } => (
|
|
|
|
|
|
"create spend wallet",
|
|
|
|
|
|
format!(
|
|
|
|
|
|
"{}\n\nType SPEND to confirm Esc to cancel\n{typed}",
|
|
|
|
|
|
wallet::SPEND_AUTHORITY_WARNING
|
|
|
|
|
|
),
|
|
|
|
|
|
),
|
|
|
|
|
|
WalletSetup::CreatePass { entry } => (
|
|
|
|
|
|
"wallet passphrase",
|
|
|
|
|
|
if entry.first().is_some() {
|
|
|
|
|
|
"re-type passphrase\n\nEnter submits Esc cancels".into()
|
|
|
|
|
|
} else {
|
|
|
|
|
|
"set a passphrase for the wallet file\n\nEnter continues Esc cancels".into()
|
|
|
|
|
|
},
|
|
|
|
|
|
),
|
|
|
|
|
|
WalletSetup::CreateSeed { seed, typed } => (
|
|
|
|
|
|
"write down this seed",
|
|
|
|
|
|
format!(
|
|
|
|
|
|
"{}\n\nthis is shown once. anyone with it can spend.\nType SEEN when you have written it down\n{typed}",
|
|
|
|
|
|
seed.as_str()
|
|
|
|
|
|
),
|
|
|
|
|
|
),
|
|
|
|
|
|
WalletSetup::ImportSeed { buf } => (
|
|
|
|
|
|
"import wallet",
|
|
|
|
|
|
format!(
|
|
|
|
|
|
"paste the 25-word seed. this is the only path that takes an existing key.\n\n{}\n\nEnter continues Esc cancels",
|
|
|
|
|
|
buf.as_str()
|
|
|
|
|
|
),
|
|
|
|
|
|
),
|
|
|
|
|
|
WalletSetup::ImportPass { entry, .. } => (
|
|
|
|
|
|
"wallet passphrase",
|
|
|
|
|
|
if entry.first().is_some() {
|
|
|
|
|
|
"re-type passphrase\n\nEnter submits Esc cancels".into()
|
|
|
|
|
|
} else {
|
|
|
|
|
|
"passphrase for the imported wallet file\n\nEnter continues Esc cancels".into()
|
|
|
|
|
|
},
|
|
|
|
|
|
),
|
|
|
|
|
|
};
|
|
|
|
|
|
draw_text_overlay(f, title, &body);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-09-10 01:54:19 -04:00
|
|
|
|
fn io_err(e: io::Error) -> String {
|
|
|
|
|
|
e.to_string()
|
|
|
|
|
|
}
|
2026-09-12 14:06:20 -04:00
|
|
|
|
|
tui: F9 works on the peer-payments screen, and frames dump the real footer
Review round 1 on the F9 `payments` row found two false affordances.
1. `footer_hints(Screen::PeerPayments)` prints `F9 menu`, and docs/TUI.md says
F9 reopens the menu, but the `KeyCode::F(9)` arm opened it only from
`Screen::Main`, so pressing F9 on the peer history did nothing.
The function keys are now routed through one table, `function_key_for(screen,
code)`, and the F9 arm no longer has the Main-only guard: it opens (or
reopens) the menu from `Main`, `WalletsSettings` and `PeerPayments`. A screen
that names a key has to answer it while it is open — that is what the table
encodes, and `mod function_key_tests` locks it, including a test that reads
the screen's own hint and asserts every `F<n>` it names is answered there.
2. The PR's frame dumps passed `"Esc back up/down select ? help"` to
`status_footer` by hand, so every dumped frame showed a footer the app never
renders. `peer_payments_footer_hint()` is now the single source both
`footer_hints` and the fixture read, and
`peer_payments_frame_shows_the_shipped_footer` pins the dumped frame's last
line to the shipped one.
Also restores the rustfmt-only reflow of unrelated tests in `tests/tui_spec.rs`
(`queued_row`, a `failed_row` call, `rgb_tokens_…`, `alert_line_…`), keeping this
card's real edits there.
Presentation only: no wire, store, session, send-path or `Node` change.
2026-09-19 00:31:42 -04:00
|
|
|
|
#[cfg(test)]
|
|
|
|
|
|
mod function_key_tests {
|
|
|
|
|
|
use super::*;
|
|
|
|
|
|
|
|
|
|
|
|
fn peer_payments_screen() -> Screen {
|
|
|
|
|
|
Screen::PeerPayments {
|
|
|
|
|
|
state: PeerPaymentsState::default(),
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// The peer history's footer prints `F9 menu`, so F9 has to reach the menu
|
|
|
|
|
|
/// while that screen is open — not only from Main.
|
|
|
|
|
|
#[test]
|
|
|
|
|
|
fn f9_opens_the_menu_from_the_peer_payments_screen() {
|
|
|
|
|
|
assert_eq!(
|
|
|
|
|
|
function_key_for(&peer_payments_screen(), KeyCode::F(9)),
|
|
|
|
|
|
Some(FunctionKey::OpenMenu),
|
|
|
|
|
|
"the screen's footer names F9 but F9 does nothing there"
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// Copy and behaviour agree: every `F<n>` the screen's own hint names must
|
|
|
|
|
|
/// be a key the screen answers. This is the test the defect class needs —
|
|
|
|
|
|
/// the hint string and the routing table are the two halves of the claim.
|
|
|
|
|
|
#[test]
|
|
|
|
|
|
fn every_function_key_named_by_the_peer_payments_hint_is_answered_there() {
|
|
|
|
|
|
let hint = peer_payments_footer_hint();
|
|
|
|
|
|
let screen = peer_payments_screen();
|
|
|
|
|
|
let mut named = 0;
|
|
|
|
|
|
for (at, _) in hint.match_indices('F') {
|
|
|
|
|
|
let digits: String = hint[at + 1..]
|
|
|
|
|
|
.chars()
|
|
|
|
|
|
.take_while(char::is_ascii_digit)
|
|
|
|
|
|
.collect();
|
|
|
|
|
|
let Ok(number) = digits.parse::<u8>() else {
|
|
|
|
|
|
continue;
|
|
|
|
|
|
};
|
|
|
|
|
|
named += 1;
|
|
|
|
|
|
assert!(
|
|
|
|
|
|
function_key_for(&screen, KeyCode::F(number)).is_some(),
|
|
|
|
|
|
"hint names F{number} ({hint:?}) but the screen does not answer it"
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
|
|
|
|
|
assert!(named > 0, "the hint names no function key: {hint:?}");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// The menu screen names `c` and `Esc`, not the function keys, but it is
|
|
|
|
|
|
/// the screen the `payments` row came from — its own keys stay its own.
|
|
|
|
|
|
#[test]
|
|
|
|
|
|
fn function_keys_stay_live_on_the_wallets_settings_screen() {
|
|
|
|
|
|
let screen = Screen::WalletsSettings {
|
|
|
|
|
|
state: WalletMenuState::default(),
|
|
|
|
|
|
};
|
|
|
|
|
|
for key in [
|
|
|
|
|
|
KeyCode::F(2),
|
|
|
|
|
|
KeyCode::F(3),
|
|
|
|
|
|
KeyCode::F(4),
|
|
|
|
|
|
KeyCode::F(5),
|
|
|
|
|
|
KeyCode::F(6),
|
|
|
|
|
|
KeyCode::F(8),
|
|
|
|
|
|
KeyCode::F(9),
|
|
|
|
|
|
] {
|
|
|
|
|
|
assert!(
|
|
|
|
|
|
function_key_for(&screen, key).is_some(),
|
|
|
|
|
|
"{key:?} is named on the menu but is not answered there"
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// A screen that names no function key keeps the key to itself: the
|
|
|
|
|
|
/// composer's `F`-less screens must not steal F-keys they never advertise.
|
|
|
|
|
|
#[test]
|
|
|
|
|
|
fn screens_that_name_no_function_key_do_not_answer_one() {
|
|
|
|
|
|
for screen in [
|
|
|
|
|
|
Screen::Paste {
|
|
|
|
|
|
buf: String::new(),
|
|
|
|
|
|
err: None,
|
|
|
|
|
|
},
|
|
|
|
|
|
Screen::WalletSetup(WalletSetup::ImportSeed {
|
|
|
|
|
|
buf: Zeroizing::new(String::new()),
|
|
|
|
|
|
}),
|
|
|
|
|
|
] {
|
|
|
|
|
|
for key in [KeyCode::F(9), KeyCode::F(6)] {
|
|
|
|
|
|
assert!(
|
|
|
|
|
|
function_key_for(&screen, key).is_none(),
|
|
|
|
|
|
"{key:?} was answered on a screen that never names it"
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-09-12 14:06:20 -04:00
|
|
|
|
#[cfg(test)]
|
|
|
|
|
|
mod passphrase_buffer_tests {
|
|
|
|
|
|
use super::*;
|
|
|
|
|
|
|
|
|
|
|
|
fn assert_zeroize_on_drop<T: zeroize::ZeroizeOnDrop>() {}
|
|
|
|
|
|
|
|
|
|
|
|
/// The typed passphrase lives in `Zeroizing` buffers, not in bare
|
|
|
|
|
|
/// `String`s that sit in the heap for the life of the screen.
|
|
|
|
|
|
#[test]
|
|
|
|
|
|
fn passphrase_buffers_are_zeroizing() {
|
|
|
|
|
|
let mut entry = PassphraseEntry::new();
|
|
|
|
|
|
entry.push('x');
|
|
|
|
|
|
|
|
|
|
|
|
let _: &Zeroizing<String> = &entry.buf;
|
|
|
|
|
|
let _: &Option<Zeroizing<String>> = &entry.first;
|
|
|
|
|
|
assert_zeroize_on_drop::<Zeroizing<String>>();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// Closing the screen (submit, mismatch or cancel) must leave nothing of
|
|
|
|
|
|
/// the typed passphrase behind in its heap buffer.
|
|
|
|
|
|
#[test]
|
|
|
|
|
|
fn closing_the_passphrase_screen_wipes_the_typed_secret() {
|
|
|
|
|
|
let mut entry = PassphraseEntry::new();
|
|
|
|
|
|
for c in "hunter2-secret".chars() {
|
|
|
|
|
|
entry.push(c);
|
|
|
|
|
|
}
|
|
|
|
|
|
assert_eq!(entry.buf(), "hunter2-secret");
|
|
|
|
|
|
|
|
|
|
|
|
let ptr = entry.buf.as_ptr();
|
|
|
|
|
|
let cap = entry.buf.capacity();
|
|
|
|
|
|
assert!(cap >= 14, "expected a heap buffer, capacity {cap}");
|
|
|
|
|
|
|
|
|
|
|
|
entry.close();
|
|
|
|
|
|
|
|
|
|
|
|
assert!(entry.buf().is_empty(), "buffer not cleared");
|
|
|
|
|
|
// SAFETY: `close()` wipes through `Zeroize`, which zeroes the whole
|
|
|
|
|
|
// capacity and *keeps* the allocation (`Vec::zeroize`: zero the
|
|
|
|
|
|
// elements, clear the length, zero the spare capacity). `entry` still
|
|
|
|
|
|
// owns that buffer, so these `cap` bytes are live memory.
|
|
|
|
|
|
let bytes = unsafe { std::slice::from_raw_parts(ptr, cap) };
|
|
|
|
|
|
assert!(
|
|
|
|
|
|
bytes.iter().all(|b| *b == 0),
|
|
|
|
|
|
"typed passphrase survived close(): {bytes:?}"
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// The first entry of the two-step backup flow is a secret too, and the
|
|
|
|
|
|
/// screen holds it across the second prompt.
|
|
|
|
|
|
#[test]
|
|
|
|
|
|
fn closing_the_passphrase_screen_drops_the_first_entry_copy() {
|
|
|
|
|
|
let mut entry = PassphraseEntry::with_first("first-typed");
|
|
|
|
|
|
assert_eq!(entry.first(), Some("first-typed"));
|
|
|
|
|
|
|
|
|
|
|
|
entry.close();
|
|
|
|
|
|
|
|
|
|
|
|
assert_eq!(
|
|
|
|
|
|
entry.first(),
|
|
|
|
|
|
None,
|
|
|
|
|
|
"first passphrase copy survived close()"
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|