2026-09-12 14:22:38 -04:00
use std ::collections ::HashMap ;
tui(wallet): chain/daemon honesty, view-only badge, address copy (OSC 52)
- Screen::Wallet.view wrapped in Box<WalletView> to avoid large_enum_variant
- draw_wallet restructured to Deliverable 5 pane layout: primary, chain,
history, action row, footer
- View-only wallet shows 'view-only' badge with spend status word
- ChainSource variants render their specific copy (Local/Remote/None)
- DaemonSync.reachable=false renders 'sync: unknown' with no balance claim
- Address copy via OSC 52 escape sequence; 'y' key; fallback hint on screen
- QR modal resized to fit 80x24 without clipping
- wallet_screen_at_with() test helper for copy_note parameter
- 33 new tests covering receive-only, local synced/syncing, remote
unreachable, view-only badge, QR modal, address copy escape sequence
All 52 TUI tests pass (10 tui_frames + 19 tui_chrome + 23 tui_spec).
Clippy clean on lib and all three test targets.
2026-09-15 19:57:29 -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: 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
2026-09-15 12:29:16 -04:00
use crate ::node ::{ DaemonSync , Node , WalletChildState } ;
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(history): payment history and tx detail screen (card t_935bf84e)
Add Screen::History with draw_history, history_row_text, history_detail.
- Per-friend payment list: direction marker, amount, verified state, age, txid
- Enter opens detail view; Esc closes
- h key from main + wallet opens history via Node::list_payments
- Empty state: 'no payments with this friend yet'
- ASCII fallback: drops ✓/✗ glyphs, uses words only
- Peer text (memo, address) sanitized via display_text
- Tests: 5 new in tui_spec.rs (row text, detail, empty, ascii), 2 frame dumps in tui_frames.rs
Signed-off-by: tui-design <tui-design@hermes>
2026-09-15 21:29:40 -04:00
use crate ::store ::{ Friend , FriendProfile , Message , OutboxEntry , OutboxStatus , Payment } ;
2026-09-15 12:29:16 -04:00
use crate ::wallet ::{ self , ChainSource , Readiness } ;
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
#[ derive(Clone, Copy, PartialEq, Eq) ]
enum ColorMode {
Rgb ,
Ansi16 ,
None ,
}
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: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.
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} " ) ;
}
truncate_chars ( & text , width as usize )
}
/// 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 \n type 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 } ;
truncate_chars ( text , budget )
}
/// 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 > ,
}
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.
pub fn note ( & self ) -> Option < String > {
let reason = | | {
short_send_reason (
self . first_error . as_deref ( ) . unwrap_or ( " unknown " ) ,
FAIL_REASON_BUDGET ,
)
} ;
match ( self . queued , self . failed ) {
( 0 , 0 ) = > None ,
( queued , 0 ) = > Some ( format! ( " {queued} queued " ) ) ,
( 0 , 1 ) = > Some ( format! ( " send failed: {} " , reason ( ) ) ) ,
( 0 , failed ) = > Some ( format! ( " send failed: {} ( {failed} failed) " , reason ( ) ) ) ,
( queued , _ ) = > Some ( format! ( " {queued} queued, send failed: {} " , reason ( ) ) ) ,
}
}
}
/// 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 ( ) ) ;
}
_ = > summary . queued + = 1 ,
}
}
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} \n Enter 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 ( )
}
tui(wallet): chain/daemon honesty, view-only badge, address copy (OSC 52)
- Screen::Wallet.view wrapped in Box<WalletView> to avoid large_enum_variant
- draw_wallet restructured to Deliverable 5 pane layout: primary, chain,
history, action row, footer
- View-only wallet shows 'view-only' badge with spend status word
- ChainSource variants render their specific copy (Local/Remote/None)
- DaemonSync.reachable=false renders 'sync: unknown' with no balance claim
- Address copy via OSC 52 escape sequence; 'y' key; fallback hint on screen
- QR modal resized to fit 80x24 without clipping
- wallet_screen_at_with() test helper for copy_note parameter
- 33 new tests covering receive-only, local synced/syncing, remote
unreachable, view-only badge, QR modal, address copy escape sequence
All 52 TUI tests pass (10 tui_frames + 19 tui_chrome + 23 tui_spec).
Clippy clean on lib and all three test targets.
2026-09-15 19:57:29 -04:00
/// Truncate `s` to `max` display cells, appending an ellipsis when it overflows.
2026-09-12 00:15:19 -04:00
fn truncate_chars ( s : & str , max : usize ) -> String {
if char_len ( s ) < = max {
return s . to_string ( ) ;
}
let e = ellipsis ( ) ;
let el = char_len ( e ) ;
if max < = el {
return e . chars ( ) . take ( max ) . collect ( ) ;
}
let head : String = s . chars ( ) . take ( max - el ) . collect ( ) ;
format! ( " {head} {e} " )
}
tui(wallet): chain/daemon honesty, view-only badge, address copy (OSC 52)
- Screen::Wallet.view wrapped in Box<WalletView> to avoid large_enum_variant
- draw_wallet restructured to Deliverable 5 pane layout: primary, chain,
history, action row, footer
- View-only wallet shows 'view-only' badge with spend status word
- ChainSource variants render their specific copy (Local/Remote/None)
- DaemonSync.reachable=false renders 'sync: unknown' with no balance claim
- Address copy via OSC 52 escape sequence; 'y' key; fallback hint on screen
- QR modal resized to fit 80x24 without clipping
- wallet_screen_at_with() test helper for copy_note parameter
- 33 new tests covering receive-only, local synced/syncing, remote
unreachable, view-only badge, QR modal, address copy escape sequence
All 52 TUI tests pass (10 tui_frames + 19 tui_chrome + 23 tui_spec).
Clippy clean on lib and all three test targets.
2026-09-15 19:57:29 -04:00
/// OSC 52 escape sequence that asks the terminal to copy `text` into the
/// system clipboard. No clipboard crate is pulled in: the text is base64'd
/// by this minimal encoder and the raw byte sequence is returned so the
/// caller can `print!` / `io::stdout().write_all` it.
pub fn osc52_copy ( text : & str ) -> String {
const B64 : & [ u8 ] =
b " ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/ " ;
let bytes = text . as_bytes ( ) ;
let mut out = String ::with_capacity ( 8 + bytes . len ( ) * 4 / 3 ) ;
out . push_str ( " \x1b ]52;c; " ) ;
for ( i , chunk ) in bytes . chunks ( 3 ) . enumerate ( ) {
let mut quad = [ 0 u8 ; 3 ] ;
quad [ .. chunk . len ( ) ] . copy_from_slice ( chunk ) ;
let v0 = ( quad [ 0 ] > > 2 ) & 0x3f ;
let v1 = ( ( quad [ 0 ] & 0x03 ) < < 4 ) | ( quad [ 1 ] > > 4 ) ;
let v2 = if chunk . len ( ) > 1 {
( ( quad [ 1 ] & 0x0f ) < < 2 ) | ( quad [ 2 ] > > 6 )
} else {
64
} ;
let v3 = if chunk . len ( ) > 2 { quad [ 2 ] & 0x3f } else { 64 } ;
for v in [ v0 , v1 , v2 , v3 ] {
if v = = 64 {
out . push ( '=' ) ;
} else {
out . push ( B64 [ v as usize ] as char ) ;
}
}
if ( i + 1 ) % 76 = = 0 {
out . push_str ( " \x1b ]52;c; " ) ;
}
}
out . push ( '\x07' ) ;
out
}
2026-09-12 00:15:19 -04:00
fn style_fg ( rgb : Color , ansi : Color ) -> Style {
match color_mode ( ) {
ColorMode ::None = > Style ::default ( ) ,
ColorMode ::Ansi16 = > Style ::default ( ) . fg ( ansi ) ,
ColorMode ::Rgb = > Style ::default ( ) . fg ( rgb ) ,
}
}
fn style_accent ( ) -> Style {
match color_mode ( ) {
ColorMode ::None = > Style ::default ( ) . add_modifier ( Modifier ::BOLD ) ,
ColorMode ::Ansi16 = > Style ::default ( ) . fg ( Color ::Yellow ) ,
ColorMode ::Rgb = > Style ::default ( ) . fg ( C_ACCENT ) ,
}
}
fn style_text ( ) -> Style {
style_fg ( C_TEXT , Color ::White )
}
fn style_dim ( ) -> Style {
style_fg ( C_DIM , Color ::DarkGray )
}
fn style_alert ( ) -> Style {
style_fg ( C_ALERT , Color ::Red )
}
fn style_stale ( ) -> Style {
style_fg ( C_STALE , Color ::Yellow )
}
fn style_border ( ) -> Style {
style_fg ( C_BORDER , Color ::DarkGray )
}
fn style_highlight ( ) -> Style {
match color_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 ) ,
}
}
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-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 \
tui: F7 wallet config screen + wallet/chain setup redesign + doc sync
Implement the F7 wallet-endpoint config screen (Screen::WalletConfig):
- Fields: rpc_url, rpc_login masked with reveal toggle, no_spend checkbox
- Test connection (t → PingResult::line), Save (s → wallet_save_config)
- Status line: 'saved · not connected', 'connected — ...', 'error: ...'
- NO_COLOR distinguishability: '·' bullets, username visible, password masked
- Password never leaks: WalletConfig::secret() redaction on all status lines
- ConfigField cycle (Tab/Esc), footer hints, help overlay entries
Redraw draw_wallet_setup (CreateWarn→CreatePass→CreateSeed→ImportPass,
CreateWarn→ImportSeq→ImportPass) with spend-authority warning, SEEN
challenge, zeroizing buffers preserved on submit/mismatch/Esc.
Update help_overlay_text() with F6 h, F7, copy key; main_footer_hints()
for F7. Extend tui_chrome.rs needle list (F6 h, F7 added).
Reconcile docs: README key table gains F6 s/n/h and F7; WALLET.md
wallet-screen paragraph updated; TUI.md Deliverable 5 marked implemented
with after frames for each config state at 80x24 and 120x40.
Tests: 30 tui_spec (incl. 7 new wallet-config tests), tui_chrome green.
cargo test --locked: 0 failures. cargo clippy --all-targets: clean.
2026-09-15 23:01:56 -04:00
F2 share invite ( string + copy ) \ n \
2026-09-10 16:53:03 -04:00
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 \
tui(history): payment history and tx detail screen (card t_935bf84e)
Add Screen::History with draw_history, history_row_text, history_detail.
- Per-friend payment list: direction marker, amount, verified state, age, txid
- Enter opens detail view; Esc closes
- h key from main + wallet opens history via Node::list_payments
- Empty state: 'no payments with this friend yet'
- ASCII fallback: drops ✓/✗ glyphs, uses words only
- Peer text (memo, address) sanitized via display_text
- Tests: 5 new in tui_spec.rs (row text, detail, empty, ascii), 2 frame dumps in tui_frames.rs
Signed-off-by: tui-design <tui-design@hermes>
2026-09-15 21:29:40 -04:00
F6 wallet ( receive address , chain , balance ) \ n \
F6 h payment history with selected friend \ n \
2026-09-15 12:29:16 -04:00
F6 s chain source : receive - only / local / remote \ n \
F6 n start or stop the app - owned daemon \ n \
tui(wallet): chain/daemon honesty, view-only badge, address copy (OSC 52)
- Screen::Wallet.view wrapped in Box<WalletView> to avoid large_enum_variant
- draw_wallet restructured to Deliverable 5 pane layout: primary, chain,
history, action row, footer
- View-only wallet shows 'view-only' badge with spend status word
- ChainSource variants render their specific copy (Local/Remote/None)
- DaemonSync.reachable=false renders 'sync: unknown' with no balance claim
- Address copy via OSC 52 escape sequence; 'y' key; fallback hint on screen
- QR modal resized to fit 80x24 without clipping
- wallet_screen_at_with() test helper for copy_note parameter
- 33 new tests covering receive-only, local synced/syncing, remote
unreachable, view-only badge, QR modal, address copy escape sequence
All 52 TUI tests pass (10 tui_frames + 19 tui_chrome + 23 tui_spec).
Clippy clean on lib and all three test targets.
2026-09-15 19:57:29 -04:00
F6 r show / hide the receive - address QR \ n \
F6 y copy receive address to clipboard ( OSC 52 ) \ n \
tui: F7 wallet config screen + wallet/chain setup redesign + doc sync
Implement the F7 wallet-endpoint config screen (Screen::WalletConfig):
- Fields: rpc_url, rpc_login masked with reveal toggle, no_spend checkbox
- Test connection (t → PingResult::line), Save (s → wallet_save_config)
- Status line: 'saved · not connected', 'connected — ...', 'error: ...'
- NO_COLOR distinguishability: '·' bullets, username visible, password masked
- Password never leaks: WalletConfig::secret() redaction on all status lines
- ConfigField cycle (Tab/Esc), footer hints, help overlay entries
Redraw draw_wallet_setup (CreateWarn→CreatePass→CreateSeed→ImportPass,
CreateWarn→ImportSeq→ImportPass) with spend-authority warning, SEEN
challenge, zeroizing buffers preserved on submit/mismatch/Esc.
Update help_overlay_text() with F6 h, F7, copy key; main_footer_hints()
for F7. Extend tui_chrome.rs needle list (F6 h, F7 added).
Reconcile docs: README key table gains F6 s/n/h and F7; WALLET.md
wallet-screen paragraph updated; TUI.md Deliverable 5 marked implemented
with after frames for each config state at 80x24 and 120x40.
Tests: 30 tui_spec (incl. 7 new wallet-config tests), tui_chrome green.
cargo test --locked: 0 failures. cargo clippy --all-targets: clean.
2026-09-15 23:01:56 -04:00
F7 wallet config ( rpc url , login , spend ) \ 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: 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 \n fp {fingerprint} \n onion {onion} \n \n no profile yet \n \n Esc 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 \n name {name} \n bio {bio} \n xmr {xmr} \n fp {fingerprint} \n onion {onion} \n \n Esc 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 {
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 ( )
} ;
let line = format! ( " onionwire tor me: {fp} onion: {onion} " ) ;
truncate_chars ( & line , width as usize )
}
/// 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 ,
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 {
" /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 > > ,
wallet: typed chain-daemon client for the Cuprate parity gaps
The chain probe was a hand-rolled brace-scanner in `src/node.rs`. Cuprate
breaks three of its assumptions, all measured in Spike A
(`docs/cuprate-launch-spike.md` §Parity gaps, evidence in that spike's
`rpc-evidence/`):
1. **A height above the tip is a bare HTTP 500 with an empty body.** monerod
answers a JSON-RPC error object instead (`TOO_BIG_HEIGHT`, code -2). The
client now parses the HTTP status once, de-chunks `Transfer-Encoding:
chunked` bodies (axum/hyper; the old brace-scan is not a parse once a blob
spans more than one chunk), and maps both spellings of the height failure to
one typed `WalletError::DaemonHeightOutOfRange`. `get_height` and `get_block`
are height-addressed: their 5xx is the height error. `get_info` is not: its
5xx is `WalletError::DaemonHttpStatus`.
2. **`get_info` metrics are not measurements.** Cuprate reports zero peers while
it downloads blocks, its restricted server answers a placeholder
`database_size` (exactly 5 GiB) and an empty `version`, and `free_space` is
`u64::MAX` on both servers. `DaemonInfo` carries height and target only, so
there is no field for a placeholder to reach the UI. The wallet screen's sync
line is now built from block-height movement between two probes: "connected
to P2P" needs the height to have moved, "no new blocks" is what a stalled
daemon gets, and Cuprate's at-rest `synchronized = true` with
`target_height = 0` reads as unknown instead of `1160/0`.
3. **`get_height` is a URI endpoint**: `{"method":"get_height"}` over
`/json_rpc` is rejected with 422, so the client uses `GET /get_height`, which
both daemons answer. The wallet-child routing rule is pinned too: it dials
the daemon's *unrestricted* listener (monerod's `--rpc-bind-port`, and
whatever port an in-process Cuprate binds for `[rpc.unrestricted]`), never the
restricted one — a restricted listener answers, so a mix-up shows up as a
wrong number rather than as an error.
Scope deviations, stated plainly:
- the card names `src/wallet.rs` + the TUI bindings. The probe itself lived in
`src/node.rs`; it now delegates (net -100 lines there), and the routing
constant/test live in `src/wallet_child.rs`. Tests are in `tests/wallet.rs`,
`tests/tui_spec.rs` and `src/wallet_child.rs`'s test module.
- `daemon_get_block()` is **not called by anything yet**: it is the entry point
the wallet's own block scan (Phase 2) needs, and the out-of-range answer it has
to survive is item 1, so the mapping lives with the client.
- the card's item 3 gives the unrestricted port as 18089 and the restricted one
as 28089. In monerod's numbering 18089 *is* the restricted port; the app's
local source already dials the unrestricted 18081. The rule is what is pinned,
not those numbers.
- `docs/cuprate-launch-spike.md` merged to `main` after this branch's base
commit, so it is not in this tree and its Recommendation bullets are not
updated here.
- based on `feat/wallet-create-import` (the wallet line, unmerged): the daemon
client has no home on `main`. Retarget to `main` when that line lands.
Proof: `cargo test --locked` 306 passed / 0 failed, `cargo clippy --locked
--all-targets -- -D warnings` clean, `rustfmt --edition 2024 --check` adds no
hunk to any file (the inherited hunks in `src/node.rs`/`src/tui.rs`/
`tests/tui_spec.rs` are unchanged in count or region).
2026-09-17 00:24:09 -04:00
/// The height the wallet screen saw last time it probed the daemon, so
/// connectivity can be read from movement instead of from `get_info`'s peer
/// counts (Cuprate reports zero peers while it is downloading blocks).
chain_last_height : std ::cell ::Cell < Option < u64 > > ,
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 ,
} ,
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 {
tui(wallet): chain/daemon honesty, view-only badge, address copy (OSC 52)
- Screen::Wallet.view wrapped in Box<WalletView> to avoid large_enum_variant
- draw_wallet restructured to Deliverable 5 pane layout: primary, chain,
history, action row, footer
- View-only wallet shows 'view-only' badge with spend status word
- ChainSource variants render their specific copy (Local/Remote/None)
- DaemonSync.reachable=false renders 'sync: unknown' with no balance claim
- Address copy via OSC 52 escape sequence; 'y' key; fallback hint on screen
- QR modal resized to fit 80x24 without clipping
- wallet_screen_at_with() test helper for copy_note parameter
- 33 new tests covering receive-only, local synced/syncing, remote
unreachable, view-only badge, QR modal, address copy escape sequence
All 52 TUI tests pass (10 tui_frames + 19 tui_chrome + 23 tui_spec).
Clippy clean on lib and all three test targets.
2026-09-15 19:57:29 -04:00
view : Box < WalletView > ,
2026-09-12 22:53:58 -04:00
qr_modal : Option < QrModal > ,
tui(wallet): chain/daemon honesty, view-only badge, address copy (OSC 52)
- Screen::Wallet.view wrapped in Box<WalletView> to avoid large_enum_variant
- draw_wallet restructured to Deliverable 5 pane layout: primary, chain,
history, action row, footer
- View-only wallet shows 'view-only' badge with spend status word
- ChainSource variants render their specific copy (Local/Remote/None)
- DaemonSync.reachable=false renders 'sync: unknown' with no balance claim
- Address copy via OSC 52 escape sequence; 'y' key; fallback hint on screen
- QR modal resized to fit 80x24 without clipping
- wallet_screen_at_with() test helper for copy_note parameter
- 33 new tests covering receive-only, local synced/syncing, remote
unreachable, view-only badge, QR modal, address copy escape sequence
All 52 TUI tests pass (10 tui_frames + 19 tui_chrome + 23 tui_spec).
Clippy clean on lib and all three test targets.
2026-09-15 19:57:29 -04:00
copy_note : Option < String > ,
2026-09-12 22:53:58 -04:00
} ,
tui(history): payment history and tx detail screen (card t_935bf84e)
Add Screen::History with draw_history, history_row_text, history_detail.
- Per-friend payment list: direction marker, amount, verified state, age, txid
- Enter opens detail view; Esc closes
- h key from main + wallet opens history via Node::list_payments
- Empty state: 'no payments with this friend yet'
- ASCII fallback: drops ✓/✗ glyphs, uses words only
- Peer text (memo, address) sanitized via display_text
- Tests: 5 new in tui_spec.rs (row text, detail, empty, ascii), 2 frame dumps in tui_frames.rs
Signed-off-by: tui-design <tui-design@hermes>
2026-09-15 21:29:40 -04:00
History {
friend_pk : Vec < u8 > ,
payments : Vec < Payment > ,
selected : usize ,
detail : bool ,
} ,
2026-09-15 12:29:16 -04:00
ChainSetup ( ChainSetup ) ,
2026-09-13 23:25:25 -04:00
WalletSetup ( WalletSetup ) ,
tui: F7 wallet config screen + wallet/chain setup redesign + doc sync
Implement the F7 wallet-endpoint config screen (Screen::WalletConfig):
- Fields: rpc_url, rpc_login masked with reveal toggle, no_spend checkbox
- Test connection (t → PingResult::line), Save (s → wallet_save_config)
- Status line: 'saved · not connected', 'connected — ...', 'error: ...'
- NO_COLOR distinguishability: '·' bullets, username visible, password masked
- Password never leaks: WalletConfig::secret() redaction on all status lines
- ConfigField cycle (Tab/Esc), footer hints, help overlay entries
Redraw draw_wallet_setup (CreateWarn→CreatePass→CreateSeed→ImportPass,
CreateWarn→ImportSeq→ImportPass) with spend-authority warning, SEEN
challenge, zeroizing buffers preserved on submit/mismatch/Esc.
Update help_overlay_text() with F6 h, F7, copy key; main_footer_hints()
for F7. Extend tui_chrome.rs needle list (F6 h, F7 added).
Reconcile docs: README key table gains F6 s/n/h and F7; WALLET.md
wallet-screen paragraph updated; TUI.md Deliverable 5 marked implemented
with after frames for each config state at 80x24 and 120x40.
Tests: 30 tui_spec (incl. 7 new wallet-config tests), tui_chrome green.
cargo test --locked: 0 failures. cargo clippy --all-targets: clean.
2026-09-15 23:01:56 -04:00
WalletConfig ( WalletConfigScreen ) ,
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: F7 wallet config screen + wallet/chain setup redesign + doc sync
Implement the F7 wallet-endpoint config screen (Screen::WalletConfig):
- Fields: rpc_url, rpc_login masked with reveal toggle, no_spend checkbox
- Test connection (t → PingResult::line), Save (s → wallet_save_config)
- Status line: 'saved · not connected', 'connected — ...', 'error: ...'
- NO_COLOR distinguishability: '·' bullets, username visible, password masked
- Password never leaks: WalletConfig::secret() redaction on all status lines
- ConfigField cycle (Tab/Esc), footer hints, help overlay entries
Redraw draw_wallet_setup (CreateWarn→CreatePass→CreateSeed→ImportPass,
CreateWarn→ImportSeq→ImportPass) with spend-authority warning, SEEN
challenge, zeroizing buffers preserved on submit/mismatch/Esc.
Update help_overlay_text() with F6 h, F7, copy key; main_footer_hints()
for F7. Extend tui_chrome.rs needle list (F6 h, F7 added).
Reconcile docs: README key table gains F6 s/n/h and F7; WALLET.md
wallet-screen paragraph updated; TUI.md Deliverable 5 marked implemented
with after frames for each config state at 80x24 and 120x40.
Tests: 30 tui_spec (incl. 7 new wallet-config tests), tui_chrome green.
cargo test --locked: 0 failures. cargo clippy --all-targets: clean.
2026-09-15 23:01:56 -04:00
/// Edit-field focus for the F7 config screen. Tab cycles
/// `RpcUrl → RpcLogin → NoSpend → Action`.
#[ derive(Debug, Clone, Copy, PartialEq, Eq) ]
pub enum ConfigField {
RpcUrl ,
RpcLogin ,
NoSpend ,
Action ,
}
impl ConfigField {
pub fn next ( self ) -> Self {
match self {
Self ::RpcUrl = > Self ::RpcLogin ,
Self ::RpcLogin = > Self ::NoSpend ,
Self ::NoSpend = > Self ::Action ,
Self ::Action = > Self ::RpcUrl ,
}
}
pub fn prev ( self ) -> Self {
match self {
Self ::RpcUrl = > Self ::Action ,
Self ::RpcLogin = > Self ::RpcUrl ,
Self ::NoSpend = > Self ::RpcLogin ,
Self ::Action = > Self ::NoSpend ,
}
}
}
/// The status line the F7 screen shows below the fields.
#[ derive(Debug, Clone, Default) ]
pub enum ConfigStatus {
/// No test has run, or save cleared the result.
#[ default ]
Idle ,
/// A probe is in flight.
Testing ,
/// Last test result, rendered through `PingResult::line()`.
Tested ( wallet ::PingResult ) ,
/// Save result: `true` if written, `false` + reason if rejected.
Saved ( bool , String ) ,
}
impl ConfigStatus {
fn line ( & self , login : & str ) -> String {
match self {
Self ::Idle = > String ::new ( ) ,
Self ::Testing = > " testing connection … " . to_string ( ) ,
Self ::Tested ( p ) = > {
let s = wallet ::WalletConfig ::new ( " " , login , false ) ;
if p . ok {
format! ( " connected — {} " , wallet ::redact ( & p . line ( ) , s . secret ( ) ) )
} else {
format! ( " not connected — {} " , wallet ::redact ( & p . line ( ) , s . secret ( ) ) )
}
}
Self ::Saved ( true , _ ) = > " saved · not connected " . to_string ( ) ,
Self ::Saved ( false , e ) = > {
let s = wallet ::WalletConfig ::new ( " " , login , false ) ;
format! ( " error: {} " , wallet ::redact ( e , s . secret ( ) ) )
}
}
}
}
/// F7 wallet-config screen state. Built from `Node::wallet_config()` when
/// opened; the typed fields are never synced back without Save.
#[ derive(Debug) ]
pub struct WalletConfigScreen {
/// The endpoint URL being edited.
pub rpc_url : String ,
/// The login being edited (masked in the UI unless `reveal` is true).
pub rpc_login : String ,
/// View-only toggle.
pub no_spend : bool ,
/// Reveal the typed login instead of dots.
pub reveal : bool ,
/// Which field the focus is on.
pub focus : ConfigField ,
/// Current status line (test / save result).
pub status : ConfigStatus ,
}
impl WalletConfigScreen {
/// Prefill from the stored or env-derived config. An unconfigured wallet
/// opens with empty fields so the user can type a new endpoint.
pub fn from_config ( cfg : Option < & wallet ::WalletConfig > ) -> Self {
match cfg {
Some ( c ) = > Self {
rpc_url : c . rpc_url . clone ( ) ,
rpc_login : c . rpc_login . as_str ( ) . to_string ( ) ,
no_spend : c . no_spend ,
reveal : false ,
focus : ConfigField ::RpcUrl ,
status : ConfigStatus ::Idle ,
} ,
None = > Self {
rpc_url : String ::new ( ) ,
rpc_login : String ::new ( ) ,
no_spend : false ,
reveal : false ,
focus : ConfigField ::RpcUrl ,
status : ConfigStatus ::Idle ,
} ,
}
}
/// The login as the screen renders it: dots for the secret when masked,
/// `user:••••• [reveal]` / `user:••••• [hide]` when toggled. The real
/// password never appears in the rendered frame under any mode.
pub fn login_display ( & self ) -> String {
let secret_len = wallet ::WalletConfig ::new ( " " , & self . rpc_login , false ) . secret ( ) . len ( ) ;
if self . reveal {
// Revealed: show the user part (before `:`), mask the secret.
if self . rpc_login . contains ( ':' ) {
let user = self . rpc_login . split ( ':' ) . next ( ) . unwrap_or ( " " ) ;
format! ( " {user} : {} [hide] " , mask_dots ( secret_len ) )
} else {
format! ( " {} [hide] " , mask_dots ( secret_len ) )
}
} else if self . rpc_login . is_empty ( ) {
format! ( " {} [reveal] " , mask_dots ( 7 ) )
} else if self . rpc_login . contains ( ':' ) {
let user = self . rpc_login . split ( ':' ) . next ( ) . unwrap_or ( " " ) ;
format! ( " {user} : {} [reveal] " , mask_dots ( secret_len ) )
} else {
format! ( " {} [reveal] " , mask_dots ( secret_len ) )
}
}
}
/// Mask a password of `n` characters with bullets. ASCII fallback under
/// `ONIONWIRE_ASCII` / `NO_COLOR`: plain dots.
fn mask_dots ( n : usize ) -> String {
let glyph = if ascii_chrome ( ) { " · " } else { " • " } ;
glyph . repeat ( n . clamp ( 1 , 40 ) )
}
2026-09-15 12:29:16 -04:00
/// How far the wallet screen dares go. Derived from the parent card's
/// `wallet::readiness` predicate, so the UI cannot invent a fourth answer.
#[ derive(Debug, Clone, Copy, PartialEq, Eq) ]
pub enum WalletReadiness {
/// Configured, answered, and spend-capable: balance is authoritative.
Ready ,
/// No wallet file / no RPC endpoint at all. Receive-only still works.
NotConfigured ,
/// Configured but the RPC has not answered (child stopped, bad login).
NotConnected ,
/// Answers, but `ONIONWIRE_WALLET_NO_SPEND=1`: balance is real, spend is not.
ViewOnly ,
}
/// `wallet::readiness` for the wallet screen: it asks "can this wallet spend?",
/// which is what a balance implies.
pub fn wallet_readiness ( configured : bool , connected : bool , no_spend : bool ) -> WalletReadiness {
match wallet ::readiness ( configured , connected , no_spend , true ) {
Readiness ::Ready = > WalletReadiness ::Ready ,
Readiness ::NotConfigured = > WalletReadiness ::NotConfigured ,
Readiness ::NotConnected = > WalletReadiness ::NotConnected ,
Readiness ::NoSpend = > WalletReadiness ::ViewOnly ,
}
}
impl WalletReadiness {
/// Whether the balance may be shown as a fact.
pub fn ready ( self ) -> bool {
matches! ( self , Self ::Ready )
}
/// The line the wallet screen prints. While this is not the ready line, the
/// balance below it is not an offer.
pub fn line ( self ) -> & 'static str {
match self {
Self ::Ready = > " ready: wallet synced — spend and receipt verification available " ,
Self ::NotConfigured = > " not ready: no wallet — receive-only until c create / i import " ,
Self ::NotConnected = > " not ready: wallet RPC not answering — balance is not authoritative " ,
Self ::ViewOnly = > " view-only wallet: spend is refused locally, before any dial " ,
}
}
}
/// Lines that must fit the wallet body at 80 columns (the body is inset by a
/// border: 78 usable, 76 with slack).
pub const WALLET_LINE_MAX : usize = 76 ;
/// The chain half of the wallet screen: what the user chose, whether the child
/// is up, how far the daemon is, and whether the wallet can be trusted to show
/// a balance yet.
pub struct ChainView {
pub source_line : String ,
pub child_line : String ,
pub sync_line : String ,
pub storage_line : String ,
pub status_line : String ,
/// `WalletReadiness::Ready` — the balance is authoritative only then.
pub ready : bool ,
}
impl ChainView {
/// Every line this block renders, in draw order. The render test asserts
/// these fit; the draw prints exactly them.
pub fn lines ( & self ) -> Vec < String > {
[
& self . source_line ,
& self . child_line ,
& self . sync_line ,
& self . storage_line ,
& self . status_line ,
]
. iter ( )
. flat_map ( | l | l . lines ( ) )
. map ( str ::to_string )
. collect ( )
}
}
/// A pruned node is a real trade-off and the screen says so instead of implying
/// an archive.
pub const PRUNED_NOTE : & str = " pruned nodes are not archives: a deep seed restore can degrade. once this wallet has scanned, its own cache is the history " ;
/// Why `.onion` chain traffic cannot start here yet, in plain words. The raw
/// child error names an argv; the user needs the missing piece.
pub const ONION_NO_SOCKS_MSG : & str =
" a remote .onion daemon needs a local SOCKS listener. \n this build does not have one yet — pick a local monerod, \n or a clearnet/loopback daemon you run yourself. " ;
wallet: in-process Cuprate chain daemon behind the cuprate-daemon feature
Phase 1 of the Cuprate integration strategy: the chain daemon can run inside
the OnionWire process instead of a spawned `monerod`. `monero-wallet-rpc` is
unchanged — it still dials the unrestricted loopback RPC on 127.0.0.1:18081,
which is the address `WalletChild::daemon_address` already returned — so no
wallet-layer code moves.
- Cargo.toml: `cuprated` (git, rev 4f8fcd1b) + `toml`, both optional, behind a
`cuprate-daemon` feature that is OFF by default. Cuprate's own `arti` feature
stays off: its arti-client 0.44 cannot unify with this crate's 0.46, and the
in-process daemon is clearnet-only, so this keeps one Tor stack in the
process. `Cargo.lock` gains the graph; no arti 0.44 appears in it.
- src/cuprate.rs (new): `CuprateNode` builds the cuprated config as TOML
(testnet, unrestricted RPC on loopback, restricted RPC disabled, inbound P2P
off), launches it, and owns it. Dropping the value is the teardown;
`shutdown()` is called before the drop so the services can drain. The type
exists in every build: without the feature `launch` fails with the feature
name instead of silently doing nothing, so the chain-source type, its stored
record and the picker do not fork on a cargo feature.
- src/wallet.rs: `ChainSource::InProcessCuprate { datadir }`.
- src/wallet_child.rs: starts/holds/stops the node, serializes the choice as
`kind = "cuprate"`, and adds `chain_datadir` so the storage gate covers both
local sources. It takes the app's Tokio handle (`with_runtime`): the launch is
async and `start()` runs on the TUI's blocking thread.
- src/node.rs: `wallet_child_start(runtime)`, `default_in_process_chain_source`.
- src/tui.rs: a fourth picker row, its testnet caveat, the chain block copy, and
a stop of the app-owned children on the quit path so they are not orphaned.
- tests/wallet.rs: a `cuprate-daemon`-gated end-to-end test that launches the
node and drives get_info / get_height / get_block through the typed daemon
client, including the above-the-tip 500 and the listener closing on drop.
- docs/WALLET.md: the fourth chain source, the feature flag, the +5.6 MB
stripped overhead, and the two limits (testnet only, no Tor in the chain
path).
Also repaired tests/tui_spec.rs, which the parent commit left un-compilable
(the Phase 2a commit had dropped all but the new imports and four new tests,
1221 lines of body); it is restored from the pre-breakage version, with the
Phase 2a imports and tests re-applied.
2026-09-17 13:17:32 -04:00
/// The four choices the picker offers, in order. A public node is never one of
2026-09-15 12:29:16 -04:00
/// them and a remote daemon is never preselected.
#[ derive(Debug, Clone, Copy, PartialEq, Eq) ]
pub enum ChainChoice {
ReceiveOnly ,
LocalMonerod ,
wallet: in-process Cuprate chain daemon behind the cuprate-daemon feature
Phase 1 of the Cuprate integration strategy: the chain daemon can run inside
the OnionWire process instead of a spawned `monerod`. `monero-wallet-rpc` is
unchanged — it still dials the unrestricted loopback RPC on 127.0.0.1:18081,
which is the address `WalletChild::daemon_address` already returned — so no
wallet-layer code moves.
- Cargo.toml: `cuprated` (git, rev 4f8fcd1b) + `toml`, both optional, behind a
`cuprate-daemon` feature that is OFF by default. Cuprate's own `arti` feature
stays off: its arti-client 0.44 cannot unify with this crate's 0.46, and the
in-process daemon is clearnet-only, so this keeps one Tor stack in the
process. `Cargo.lock` gains the graph; no arti 0.44 appears in it.
- src/cuprate.rs (new): `CuprateNode` builds the cuprated config as TOML
(testnet, unrestricted RPC on loopback, restricted RPC disabled, inbound P2P
off), launches it, and owns it. Dropping the value is the teardown;
`shutdown()` is called before the drop so the services can drain. The type
exists in every build: without the feature `launch` fails with the feature
name instead of silently doing nothing, so the chain-source type, its stored
record and the picker do not fork on a cargo feature.
- src/wallet.rs: `ChainSource::InProcessCuprate { datadir }`.
- src/wallet_child.rs: starts/holds/stops the node, serializes the choice as
`kind = "cuprate"`, and adds `chain_datadir` so the storage gate covers both
local sources. It takes the app's Tokio handle (`with_runtime`): the launch is
async and `start()` runs on the TUI's blocking thread.
- src/node.rs: `wallet_child_start(runtime)`, `default_in_process_chain_source`.
- src/tui.rs: a fourth picker row, its testnet caveat, the chain block copy, and
a stop of the app-owned children on the quit path so they are not orphaned.
- tests/wallet.rs: a `cuprate-daemon`-gated end-to-end test that launches the
node and drives get_info / get_height / get_block through the typed daemon
client, including the above-the-tip 500 and the listener closing on drop.
- docs/WALLET.md: the fourth chain source, the feature flag, the +5.6 MB
stripped overhead, and the two limits (testnet only, no Tor in the chain
path).
Also repaired tests/tui_spec.rs, which the parent commit left un-compilable
(the Phase 2a commit had dropped all but the new imports and four new tests,
1221 lines of body); it is restored from the pre-breakage version, with the
Phase 2a imports and tests re-applied.
2026-09-17 13:17:32 -04:00
InProcessCuprate ,
2026-09-15 12:29:16 -04:00
RemoteDaemon ,
}
impl ChainChoice {
wallet: in-process Cuprate chain daemon behind the cuprate-daemon feature
Phase 1 of the Cuprate integration strategy: the chain daemon can run inside
the OnionWire process instead of a spawned `monerod`. `monero-wallet-rpc` is
unchanged — it still dials the unrestricted loopback RPC on 127.0.0.1:18081,
which is the address `WalletChild::daemon_address` already returned — so no
wallet-layer code moves.
- Cargo.toml: `cuprated` (git, rev 4f8fcd1b) + `toml`, both optional, behind a
`cuprate-daemon` feature that is OFF by default. Cuprate's own `arti` feature
stays off: its arti-client 0.44 cannot unify with this crate's 0.46, and the
in-process daemon is clearnet-only, so this keeps one Tor stack in the
process. `Cargo.lock` gains the graph; no arti 0.44 appears in it.
- src/cuprate.rs (new): `CuprateNode` builds the cuprated config as TOML
(testnet, unrestricted RPC on loopback, restricted RPC disabled, inbound P2P
off), launches it, and owns it. Dropping the value is the teardown;
`shutdown()` is called before the drop so the services can drain. The type
exists in every build: without the feature `launch` fails with the feature
name instead of silently doing nothing, so the chain-source type, its stored
record and the picker do not fork on a cargo feature.
- src/wallet.rs: `ChainSource::InProcessCuprate { datadir }`.
- src/wallet_child.rs: starts/holds/stops the node, serializes the choice as
`kind = "cuprate"`, and adds `chain_datadir` so the storage gate covers both
local sources. It takes the app's Tokio handle (`with_runtime`): the launch is
async and `start()` runs on the TUI's blocking thread.
- src/node.rs: `wallet_child_start(runtime)`, `default_in_process_chain_source`.
- src/tui.rs: a fourth picker row, its testnet caveat, the chain block copy, and
a stop of the app-owned children on the quit path so they are not orphaned.
- tests/wallet.rs: a `cuprate-daemon`-gated end-to-end test that launches the
node and drives get_info / get_height / get_block through the typed daemon
client, including the above-the-tip 500 and the listener closing on drop.
- docs/WALLET.md: the fourth chain source, the feature flag, the +5.6 MB
stripped overhead, and the two limits (testnet only, no Tor in the chain
path).
Also repaired tests/tui_spec.rs, which the parent commit left un-compilable
(the Phase 2a commit had dropped all but the new imports and four new tests,
1221 lines of body); it is restored from the pre-breakage version, with the
Phase 2a imports and tests re-applied.
2026-09-17 13:17:32 -04:00
pub const ALL : [ ChainChoice ; 4 ] = [
Self ::ReceiveOnly ,
Self ::LocalMonerod ,
Self ::InProcessCuprate ,
Self ::RemoteDaemon ,
] ;
2026-09-15 12:29:16 -04:00
pub fn label ( self ) -> & 'static str {
match self {
Self ::ReceiveOnly = > " receive-only (no daemon) " ,
Self ::LocalMonerod = > " spawn a local monerod " ,
wallet: in-process Cuprate chain daemon behind the cuprate-daemon feature
Phase 1 of the Cuprate integration strategy: the chain daemon can run inside
the OnionWire process instead of a spawned `monerod`. `monero-wallet-rpc` is
unchanged — it still dials the unrestricted loopback RPC on 127.0.0.1:18081,
which is the address `WalletChild::daemon_address` already returned — so no
wallet-layer code moves.
- Cargo.toml: `cuprated` (git, rev 4f8fcd1b) + `toml`, both optional, behind a
`cuprate-daemon` feature that is OFF by default. Cuprate's own `arti` feature
stays off: its arti-client 0.44 cannot unify with this crate's 0.46, and the
in-process daemon is clearnet-only, so this keeps one Tor stack in the
process. `Cargo.lock` gains the graph; no arti 0.44 appears in it.
- src/cuprate.rs (new): `CuprateNode` builds the cuprated config as TOML
(testnet, unrestricted RPC on loopback, restricted RPC disabled, inbound P2P
off), launches it, and owns it. Dropping the value is the teardown;
`shutdown()` is called before the drop so the services can drain. The type
exists in every build: without the feature `launch` fails with the feature
name instead of silently doing nothing, so the chain-source type, its stored
record and the picker do not fork on a cargo feature.
- src/wallet.rs: `ChainSource::InProcessCuprate { datadir }`.
- src/wallet_child.rs: starts/holds/stops the node, serializes the choice as
`kind = "cuprate"`, and adds `chain_datadir` so the storage gate covers both
local sources. It takes the app's Tokio handle (`with_runtime`): the launch is
async and `start()` runs on the TUI's blocking thread.
- src/node.rs: `wallet_child_start(runtime)`, `default_in_process_chain_source`.
- src/tui.rs: a fourth picker row, its testnet caveat, the chain block copy, and
a stop of the app-owned children on the quit path so they are not orphaned.
- tests/wallet.rs: a `cuprate-daemon`-gated end-to-end test that launches the
node and drives get_info / get_height / get_block through the typed daemon
client, including the above-the-tip 500 and the listener closing on drop.
- docs/WALLET.md: the fourth chain source, the feature flag, the +5.6 MB
stripped overhead, and the two limits (testnet only, no Tor in the chain
path).
Also repaired tests/tui_spec.rs, which the parent commit left un-compilable
(the Phase 2a commit had dropped all but the new imports and four new tests,
1221 lines of body); it is restored from the pre-breakage version, with the
Phase 2a imports and tests re-applied.
2026-09-17 13:17:32 -04:00
Self ::InProcessCuprate = > " run an in-process daemon " ,
2026-09-15 12:29:16 -04:00
Self ::RemoteDaemon = > " enter a daemon address " ,
}
}
wallet: in-process Cuprate chain daemon behind the cuprate-daemon feature
Phase 1 of the Cuprate integration strategy: the chain daemon can run inside
the OnionWire process instead of a spawned `monerod`. `monero-wallet-rpc` is
unchanged — it still dials the unrestricted loopback RPC on 127.0.0.1:18081,
which is the address `WalletChild::daemon_address` already returned — so no
wallet-layer code moves.
- Cargo.toml: `cuprated` (git, rev 4f8fcd1b) + `toml`, both optional, behind a
`cuprate-daemon` feature that is OFF by default. Cuprate's own `arti` feature
stays off: its arti-client 0.44 cannot unify with this crate's 0.46, and the
in-process daemon is clearnet-only, so this keeps one Tor stack in the
process. `Cargo.lock` gains the graph; no arti 0.44 appears in it.
- src/cuprate.rs (new): `CuprateNode` builds the cuprated config as TOML
(testnet, unrestricted RPC on loopback, restricted RPC disabled, inbound P2P
off), launches it, and owns it. Dropping the value is the teardown;
`shutdown()` is called before the drop so the services can drain. The type
exists in every build: without the feature `launch` fails with the feature
name instead of silently doing nothing, so the chain-source type, its stored
record and the picker do not fork on a cargo feature.
- src/wallet.rs: `ChainSource::InProcessCuprate { datadir }`.
- src/wallet_child.rs: starts/holds/stops the node, serializes the choice as
`kind = "cuprate"`, and adds `chain_datadir` so the storage gate covers both
local sources. It takes the app's Tokio handle (`with_runtime`): the launch is
async and `start()` runs on the TUI's blocking thread.
- src/node.rs: `wallet_child_start(runtime)`, `default_in_process_chain_source`.
- src/tui.rs: a fourth picker row, its testnet caveat, the chain block copy, and
a stop of the app-owned children on the quit path so they are not orphaned.
- tests/wallet.rs: a `cuprate-daemon`-gated end-to-end test that launches the
node and drives get_info / get_height / get_block through the typed daemon
client, including the above-the-tip 500 and the listener closing on drop.
- docs/WALLET.md: the fourth chain source, the feature flag, the +5.6 MB
stripped overhead, and the two limits (testnet only, no Tor in the chain
path).
Also repaired tests/tui_spec.rs, which the parent commit left un-compilable
(the Phase 2a commit had dropped all but the new imports and four new tests,
1221 lines of body); it is restored from the pre-breakage version, with the
Phase 2a imports and tests re-applied.
2026-09-17 13:17:32 -04:00
/// One line under the label, so the choice is not a mystery. The in-process
/// row carries [`crate::cuprate::TESTNET_ONLY`]'s fact: it is not a daemon
/// the user can treat as a mainnet node yet.
2026-09-15 12:29:16 -04:00
pub fn detail ( self ) -> & 'static str {
match self {
Self ::ReceiveOnly = > " chain traffic stays off this device entirely " ,
Self ::LocalMonerod = > " the app owns monerod; chain stays on this device " ,
wallet: in-process Cuprate chain daemon behind the cuprate-daemon feature
Phase 1 of the Cuprate integration strategy: the chain daemon can run inside
the OnionWire process instead of a spawned `monerod`. `monero-wallet-rpc` is
unchanged — it still dials the unrestricted loopback RPC on 127.0.0.1:18081,
which is the address `WalletChild::daemon_address` already returned — so no
wallet-layer code moves.
- Cargo.toml: `cuprated` (git, rev 4f8fcd1b) + `toml`, both optional, behind a
`cuprate-daemon` feature that is OFF by default. Cuprate's own `arti` feature
stays off: its arti-client 0.44 cannot unify with this crate's 0.46, and the
in-process daemon is clearnet-only, so this keeps one Tor stack in the
process. `Cargo.lock` gains the graph; no arti 0.44 appears in it.
- src/cuprate.rs (new): `CuprateNode` builds the cuprated config as TOML
(testnet, unrestricted RPC on loopback, restricted RPC disabled, inbound P2P
off), launches it, and owns it. Dropping the value is the teardown;
`shutdown()` is called before the drop so the services can drain. The type
exists in every build: without the feature `launch` fails with the feature
name instead of silently doing nothing, so the chain-source type, its stored
record and the picker do not fork on a cargo feature.
- src/wallet.rs: `ChainSource::InProcessCuprate { datadir }`.
- src/wallet_child.rs: starts/holds/stops the node, serializes the choice as
`kind = "cuprate"`, and adds `chain_datadir` so the storage gate covers both
local sources. It takes the app's Tokio handle (`with_runtime`): the launch is
async and `start()` runs on the TUI's blocking thread.
- src/node.rs: `wallet_child_start(runtime)`, `default_in_process_chain_source`.
- src/tui.rs: a fourth picker row, its testnet caveat, the chain block copy, and
a stop of the app-owned children on the quit path so they are not orphaned.
- tests/wallet.rs: a `cuprate-daemon`-gated end-to-end test that launches the
node and drives get_info / get_height / get_block through the typed daemon
client, including the above-the-tip 500 and the listener closing on drop.
- docs/WALLET.md: the fourth chain source, the feature flag, the +5.6 MB
stripped overhead, and the two limits (testnet only, no Tor in the chain
path).
Also repaired tests/tui_spec.rs, which the parent commit left un-compilable
(the Phase 2a commit had dropped all but the new imports and four new tests,
1221 lines of body); it is restored from the pre-breakage version, with the
Phase 2a imports and tests re-applied.
2026-09-17 13:17:32 -04:00
Self ::InProcessCuprate = > " Cuprate in this app: testnet only, no binary " ,
2026-09-15 12:29:16 -04:00
Self ::RemoteDaemon = > " someone else's daemon: they see your addresses " ,
}
}
/// Which choice the stored source corresponds to. A stored source is shown
/// as the current pick, never as a preselected remote.
pub fn of ( source : & ChainSource ) -> Self {
match source {
ChainSource ::None = > Self ::ReceiveOnly ,
ChainSource ::Local { .. } = > Self ::LocalMonerod ,
wallet: in-process Cuprate chain daemon behind the cuprate-daemon feature
Phase 1 of the Cuprate integration strategy: the chain daemon can run inside
the OnionWire process instead of a spawned `monerod`. `monero-wallet-rpc` is
unchanged — it still dials the unrestricted loopback RPC on 127.0.0.1:18081,
which is the address `WalletChild::daemon_address` already returned — so no
wallet-layer code moves.
- Cargo.toml: `cuprated` (git, rev 4f8fcd1b) + `toml`, both optional, behind a
`cuprate-daemon` feature that is OFF by default. Cuprate's own `arti` feature
stays off: its arti-client 0.44 cannot unify with this crate's 0.46, and the
in-process daemon is clearnet-only, so this keeps one Tor stack in the
process. `Cargo.lock` gains the graph; no arti 0.44 appears in it.
- src/cuprate.rs (new): `CuprateNode` builds the cuprated config as TOML
(testnet, unrestricted RPC on loopback, restricted RPC disabled, inbound P2P
off), launches it, and owns it. Dropping the value is the teardown;
`shutdown()` is called before the drop so the services can drain. The type
exists in every build: without the feature `launch` fails with the feature
name instead of silently doing nothing, so the chain-source type, its stored
record and the picker do not fork on a cargo feature.
- src/wallet.rs: `ChainSource::InProcessCuprate { datadir }`.
- src/wallet_child.rs: starts/holds/stops the node, serializes the choice as
`kind = "cuprate"`, and adds `chain_datadir` so the storage gate covers both
local sources. It takes the app's Tokio handle (`with_runtime`): the launch is
async and `start()` runs on the TUI's blocking thread.
- src/node.rs: `wallet_child_start(runtime)`, `default_in_process_chain_source`.
- src/tui.rs: a fourth picker row, its testnet caveat, the chain block copy, and
a stop of the app-owned children on the quit path so they are not orphaned.
- tests/wallet.rs: a `cuprate-daemon`-gated end-to-end test that launches the
node and drives get_info / get_height / get_block through the typed daemon
client, including the above-the-tip 500 and the listener closing on drop.
- docs/WALLET.md: the fourth chain source, the feature flag, the +5.6 MB
stripped overhead, and the two limits (testnet only, no Tor in the chain
path).
Also repaired tests/tui_spec.rs, which the parent commit left un-compilable
(the Phase 2a commit had dropped all but the new imports and four new tests,
1221 lines of body); it is restored from the pre-breakage version, with the
Phase 2a imports and tests re-applied.
2026-09-17 13:17:32 -04:00
ChainSource ::InProcessCuprate { .. } = > Self ::InProcessCuprate ,
2026-09-15 12:29:16 -04:00
ChainSource ::Remote { .. } = > Self ::RemoteDaemon ,
}
}
}
enum ChainSetup {
Choose {
index : usize ,
} ,
RemoteAddr {
buf : String ,
err : Option < String > ,
} ,
/// The trust shift, shown before anything is saved.
RemoteWarn {
host : String ,
port : u16 ,
onion : bool ,
} ,
}
/// What the F6 wallet screen draws. Built through [`wallet_view`] so the
/// not-ready rules are testable without a live node.
pub struct WalletView {
pub receive_addr : String ,
pub balance : String ,
pub transfers : Vec < wallet ::TransferRow > ,
pub chain : ChainView ,
tui(wallet): chain/daemon honesty, view-only badge, address copy (OSC 52)
- Screen::Wallet.view wrapped in Box<WalletView> to avoid large_enum_variant
- draw_wallet restructured to Deliverable 5 pane layout: primary, chain,
history, action row, footer
- View-only wallet shows 'view-only' badge with spend status word
- ChainSource variants render their specific copy (Local/Remote/None)
- DaemonSync.reachable=false renders 'sync: unknown' with no balance claim
- Address copy via OSC 52 escape sequence; 'y' key; fallback hint on screen
- QR modal resized to fit 80x24 without clipping
- wallet_screen_at_with() test helper for copy_note parameter
- 33 new tests covering receive-only, local synced/syncing, remote
unreachable, view-only badge, QR modal, address copy escape sequence
All 52 TUI tests pass (10 tui_frames + 19 tui_chrome + 23 tui_spec).
Clippy clean on lib and all three test targets.
2026-09-15 19:57:29 -04:00
/// `no_spend` — the wallet can receive but `/tip` is refused locally.
/// Shows a `view-only` badge (glyph + word), never color-only.
pub no_spend : bool ,
2026-09-15 12:29:16 -04:00
}
/// Assemble the wallet screen, applying the one rule that matters: while the
/// wallet is not ready the balance is **not** rendered as a fact.
pub fn wallet_view (
receive_addr : String ,
balance : String ,
transfers : Vec < wallet ::TransferRow > ,
chain : ChainView ,
tui(wallet): chain/daemon honesty, view-only badge, address copy (OSC 52)
- Screen::Wallet.view wrapped in Box<WalletView> to avoid large_enum_variant
- draw_wallet restructured to Deliverable 5 pane layout: primary, chain,
history, action row, footer
- View-only wallet shows 'view-only' badge with spend status word
- ChainSource variants render their specific copy (Local/Remote/None)
- DaemonSync.reachable=false renders 'sync: unknown' with no balance claim
- Address copy via OSC 52 escape sequence; 'y' key; fallback hint on screen
- QR modal resized to fit 80x24 without clipping
- wallet_screen_at_with() test helper for copy_note parameter
- 33 new tests covering receive-only, local synced/syncing, remote
unreachable, view-only badge, QR modal, address copy escape sequence
All 52 TUI tests pass (10 tui_frames + 19 tui_chrome + 23 tui_spec).
Clippy clean on lib and all three test targets.
2026-09-15 19:57:29 -04:00
no_spend : bool ,
2026-09-15 12:29:16 -04:00
) -> WalletView {
if chain . ready {
WalletView {
receive_addr ,
balance ,
transfers ,
chain ,
tui(wallet): chain/daemon honesty, view-only badge, address copy (OSC 52)
- Screen::Wallet.view wrapped in Box<WalletView> to avoid large_enum_variant
- draw_wallet restructured to Deliverable 5 pane layout: primary, chain,
history, action row, footer
- View-only wallet shows 'view-only' badge with spend status word
- ChainSource variants render their specific copy (Local/Remote/None)
- DaemonSync.reachable=false renders 'sync: unknown' with no balance claim
- Address copy via OSC 52 escape sequence; 'y' key; fallback hint on screen
- QR modal resized to fit 80x24 without clipping
- wallet_screen_at_with() test helper for copy_note parameter
- 33 new tests covering receive-only, local synced/syncing, remote
unreachable, view-only badge, QR modal, address copy escape sequence
All 52 TUI tests pass (10 tui_frames + 19 tui_chrome + 23 tui_spec).
Clippy clean on lib and all three test targets.
2026-09-15 19:57:29 -04:00
no_spend ,
2026-09-15 12:29:16 -04:00
}
} else {
WalletView {
receive_addr ,
balance : " not synced — unavailable " . to_string ( ) ,
transfers : Vec ::new ( ) ,
chain ,
tui(wallet): chain/daemon honesty, view-only badge, address copy (OSC 52)
- Screen::Wallet.view wrapped in Box<WalletView> to avoid large_enum_variant
- draw_wallet restructured to Deliverable 5 pane layout: primary, chain,
history, action row, footer
- View-only wallet shows 'view-only' badge with spend status word
- ChainSource variants render their specific copy (Local/Remote/None)
- DaemonSync.reachable=false renders 'sync: unknown' with no balance claim
- Address copy via OSC 52 escape sequence; 'y' key; fallback hint on screen
- QR modal resized to fit 80x24 without clipping
- wallet_screen_at_with() test helper for copy_note parameter
- 33 new tests covering receive-only, local synced/syncing, remote
unreachable, view-only badge, QR modal, address copy escape sequence
All 52 TUI tests pass (10 tui_frames + 19 tui_chrome + 23 tui_spec).
Clippy clean on lib and all three test targets.
2026-09-15 19:57:29 -04:00
no_spend ,
2026-09-15 12:29:16 -04:00
}
}
}
wallet: typed chain-daemon client for the Cuprate parity gaps
The chain probe was a hand-rolled brace-scanner in `src/node.rs`. Cuprate
breaks three of its assumptions, all measured in Spike A
(`docs/cuprate-launch-spike.md` §Parity gaps, evidence in that spike's
`rpc-evidence/`):
1. **A height above the tip is a bare HTTP 500 with an empty body.** monerod
answers a JSON-RPC error object instead (`TOO_BIG_HEIGHT`, code -2). The
client now parses the HTTP status once, de-chunks `Transfer-Encoding:
chunked` bodies (axum/hyper; the old brace-scan is not a parse once a blob
spans more than one chunk), and maps both spellings of the height failure to
one typed `WalletError::DaemonHeightOutOfRange`. `get_height` and `get_block`
are height-addressed: their 5xx is the height error. `get_info` is not: its
5xx is `WalletError::DaemonHttpStatus`.
2. **`get_info` metrics are not measurements.** Cuprate reports zero peers while
it downloads blocks, its restricted server answers a placeholder
`database_size` (exactly 5 GiB) and an empty `version`, and `free_space` is
`u64::MAX` on both servers. `DaemonInfo` carries height and target only, so
there is no field for a placeholder to reach the UI. The wallet screen's sync
line is now built from block-height movement between two probes: "connected
to P2P" needs the height to have moved, "no new blocks" is what a stalled
daemon gets, and Cuprate's at-rest `synchronized = true` with
`target_height = 0` reads as unknown instead of `1160/0`.
3. **`get_height` is a URI endpoint**: `{"method":"get_height"}` over
`/json_rpc` is rejected with 422, so the client uses `GET /get_height`, which
both daemons answer. The wallet-child routing rule is pinned too: it dials
the daemon's *unrestricted* listener (monerod's `--rpc-bind-port`, and
whatever port an in-process Cuprate binds for `[rpc.unrestricted]`), never the
restricted one — a restricted listener answers, so a mix-up shows up as a
wrong number rather than as an error.
Scope deviations, stated plainly:
- the card names `src/wallet.rs` + the TUI bindings. The probe itself lived in
`src/node.rs`; it now delegates (net -100 lines there), and the routing
constant/test live in `src/wallet_child.rs`. Tests are in `tests/wallet.rs`,
`tests/tui_spec.rs` and `src/wallet_child.rs`'s test module.
- `daemon_get_block()` is **not called by anything yet**: it is the entry point
the wallet's own block scan (Phase 2) needs, and the out-of-range answer it has
to survive is item 1, so the mapping lives with the client.
- the card's item 3 gives the unrestricted port as 18089 and the restricted one
as 28089. In monerod's numbering 18089 *is* the restricted port; the app's
local source already dials the unrestricted 18081. The rule is what is pinned,
not those numbers.
- `docs/cuprate-launch-spike.md` merged to `main` after this branch's base
commit, so it is not in this tree and its Recommendation bullets are not
updated here.
- based on `feat/wallet-create-import` (the wallet line, unmerged): the daemon
client has no home on `main`. Retarget to `main` when that line lands.
Proof: `cargo test --locked` 306 passed / 0 failed, `cargo clippy --locked
--all-targets -- -D warnings` clean, `rustfmt --edition 2024 --check` adds no
hunk to any file (the inherited hunks in `src/node.rs`/`src/tui.rs`/
`tests/tui_spec.rs` are unchanged in count or region).
2026-09-17 00:24:09 -04:00
/// The sync line: what the daemon's own numbers say, and nothing else.
///
/// Connectivity is inferred from **block-height movement** between two probes.
/// It is never inferred from `get_info` peer counts (Cuprate answers
/// `outgoing_connections_count = 0` while it is downloading blocks) and never
/// from `database_size`/`free_space`/`version` (its restricted server answers a
/// 5 GiB placeholder, `u64::MAX` and an empty string).
///
/// `previous_height` is the height of the previous probe on this screen, or
/// `None` when there is no earlier sample to compare with.
pub fn sync_line ( sync : & DaemonSync , previous_height : Option < u64 > ) -> String {
if ! sync . reachable {
return format! (
" sync: unknown — {} " ,
sync . note . as_deref ( ) . unwrap_or ( " no daemon " )
) ;
}
if sync . target_height = = 0 {
// No target is not "caught up": Cuprate says `synchronized = true` with
// `target_height = 0` while it has no peers to sync from. Showing
// `1160/0` would dress that up as progress.
return format! (
" sync: unknown — daemon reports no chain target (height {}) " ,
sync . height
) ;
}
if sync . height > = sync . target_height {
return format! ( " sync: synced — height {} " , sync . height ) ;
}
match previous_height {
Some ( previous ) if previous < sync . height = > format! (
" sync: connected to P2P — syncing {}/{} " ,
sync . height , sync . target_height
) ,
Some ( _ ) = > format! (
" sync: no new blocks — {}/{} (daemon answering, no progress) " ,
sync . height , sync . target_height
) ,
None = > format! ( " sync: syncing — {} / {} " , sync . height , sync . target_height ) ,
}
}
2026-09-15 12:29:16 -04:00
/// Pure builder for the chain block: every honest-status rule lives here.
wallet: typed chain-daemon client for the Cuprate parity gaps
The chain probe was a hand-rolled brace-scanner in `src/node.rs`. Cuprate
breaks three of its assumptions, all measured in Spike A
(`docs/cuprate-launch-spike.md` §Parity gaps, evidence in that spike's
`rpc-evidence/`):
1. **A height above the tip is a bare HTTP 500 with an empty body.** monerod
answers a JSON-RPC error object instead (`TOO_BIG_HEIGHT`, code -2). The
client now parses the HTTP status once, de-chunks `Transfer-Encoding:
chunked` bodies (axum/hyper; the old brace-scan is not a parse once a blob
spans more than one chunk), and maps both spellings of the height failure to
one typed `WalletError::DaemonHeightOutOfRange`. `get_height` and `get_block`
are height-addressed: their 5xx is the height error. `get_info` is not: its
5xx is `WalletError::DaemonHttpStatus`.
2. **`get_info` metrics are not measurements.** Cuprate reports zero peers while
it downloads blocks, its restricted server answers a placeholder
`database_size` (exactly 5 GiB) and an empty `version`, and `free_space` is
`u64::MAX` on both servers. `DaemonInfo` carries height and target only, so
there is no field for a placeholder to reach the UI. The wallet screen's sync
line is now built from block-height movement between two probes: "connected
to P2P" needs the height to have moved, "no new blocks" is what a stalled
daemon gets, and Cuprate's at-rest `synchronized = true` with
`target_height = 0` reads as unknown instead of `1160/0`.
3. **`get_height` is a URI endpoint**: `{"method":"get_height"}` over
`/json_rpc` is rejected with 422, so the client uses `GET /get_height`, which
both daemons answer. The wallet-child routing rule is pinned too: it dials
the daemon's *unrestricted* listener (monerod's `--rpc-bind-port`, and
whatever port an in-process Cuprate binds for `[rpc.unrestricted]`), never the
restricted one — a restricted listener answers, so a mix-up shows up as a
wrong number rather than as an error.
Scope deviations, stated plainly:
- the card names `src/wallet.rs` + the TUI bindings. The probe itself lived in
`src/node.rs`; it now delegates (net -100 lines there), and the routing
constant/test live in `src/wallet_child.rs`. Tests are in `tests/wallet.rs`,
`tests/tui_spec.rs` and `src/wallet_child.rs`'s test module.
- `daemon_get_block()` is **not called by anything yet**: it is the entry point
the wallet's own block scan (Phase 2) needs, and the out-of-range answer it has
to survive is item 1, so the mapping lives with the client.
- the card's item 3 gives the unrestricted port as 18089 and the restricted one
as 28089. In monerod's numbering 18089 *is* the restricted port; the app's
local source already dials the unrestricted 18081. The rule is what is pinned,
not those numbers.
- `docs/cuprate-launch-spike.md` merged to `main` after this branch's base
commit, so it is not in this tree and its Recommendation bullets are not
updated here.
- based on `feat/wallet-create-import` (the wallet line, unmerged): the daemon
client has no home on `main`. Retarget to `main` when that line lands.
Proof: `cargo test --locked` 306 passed / 0 failed, `cargo clippy --locked
--all-targets -- -D warnings` clean, `rustfmt --edition 2024 --check` adds no
hunk to any file (the inherited hunks in `src/node.rs`/`src/tui.rs`/
`tests/tui_spec.rs` are unchanged in count or region).
2026-09-17 00:24:09 -04:00
///
/// The no-history form: callers that have no earlier probe to compare with (the
/// frame tests, the first draw) get the same lines they always did.
2026-09-15 12:29:16 -04:00
pub fn chain_view (
source : & ChainSource ,
child : WalletChildState ,
sync : & DaemonSync ,
free_gb : Option < u64 > ,
readiness : WalletReadiness ,
wallet: typed chain-daemon client for the Cuprate parity gaps
The chain probe was a hand-rolled brace-scanner in `src/node.rs`. Cuprate
breaks three of its assumptions, all measured in Spike A
(`docs/cuprate-launch-spike.md` §Parity gaps, evidence in that spike's
`rpc-evidence/`):
1. **A height above the tip is a bare HTTP 500 with an empty body.** monerod
answers a JSON-RPC error object instead (`TOO_BIG_HEIGHT`, code -2). The
client now parses the HTTP status once, de-chunks `Transfer-Encoding:
chunked` bodies (axum/hyper; the old brace-scan is not a parse once a blob
spans more than one chunk), and maps both spellings of the height failure to
one typed `WalletError::DaemonHeightOutOfRange`. `get_height` and `get_block`
are height-addressed: their 5xx is the height error. `get_info` is not: its
5xx is `WalletError::DaemonHttpStatus`.
2. **`get_info` metrics are not measurements.** Cuprate reports zero peers while
it downloads blocks, its restricted server answers a placeholder
`database_size` (exactly 5 GiB) and an empty `version`, and `free_space` is
`u64::MAX` on both servers. `DaemonInfo` carries height and target only, so
there is no field for a placeholder to reach the UI. The wallet screen's sync
line is now built from block-height movement between two probes: "connected
to P2P" needs the height to have moved, "no new blocks" is what a stalled
daemon gets, and Cuprate's at-rest `synchronized = true` with
`target_height = 0` reads as unknown instead of `1160/0`.
3. **`get_height` is a URI endpoint**: `{"method":"get_height"}` over
`/json_rpc` is rejected with 422, so the client uses `GET /get_height`, which
both daemons answer. The wallet-child routing rule is pinned too: it dials
the daemon's *unrestricted* listener (monerod's `--rpc-bind-port`, and
whatever port an in-process Cuprate binds for `[rpc.unrestricted]`), never the
restricted one — a restricted listener answers, so a mix-up shows up as a
wrong number rather than as an error.
Scope deviations, stated plainly:
- the card names `src/wallet.rs` + the TUI bindings. The probe itself lived in
`src/node.rs`; it now delegates (net -100 lines there), and the routing
constant/test live in `src/wallet_child.rs`. Tests are in `tests/wallet.rs`,
`tests/tui_spec.rs` and `src/wallet_child.rs`'s test module.
- `daemon_get_block()` is **not called by anything yet**: it is the entry point
the wallet's own block scan (Phase 2) needs, and the out-of-range answer it has
to survive is item 1, so the mapping lives with the client.
- the card's item 3 gives the unrestricted port as 18089 and the restricted one
as 28089. In monerod's numbering 18089 *is* the restricted port; the app's
local source already dials the unrestricted 18081. The rule is what is pinned,
not those numbers.
- `docs/cuprate-launch-spike.md` merged to `main` after this branch's base
commit, so it is not in this tree and its Recommendation bullets are not
updated here.
- based on `feat/wallet-create-import` (the wallet line, unmerged): the daemon
client has no home on `main`. Retarget to `main` when that line lands.
Proof: `cargo test --locked` 306 passed / 0 failed, `cargo clippy --locked
--all-targets -- -D warnings` clean, `rustfmt --edition 2024 --check` adds no
hunk to any file (the inherited hunks in `src/node.rs`/`src/tui.rs`/
`tests/tui_spec.rs` are unchanged in count or region).
2026-09-17 00:24:09 -04:00
) -> ChainView {
chain_view_with_progress ( source , child , sync , free_gb , readiness , None )
}
/// [`chain_view`] with the previous probe's height, which is what the live
/// screen passes: it is the only input that can tell "syncing" apart from
/// "connected but stalled".
pub fn chain_view_with_progress (
source : & ChainSource ,
child : WalletChildState ,
sync : & DaemonSync ,
free_gb : Option < u64 > ,
readiness : WalletReadiness ,
previous_height : Option < u64 > ,
2026-09-15 12:29:16 -04:00
) -> ChainView {
let source_line = match source {
ChainSource ::None = > " chain: receive-only — no daemon, no chain traffic " . to_string ( ) ,
ChainSource ::Local {
monerod_bin ,
datadir ,
} = > format! (
" chain: local monerod ({}) — chain in {} " ,
monerod_bin . display ( ) ,
datadir . display ( )
) ,
wallet: in-process Cuprate chain daemon behind the cuprate-daemon feature
Phase 1 of the Cuprate integration strategy: the chain daemon can run inside
the OnionWire process instead of a spawned `monerod`. `monero-wallet-rpc` is
unchanged — it still dials the unrestricted loopback RPC on 127.0.0.1:18081,
which is the address `WalletChild::daemon_address` already returned — so no
wallet-layer code moves.
- Cargo.toml: `cuprated` (git, rev 4f8fcd1b) + `toml`, both optional, behind a
`cuprate-daemon` feature that is OFF by default. Cuprate's own `arti` feature
stays off: its arti-client 0.44 cannot unify with this crate's 0.46, and the
in-process daemon is clearnet-only, so this keeps one Tor stack in the
process. `Cargo.lock` gains the graph; no arti 0.44 appears in it.
- src/cuprate.rs (new): `CuprateNode` builds the cuprated config as TOML
(testnet, unrestricted RPC on loopback, restricted RPC disabled, inbound P2P
off), launches it, and owns it. Dropping the value is the teardown;
`shutdown()` is called before the drop so the services can drain. The type
exists in every build: without the feature `launch` fails with the feature
name instead of silently doing nothing, so the chain-source type, its stored
record and the picker do not fork on a cargo feature.
- src/wallet.rs: `ChainSource::InProcessCuprate { datadir }`.
- src/wallet_child.rs: starts/holds/stops the node, serializes the choice as
`kind = "cuprate"`, and adds `chain_datadir` so the storage gate covers both
local sources. It takes the app's Tokio handle (`with_runtime`): the launch is
async and `start()` runs on the TUI's blocking thread.
- src/node.rs: `wallet_child_start(runtime)`, `default_in_process_chain_source`.
- src/tui.rs: a fourth picker row, its testnet caveat, the chain block copy, and
a stop of the app-owned children on the quit path so they are not orphaned.
- tests/wallet.rs: a `cuprate-daemon`-gated end-to-end test that launches the
node and drives get_info / get_height / get_block through the typed daemon
client, including the above-the-tip 500 and the listener closing on drop.
- docs/WALLET.md: the fourth chain source, the feature flag, the +5.6 MB
stripped overhead, and the two limits (testnet only, no Tor in the chain
path).
Also repaired tests/tui_spec.rs, which the parent commit left un-compilable
(the Phase 2a commit had dropped all but the new imports and four new tests,
1221 lines of body); it is restored from the pre-breakage version, with the
Phase 2a imports and tests re-applied.
2026-09-17 13:17:32 -04:00
ChainSource ::InProcessCuprate { datadir } = > format! (
// The caveat is not decoration: this daemon runs testnet, and a
// user who reads it as a mainnet node would be misled.
" chain: in-process daemon — {}; chain in {} " ,
crate ::cuprate ::TESTNET_ONLY ,
datadir . display ( )
) ,
2026-09-15 12:29:16 -04:00
ChainSource ::Remote { host , port } = > format! ( " chain: remote daemon {host} : {port} " ) ,
} ;
let child_line = match child {
WalletChildState ::Off = > " daemon: not configured — press s to choose a chain source " ,
WalletChildState ::Stopped = > " daemon: stopped — press n to start it " ,
WalletChildState ::Running = > " daemon: running (child owned by this app) " ,
}
. to_string ( ) ;
wallet: typed chain-daemon client for the Cuprate parity gaps
The chain probe was a hand-rolled brace-scanner in `src/node.rs`. Cuprate
breaks three of its assumptions, all measured in Spike A
(`docs/cuprate-launch-spike.md` §Parity gaps, evidence in that spike's
`rpc-evidence/`):
1. **A height above the tip is a bare HTTP 500 with an empty body.** monerod
answers a JSON-RPC error object instead (`TOO_BIG_HEIGHT`, code -2). The
client now parses the HTTP status once, de-chunks `Transfer-Encoding:
chunked` bodies (axum/hyper; the old brace-scan is not a parse once a blob
spans more than one chunk), and maps both spellings of the height failure to
one typed `WalletError::DaemonHeightOutOfRange`. `get_height` and `get_block`
are height-addressed: their 5xx is the height error. `get_info` is not: its
5xx is `WalletError::DaemonHttpStatus`.
2. **`get_info` metrics are not measurements.** Cuprate reports zero peers while
it downloads blocks, its restricted server answers a placeholder
`database_size` (exactly 5 GiB) and an empty `version`, and `free_space` is
`u64::MAX` on both servers. `DaemonInfo` carries height and target only, so
there is no field for a placeholder to reach the UI. The wallet screen's sync
line is now built from block-height movement between two probes: "connected
to P2P" needs the height to have moved, "no new blocks" is what a stalled
daemon gets, and Cuprate's at-rest `synchronized = true` with
`target_height = 0` reads as unknown instead of `1160/0`.
3. **`get_height` is a URI endpoint**: `{"method":"get_height"}` over
`/json_rpc` is rejected with 422, so the client uses `GET /get_height`, which
both daemons answer. The wallet-child routing rule is pinned too: it dials
the daemon's *unrestricted* listener (monerod's `--rpc-bind-port`, and
whatever port an in-process Cuprate binds for `[rpc.unrestricted]`), never the
restricted one — a restricted listener answers, so a mix-up shows up as a
wrong number rather than as an error.
Scope deviations, stated plainly:
- the card names `src/wallet.rs` + the TUI bindings. The probe itself lived in
`src/node.rs`; it now delegates (net -100 lines there), and the routing
constant/test live in `src/wallet_child.rs`. Tests are in `tests/wallet.rs`,
`tests/tui_spec.rs` and `src/wallet_child.rs`'s test module.
- `daemon_get_block()` is **not called by anything yet**: it is the entry point
the wallet's own block scan (Phase 2) needs, and the out-of-range answer it has
to survive is item 1, so the mapping lives with the client.
- the card's item 3 gives the unrestricted port as 18089 and the restricted one
as 28089. In monerod's numbering 18089 *is* the restricted port; the app's
local source already dials the unrestricted 18081. The rule is what is pinned,
not those numbers.
- `docs/cuprate-launch-spike.md` merged to `main` after this branch's base
commit, so it is not in this tree and its Recommendation bullets are not
updated here.
- based on `feat/wallet-create-import` (the wallet line, unmerged): the daemon
client has no home on `main`. Retarget to `main` when that line lands.
Proof: `cargo test --locked` 306 passed / 0 failed, `cargo clippy --locked
--all-targets -- -D warnings` clean, `rustfmt --edition 2024 --check` adds no
hunk to any file (the inherited hunks in `src/node.rs`/`src/tui.rs`/
`tests/tui_spec.rs` are unchanged in count or region).
2026-09-17 00:24:09 -04:00
let sync_text = sync_line ( sync , previous_height ) ;
2026-09-15 12:29:16 -04:00
let storage_line = match ( source , free_gb ) {
wallet: in-process Cuprate chain daemon behind the cuprate-daemon feature
Phase 1 of the Cuprate integration strategy: the chain daemon can run inside
the OnionWire process instead of a spawned `monerod`. `monero-wallet-rpc` is
unchanged — it still dials the unrestricted loopback RPC on 127.0.0.1:18081,
which is the address `WalletChild::daemon_address` already returned — so no
wallet-layer code moves.
- Cargo.toml: `cuprated` (git, rev 4f8fcd1b) + `toml`, both optional, behind a
`cuprate-daemon` feature that is OFF by default. Cuprate's own `arti` feature
stays off: its arti-client 0.44 cannot unify with this crate's 0.46, and the
in-process daemon is clearnet-only, so this keeps one Tor stack in the
process. `Cargo.lock` gains the graph; no arti 0.44 appears in it.
- src/cuprate.rs (new): `CuprateNode` builds the cuprated config as TOML
(testnet, unrestricted RPC on loopback, restricted RPC disabled, inbound P2P
off), launches it, and owns it. Dropping the value is the teardown;
`shutdown()` is called before the drop so the services can drain. The type
exists in every build: without the feature `launch` fails with the feature
name instead of silently doing nothing, so the chain-source type, its stored
record and the picker do not fork on a cargo feature.
- src/wallet.rs: `ChainSource::InProcessCuprate { datadir }`.
- src/wallet_child.rs: starts/holds/stops the node, serializes the choice as
`kind = "cuprate"`, and adds `chain_datadir` so the storage gate covers both
local sources. It takes the app's Tokio handle (`with_runtime`): the launch is
async and `start()` runs on the TUI's blocking thread.
- src/node.rs: `wallet_child_start(runtime)`, `default_in_process_chain_source`.
- src/tui.rs: a fourth picker row, its testnet caveat, the chain block copy, and
a stop of the app-owned children on the quit path so they are not orphaned.
- tests/wallet.rs: a `cuprate-daemon`-gated end-to-end test that launches the
node and drives get_info / get_height / get_block through the typed daemon
client, including the above-the-tip 500 and the listener closing on drop.
- docs/WALLET.md: the fourth chain source, the feature flag, the +5.6 MB
stripped overhead, and the two limits (testnet only, no Tor in the chain
path).
Also repaired tests/tui_spec.rs, which the parent commit left un-compilable
(the Phase 2a commit had dropped all but the new imports and four new tests,
1221 lines of body); it is restored from the pre-breakage version, with the
Phase 2a imports and tests re-applied.
2026-09-17 13:17:32 -04:00
// Both local sources put the chain on this device's disk; only the
// *owner* of the daemon differs.
( ChainSource ::Local { .. } | ChainSource ::InProcessCuprate { .. } , Some ( gb ) ) = > format! (
2026-09-15 12:29:16 -04:00
" storage: {gb} GB free here — pruned mainnet wants ~50-60 GB, a full node ~200 GB "
) ,
wallet: in-process Cuprate chain daemon behind the cuprate-daemon feature
Phase 1 of the Cuprate integration strategy: the chain daemon can run inside
the OnionWire process instead of a spawned `monerod`. `monero-wallet-rpc` is
unchanged — it still dials the unrestricted loopback RPC on 127.0.0.1:18081,
which is the address `WalletChild::daemon_address` already returned — so no
wallet-layer code moves.
- Cargo.toml: `cuprated` (git, rev 4f8fcd1b) + `toml`, both optional, behind a
`cuprate-daemon` feature that is OFF by default. Cuprate's own `arti` feature
stays off: its arti-client 0.44 cannot unify with this crate's 0.46, and the
in-process daemon is clearnet-only, so this keeps one Tor stack in the
process. `Cargo.lock` gains the graph; no arti 0.44 appears in it.
- src/cuprate.rs (new): `CuprateNode` builds the cuprated config as TOML
(testnet, unrestricted RPC on loopback, restricted RPC disabled, inbound P2P
off), launches it, and owns it. Dropping the value is the teardown;
`shutdown()` is called before the drop so the services can drain. The type
exists in every build: without the feature `launch` fails with the feature
name instead of silently doing nothing, so the chain-source type, its stored
record and the picker do not fork on a cargo feature.
- src/wallet.rs: `ChainSource::InProcessCuprate { datadir }`.
- src/wallet_child.rs: starts/holds/stops the node, serializes the choice as
`kind = "cuprate"`, and adds `chain_datadir` so the storage gate covers both
local sources. It takes the app's Tokio handle (`with_runtime`): the launch is
async and `start()` runs on the TUI's blocking thread.
- src/node.rs: `wallet_child_start(runtime)`, `default_in_process_chain_source`.
- src/tui.rs: a fourth picker row, its testnet caveat, the chain block copy, and
a stop of the app-owned children on the quit path so they are not orphaned.
- tests/wallet.rs: a `cuprate-daemon`-gated end-to-end test that launches the
node and drives get_info / get_height / get_block through the typed daemon
client, including the above-the-tip 500 and the listener closing on drop.
- docs/WALLET.md: the fourth chain source, the feature flag, the +5.6 MB
stripped overhead, and the two limits (testnet only, no Tor in the chain
path).
Also repaired tests/tui_spec.rs, which the parent commit left un-compilable
(the Phase 2a commit had dropped all but the new imports and four new tests,
1221 lines of body); it is restored from the pre-breakage version, with the
Phase 2a imports and tests re-applied.
2026-09-17 13:17:32 -04:00
( ChainSource ::Local { .. } | ChainSource ::InProcessCuprate { .. } , None ) = > {
" storage: could not read free space " . to_string ( )
}
2026-09-15 12:29:16 -04:00
( ChainSource ::Remote { .. } , _ ) = > {
" storage: on the daemon operator's disk, not yours " . to_string ( )
}
( ChainSource ::None , _ ) = > " storage: nothing stored on this device " . to_string ( ) ,
} ;
ChainView {
source_line : truncate_chars ( & source_line , WALLET_LINE_MAX ) ,
child_line : truncate_chars ( & child_line , WALLET_LINE_MAX ) ,
wallet: typed chain-daemon client for the Cuprate parity gaps
The chain probe was a hand-rolled brace-scanner in `src/node.rs`. Cuprate
breaks three of its assumptions, all measured in Spike A
(`docs/cuprate-launch-spike.md` §Parity gaps, evidence in that spike's
`rpc-evidence/`):
1. **A height above the tip is a bare HTTP 500 with an empty body.** monerod
answers a JSON-RPC error object instead (`TOO_BIG_HEIGHT`, code -2). The
client now parses the HTTP status once, de-chunks `Transfer-Encoding:
chunked` bodies (axum/hyper; the old brace-scan is not a parse once a blob
spans more than one chunk), and maps both spellings of the height failure to
one typed `WalletError::DaemonHeightOutOfRange`. `get_height` and `get_block`
are height-addressed: their 5xx is the height error. `get_info` is not: its
5xx is `WalletError::DaemonHttpStatus`.
2. **`get_info` metrics are not measurements.** Cuprate reports zero peers while
it downloads blocks, its restricted server answers a placeholder
`database_size` (exactly 5 GiB) and an empty `version`, and `free_space` is
`u64::MAX` on both servers. `DaemonInfo` carries height and target only, so
there is no field for a placeholder to reach the UI. The wallet screen's sync
line is now built from block-height movement between two probes: "connected
to P2P" needs the height to have moved, "no new blocks" is what a stalled
daemon gets, and Cuprate's at-rest `synchronized = true` with
`target_height = 0` reads as unknown instead of `1160/0`.
3. **`get_height` is a URI endpoint**: `{"method":"get_height"}` over
`/json_rpc` is rejected with 422, so the client uses `GET /get_height`, which
both daemons answer. The wallet-child routing rule is pinned too: it dials
the daemon's *unrestricted* listener (monerod's `--rpc-bind-port`, and
whatever port an in-process Cuprate binds for `[rpc.unrestricted]`), never the
restricted one — a restricted listener answers, so a mix-up shows up as a
wrong number rather than as an error.
Scope deviations, stated plainly:
- the card names `src/wallet.rs` + the TUI bindings. The probe itself lived in
`src/node.rs`; it now delegates (net -100 lines there), and the routing
constant/test live in `src/wallet_child.rs`. Tests are in `tests/wallet.rs`,
`tests/tui_spec.rs` and `src/wallet_child.rs`'s test module.
- `daemon_get_block()` is **not called by anything yet**: it is the entry point
the wallet's own block scan (Phase 2) needs, and the out-of-range answer it has
to survive is item 1, so the mapping lives with the client.
- the card's item 3 gives the unrestricted port as 18089 and the restricted one
as 28089. In monerod's numbering 18089 *is* the restricted port; the app's
local source already dials the unrestricted 18081. The rule is what is pinned,
not those numbers.
- `docs/cuprate-launch-spike.md` merged to `main` after this branch's base
commit, so it is not in this tree and its Recommendation bullets are not
updated here.
- based on `feat/wallet-create-import` (the wallet line, unmerged): the daemon
client has no home on `main`. Retarget to `main` when that line lands.
Proof: `cargo test --locked` 306 passed / 0 failed, `cargo clippy --locked
--all-targets -- -D warnings` clean, `rustfmt --edition 2024 --check` adds no
hunk to any file (the inherited hunks in `src/node.rs`/`src/tui.rs`/
`tests/tui_spec.rs` are unchanged in count or region).
2026-09-17 00:24:09 -04:00
sync_line : truncate_chars ( & sync_text , WALLET_LINE_MAX ) ,
2026-09-15 12:29:16 -04:00
storage_line : truncate_chars ( & storage_line , WALLET_LINE_MAX ) ,
status_line : readiness . line ( ) . to_string ( ) ,
ready : readiness . ready ( ) ,
}
}
/// `.onion` chain traffic needs the SOCKS listener this build does not have
/// yet. Checked before anything is dialled or spawned.
pub fn is_onion_host ( host : & str ) -> bool {
host . trim ( ) . to_ascii_lowercase ( ) . ends_with ( " .onion " )
}
/// `host:port` from the picker's address field.
///
/// A `.onion`, a loopback host, and a clearnet host are all accepted — clearnet
/// only because the user typed it here. There is no default port: picking one
/// would be us choosing a daemon for them.
pub fn parse_daemon_addr ( raw : & str ) -> Result < ( String , u16 ) , String > {
let s = raw . trim ( ) ;
if s . is_empty ( ) {
return Err ( " enter host:port " . into ( ) ) ;
}
if s . chars ( ) . any ( char ::is_whitespace ) {
return Err ( " no spaces in host:port " . into ( ) ) ;
}
let ( host , port ) = s
. rsplit_once ( ':' )
. ok_or_else ( | | " missing :port — write host:port " . to_string ( ) ) ? ;
let host = host . trim ( ) ;
if host . is_empty ( ) {
return Err ( " missing host — write host:port " . into ( ) ) ;
}
if host . contains ( '/' ) {
return Err ( " no path — host:port only " . into ( ) ) ;
}
let port : u16 = port
. trim ( )
. parse ( )
. map_err ( | _ | " port must be 1-65535 " . to_string ( ) ) ? ;
if port = = 0 {
return Err ( " port must be 1-65535 " . into ( ) ) ;
}
Ok ( ( host . to_string ( ) , port ) )
}
/// The budget for the daemon `get_info` probe behind the sync line. Short on
/// purpose: a dead daemon must show as unknown, not freeze the screen.
pub const CHAIN_SYNC_BUDGET : Duration = Duration ::from_secs ( 2 ) ;
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 ,
wallet: typed chain-daemon client for the Cuprate parity gaps
The chain probe was a hand-rolled brace-scanner in `src/node.rs`. Cuprate
breaks three of its assumptions, all measured in Spike A
(`docs/cuprate-launch-spike.md` §Parity gaps, evidence in that spike's
`rpc-evidence/`):
1. **A height above the tip is a bare HTTP 500 with an empty body.** monerod
answers a JSON-RPC error object instead (`TOO_BIG_HEIGHT`, code -2). The
client now parses the HTTP status once, de-chunks `Transfer-Encoding:
chunked` bodies (axum/hyper; the old brace-scan is not a parse once a blob
spans more than one chunk), and maps both spellings of the height failure to
one typed `WalletError::DaemonHeightOutOfRange`. `get_height` and `get_block`
are height-addressed: their 5xx is the height error. `get_info` is not: its
5xx is `WalletError::DaemonHttpStatus`.
2. **`get_info` metrics are not measurements.** Cuprate reports zero peers while
it downloads blocks, its restricted server answers a placeholder
`database_size` (exactly 5 GiB) and an empty `version`, and `free_space` is
`u64::MAX` on both servers. `DaemonInfo` carries height and target only, so
there is no field for a placeholder to reach the UI. The wallet screen's sync
line is now built from block-height movement between two probes: "connected
to P2P" needs the height to have moved, "no new blocks" is what a stalled
daemon gets, and Cuprate's at-rest `synchronized = true` with
`target_height = 0` reads as unknown instead of `1160/0`.
3. **`get_height` is a URI endpoint**: `{"method":"get_height"}` over
`/json_rpc` is rejected with 422, so the client uses `GET /get_height`, which
both daemons answer. The wallet-child routing rule is pinned too: it dials
the daemon's *unrestricted* listener (monerod's `--rpc-bind-port`, and
whatever port an in-process Cuprate binds for `[rpc.unrestricted]`), never the
restricted one — a restricted listener answers, so a mix-up shows up as a
wrong number rather than as an error.
Scope deviations, stated plainly:
- the card names `src/wallet.rs` + the TUI bindings. The probe itself lived in
`src/node.rs`; it now delegates (net -100 lines there), and the routing
constant/test live in `src/wallet_child.rs`. Tests are in `tests/wallet.rs`,
`tests/tui_spec.rs` and `src/wallet_child.rs`'s test module.
- `daemon_get_block()` is **not called by anything yet**: it is the entry point
the wallet's own block scan (Phase 2) needs, and the out-of-range answer it has
to survive is item 1, so the mapping lives with the client.
- the card's item 3 gives the unrestricted port as 18089 and the restricted one
as 28089. In monerod's numbering 18089 *is* the restricted port; the app's
local source already dials the unrestricted 18081. The rule is what is pinned,
not those numbers.
- `docs/cuprate-launch-spike.md` merged to `main` after this branch's base
commit, so it is not in this tree and its Recommendation bullets are not
updated here.
- based on `feat/wallet-create-import` (the wallet line, unmerged): the daemon
client has no home on `main`. Retarget to `main` when that line lands.
Proof: `cargo test --locked` 306 passed / 0 failed, `cargo clippy --locked
--all-targets -- -D warnings` clean, `rustfmt --edition 2024 --check` adds no
hunk to any file (the inherited hunks in `src/node.rs`/`src/tui.rs`/
`tests/tui_spec.rs` are unchanged in count or region).
2026-09-17 00:24:09 -04:00
chain_last_height : std ::cell ::Cell ::new ( 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 ) ? {
wallet: in-process Cuprate chain daemon behind the cuprate-daemon feature
Phase 1 of the Cuprate integration strategy: the chain daemon can run inside
the OnionWire process instead of a spawned `monerod`. `monero-wallet-rpc` is
unchanged — it still dials the unrestricted loopback RPC on 127.0.0.1:18081,
which is the address `WalletChild::daemon_address` already returned — so no
wallet-layer code moves.
- Cargo.toml: `cuprated` (git, rev 4f8fcd1b) + `toml`, both optional, behind a
`cuprate-daemon` feature that is OFF by default. Cuprate's own `arti` feature
stays off: its arti-client 0.44 cannot unify with this crate's 0.46, and the
in-process daemon is clearnet-only, so this keeps one Tor stack in the
process. `Cargo.lock` gains the graph; no arti 0.44 appears in it.
- src/cuprate.rs (new): `CuprateNode` builds the cuprated config as TOML
(testnet, unrestricted RPC on loopback, restricted RPC disabled, inbound P2P
off), launches it, and owns it. Dropping the value is the teardown;
`shutdown()` is called before the drop so the services can drain. The type
exists in every build: without the feature `launch` fails with the feature
name instead of silently doing nothing, so the chain-source type, its stored
record and the picker do not fork on a cargo feature.
- src/wallet.rs: `ChainSource::InProcessCuprate { datadir }`.
- src/wallet_child.rs: starts/holds/stops the node, serializes the choice as
`kind = "cuprate"`, and adds `chain_datadir` so the storage gate covers both
local sources. It takes the app's Tokio handle (`with_runtime`): the launch is
async and `start()` runs on the TUI's blocking thread.
- src/node.rs: `wallet_child_start(runtime)`, `default_in_process_chain_source`.
- src/tui.rs: a fourth picker row, its testnet caveat, the chain block copy, and
a stop of the app-owned children on the quit path so they are not orphaned.
- tests/wallet.rs: a `cuprate-daemon`-gated end-to-end test that launches the
node and drives get_info / get_height / get_block through the typed daemon
client, including the above-the-tip 500 and the listener closing on drop.
- docs/WALLET.md: the fourth chain source, the feature flag, the +5.6 MB
stripped overhead, and the two limits (testnet only, no Tor in the chain
path).
Also repaired tests/tui_spec.rs, which the parent commit left un-compilable
(the Phase 2a commit had dropped all but the new imports and four new tests,
1221 lines of body); it is restored from the pre-breakage version, with the
Phase 2a imports and tests re-applied.
2026-09-17 13:17:32 -04:00
// The children this app owns are not detached. Without this,
// `monero-wallet-rpc` (and a spawned `monerod`) would outlive the
// app as orphans, and an in-process Cuprate node would never get
// its shutdown asked for.
if let Err ( e ) = self . node . wallet_child_stop ( ) {
eprintln! ( " wallet child on exit: {e} " ) ;
}
2026-09-10 02:49:42 -04:00
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 ;
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 ;
2026-09-10 01:54:19 -04:00
match & mut self . screen {
Screen ::Main = > match key . code {
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
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 01:54:19 -04:00
KeyCode ::F ( 2 ) = > self . open_share ( ) ? ,
KeyCode ::F ( 3 ) = > {
self . screen = Screen ::Paste {
buf : String ::new ( ) ,
err : None ,
} ;
}
2026-09-10 02:43:45 -04:00
KeyCode ::F ( 4 ) = > {
self . screen = Screen ::Rotate {
prompt : RotatePrompt ::new ( ) ,
} ;
}
2026-09-10 14:25:31 -04:00
KeyCode ::F ( 5 ) = > self . who_open = true ,
2026-09-12 22:53:58 -04:00
KeyCode ::F ( 6 ) = > self . open_wallet ( ) ? ,
tui(history): payment history and tx detail screen (card t_935bf84e)
Add Screen::History with draw_history, history_row_text, history_detail.
- Per-friend payment list: direction marker, amount, verified state, age, txid
- Enter opens detail view; Esc closes
- h key from main + wallet opens history via Node::list_payments
- Empty state: 'no payments with this friend yet'
- ASCII fallback: drops ✓/✗ glyphs, uses words only
- Peer text (memo, address) sanitized via display_text
- Tests: 5 new in tui_spec.rs (row text, detail, empty, ascii), 2 frame dumps in tui_frames.rs
Signed-off-by: tui-design <tui-design@hermes>
2026-09-15 21:29:40 -04:00
KeyCode ::Char ( 'h' ) = > self . open_history ( ) ? ,
tui: F7 wallet config screen + wallet/chain setup redesign + doc sync
Implement the F7 wallet-endpoint config screen (Screen::WalletConfig):
- Fields: rpc_url, rpc_login masked with reveal toggle, no_spend checkbox
- Test connection (t → PingResult::line), Save (s → wallet_save_config)
- Status line: 'saved · not connected', 'connected — ...', 'error: ...'
- NO_COLOR distinguishability: '·' bullets, username visible, password masked
- Password never leaks: WalletConfig::secret() redaction on all status lines
- ConfigField cycle (Tab/Esc), footer hints, help overlay entries
Redraw draw_wallet_setup (CreateWarn→CreatePass→CreateSeed→ImportPass,
CreateWarn→ImportSeq→ImportPass) with spend-authority warning, SEEN
challenge, zeroizing buffers preserved on submit/mismatch/Esc.
Update help_overlay_text() with F6 h, F7, copy key; main_footer_hints()
for F7. Extend tui_chrome.rs needle list (F6 h, F7 added).
Reconcile docs: README key table gains F6 s/n/h and F7; WALLET.md
wallet-screen paragraph updated; TUI.md Deliverable 5 marked implemented
with after frames for each config state at 80x24 and 120x40.
Tests: 30 tui_spec (incl. 7 new wallet-config tests), tui_chrome green.
cargo test --locked: 0 failures. cargo clippy --all-targets: clean.
2026-09-15 23:01:56 -04:00
KeyCode ::F ( 7 ) = > self . open_wallet_config ( ) ,
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 ;
}
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-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-15 12:29:16 -04:00
KeyCode ::Char ( 's' ) = > self . open_chain_setup ( ) ,
KeyCode ::Char ( 'n' ) = > self . toggle_wallet_child ( ) ,
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 ( ) ) ,
} ) ;
}
tui(wallet): chain/daemon honesty, view-only badge, address copy (OSC 52)
- Screen::Wallet.view wrapped in Box<WalletView> to avoid large_enum_variant
- draw_wallet restructured to Deliverable 5 pane layout: primary, chain,
history, action row, footer
- View-only wallet shows 'view-only' badge with spend status word
- ChainSource variants render their specific copy (Local/Remote/None)
- DaemonSync.reachable=false renders 'sync: unknown' with no balance claim
- Address copy via OSC 52 escape sequence; 'y' key; fallback hint on screen
- QR modal resized to fit 80x24 without clipping
- wallet_screen_at_with() test helper for copy_note parameter
- 33 new tests covering receive-only, local synced/syncing, remote
unreachable, view-only badge, QR modal, address copy escape sequence
All 52 TUI tests pass (10 tui_frames + 19 tui_chrome + 23 tui_spec).
Clippy clean on lib and all three test targets.
2026-09-15 19:57:29 -04:00
KeyCode ::Char ( 'y' ) = > self . wallet_copy_address ( ) ,
tui(history): payment history and tx detail screen (card t_935bf84e)
Add Screen::History with draw_history, history_row_text, history_detail.
- Per-friend payment list: direction marker, amount, verified state, age, txid
- Enter opens detail view; Esc closes
- h key from main + wallet opens history via Node::list_payments
- Empty state: 'no payments with this friend yet'
- ASCII fallback: drops ✓/✗ glyphs, uses words only
- Peer text (memo, address) sanitized via display_text
- Tests: 5 new in tui_spec.rs (row text, detail, empty, ascii), 2 frame dumps in tui_frames.rs
Signed-off-by: tui-design <tui-design@hermes>
2026-09-15 21:29:40 -04:00
KeyCode ::Char ( 'h' ) = > self . open_history ( ) ? ,
tui: F7 wallet config screen + wallet/chain setup redesign + doc sync
Implement the F7 wallet-endpoint config screen (Screen::WalletConfig):
- Fields: rpc_url, rpc_login masked with reveal toggle, no_spend checkbox
- Test connection (t → PingResult::line), Save (s → wallet_save_config)
- Status line: 'saved · not connected', 'connected — ...', 'error: ...'
- NO_COLOR distinguishability: '·' bullets, username visible, password masked
- Password never leaks: WalletConfig::secret() redaction on all status lines
- ConfigField cycle (Tab/Esc), footer hints, help overlay entries
Redraw draw_wallet_setup (CreateWarn→CreatePass→CreateSeed→ImportPass,
CreateWarn→ImportSeq→ImportPass) with spend-authority warning, SEEN
challenge, zeroizing buffers preserved on submit/mismatch/Esc.
Update help_overlay_text() with F6 h, F7, copy key; main_footer_hints()
for F7. Extend tui_chrome.rs needle list (F6 h, F7 added).
Reconcile docs: README key table gains F6 s/n/h and F7; WALLET.md
wallet-screen paragraph updated; TUI.md Deliverable 5 marked implemented
with after frames for each config state at 80x24 and 120x40.
Tests: 30 tui_spec (incl. 7 new wallet-config tests), tui_chrome green.
cargo test --locked: 0 failures. cargo clippy --all-targets: clean.
2026-09-15 23:01:56 -04:00
KeyCode ::F ( 7 ) = > self . open_wallet_config ( ) ,
tui(history): payment history and tx detail screen (card t_935bf84e)
Add Screen::History with draw_history, history_row_text, history_detail.
- Per-friend payment list: direction marker, amount, verified state, age, txid
- Enter opens detail view; Esc closes
- h key from main + wallet opens history via Node::list_payments
- Empty state: 'no payments with this friend yet'
- ASCII fallback: drops ✓/✗ glyphs, uses words only
- Peer text (memo, address) sanitized via display_text
- Tests: 5 new in tui_spec.rs (row text, detail, empty, ascii), 2 frame dumps in tui_frames.rs
Signed-off-by: tui-design <tui-design@hermes>
2026-09-15 21:29:40 -04:00
_ = > { }
} ,
Screen ::History { selected , payments , detail , .. } = > match key . code {
KeyCode ::Esc = > self . screen = Screen ::Main ,
KeyCode ::Up = > {
if ! payments . is_empty ( ) {
* selected = selected . saturating_sub ( 1 ) ;
}
}
KeyCode ::Down = > {
if ! payments . is_empty ( ) {
* selected = ( * selected + 1 ) . min ( payments . len ( ) . saturating_sub ( 1 ) ) ;
}
}
KeyCode ::Enter = > {
* detail = ! * detail ;
}
2026-09-12 22:53:58 -04:00
_ = > { }
} ,
2026-09-15 12:29:16 -04:00
Screen ::ChainSetup ( _ ) = > self . handle_chain_setup ( key ) ? ,
2026-09-13 23:25:25 -04:00
Screen ::WalletSetup ( _ ) = > self . handle_wallet_setup ( key ) ? ,
tui: F7 wallet config screen + wallet/chain setup redesign + doc sync
Implement the F7 wallet-endpoint config screen (Screen::WalletConfig):
- Fields: rpc_url, rpc_login masked with reveal toggle, no_spend checkbox
- Test connection (t → PingResult::line), Save (s → wallet_save_config)
- Status line: 'saved · not connected', 'connected — ...', 'error: ...'
- NO_COLOR distinguishability: '·' bullets, username visible, password masked
- Password never leaks: WalletConfig::secret() redaction on all status lines
- ConfigField cycle (Tab/Esc), footer hints, help overlay entries
Redraw draw_wallet_setup (CreateWarn→CreatePass→CreateSeed→ImportPass,
CreateWarn→ImportSeq→ImportPass) with spend-authority warning, SEEN
challenge, zeroizing buffers preserved on submit/mismatch/Esc.
Update help_overlay_text() with F6 h, F7, copy key; main_footer_hints()
for F7. Extend tui_chrome.rs needle list (F6 h, F7 added).
Reconcile docs: README key table gains F6 s/n/h and F7; WALLET.md
wallet-screen paragraph updated; TUI.md Deliverable 5 marked implemented
with after frames for each config state at 80x24 and 120x40.
Tests: 30 tui_spec (incl. 7 new wallet-config tests), tui_chrome green.
cargo test --locked: 0 failures. cargo clippy --all-targets: clean.
2026-09-15 23:01:56 -04:00
Screen ::WalletConfig ( _ ) = > self . handle_wallet_config ( key ) ? ,
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 ) ;
}
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-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 > {
self . screen = Screen ::Wallet {
tui(wallet): chain/daemon honesty, view-only badge, address copy (OSC 52)
- Screen::Wallet.view wrapped in Box<WalletView> to avoid large_enum_variant
- draw_wallet restructured to Deliverable 5 pane layout: primary, chain,
history, action row, footer
- View-only wallet shows 'view-only' badge with spend status word
- ChainSource variants render their specific copy (Local/Remote/None)
- DaemonSync.reachable=false renders 'sync: unknown' with no balance claim
- Address copy via OSC 52 escape sequence; 'y' key; fallback hint on screen
- QR modal resized to fit 80x24 without clipping
- wallet_screen_at_with() test helper for copy_note parameter
- 33 new tests covering receive-only, local synced/syncing, remote
unreachable, view-only badge, QR modal, address copy escape sequence
All 52 TUI tests pass (10 tui_frames + 19 tui_chrome + 23 tui_spec).
Clippy clean on lib and all three test targets.
2026-09-15 19:57:29 -04:00
view : Box ::new ( self . build_wallet_view ( ) ) ,
2026-09-12 22:53:58 -04:00
qr_modal : None ,
tui(wallet): chain/daemon honesty, view-only badge, address copy (OSC 52)
- Screen::Wallet.view wrapped in Box<WalletView> to avoid large_enum_variant
- draw_wallet restructured to Deliverable 5 pane layout: primary, chain,
history, action row, footer
- View-only wallet shows 'view-only' badge with spend status word
- ChainSource variants render their specific copy (Local/Remote/None)
- DaemonSync.reachable=false renders 'sync: unknown' with no balance claim
- Address copy via OSC 52 escape sequence; 'y' key; fallback hint on screen
- QR modal resized to fit 80x24 without clipping
- wallet_screen_at_with() test helper for copy_note parameter
- 33 new tests covering receive-only, local synced/syncing, remote
unreachable, view-only badge, QR modal, address copy escape sequence
All 52 TUI tests pass (10 tui_frames + 19 tui_chrome + 23 tui_spec).
Clippy clean on lib and all three test targets.
2026-09-15 19:57:29 -04:00
copy_note : None ,
2026-09-12 22:53:58 -04:00
} ;
Ok ( ( ) )
}
tui(history): payment history and tx detail screen (card t_935bf84e)
Add Screen::History with draw_history, history_row_text, history_detail.
- Per-friend payment list: direction marker, amount, verified state, age, txid
- Enter opens detail view; Esc closes
- h key from main + wallet opens history via Node::list_payments
- Empty state: 'no payments with this friend yet'
- ASCII fallback: drops ✓/✗ glyphs, uses words only
- Peer text (memo, address) sanitized via display_text
- Tests: 5 new in tui_spec.rs (row text, detail, empty, ascii), 2 frame dumps in tui_frames.rs
Signed-off-by: tui-design <tui-design@hermes>
2026-09-15 21:29:40 -04:00
/// `h` from main or the wallet screen: open payment history for the
/// selected friend. The list is loaded once on open and re-read only on
/// an explicit refresh, so the 100ms poll never hits the store per frame.
fn open_history ( & mut self ) -> 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 ( ) ;
let payments = self . node . list_payments ( & pk ) . unwrap_or_default ( ) ;
self . screen = Screen ::History {
friend_pk : pk ,
payments ,
selected : 0 ,
detail : false ,
} ;
Ok ( ( ) )
}
tui: F7 wallet config screen + wallet/chain setup redesign + doc sync
Implement the F7 wallet-endpoint config screen (Screen::WalletConfig):
- Fields: rpc_url, rpc_login masked with reveal toggle, no_spend checkbox
- Test connection (t → PingResult::line), Save (s → wallet_save_config)
- Status line: 'saved · not connected', 'connected — ...', 'error: ...'
- NO_COLOR distinguishability: '·' bullets, username visible, password masked
- Password never leaks: WalletConfig::secret() redaction on all status lines
- ConfigField cycle (Tab/Esc), footer hints, help overlay entries
Redraw draw_wallet_setup (CreateWarn→CreatePass→CreateSeed→ImportPass,
CreateWarn→ImportSeq→ImportPass) with spend-authority warning, SEEN
challenge, zeroizing buffers preserved on submit/mismatch/Esc.
Update help_overlay_text() with F6 h, F7, copy key; main_footer_hints()
for F7. Extend tui_chrome.rs needle list (F6 h, F7 added).
Reconcile docs: README key table gains F6 s/n/h and F7; WALLET.md
wallet-screen paragraph updated; TUI.md Deliverable 5 marked implemented
with after frames for each config state at 80x24 and 120x40.
Tests: 30 tui_spec (incl. 7 new wallet-config tests), tui_chrome green.
cargo test --locked: 0 failures. cargo clippy --all-targets: clean.
2026-09-15 23:01:56 -04:00
/// F7: open the wallet-config screen, prefilled with the stored or
/// env-derived config. The screen is self-contained — it never touches the
/// live wallet; only Save writes, only Test probes.
fn open_wallet_config ( & mut self ) {
let cfg = self . node . wallet_config ( ) ;
let screen = WalletConfigScreen ::from_config ( cfg . as_ref ( ) ) ;
self . screen = Screen ::WalletConfig ( screen ) ;
}
2026-09-15 12:29:16 -04:00
/// Draw state for the wallet screen.
///
/// One probe per open/refresh, then everything the screen says comes from
/// that answer: a balance rendered while the RPC is silent is the lie this
/// screen must not tell. Not being configured is a state to *show* (F6 must
/// open either way), not an error to bail out of.
fn build_wallet_view ( & self ) -> WalletView {
let status = self . rt . block_on ( self . node . wallet_refresh ( ) ) ;
let no_spend = self
. node
. wallet_config ( )
. map ( | c | c . no_spend )
. unwrap_or ( false ) ;
let readiness = wallet_readiness ( status . configured , status . connected , no_spend ) ;
let source = self . node . wallet_chain_source ( ) ;
let child = self . node . wallet_child_state ( ) ;
let sync = self
. rt
. block_on ( self . node . wallet_chain_sync ( CHAIN_SYNC_BUDGET ) ) ;
wallet: typed chain-daemon client for the Cuprate parity gaps
The chain probe was a hand-rolled brace-scanner in `src/node.rs`. Cuprate
breaks three of its assumptions, all measured in Spike A
(`docs/cuprate-launch-spike.md` §Parity gaps, evidence in that spike's
`rpc-evidence/`):
1. **A height above the tip is a bare HTTP 500 with an empty body.** monerod
answers a JSON-RPC error object instead (`TOO_BIG_HEIGHT`, code -2). The
client now parses the HTTP status once, de-chunks `Transfer-Encoding:
chunked` bodies (axum/hyper; the old brace-scan is not a parse once a blob
spans more than one chunk), and maps both spellings of the height failure to
one typed `WalletError::DaemonHeightOutOfRange`. `get_height` and `get_block`
are height-addressed: their 5xx is the height error. `get_info` is not: its
5xx is `WalletError::DaemonHttpStatus`.
2. **`get_info` metrics are not measurements.** Cuprate reports zero peers while
it downloads blocks, its restricted server answers a placeholder
`database_size` (exactly 5 GiB) and an empty `version`, and `free_space` is
`u64::MAX` on both servers. `DaemonInfo` carries height and target only, so
there is no field for a placeholder to reach the UI. The wallet screen's sync
line is now built from block-height movement between two probes: "connected
to P2P" needs the height to have moved, "no new blocks" is what a stalled
daemon gets, and Cuprate's at-rest `synchronized = true` with
`target_height = 0` reads as unknown instead of `1160/0`.
3. **`get_height` is a URI endpoint**: `{"method":"get_height"}` over
`/json_rpc` is rejected with 422, so the client uses `GET /get_height`, which
both daemons answer. The wallet-child routing rule is pinned too: it dials
the daemon's *unrestricted* listener (monerod's `--rpc-bind-port`, and
whatever port an in-process Cuprate binds for `[rpc.unrestricted]`), never the
restricted one — a restricted listener answers, so a mix-up shows up as a
wrong number rather than as an error.
Scope deviations, stated plainly:
- the card names `src/wallet.rs` + the TUI bindings. The probe itself lived in
`src/node.rs`; it now delegates (net -100 lines there), and the routing
constant/test live in `src/wallet_child.rs`. Tests are in `tests/wallet.rs`,
`tests/tui_spec.rs` and `src/wallet_child.rs`'s test module.
- `daemon_get_block()` is **not called by anything yet**: it is the entry point
the wallet's own block scan (Phase 2) needs, and the out-of-range answer it has
to survive is item 1, so the mapping lives with the client.
- the card's item 3 gives the unrestricted port as 18089 and the restricted one
as 28089. In monerod's numbering 18089 *is* the restricted port; the app's
local source already dials the unrestricted 18081. The rule is what is pinned,
not those numbers.
- `docs/cuprate-launch-spike.md` merged to `main` after this branch's base
commit, so it is not in this tree and its Recommendation bullets are not
updated here.
- based on `feat/wallet-create-import` (the wallet line, unmerged): the daemon
client has no home on `main`. Retarget to `main` when that line lands.
Proof: `cargo test --locked` 306 passed / 0 failed, `cargo clippy --locked
--all-targets -- -D warnings` clean, `rustfmt --edition 2024 --check` adds no
hunk to any file (the inherited hunks in `src/node.rs`/`src/tui.rs`/
`tests/tui_spec.rs` are unchanged in count or region).
2026-09-17 00:24:09 -04:00
// The only thing that can distinguish "connected and syncing" from
// "answering but stalled" is whether the height moved since last draw.
let previous_height = self . chain_last_height . get ( ) ;
self . chain_last_height . set ( if sync . reachable {
Some ( sync . height )
} else {
None
} ) ;
let chain = chain_view_with_progress (
2026-09-15 12:29:16 -04:00
& source ,
child ,
& sync ,
self . node . wallet_chain_free_gb ( ) ,
readiness ,
wallet: typed chain-daemon client for the Cuprate parity gaps
The chain probe was a hand-rolled brace-scanner in `src/node.rs`. Cuprate
breaks three of its assumptions, all measured in Spike A
(`docs/cuprate-launch-spike.md` §Parity gaps, evidence in that spike's
`rpc-evidence/`):
1. **A height above the tip is a bare HTTP 500 with an empty body.** monerod
answers a JSON-RPC error object instead (`TOO_BIG_HEIGHT`, code -2). The
client now parses the HTTP status once, de-chunks `Transfer-Encoding:
chunked` bodies (axum/hyper; the old brace-scan is not a parse once a blob
spans more than one chunk), and maps both spellings of the height failure to
one typed `WalletError::DaemonHeightOutOfRange`. `get_height` and `get_block`
are height-addressed: their 5xx is the height error. `get_info` is not: its
5xx is `WalletError::DaemonHttpStatus`.
2. **`get_info` metrics are not measurements.** Cuprate reports zero peers while
it downloads blocks, its restricted server answers a placeholder
`database_size` (exactly 5 GiB) and an empty `version`, and `free_space` is
`u64::MAX` on both servers. `DaemonInfo` carries height and target only, so
there is no field for a placeholder to reach the UI. The wallet screen's sync
line is now built from block-height movement between two probes: "connected
to P2P" needs the height to have moved, "no new blocks" is what a stalled
daemon gets, and Cuprate's at-rest `synchronized = true` with
`target_height = 0` reads as unknown instead of `1160/0`.
3. **`get_height` is a URI endpoint**: `{"method":"get_height"}` over
`/json_rpc` is rejected with 422, so the client uses `GET /get_height`, which
both daemons answer. The wallet-child routing rule is pinned too: it dials
the daemon's *unrestricted* listener (monerod's `--rpc-bind-port`, and
whatever port an in-process Cuprate binds for `[rpc.unrestricted]`), never the
restricted one — a restricted listener answers, so a mix-up shows up as a
wrong number rather than as an error.
Scope deviations, stated plainly:
- the card names `src/wallet.rs` + the TUI bindings. The probe itself lived in
`src/node.rs`; it now delegates (net -100 lines there), and the routing
constant/test live in `src/wallet_child.rs`. Tests are in `tests/wallet.rs`,
`tests/tui_spec.rs` and `src/wallet_child.rs`'s test module.
- `daemon_get_block()` is **not called by anything yet**: it is the entry point
the wallet's own block scan (Phase 2) needs, and the out-of-range answer it has
to survive is item 1, so the mapping lives with the client.
- the card's item 3 gives the unrestricted port as 18089 and the restricted one
as 28089. In monerod's numbering 18089 *is* the restricted port; the app's
local source already dials the unrestricted 18081. The rule is what is pinned,
not those numbers.
- `docs/cuprate-launch-spike.md` merged to `main` after this branch's base
commit, so it is not in this tree and its Recommendation bullets are not
updated here.
- based on `feat/wallet-create-import` (the wallet line, unmerged): the daemon
client has no home on `main`. Retarget to `main` when that line lands.
Proof: `cargo test --locked` 306 passed / 0 failed, `cargo clippy --locked
--all-targets -- -D warnings` clean, `rustfmt --edition 2024 --check` adds no
hunk to any file (the inherited hunks in `src/node.rs`/`src/tui.rs`/
`tests/tui_spec.rs` are unchanged in count or region).
2026-09-17 00:24:09 -04:00
previous_height ,
2026-09-15 12:29:16 -04:00
) ;
let receive_addr = self
. rt
. block_on ( self . node . wallet_receive_address ( ) )
. unwrap_or_default ( ) ;
let balance = self . rt . block_on ( self . node . wallet_balance ( ) ) ;
let transfers = self
. rt
. block_on ( self . node . wallet_recent_transfers ( 8 ) )
. unwrap_or_default ( ) ;
tui(wallet): chain/daemon honesty, view-only badge, address copy (OSC 52)
- Screen::Wallet.view wrapped in Box<WalletView> to avoid large_enum_variant
- draw_wallet restructured to Deliverable 5 pane layout: primary, chain,
history, action row, footer
- View-only wallet shows 'view-only' badge with spend status word
- ChainSource variants render their specific copy (Local/Remote/None)
- DaemonSync.reachable=false renders 'sync: unknown' with no balance claim
- Address copy via OSC 52 escape sequence; 'y' key; fallback hint on screen
- QR modal resized to fit 80x24 without clipping
- wallet_screen_at_with() test helper for copy_note parameter
- 33 new tests covering receive-only, local synced/syncing, remote
unreachable, view-only badge, QR modal, address copy escape sequence
All 52 TUI tests pass (10 tui_frames + 19 tui_chrome + 23 tui_spec).
Clippy clean on lib and all three test targets.
2026-09-15 19:57:29 -04:00
wallet_view ( receive_addr , balance , transfers , chain , no_spend )
2026-09-15 12:29:16 -04:00
}
/// Re-read the wallet screen after something changed what it shows.
fn refresh_wallet ( & mut self ) {
let view = self . build_wallet_view ( ) ;
if let Screen ::Wallet { view : slot , .. } = & mut self . screen {
tui(wallet): chain/daemon honesty, view-only badge, address copy (OSC 52)
- Screen::Wallet.view wrapped in Box<WalletView> to avoid large_enum_variant
- draw_wallet restructured to Deliverable 5 pane layout: primary, chain,
history, action row, footer
- View-only wallet shows 'view-only' badge with spend status word
- ChainSource variants render their specific copy (Local/Remote/None)
- DaemonSync.reachable=false renders 'sync: unknown' with no balance claim
- Address copy via OSC 52 escape sequence; 'y' key; fallback hint on screen
- QR modal resized to fit 80x24 without clipping
- wallet_screen_at_with() test helper for copy_note parameter
- 33 new tests covering receive-only, local synced/syncing, remote
unreachable, view-only badge, QR modal, address copy escape sequence
All 52 TUI tests pass (10 tui_frames + 19 tui_chrome + 23 tui_spec).
Clippy clean on lib and all three test targets.
2026-09-15 19:57:29 -04:00
* * slot = view ;
2026-09-15 12:29:16 -04:00
}
}
/// `s`: pick the chain source, with the stored choice shown as current.
fn open_chain_setup ( & mut self ) {
let current = ChainChoice ::of ( & self . node . wallet_chain_source ( ) ) ;
let index = ChainChoice ::ALL
. iter ( )
. position ( | c | * c = = current )
. unwrap_or ( 0 ) ;
self . screen = Screen ::ChainSetup ( ChainSetup ::Choose { index } ) ;
}
/// `n`: start or stop the app-owned child.
///
/// A failure here is a normal thing to learn ("monerod is not on PATH"), so
/// it lands on the screen as a note, never as a fatal error that closes the
/// app.
fn toggle_wallet_child ( & mut self ) {
if let ChainSource ::Remote { host , .. } = self . node . wallet_chain_source ( )
& & is_onion_host ( & host )
{
// Say the missing piece in plain words, before any spawn attempt
// turns into a raw argv error.
self . status_note = Some ( ONION_NO_SOCKS_MSG . replace ( '\n' , " " ) ) ;
self . refresh_wallet ( ) ;
return ;
}
let result = match self . node . wallet_child_state ( ) {
WalletChildState ::Running = > self . node . wallet_child_stop ( ) ,
wallet: in-process Cuprate chain daemon behind the cuprate-daemon feature
Phase 1 of the Cuprate integration strategy: the chain daemon can run inside
the OnionWire process instead of a spawned `monerod`. `monero-wallet-rpc` is
unchanged — it still dials the unrestricted loopback RPC on 127.0.0.1:18081,
which is the address `WalletChild::daemon_address` already returned — so no
wallet-layer code moves.
- Cargo.toml: `cuprated` (git, rev 4f8fcd1b) + `toml`, both optional, behind a
`cuprate-daemon` feature that is OFF by default. Cuprate's own `arti` feature
stays off: its arti-client 0.44 cannot unify with this crate's 0.46, and the
in-process daemon is clearnet-only, so this keeps one Tor stack in the
process. `Cargo.lock` gains the graph; no arti 0.44 appears in it.
- src/cuprate.rs (new): `CuprateNode` builds the cuprated config as TOML
(testnet, unrestricted RPC on loopback, restricted RPC disabled, inbound P2P
off), launches it, and owns it. Dropping the value is the teardown;
`shutdown()` is called before the drop so the services can drain. The type
exists in every build: without the feature `launch` fails with the feature
name instead of silently doing nothing, so the chain-source type, its stored
record and the picker do not fork on a cargo feature.
- src/wallet.rs: `ChainSource::InProcessCuprate { datadir }`.
- src/wallet_child.rs: starts/holds/stops the node, serializes the choice as
`kind = "cuprate"`, and adds `chain_datadir` so the storage gate covers both
local sources. It takes the app's Tokio handle (`with_runtime`): the launch is
async and `start()` runs on the TUI's blocking thread.
- src/node.rs: `wallet_child_start(runtime)`, `default_in_process_chain_source`.
- src/tui.rs: a fourth picker row, its testnet caveat, the chain block copy, and
a stop of the app-owned children on the quit path so they are not orphaned.
- tests/wallet.rs: a `cuprate-daemon`-gated end-to-end test that launches the
node and drives get_info / get_height / get_block through the typed daemon
client, including the above-the-tip 500 and the listener closing on drop.
- docs/WALLET.md: the fourth chain source, the feature flag, the +5.6 MB
stripped overhead, and the two limits (testnet only, no Tor in the chain
path).
Also repaired tests/tui_spec.rs, which the parent commit left un-compilable
(the Phase 2a commit had dropped all but the new imports and four new tests,
1221 lines of body); it is restored from the pre-breakage version, with the
Phase 2a imports and tests re-applied.
2026-09-17 13:17:32 -04:00
_ = > self . node . wallet_child_start ( & self . rt ) ,
2026-09-15 12:29:16 -04:00
} ;
self . status_note = Some ( match result {
Ok ( ( ) ) = > match self . node . wallet_child_state ( ) {
WalletChildState ::Running = > " wallet child started " . to_string ( ) ,
_ = > " wallet child stopped " . to_string ( ) ,
} ,
Err ( e ) = > format! ( " wallet child: {e} " ) ,
} ) ;
self . refresh_wallet ( ) ;
}
/// Chain-source picker keys. Kept as one state machine so the picker cannot
/// leave the wallet screen in a half-open state.
fn handle_chain_setup ( & mut self , key : KeyEvent ) -> Result < ( ) , String > {
let mut pick = None ;
let mut warn = None ;
let mut save = false ;
let mut back = false ;
{
let Screen ::ChainSetup ( setup ) = & mut self . screen else {
return Ok ( ( ) ) ;
} ;
match setup {
ChainSetup ::Choose { index } = > match key . code {
KeyCode ::Esc = > back = true ,
KeyCode ::Up | KeyCode ::Char ( 'k' ) = > * index = index . saturating_sub ( 1 ) ,
KeyCode ::Down | KeyCode ::Char ( 'j' ) = > {
* index = ( * index + 1 ) . min ( ChainChoice ::ALL . len ( ) - 1 )
}
KeyCode ::Enter = > pick = Some ( ChainChoice ::ALL [ * index ] ) ,
_ = > { }
} ,
ChainSetup ::RemoteAddr { buf , err } = > match key . code {
KeyCode ::Esc = > back = true ,
KeyCode ::Backspace = > {
buf . pop ( ) ;
* err = None ;
}
KeyCode ::Enter = > match parse_daemon_addr ( buf ) {
Ok ( ( host , port ) ) = > {
warn = Some ( ( host , port ) ) ;
}
Err ( e ) = > * err = Some ( e ) ,
} ,
KeyCode ::Char ( c ) if ! key . modifiers . contains ( KeyModifiers ::CONTROL ) = > {
buf . push ( c ) ;
* err = None ;
}
_ = > { }
} ,
ChainSetup ::RemoteWarn { .. } = > match key . code {
KeyCode ::Esc = > back = true ,
KeyCode ::Enter = > save = true ,
_ = > { }
} ,
}
}
if let Some ( choice ) = pick {
match choice {
ChainChoice ::RemoteDaemon = > {
self . screen = Screen ::ChainSetup ( ChainSetup ::RemoteAddr {
buf : String ::new ( ) ,
err : None ,
} ) ;
}
ChainChoice ::ReceiveOnly = > self . apply_chain_source ( ChainSource ::None , None ) ,
ChainChoice ::LocalMonerod = > {
let source = self . node . default_local_chain_source ( ) ;
self . apply_chain_source ( source , None ) ;
}
wallet: in-process Cuprate chain daemon behind the cuprate-daemon feature
Phase 1 of the Cuprate integration strategy: the chain daemon can run inside
the OnionWire process instead of a spawned `monerod`. `monero-wallet-rpc` is
unchanged — it still dials the unrestricted loopback RPC on 127.0.0.1:18081,
which is the address `WalletChild::daemon_address` already returned — so no
wallet-layer code moves.
- Cargo.toml: `cuprated` (git, rev 4f8fcd1b) + `toml`, both optional, behind a
`cuprate-daemon` feature that is OFF by default. Cuprate's own `arti` feature
stays off: its arti-client 0.44 cannot unify with this crate's 0.46, and the
in-process daemon is clearnet-only, so this keeps one Tor stack in the
process. `Cargo.lock` gains the graph; no arti 0.44 appears in it.
- src/cuprate.rs (new): `CuprateNode` builds the cuprated config as TOML
(testnet, unrestricted RPC on loopback, restricted RPC disabled, inbound P2P
off), launches it, and owns it. Dropping the value is the teardown;
`shutdown()` is called before the drop so the services can drain. The type
exists in every build: without the feature `launch` fails with the feature
name instead of silently doing nothing, so the chain-source type, its stored
record and the picker do not fork on a cargo feature.
- src/wallet.rs: `ChainSource::InProcessCuprate { datadir }`.
- src/wallet_child.rs: starts/holds/stops the node, serializes the choice as
`kind = "cuprate"`, and adds `chain_datadir` so the storage gate covers both
local sources. It takes the app's Tokio handle (`with_runtime`): the launch is
async and `start()` runs on the TUI's blocking thread.
- src/node.rs: `wallet_child_start(runtime)`, `default_in_process_chain_source`.
- src/tui.rs: a fourth picker row, its testnet caveat, the chain block copy, and
a stop of the app-owned children on the quit path so they are not orphaned.
- tests/wallet.rs: a `cuprate-daemon`-gated end-to-end test that launches the
node and drives get_info / get_height / get_block through the typed daemon
client, including the above-the-tip 500 and the listener closing on drop.
- docs/WALLET.md: the fourth chain source, the feature flag, the +5.6 MB
stripped overhead, and the two limits (testnet only, no Tor in the chain
path).
Also repaired tests/tui_spec.rs, which the parent commit left un-compilable
(the Phase 2a commit had dropped all but the new imports and four new tests,
1221 lines of body); it is restored from the pre-breakage version, with the
Phase 2a imports and tests re-applied.
2026-09-17 13:17:32 -04:00
ChainChoice ::InProcessCuprate = > {
let source = self . node . default_in_process_chain_source ( ) ;
// The saved note says the caveat again: the picker's row is
// gone once this screen closes.
let note = format! (
" chain source saved — in-process daemon, {} " ,
crate ::cuprate ::TESTNET_ONLY
) ;
self . apply_chain_source ( source , Some ( note ) ) ;
}
2026-09-15 12:29:16 -04:00
}
return Ok ( ( ) ) ;
}
if let Some ( ( host , port ) ) = warn {
let onion = is_onion_host ( & host ) ;
self . screen = Screen ::ChainSetup ( ChainSetup ::RemoteWarn {
host ,
port ,
onion ,
} ) ;
return Ok ( ( ) ) ;
}
if save {
let Screen ::ChainSetup ( ChainSetup ::RemoteWarn { host , port , .. } ) = & self . screen else {
return Ok ( ( ) ) ;
} ;
let source = ChainSource ::Remote {
host : host . clone ( ) ,
port : * port ,
} ;
let note = if is_onion_host ( host ) {
Some ( " saved — starting it needs a local SOCKS listener (not wired yet) " . to_string ( ) )
} else {
None
} ;
self . apply_chain_source ( source , note ) ;
return Ok ( ( ) ) ;
}
if back {
self . screen = Screen ::Wallet {
tui(wallet): chain/daemon honesty, view-only badge, address copy (OSC 52)
- Screen::Wallet.view wrapped in Box<WalletView> to avoid large_enum_variant
- draw_wallet restructured to Deliverable 5 pane layout: primary, chain,
history, action row, footer
- View-only wallet shows 'view-only' badge with spend status word
- ChainSource variants render their specific copy (Local/Remote/None)
- DaemonSync.reachable=false renders 'sync: unknown' with no balance claim
- Address copy via OSC 52 escape sequence; 'y' key; fallback hint on screen
- QR modal resized to fit 80x24 without clipping
- wallet_screen_at_with() test helper for copy_note parameter
- 33 new tests covering receive-only, local synced/syncing, remote
unreachable, view-only badge, QR modal, address copy escape sequence
All 52 TUI tests pass (10 tui_frames + 19 tui_chrome + 23 tui_spec).
Clippy clean on lib and all three test targets.
2026-09-15 19:57:29 -04:00
view : Box ::new ( self . build_wallet_view ( ) ) ,
2026-09-15 12:29:16 -04:00
qr_modal : None ,
tui(wallet): chain/daemon honesty, view-only badge, address copy (OSC 52)
- Screen::Wallet.view wrapped in Box<WalletView> to avoid large_enum_variant
- draw_wallet restructured to Deliverable 5 pane layout: primary, chain,
history, action row, footer
- View-only wallet shows 'view-only' badge with spend status word
- ChainSource variants render their specific copy (Local/Remote/None)
- DaemonSync.reachable=false renders 'sync: unknown' with no balance claim
- Address copy via OSC 52 escape sequence; 'y' key; fallback hint on screen
- QR modal resized to fit 80x24 without clipping
- wallet_screen_at_with() test helper for copy_note parameter
- 33 new tests covering receive-only, local synced/syncing, remote
unreachable, view-only badge, QR modal, address copy escape sequence
All 52 TUI tests pass (10 tui_frames + 19 tui_chrome + 23 tui_spec).
Clippy clean on lib and all three test targets.
2026-09-15 19:57:29 -04:00
copy_note : None ,
2026-09-15 12:29:16 -04:00
} ;
}
Ok ( ( ) )
}
/// Persist a pick and return to the wallet screen, where the choice is
/// visible at rest (AC 4). A save that fails says so instead of pretending.
fn apply_chain_source ( & mut self , source : ChainSource , note : Option < String > ) {
self . status_note = Some ( match self . node . wallet_set_chain_source ( & source ) {
Ok ( ( ) ) = > note . unwrap_or_else ( | | " chain source saved " . to_string ( ) ) ,
Err ( e ) = > format! ( " chain source not saved: {e} " ) ,
} ) ;
self . screen = Screen ::Wallet {
tui(wallet): chain/daemon honesty, view-only badge, address copy (OSC 52)
- Screen::Wallet.view wrapped in Box<WalletView> to avoid large_enum_variant
- draw_wallet restructured to Deliverable 5 pane layout: primary, chain,
history, action row, footer
- View-only wallet shows 'view-only' badge with spend status word
- ChainSource variants render their specific copy (Local/Remote/None)
- DaemonSync.reachable=false renders 'sync: unknown' with no balance claim
- Address copy via OSC 52 escape sequence; 'y' key; fallback hint on screen
- QR modal resized to fit 80x24 without clipping
- wallet_screen_at_with() test helper for copy_note parameter
- 33 new tests covering receive-only, local synced/syncing, remote
unreachable, view-only badge, QR modal, address copy escape sequence
All 52 TUI tests pass (10 tui_frames + 19 tui_chrome + 23 tui_spec).
Clippy clean on lib and all three test targets.
2026-09-15 19:57:29 -04:00
view : Box ::new ( self . build_wallet_view ( ) ) ,
2026-09-15 12:29:16 -04:00
qr_modal : None ,
tui(wallet): chain/daemon honesty, view-only badge, address copy (OSC 52)
- Screen::Wallet.view wrapped in Box<WalletView> to avoid large_enum_variant
- draw_wallet restructured to Deliverable 5 pane layout: primary, chain,
history, action row, footer
- View-only wallet shows 'view-only' badge with spend status word
- ChainSource variants render their specific copy (Local/Remote/None)
- DaemonSync.reachable=false renders 'sync: unknown' with no balance claim
- Address copy via OSC 52 escape sequence; 'y' key; fallback hint on screen
- QR modal resized to fit 80x24 without clipping
- wallet_screen_at_with() test helper for copy_note parameter
- 33 new tests covering receive-only, local synced/syncing, remote
unreachable, view-only badge, QR modal, address copy escape sequence
All 52 TUI tests pass (10 tui_frames + 19 tui_chrome + 23 tui_spec).
Clippy clean on lib and all three test targets.
2026-09-15 19:57:29 -04:00
copy_note : None ,
2026-09-15 12:29:16 -04:00
} ;
}
2026-09-12 22:53:58 -04:00
fn wallet_toggle_qr ( & mut self ) {
let Screen ::Wallet {
ref mut qr_modal ,
2026-09-15 12:29:16 -04:00
ref view ,
2026-09-12 22:53:58 -04:00
..
} = self . screen
else {
return ;
} ;
2026-09-15 12:29:16 -04:00
let receive_addr = & view . receive_addr ;
2026-09-12 22:53:58 -04:00
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 ( ) ,
} ) ;
}
tui(wallet): chain/daemon honesty, view-only badge, address copy (OSC 52)
- Screen::Wallet.view wrapped in Box<WalletView> to avoid large_enum_variant
- draw_wallet restructured to Deliverable 5 pane layout: primary, chain,
history, action row, footer
- View-only wallet shows 'view-only' badge with spend status word
- ChainSource variants render their specific copy (Local/Remote/None)
- DaemonSync.reachable=false renders 'sync: unknown' with no balance claim
- Address copy via OSC 52 escape sequence; 'y' key; fallback hint on screen
- QR modal resized to fit 80x24 without clipping
- wallet_screen_at_with() test helper for copy_note parameter
- 33 new tests covering receive-only, local synced/syncing, remote
unreachable, view-only badge, QR modal, address copy escape sequence
All 52 TUI tests pass (10 tui_frames + 19 tui_chrome + 23 tui_spec).
Clippy clean on lib and all three test targets.
2026-09-15 19:57:29 -04:00
/// OSC 52 copy of the receive address. If there is an address it is
/// base64'd inline (no clipboard crate) and written through the terminal;
/// the fallback hint is shown on the next frame so the user can still
/// mouse-select if their emulator blocks OSC 52.
fn wallet_copy_address ( & mut self ) {
let addr = match & self . screen {
Screen ::Wallet { view , .. } = > view . receive_addr . clone ( ) ,
_ = > return ,
} ;
if addr . is_empty ( ) {
self . status_note = Some ( " no address to copy — create or import a wallet first " . into ( ) ) ;
return ;
}
// OSC 52 is emitted on the terminal, not the ratatui frame buffer.
print! ( " {} " , osc52_copy ( & addr ) ) ;
let _ = io ::stdout ( ) . flush ( ) ;
self . status_note = Some (
" copied — if your terminal blocked it, select the address above " . into ( ) ,
) ;
if let Screen ::Wallet { copy_note , .. } = & mut self . screen {
* copy_note = self . status_note . 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 ( ( ) )
}
tui: F7 wallet config screen + wallet/chain setup redesign + doc sync
Implement the F7 wallet-endpoint config screen (Screen::WalletConfig):
- Fields: rpc_url, rpc_login masked with reveal toggle, no_spend checkbox
- Test connection (t → PingResult::line), Save (s → wallet_save_config)
- Status line: 'saved · not connected', 'connected — ...', 'error: ...'
- NO_COLOR distinguishability: '·' bullets, username visible, password masked
- Password never leaks: WalletConfig::secret() redaction on all status lines
- ConfigField cycle (Tab/Esc), footer hints, help overlay entries
Redraw draw_wallet_setup (CreateWarn→CreatePass→CreateSeed→ImportPass,
CreateWarn→ImportSeq→ImportPass) with spend-authority warning, SEEN
challenge, zeroizing buffers preserved on submit/mismatch/Esc.
Update help_overlay_text() with F6 h, F7, copy key; main_footer_hints()
for F7. Extend tui_chrome.rs needle list (F6 h, F7 added).
Reconcile docs: README key table gains F6 s/n/h and F7; WALLET.md
wallet-screen paragraph updated; TUI.md Deliverable 5 marked implemented
with after frames for each config state at 80x24 and 120x40.
Tests: 30 tui_spec (incl. 7 new wallet-config tests), tui_chrome green.
cargo test --locked: 0 failures. cargo clippy --all-targets: clean.
2026-09-15 23:01:56 -04:00
/// F7 wallet-config key handling. Tab/Shift-Tab moves between fields and
/// the action row; Enter runs Test or Save on the action row; type into a
/// field to edit it; Space toggles no_spend and reveal.
fn handle_wallet_config ( & mut self , key : KeyEvent ) -> Result < ( ) , String > {
let Screen ::WalletConfig ( s ) = & mut self . screen else {
return Ok ( ( ) ) ;
} ;
match key . code {
KeyCode ::Esc = > {
self . screen = Screen ::Wallet {
view : Box ::new ( self . build_wallet_view ( ) ) ,
qr_modal : None ,
copy_note : None ,
} ;
}
KeyCode ::Tab = > {
s . focus = s . focus . next ( ) ;
}
KeyCode ::BackTab = > {
s . focus = s . focus . prev ( ) ;
}
KeyCode ::Enter = > {
if s . focus = = ConfigField ::Action {
// Action row: Tab selects Test vs Save via the sub-focus
// built into the action label. We treat Enter on Action as
// Save (the primary action). Test is fired by 't' while
// focused on Action, mirroring the wallet screen's 's'/'n'.
self . wallet_config_save ( ) ? ;
}
}
// Field editing
KeyCode ::Char ( c ) if ! key . modifiers . contains ( KeyModifiers ::CONTROL ) = > {
match s . focus {
ConfigField ::RpcUrl = > {
s . rpc_url . push ( c ) ;
}
ConfigField ::RpcLogin = > {
s . rpc_login . push ( c ) ;
}
ConfigField ::NoSpend = > {
if c = = ' ' | | c = = '\r' {
s . no_spend = ! s . no_spend ;
}
}
ConfigField ::Action = > {
match c {
't' = > self . wallet_config_test ( ) ? ,
's' = > self . wallet_config_save ( ) ? ,
'r' = > s . reveal = ! s . reveal ,
_ = > { }
}
}
}
}
KeyCode ::Backspace = > {
match s . focus {
ConfigField ::RpcUrl = > {
s . rpc_url . pop ( ) ;
}
ConfigField ::RpcLogin = > {
s . rpc_login . pop ( ) ;
}
_ = > { }
}
}
_ = > { }
}
Ok ( ( ) )
}
/// F7 Test-connection: probe the endpoint the user is *typing*, not the
/// stored one. The result lands on the screen; the live wallet is untouched.
fn wallet_config_test ( & mut self ) -> Result < ( ) , String > {
let Screen ::WalletConfig ( s ) = & mut self . screen else {
return Ok ( ( ) ) ;
} ;
let url = s . rpc_url . clone ( ) ;
let login = s . rpc_login . clone ( ) ;
s . status = ConfigStatus ::Testing ;
let result = self . rt . block_on ( self . node . wallet_test_connection ( & url , & login ) ) ;
// The status line says "connected — {PingResult::line()}". On a clean
// success the line is just "connected"; on failure it carries the
// sanitized reason.
s . status = if result . ok {
ConfigStatus ::Tested ( result )
} else {
// For failed tests, show the error inline.
ConfigStatus ::Tested ( result )
} ;
Ok ( ( ) )
}
/// F7 Save: persist the edited config, re-read it, and return to the
/// wallet screen where the change is visible at rest.
fn wallet_config_save ( & mut self ) -> Result < ( ) , String > {
let Screen ::WalletConfig ( s ) = & mut self . screen else {
return Ok ( ( ) ) ;
} ;
let cfg = wallet ::WalletConfig ::new ( & s . rpc_url , & s . rpc_login , s . no_spend ) ;
match self . node . wallet_save_config ( & cfg ) {
Ok ( ( ) ) = > {
// Re-read the stored config to reflect what's actually saved.
let _stored = WalletConfigScreen ::from_config ( self . node . wallet_config ( ) . as_ref ( ) ) ;
s . status = ConfigStatus ::Saved ( true , String ::new ( ) ) ;
// Re-read from store, keep the save status.
self . screen = Screen ::Wallet {
view : Box ::new ( self . build_wallet_view ( ) ) ,
qr_modal : None ,
copy_note : None ,
} ;
}
Err ( e ) = > {
s . status = ConfigStatus ::Saved ( false , wallet ::redact ( & e , cfg . secret ( ) ) ) ;
}
}
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 ( ) ;
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 ( ) ;
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 \n Esc 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-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 ( ) ) ,
tui(wallet): chain/daemon honesty, view-only badge, address copy (OSC 52)
- Screen::Wallet.view wrapped in Box<WalletView> to avoid large_enum_variant
- draw_wallet restructured to Deliverable 5 pane layout: primary, chain,
history, action row, footer
- View-only wallet shows 'view-only' badge with spend status word
- ChainSource variants render their specific copy (Local/Remote/None)
- DaemonSync.reachable=false renders 'sync: unknown' with no balance claim
- Address copy via OSC 52 escape sequence; 'y' key; fallback hint on screen
- QR modal resized to fit 80x24 without clipping
- wallet_screen_at_with() test helper for copy_note parameter
- 33 new tests covering receive-only, local synced/syncing, remote
unreachable, view-only badge, QR modal, address copy escape sequence
All 52 TUI tests pass (10 tui_frames + 19 tui_chrome + 23 tui_spec).
Clippy clean on lib and all three test targets.
2026-09-15 19:57:29 -04:00
Screen ::Wallet { view , qr_modal , copy_note } = > {
draw_wallet ( f , view . as_ref ( ) , qr_modal . as_ref ( ) , copy_note . as_deref ( ) )
}
tui(history): payment history and tx detail screen (card t_935bf84e)
Add Screen::History with draw_history, history_row_text, history_detail.
- Per-friend payment list: direction marker, amount, verified state, age, txid
- Enter opens detail view; Esc closes
- h key from main + wallet opens history via Node::list_payments
- Empty state: 'no payments with this friend yet'
- ASCII fallback: drops ✓/✗ glyphs, uses words only
- Peer text (memo, address) sanitized via display_text
- Tests: 5 new in tui_spec.rs (row text, detail, empty, ascii), 2 frame dumps in tui_frames.rs
Signed-off-by: tui-design <tui-design@hermes>
2026-09-15 21:29:40 -04:00
Screen ::History { friend_pk , payments , selected , detail } = > {
let name = self . friends . iter ( ) . find ( | fr | & fr . pubkey = = friend_pk )
. and_then ( | fr | fr . petname . as_deref ( ) )
. unwrap_or ( " friend " ) ;
draw_history ( f , payments , * selected , * detail , name , unix_now_secs ( ) )
}
2026-09-15 12:29:16 -04:00
Screen ::ChainSetup ( setup ) = > draw_chain_setup ( f , setup ) ,
2026-09-13 23:25:25 -04:00
Screen ::WalletSetup ( setup ) = > draw_wallet_setup ( f , setup ) ,
tui: F7 wallet config screen + wallet/chain setup redesign + doc sync
Implement the F7 wallet-endpoint config screen (Screen::WalletConfig):
- Fields: rpc_url, rpc_login masked with reveal toggle, no_spend checkbox
- Test connection (t → PingResult::line), Save (s → wallet_save_config)
- Status line: 'saved · not connected', 'connected — ...', 'error: ...'
- NO_COLOR distinguishability: '·' bullets, username visible, password masked
- Password never leaks: WalletConfig::secret() redaction on all status lines
- ConfigField cycle (Tab/Esc), footer hints, help overlay entries
Redraw draw_wallet_setup (CreateWarn→CreatePass→CreateSeed→ImportPass,
CreateWarn→ImportSeq→ImportPass) with spend-authority warning, SEEN
challenge, zeroizing buffers preserved on submit/mismatch/Esc.
Update help_overlay_text() with F6 h, F7, copy key; main_footer_hints()
for F7. Extend tui_chrome.rs needle list (F6 h, F7 added).
Reconcile docs: README key table gains F6 s/n/h and F7; WALLET.md
wallet-screen paragraph updated; TUI.md Deliverable 5 marked implemented
with after frames for each config state at 80x24 and 120x40.
Tests: 30 tui_spec (incl. 7 new wallet-config tests), tui_chrome green.
cargo test --locked: 0 failures. cargo clippy --all-targets: clean.
2026-09-15 23:01:56 -04:00
Screen ::WalletConfig ( s ) = > draw_wallet_config ( f , s ) ,
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 ) {
let area = f . area ( ) ;
2026-09-12 00:15:19 -04:00
let header = main_header_line ( area . width , & self . me_fp , & self . me_onion ) ;
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 alert_h = u16 ::from ( self . alert . is_some ( ) ) ;
2026-09-10 02:49:42 -04:00
let cols = Layout ::vertical ( [
2026-09-12 00:15:19 -04:00
Constraint ::Length ( 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
Constraint ::Length ( alert_h ) ,
Constraint ::Min ( 3 ) ,
Constraint ::Length ( 3 ) ,
2026-09-10 02:49:42 -04:00
Constraint ::Length ( 1 ) ,
] )
. split ( 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
2026-09-12 00:15:19 -04:00
f . render_widget ( Paragraph ::new ( header ) . style ( style_accent ( ) ) , cols [ 0 ] ) ;
2026-09-10 02:07:40 -04:00
if let Some ( msg ) = & self . alert {
2026-09-12 00:54:16 -04:00
let text = alert_line ( msg , area . width ) ;
2026-09-12 00:15:19 -04:00
f . render_widget ( Paragraph ::new ( text ) . style ( style_alert ( ) ) , cols [ 1 ] ) ;
2026-09-10 02:07:40 -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
2026-09-12 00:15:19 -04:00
let roster_w = roster_col_width ( area . width ) . min ( cols [ 2 ] . width . saturating_sub ( 10 ) ) ;
2026-09-10 01:54:19 -04:00
let panes =
2026-09-12 00:15:19 -04:00
Layout ::horizontal ( [ Constraint ::Length ( roster_w ) , Constraint ::Min ( 10 ) ] ) . split ( cols [ 2 ] ) ;
let inner_roster = panes [ 0 ] . width . saturating_sub ( 2 ) ;
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 stale_n = self . friends . iter ( ) . filter ( | fr | ! fr . last_connect_ok ) . count ( ) ;
let roster_title = if stale_n > 0 {
format! ( " roster {} {stale_n} stale " , self . friends . len ( ) )
} else {
format! ( " roster {} " , self . friends . len ( ) )
} ;
2026-09-10 01:54:19 -04:00
2026-09-12 00:15:19 -04:00
let items : Vec < ListItem > = if self . friends . is_empty ( ) {
vec! [ ListItem ::new ( " no friends " ) . style ( style_dim ( ) ) ]
} else {
self . friends
. iter ( )
. map ( | friend | {
let raw = friend . petname . as_deref ( ) . unwrap_or ( & friend . fingerprint ) ;
let name = sanitize ::display_text ( raw . as_bytes ( ) ) ;
let line = roster_row_text (
& name ,
& friend . fingerprint ,
! friend . last_connect_ok ,
inner_roster ,
) ;
let style = if friend . last_connect_ok {
style_text ( )
} else {
style_stale ( )
} ;
ListItem ::new ( line ) . style ( style )
} )
. collect ( )
} ;
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 roster = List ::new ( items )
2026-09-12 00:15:19 -04:00
. highlight_style ( style_highlight ( ) )
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
. highlight_symbol ( " > " )
. block ( self . pane_block ( & roster_title , Pane ::Roster ) ) ;
let mut roster_state = ListState ::default ( ) ;
if ! self . friends . is_empty ( ) {
roster_state . select ( Some ( self . selected ) ) ;
}
f . render_stateful_widget ( roster , panes [ 0 ] , & mut roster_state ) ;
2026-09-12 14:22:38 -04:00
let ( chat_lines , summary ) = self . chat_view ( ) ;
let chat_name = self . friends . get ( self . selected ) . map ( | friend | {
friend
. petname
. as_deref ( )
. unwrap_or ( & friend . fingerprint )
. to_string ( )
} ) ;
draw_chat (
f ,
panes [ 1 ] ,
& chat_lines ,
chat_name . as_deref ( ) ,
self . focus = = Pane ::Chat ,
self . chat_scroll ,
) ;
2026-09-10 01:54:19 -04:00
2026-09-12 00:15:19 -04:00
let mark = if self . focus = = Pane ::Composer {
" > "
2026-09-10 02:49:42 -04:00
} else {
2026-09-12 00:15:19 -04:00
" "
2026-09-10 02:49:42 -04:00
} ;
2026-09-12 00:15:19 -04:00
let ( cmd , cmd_style ) = if self . composer . is_empty ( ) {
( format! ( " {mark} message " ) , style_dim ( ) )
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
let style = if self . focus = = Pane ::Composer {
style_text ( ) . add_modifier ( Modifier ::BOLD )
} else {
style_text ( )
} ;
( format! ( " {mark} {} " , self . composer ) , 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
} ;
f . render_widget (
Paragraph ::new ( cmd )
. style ( cmd_style )
2026-09-12 00:15: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
cols [ 3 ] ,
) ;
2026-09-12 14:22:38 -04:00
let footer = self . footer_line ( area . width , & summary ) ;
2026-09-12 00:15:19 -04:00
f . render_widget ( Paragraph ::new ( footer ) . style ( style_dim ( ) ) , cols [ 4 ] ) ;
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 14:22:38 -04:00
fn footer_line ( & self , width : u16 , summary : & OutboxSummary ) -> String {
// The outbox is the source of truth while anything is outstanding; the
// transient note still covers "sending", "sent file x", "invoice sent".
let note = summary . note ( ) . or_else ( | | self . status_note . clone ( ) ) ;
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
status_footer (
width ,
& self . me_fp ,
& self . me_onion ,
2026-09-12 14:22:38 -04:00
note . as_deref ( ) ,
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
footer_hints ( & self . screen ) ,
)
}
2026-09-12 14:22:38 -04:00
fn chat_view ( & self ) -> ( Vec < String > , OutboxSummary ) {
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 (
vec! [
" no friends yet " . into ( ) ,
" F3 paste an invite to add one " . into ( ) ,
] ,
OutboxSummary ::default ( ) ,
) ;
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 ( ) ;
chat_with_delivery ( & msgs , & pending , unix_now_secs ( ) )
}
Err ( e ) = > ( vec! [ e ] , OutboxSummary ::default ( ) ) ,
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 pane_block < ' a > ( & self , title : & ' a str , pane : Pane ) -> Block < ' a > {
2026-09-12 14:22:38 -04:00
pane_block_for ( title , self . focus = = pane )
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 14:22:38 -04:00
/// Pane chrome without an `App`: focus is accent border + bold title, never
/// color alone (the `> ` marks come from the callers).
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 ,
) {
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 (
Paragraph ::new ( lines . join ( " \n " ) )
. style ( style_text ( ) )
. wrap ( Wrap { trim : false } )
. scroll ( ( scroll , 0 ) )
. block ( pane_block_for ( & title , focused ) ) ,
area ,
) ;
}
2026-09-12 00:15:19 -04:00
/// Status bar: never drop a non-empty `status_note`. Always keep `TOR`, `me:`, `? 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 status_footer (
width : u16 ,
me_fp : & str ,
me_onion : & str ,
status_note : Option < & str > ,
hints : & str ,
) -> String {
let w = width as usize ;
2026-09-12 00:15:19 -04:00
let gap = if w > = 120 { " " } else { " " } ;
let help = " ? help " ;
let me = format! ( " TOR me: {} " , truncate_fp ( me_fp ) ) ;
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} " ) ;
}
let onion_full = if me_onion . is_empty ( ) {
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
" unset " . to_string ( )
2026-09-12 00:15:19 -04:00
} else {
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
me_onion . to_string ( )
2026-09-12 00:15:19 -04:00
} ;
let onion_short = if me_onion . is_empty ( ) {
" unset " . to_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
} else {
truncate_fp ( me_onion )
} ;
2026-09-12 00:15:19 -04:00
if ! note . is_empty ( ) {
let fixed = char_len ( & me ) + char_len ( help ) + 2 * gap . len ( ) ;
let budget = w . saturating_sub ( fixed ) ;
if char_len ( & note ) > budget {
note = truncate_chars ( & note , budget . max ( 12 ) ) ;
}
}
let mut parts : Vec < String > = Vec ::new ( ) ;
if ! note . is_empty ( ) {
parts . push ( note ) ;
}
parts . push ( me ) ;
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 ) ;
}
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 ) ;
if char_len ( & line ) < = w {
line
} else {
truncate_chars ( & 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 ) ;
char_len ( & 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
}
/// Main-screen key hints. Kept short so width 80 still shows TOR + identity + `? help`.
pub fn main_footer_hints ( ) -> & 'static str {
tui(history): payment history and tx detail screen (card t_935bf84e)
Add Screen::History with draw_history, history_row_text, history_detail.
- Per-friend payment list: direction marker, amount, verified state, age, txid
- Enter opens detail view; Esc closes
- h key from main + wallet opens history via Node::list_payments
- Empty state: 'no payments with this friend yet'
- ASCII fallback: drops ✓/✗ glyphs, uses words only
- Peer text (memo, address) sanitized via display_text
- Tests: 5 new in tui_spec.rs (row text, detail, empty, ascii), 2 frame dumps in tui_frames.rs
Signed-off-by: tui-design <tui-design@hermes>
2026-09-15 21:29:40 -04:00
" Tab F2 F3 F4 F5 F6 h ? 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
}
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 " ,
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 " ,
tui(history): payment history and tx detail screen (card t_935bf84e)
Add Screen::History with draw_history, history_row_text, history_detail.
- Per-friend payment list: direction marker, amount, verified state, age, txid
- Enter opens detail view; Esc closes
- h key from main + wallet opens history via Node::list_payments
- Empty state: 'no payments with this friend yet'
- ASCII fallback: drops ✓/✗ glyphs, uses words only
- Peer text (memo, address) sanitized via display_text
- Tests: 5 new in tui_spec.rs (row text, detail, empty, ascii), 2 frame dumps in tui_frames.rs
Signed-off-by: tui-design <tui-design@hermes>
2026-09-15 21:29:40 -04:00
Screen ::Wallet { .. } = > " s chain n node c create i import h history r qr y copy Esc back ? help " ,
Screen ::History { .. } = > " Enter detail Esc back ? help " ,
2026-09-15 12:29:16 -04:00
Screen ::ChainSetup ( _ ) = > " Enter select/save Esc back ? help " ,
tui: F7 wallet config screen + wallet/chain setup redesign + doc sync
Implement the F7 wallet-endpoint config screen (Screen::WalletConfig):
- Fields: rpc_url, rpc_login masked with reveal toggle, no_spend checkbox
- Test connection (t → PingResult::line), Save (s → wallet_save_config)
- Status line: 'saved · not connected', 'connected — ...', 'error: ...'
- NO_COLOR distinguishability: '·' bullets, username visible, password masked
- Password never leaks: WalletConfig::secret() redaction on all status lines
- ConfigField cycle (Tab/Esc), footer hints, help overlay entries
Redraw draw_wallet_setup (CreateWarn→CreatePass→CreateSeed→ImportPass,
CreateWarn→ImportSeq→ImportPass) with spend-authority warning, SEEN
challenge, zeroizing buffers preserved on submit/mismatch/Esc.
Update help_overlay_text() with F6 h, F7, copy key; main_footer_hints()
for F7. Extend tui_chrome.rs needle list (F6 h, F7 added).
Reconcile docs: README key table gains F6 s/n/h and F7; WALLET.md
wallet-screen paragraph updated; TUI.md Deliverable 5 marked implemented
with after frames for each config state at 80x24 and 120x40.
Tests: 30 tui_spec (incl. 7 new wallet-config tests), tui_chrome green.
cargo test --locked: 0 failures. cargo clippy --all-targets: clean.
2026-09-15 23:01:56 -04:00
Screen ::WalletConfig ( _ ) = > " Tab fields t test s save 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 " ,
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
}
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 \n fp {fp} \n onion {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 \n fp {} \n onion {} \n \n y 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-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) \n Enter 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 \n Enter 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 ( ) ,
) ;
}
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 ( ) ;
2026-09-12 00:15:19 -04:00
let popup = if area . height < 28 {
area
} else {
let lines = text . lines ( ) . count ( ) as u16 + 2 ;
let text_w = text
. lines ( )
. map ( | l | l . chars ( ) . count ( ) as u16 )
. max ( )
. unwrap_or ( 40 )
. saturating_add ( 4 ) ;
let width = text_w . min ( area . width ) . max ( 10 ) ;
let height = lines . min ( area . height ) . max ( 3 ) ;
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 | {
let n = char_len ( l ) as u16 ;
if n = = 0 { 1 } else { n . div_ceil ( inner_w ) }
} )
. 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 ,
) ;
}
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 ( ) )
}
fn roster_row_text ( name : & str , fingerprint : & str , stale : bool , inner_width : u16 ) -> String {
let budget = ( inner_width as usize ) . saturating_sub ( 2 ) ;
let fp = truncate_fp ( fingerprint ) ;
let fp_part = format! ( " {fp} " ) ;
let mut stale_s = if stale { " stale " } else { " " } . to_string ( ) ;
let suffix_len = char_len ( & fp_part ) + char_len ( & stale_s ) ;
let mut name_budget = budget . saturating_sub ( suffix_len ) ;
if name_budget < 1 & & stale {
stale_s = " s " . into ( ) ;
name_budget = budget . saturating_sub ( char_len ( & fp_part ) + char_len ( & stale_s ) ) ;
}
let shown = if name_budget = = 0 {
String ::new ( )
} else {
truncate_chars ( name , name_budget )
} ;
let line = format! ( " {shown} {fp_part} {stale_s} " ) ;
if char_len ( & line ) > budget {
truncate_chars ( & line , budget )
} else {
line
}
2026-09-10 01:54:19 -04:00
}
fn to_hex ( bytes : & [ u8 ] ) -> String {
bytes . iter ( ) . map ( | b | format! ( " {b:02x} " ) ) . collect ( )
}
2026-09-15 12:29:16 -04:00
/// The `monero:` QR popup over the wallet screen. `pub` (fields private) because
/// [`draw_wallet`] takes one: the render spec draws the real screen.
2026-09-12 22:53:58 -04:00
#[ derive(Clone, Debug) ]
2026-09-15 12:29:16 -04:00
pub struct QrModal {
2026-09-12 22:53:58 -04:00
closed : bool ,
matrix_rows : Vec < String > ,
#[ allow(dead_code) ]
uri : String ,
}
tui(wallet): chain/daemon honesty, view-only badge, address copy (OSC 52)
- Screen::Wallet.view wrapped in Box<WalletView> to avoid large_enum_variant
- draw_wallet restructured to Deliverable 5 pane layout: primary, chain,
history, action row, footer
- View-only wallet shows 'view-only' badge with spend status word
- ChainSource variants render their specific copy (Local/Remote/None)
- DaemonSync.reachable=false renders 'sync: unknown' with no balance claim
- Address copy via OSC 52 escape sequence; 'y' key; fallback hint on screen
- QR modal resized to fit 80x24 without clipping
- wallet_screen_at_with() test helper for copy_note parameter
- 33 new tests covering receive-only, local synced/syncing, remote
unreachable, view-only badge, QR modal, address copy escape sequence
All 52 TUI tests pass (10 tui_frames + 19 tui_chrome + 23 tui_spec).
Clippy clean on lib and all three test targets.
2026-09-15 19:57:29 -04:00
impl QrModal {
/// Public constructor so tests can build a modal to exercise `draw_wallet`'s
/// QR path without touching the private `App` / `Node`.
pub fn test_new ( closed : bool , matrix_rows : Vec < String > , uri : String ) -> Self {
Self {
closed ,
matrix_rows ,
uri ,
}
}
}
2026-09-15 12:29:16 -04:00
/// The F6 wallet screen.
///
/// `pub` on purpose: the not-ready render is a spec of this card, so the test
/// draws this for real at a fixed size rather than a stand-in.
tui(wallet): chain/daemon honesty, view-only badge, address copy (OSC 52)
- Screen::Wallet.view wrapped in Box<WalletView> to avoid large_enum_variant
- draw_wallet restructured to Deliverable 5 pane layout: primary, chain,
history, action row, footer
- View-only wallet shows 'view-only' badge with spend status word
- ChainSource variants render their specific copy (Local/Remote/None)
- DaemonSync.reachable=false renders 'sync: unknown' with no balance claim
- Address copy via OSC 52 escape sequence; 'y' key; fallback hint on screen
- QR modal resized to fit 80x24 without clipping
- wallet_screen_at_with() test helper for copy_note parameter
- 33 new tests covering receive-only, local synced/syncing, remote
unreachable, view-only badge, QR modal, address copy escape sequence
All 52 TUI tests pass (10 tui_frames + 19 tui_chrome + 23 tui_spec).
Clippy clean on lib and all three test targets.
2026-09-15 19:57:29 -04:00
/// The wallet screen: address, balance, chain state, transfer history, QR modal,
/// and address copy (OSC 52 + fallback hint). Pure draw — the not-ready rules
/// live in `wallet_view` / `chain_view`; this only renders what it is given.
pub fn draw_wallet ( f : & mut Frame , view : & WalletView , modal : Option < & QrModal > , copy_note : Option < & str > ) {
2026-09-12 22:53:58 -04:00
let area = f . area ( ) ;
tui(wallet): chain/daemon honesty, view-only badge, address copy (OSC 52)
- Screen::Wallet.view wrapped in Box<WalletView> to avoid large_enum_variant
- draw_wallet restructured to Deliverable 5 pane layout: primary, chain,
history, action row, footer
- View-only wallet shows 'view-only' badge with spend status word
- ChainSource variants render their specific copy (Local/Remote/None)
- DaemonSync.reachable=false renders 'sync: unknown' with no balance claim
- Address copy via OSC 52 escape sequence; 'y' key; fallback hint on screen
- QR modal resized to fit 80x24 without clipping
- wallet_screen_at_with() test helper for copy_note parameter
- 33 new tests covering receive-only, local synced/syncing, remote
unreachable, view-only badge, QR modal, address copy escape sequence
All 52 TUI tests pass (10 tui_frames + 19 tui_chrome + 23 tui_spec).
Clippy clean on lib and all three test targets.
2026-09-15 19:57:29 -04:00
// --- QR modal (on top of everything) -----------------------------------
2026-09-12 22:53:58 -04:00
if let Some ( m ) = modal {
f . render_widget ( Clear , area ) ;
tui(wallet): chain/daemon honesty, view-only badge, address copy (OSC 52)
- Screen::Wallet.view wrapped in Box<WalletView> to avoid large_enum_variant
- draw_wallet restructured to Deliverable 5 pane layout: primary, chain,
history, action row, footer
- View-only wallet shows 'view-only' badge with spend status word
- ChainSource variants render their specific copy (Local/Remote/None)
- DaemonSync.reachable=false renders 'sync: unknown' with no balance claim
- Address copy via OSC 52 escape sequence; 'y' key; fallback hint on screen
- QR modal resized to fit 80x24 without clipping
- wallet_screen_at_with() test helper for copy_note parameter
- 33 new tests covering receive-only, local synced/syncing, remote
unreachable, view-only badge, QR modal, address copy escape sequence
All 52 TUI tests pass (10 tui_frames + 19 tui_chrome + 23 tui_spec).
Clippy clean on lib and all three test targets.
2026-09-15 19:57:29 -04:00
// Cap the popup so it never clips at 80x24: a QR matrix is square,
// and one-cell-glyphs are double-width to the eye, so 46 chars is
// the largest matrix that fits in 80 with a border + title + margins.
let max_mat = 46 u16 ;
let popup_w = max_mat . min ( area . width . saturating_sub ( 4 ) . max ( 1 ) ) . saturating_add ( 2 ) ;
2026-09-12 22:53:58 -04:00
let rows = m . matrix_rows . len ( ) . max ( 1 ) ;
tui(wallet): chain/daemon honesty, view-only badge, address copy (OSC 52)
- Screen::Wallet.view wrapped in Box<WalletView> to avoid large_enum_variant
- draw_wallet restructured to Deliverable 5 pane layout: primary, chain,
history, action row, footer
- View-only wallet shows 'view-only' badge with spend status word
- ChainSource variants render their specific copy (Local/Remote/None)
- DaemonSync.reachable=false renders 'sync: unknown' with no balance claim
- Address copy via OSC 52 escape sequence; 'y' key; fallback hint on screen
- QR modal resized to fit 80x24 without clipping
- wallet_screen_at_with() test helper for copy_note parameter
- 33 new tests covering receive-only, local synced/syncing, remote
unreachable, view-only badge, QR modal, address copy escape sequence
All 52 TUI tests pass (10 tui_frames + 19 tui_chrome + 23 tui_spec).
Clippy clean on lib and all three test targets.
2026-09-15 19:57:29 -04:00
let popup_h = ( rows as u16 ) . min ( area . height . saturating_sub ( 4 ) . max ( 1 ) ) . saturating_add ( 2 ) ;
2026-09-12 22:53:58 -04:00
let x = area . x + ( area . width . saturating_sub ( popup_w ) ) / 2 ;
let y = area . y + ( area . height . saturating_sub ( popup_h ) ) / 2 ;
tui(wallet): chain/daemon honesty, view-only badge, address copy (OSC 52)
- Screen::Wallet.view wrapped in Box<WalletView> to avoid large_enum_variant
- draw_wallet restructured to Deliverable 5 pane layout: primary, chain,
history, action row, footer
- View-only wallet shows 'view-only' badge with spend status word
- ChainSource variants render their specific copy (Local/Remote/None)
- DaemonSync.reachable=false renders 'sync: unknown' with no balance claim
- Address copy via OSC 52 escape sequence; 'y' key; fallback hint on screen
- QR modal resized to fit 80x24 without clipping
- wallet_screen_at_with() test helper for copy_note parameter
- 33 new tests covering receive-only, local synced/syncing, remote
unreachable, view-only badge, QR modal, address copy escape sequence
All 52 TUI tests pass (10 tui_frames + 19 tui_chrome + 23 tui_spec).
Clippy clean on lib and all three test targets.
2026-09-15 19:57:29 -04:00
let popup = Rect { x , y , width : popup_w , height : popup_h } ;
2026-09-12 22:53:58 -04:00
f . render_widget ( Clear , popup ) ;
tui(wallet): chain/daemon honesty, view-only badge, address copy (OSC 52)
- Screen::Wallet.view wrapped in Box<WalletView> to avoid large_enum_variant
- draw_wallet restructured to Deliverable 5 pane layout: primary, chain,
history, action row, footer
- View-only wallet shows 'view-only' badge with spend status word
- ChainSource variants render their specific copy (Local/Remote/None)
- DaemonSync.reachable=false renders 'sync: unknown' with no balance claim
- Address copy via OSC 52 escape sequence; 'y' key; fallback hint on screen
- QR modal resized to fit 80x24 without clipping
- wallet_screen_at_with() test helper for copy_note parameter
- 33 new tests covering receive-only, local synced/syncing, remote
unreachable, view-only badge, QR modal, address copy escape sequence
All 52 TUI tests pass (10 tui_frames + 19 tui_chrome + 23 tui_spec).
Clippy clean on lib and all three test targets.
2026-09-15 19:57:29 -04:00
let mut body = String ::from ( " receive address \n Esc or r closes \n \n " ) ;
2026-09-12 22:53:58 -04:00
if m . matrix_rows . is_empty ( ) {
body . push_str ( " (qr error) " ) ;
} else {
tui(wallet): chain/daemon honesty, view-only badge, address copy (OSC 52)
- Screen::Wallet.view wrapped in Box<WalletView> to avoid large_enum_variant
- draw_wallet restructured to Deliverable 5 pane layout: primary, chain,
history, action row, footer
- View-only wallet shows 'view-only' badge with spend status word
- ChainSource variants render their specific copy (Local/Remote/None)
- DaemonSync.reachable=false renders 'sync: unknown' with no balance claim
- Address copy via OSC 52 escape sequence; 'y' key; fallback hint on screen
- QR modal resized to fit 80x24 without clipping
- wallet_screen_at_with() test helper for copy_note parameter
- 33 new tests covering receive-only, local synced/syncing, remote
unreachable, view-only badge, QR modal, address copy escape sequence
All 52 TUI tests pass (10 tui_frames + 19 tui_chrome + 23 tui_spec).
Clippy clean on lib and all three test targets.
2026-09-15 19:57:29 -04:00
let inner_h = popup_h . saturating_sub ( 2 ) . max ( 1 ) as usize ;
for row in m . matrix_rows . iter ( ) . take ( inner_h ) {
// Each QR row may be wider than the popup; truncate to fit.
let row_str : String = row . chars ( ) . take ( popup_w . saturating_sub ( 2 ) as usize ) . collect ( ) ;
body . push_str ( & row_str ) ;
2026-09-12 22:53:58 -04:00
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 ;
}
tui(wallet): chain/daemon honesty, view-only badge, address copy (OSC 52)
- Screen::Wallet.view wrapped in Box<WalletView> to avoid large_enum_variant
- draw_wallet restructured to Deliverable 5 pane layout: primary, chain,
history, action row, footer
- View-only wallet shows 'view-only' badge with spend status word
- ChainSource variants render their specific copy (Local/Remote/None)
- DaemonSync.reachable=false renders 'sync: unknown' with no balance claim
- Address copy via OSC 52 escape sequence; 'y' key; fallback hint on screen
- QR modal resized to fit 80x24 without clipping
- wallet_screen_at_with() test helper for copy_note parameter
- 33 new tests covering receive-only, local synced/syncing, remote
unreachable, view-only badge, QR modal, address copy escape sequence
All 52 TUI tests pass (10 tui_frames + 19 tui_chrome + 23 tui_spec).
Clippy clean on lib and all three test targets.
2026-09-15 19:57:29 -04:00
// --- Five-row vertical layout: title, primary, chain, history, footer ---
2026-09-12 22:53:58 -04:00
let cols = Layout ::vertical ( [
tui(wallet): chain/daemon honesty, view-only badge, address copy (OSC 52)
- Screen::Wallet.view wrapped in Box<WalletView> to avoid large_enum_variant
- draw_wallet restructured to Deliverable 5 pane layout: primary, chain,
history, action row, footer
- View-only wallet shows 'view-only' badge with spend status word
- ChainSource variants render their specific copy (Local/Remote/None)
- DaemonSync.reachable=false renders 'sync: unknown' with no balance claim
- Address copy via OSC 52 escape sequence; 'y' key; fallback hint on screen
- QR modal resized to fit 80x24 without clipping
- wallet_screen_at_with() test helper for copy_note parameter
- 33 new tests covering receive-only, local synced/syncing, remote
unreachable, view-only badge, QR modal, address copy escape sequence
All 52 TUI tests pass (10 tui_frames + 19 tui_chrome + 23 tui_spec).
Clippy clean on lib and all three test targets.
2026-09-15 19:57:29 -04:00
// 1. Title bar
2026-09-12 22:53:58 -04:00
Constraint ::Length ( 2 ) ,
tui(wallet): chain/daemon honesty, view-only badge, address copy (OSC 52)
- Screen::Wallet.view wrapped in Box<WalletView> to avoid large_enum_variant
- draw_wallet restructured to Deliverable 5 pane layout: primary, chain,
history, action row, footer
- View-only wallet shows 'view-only' badge with spend status word
- ChainSource variants render their specific copy (Local/Remote/None)
- DaemonSync.reachable=false renders 'sync: unknown' with no balance claim
- Address copy via OSC 52 escape sequence; 'y' key; fallback hint on screen
- QR modal resized to fit 80x24 without clipping
- wallet_screen_at_with() test helper for copy_note parameter
- 33 new tests covering receive-only, local synced/syncing, remote
unreachable, view-only badge, QR modal, address copy escape sequence
All 52 TUI tests pass (10 tui_frames + 19 tui_chrome + 23 tui_spec).
Clippy clean on lib and all three test targets.
2026-09-15 19:57:29 -04:00
// 2. Primary block: address + balance + readiness + view-only badge
Constraint ::Length ( 8 ) ,
// 3. Chain block: 5 chain lines
Constraint ::Length ( 7 ) ,
// 4. History block: up to 6 transfer rows (or "none")
Constraint ::Max ( 8 ) ,
// 5. Footer: status note or action row
2026-09-12 22:53:58 -04:00
Constraint ::Length ( 1 ) ,
] )
. split ( area ) ;
tui(wallet): chain/daemon honesty, view-only badge, address copy (OSC 52)
- Screen::Wallet.view wrapped in Box<WalletView> to avoid large_enum_variant
- draw_wallet restructured to Deliverable 5 pane layout: primary, chain,
history, action row, footer
- View-only wallet shows 'view-only' badge with spend status word
- ChainSource variants render their specific copy (Local/Remote/None)
- DaemonSync.reachable=false renders 'sync: unknown' with no balance claim
- Address copy via OSC 52 escape sequence; 'y' key; fallback hint on screen
- QR modal resized to fit 80x24 without clipping
- wallet_screen_at_with() test helper for copy_note parameter
- 33 new tests covering receive-only, local synced/syncing, remote
unreachable, view-only badge, QR modal, address copy escape sequence
All 52 TUI tests pass (10 tui_frames + 19 tui_chrome + 23 tui_spec).
Clippy clean on lib and all three test targets.
2026-09-15 19:57:29 -04:00
// 1. Title
2026-09-12 22:53:58 -04:00
f . render_widget (
Paragraph ::new ( " wallet " )
. style ( style_accent ( ) )
. block ( pane_block_for ( " wallet " , true ) ) ,
cols [ 0 ] ,
) ;
tui(wallet): chain/daemon honesty, view-only badge, address copy (OSC 52)
- Screen::Wallet.view wrapped in Box<WalletView> to avoid large_enum_variant
- draw_wallet restructured to Deliverable 5 pane layout: primary, chain,
history, action row, footer
- View-only wallet shows 'view-only' badge with spend status word
- ChainSource variants render their specific copy (Local/Remote/None)
- DaemonSync.reachable=false renders 'sync: unknown' with no balance claim
- Address copy via OSC 52 escape sequence; 'y' key; fallback hint on screen
- QR modal resized to fit 80x24 without clipping
- wallet_screen_at_with() test helper for copy_note parameter
- 33 new tests covering receive-only, local synced/syncing, remote
unreachable, view-only badge, QR modal, address copy escape sequence
All 52 TUI tests pass (10 tui_frames + 19 tui_chrome + 23 tui_spec).
Clippy clean on lib and all three test targets.
2026-09-15 19:57:29 -04:00
// 2. Primary block — address, balance, readiness, badge
2026-09-15 12:29:16 -04:00
let addr_line = if view . receive_addr . is_empty ( ) {
" no address yet — /profile xmr, or create a wallet " . to_string ( )
2026-09-12 22:53:58 -04:00
} else {
2026-09-15 12:29:16 -04:00
view . receive_addr . clone ( )
2026-09-12 22:53:58 -04:00
} ;
tui(wallet): chain/daemon honesty, view-only badge, address copy (OSC 52)
- Screen::Wallet.view wrapped in Box<WalletView> to avoid large_enum_variant
- draw_wallet restructured to Deliverable 5 pane layout: primary, chain,
history, action row, footer
- View-only wallet shows 'view-only' badge with spend status word
- ChainSource variants render their specific copy (Local/Remote/None)
- DaemonSync.reachable=false renders 'sync: unknown' with no balance claim
- Address copy via OSC 52 escape sequence; 'y' key; fallback hint on screen
- QR modal resized to fit 80x24 without clipping
- wallet_screen_at_with() test helper for copy_note parameter
- 33 new tests covering receive-only, local synced/syncing, remote
unreachable, view-only badge, QR modal, address copy escape sequence
All 52 TUI tests pass (10 tui_frames + 19 tui_chrome + 23 tui_spec).
Clippy clean on lib and all three test targets.
2026-09-15 19:57:29 -04:00
2026-09-15 20:04:28 -04:00
// View-only badge: glyph + word, never colour-only, never emoji, and the
// same under NO_COLOR / ONIONWIRE_ASCII (the word carries the meaning).
tui(wallet): chain/daemon honesty, view-only badge, address copy (OSC 52)
- Screen::Wallet.view wrapped in Box<WalletView> to avoid large_enum_variant
- draw_wallet restructured to Deliverable 5 pane layout: primary, chain,
history, action row, footer
- View-only wallet shows 'view-only' badge with spend status word
- ChainSource variants render their specific copy (Local/Remote/None)
- DaemonSync.reachable=false renders 'sync: unknown' with no balance claim
- Address copy via OSC 52 escape sequence; 'y' key; fallback hint on screen
- QR modal resized to fit 80x24 without clipping
- wallet_screen_at_with() test helper for copy_note parameter
- 33 new tests covering receive-only, local synced/syncing, remote
unreachable, view-only badge, QR modal, address copy escape sequence
All 52 TUI tests pass (10 tui_frames + 19 tui_chrome + 23 tui_spec).
Clippy clean on lib and all three test targets.
2026-09-15 19:57:29 -04:00
let badge = if view . no_spend {
2026-09-15 20:04:28 -04:00
" [!] view-only — /tip off "
tui(wallet): chain/daemon honesty, view-only badge, address copy (OSC 52)
- Screen::Wallet.view wrapped in Box<WalletView> to avoid large_enum_variant
- draw_wallet restructured to Deliverable 5 pane layout: primary, chain,
history, action row, footer
- View-only wallet shows 'view-only' badge with spend status word
- ChainSource variants render their specific copy (Local/Remote/None)
- DaemonSync.reachable=false renders 'sync: unknown' with no balance claim
- Address copy via OSC 52 escape sequence; 'y' key; fallback hint on screen
- QR modal resized to fit 80x24 without clipping
- wallet_screen_at_with() test helper for copy_note parameter
- 33 new tests covering receive-only, local synced/syncing, remote
unreachable, view-only badge, QR modal, address copy escape sequence
All 52 TUI tests pass (10 tui_frames + 19 tui_chrome + 23 tui_spec).
Clippy clean on lib and all three test targets.
2026-09-15 19:57:29 -04:00
} else {
2026-09-15 20:04:28 -04:00
" [ok] spend enabled "
tui(wallet): chain/daemon honesty, view-only badge, address copy (OSC 52)
- Screen::Wallet.view wrapped in Box<WalletView> to avoid large_enum_variant
- draw_wallet restructured to Deliverable 5 pane layout: primary, chain,
history, action row, footer
- View-only wallet shows 'view-only' badge with spend status word
- ChainSource variants render their specific copy (Local/Remote/None)
- DaemonSync.reachable=false renders 'sync: unknown' with no balance claim
- Address copy via OSC 52 escape sequence; 'y' key; fallback hint on screen
- QR modal resized to fit 80x24 without clipping
- wallet_screen_at_with() test helper for copy_note parameter
- 33 new tests covering receive-only, local synced/syncing, remote
unreachable, view-only badge, QR modal, address copy escape sequence
All 52 TUI tests pass (10 tui_frames + 19 tui_chrome + 23 tui_spec).
Clippy clean on lib and all three test targets.
2026-09-15 19:57:29 -04:00
} ;
let primary_lines : Vec < String > = if view . receive_addr . is_empty ( ) {
vec! [
format! ( " address {addr_line} " ) ,
format! ( " balance {} " , view . balance ) ,
String ::new ( ) ,
badge . to_string ( ) ,
String ::new ( ) ,
view . chain . status_line . clone ( ) ,
]
} else {
vec! [
format! ( " address {} " , truncate_chars ( & addr_line , 74 ) ) ,
format! ( " balance {} " , view . balance ) ,
String ::new ( ) ,
badge . to_string ( ) ,
String ::new ( ) ,
view . chain . status_line . clone ( ) ,
]
} ;
f . render_widget (
Paragraph ::new ( primary_lines . join ( " \n " ) )
. style ( style_text ( ) )
. wrap ( Wrap { trim : false } )
. block (
apply_chrome_borders ( Block ::default ( ) )
. border_style ( style_border ( ) )
. title ( " wallet " ) ,
) ,
cols [ 1 ] ,
) ;
// 3. Chain block
let chain_lines : Vec < String > = view . chain . lines ( ) ;
f . render_widget (
Paragraph ::new ( chain_lines . join ( " \n " ) )
. style ( style_text ( ) )
. wrap ( Wrap { trim : false } )
. block (
apply_chrome_borders ( Block ::default ( ) )
. border_style ( style_border ( ) )
. title ( " chain " ) ,
) ,
cols [ 2 ] ,
) ;
// 4. History block
let mut history_lines : Vec < String > = vec! [ " recent transfers " . to_string ( ) ] ;
2026-09-15 12:29:16 -04:00
if view . transfers . is_empty ( ) {
tui(wallet): chain/daemon honesty, view-only badge, address copy (OSC 52)
- Screen::Wallet.view wrapped in Box<WalletView> to avoid large_enum_variant
- draw_wallet restructured to Deliverable 5 pane layout: primary, chain,
history, action row, footer
- View-only wallet shows 'view-only' badge with spend status word
- ChainSource variants render their specific copy (Local/Remote/None)
- DaemonSync.reachable=false renders 'sync: unknown' with no balance claim
- Address copy via OSC 52 escape sequence; 'y' key; fallback hint on screen
- QR modal resized to fit 80x24 without clipping
- wallet_screen_at_with() test helper for copy_note parameter
- 33 new tests covering receive-only, local synced/syncing, remote
unreachable, view-only badge, QR modal, address copy escape sequence
All 52 TUI tests pass (10 tui_frames + 19 tui_chrome + 23 tui_spec).
Clippy clean on lib and all three test targets.
2026-09-15 19:57:29 -04:00
history_lines . push ( " (none shown) " . to_string ( ) ) ;
2026-09-12 22:53:58 -04:00
} else {
tui(wallet): chain/daemon honesty, view-only badge, address copy (OSC 52)
- Screen::Wallet.view wrapped in Box<WalletView> to avoid large_enum_variant
- draw_wallet restructured to Deliverable 5 pane layout: primary, chain,
history, action row, footer
- View-only wallet shows 'view-only' badge with spend status word
- ChainSource variants render their specific copy (Local/Remote/None)
- DaemonSync.reachable=false renders 'sync: unknown' with no balance claim
- Address copy via OSC 52 escape sequence; 'y' key; fallback hint on screen
- QR modal resized to fit 80x24 without clipping
- wallet_screen_at_with() test helper for copy_note parameter
- 33 new tests covering receive-only, local synced/syncing, remote
unreachable, view-only badge, QR modal, address copy escape sequence
All 52 TUI tests pass (10 tui_frames + 19 tui_chrome + 23 tui_spec).
Clippy clean on lib and all three test targets.
2026-09-15 19:57:29 -04:00
for t in view . transfers . iter ( ) . take ( 6 ) {
2026-09-12 22:53:58 -04:00
let xmr = crate ::pay ::atomic_to_xmr_str ( & t . amount ) ;
tui(wallet): chain/daemon honesty, view-only badge, address copy (OSC 52)
- Screen::Wallet.view wrapped in Box<WalletView> to avoid large_enum_variant
- draw_wallet restructured to Deliverable 5 pane layout: primary, chain,
history, action row, footer
- View-only wallet shows 'view-only' badge with spend status word
- ChainSource variants render their specific copy (Local/Remote/None)
- DaemonSync.reachable=false renders 'sync: unknown' with no balance claim
- Address copy via OSC 52 escape sequence; 'y' key; fallback hint on screen
- QR modal resized to fit 80x24 without clipping
- wallet_screen_at_with() test helper for copy_note parameter
- 33 new tests covering receive-only, local synced/syncing, remote
unreachable, view-only badge, QR modal, address copy escape sequence
All 52 TUI tests pass (10 tui_frames + 19 tui_chrome + 23 tui_spec).
Clippy clean on lib and all three test targets.
2026-09-15 19:57:29 -04:00
let txid_short = truncate_chars ( & t . txid , 12 ) ;
history_lines . push ( format! ( " {txid_short} {xmr} XMR " ) ) ;
2026-09-12 22:53:58 -04:00
}
}
tui(wallet): chain/daemon honesty, view-only badge, address copy (OSC 52)
- Screen::Wallet.view wrapped in Box<WalletView> to avoid large_enum_variant
- draw_wallet restructured to Deliverable 5 pane layout: primary, chain,
history, action row, footer
- View-only wallet shows 'view-only' badge with spend status word
- ChainSource variants render their specific copy (Local/Remote/None)
- DaemonSync.reachable=false renders 'sync: unknown' with no balance claim
- Address copy via OSC 52 escape sequence; 'y' key; fallback hint on screen
- QR modal resized to fit 80x24 without clipping
- wallet_screen_at_with() test helper for copy_note parameter
- 33 new tests covering receive-only, local synced/syncing, remote
unreachable, view-only badge, QR modal, address copy escape sequence
All 52 TUI tests pass (10 tui_frames + 19 tui_chrome + 23 tui_spec).
Clippy clean on lib and all three test targets.
2026-09-15 19:57:29 -04:00
let history_text = history_lines . join ( " \n " ) ;
2026-09-12 22:53:58 -04:00
f . render_widget (
tui(wallet): chain/daemon honesty, view-only badge, address copy (OSC 52)
- Screen::Wallet.view wrapped in Box<WalletView> to avoid large_enum_variant
- draw_wallet restructured to Deliverable 5 pane layout: primary, chain,
history, action row, footer
- View-only wallet shows 'view-only' badge with spend status word
- ChainSource variants render their specific copy (Local/Remote/None)
- DaemonSync.reachable=false renders 'sync: unknown' with no balance claim
- Address copy via OSC 52 escape sequence; 'y' key; fallback hint on screen
- QR modal resized to fit 80x24 without clipping
- wallet_screen_at_with() test helper for copy_note parameter
- 33 new tests covering receive-only, local synced/syncing, remote
unreachable, view-only badge, QR modal, address copy escape sequence
All 52 TUI tests pass (10 tui_frames + 19 tui_chrome + 23 tui_spec).
Clippy clean on lib and all three test targets.
2026-09-15 19:57:29 -04:00
Paragraph ::new ( history_text )
2026-09-12 22:53:58 -04:00
. style ( style_text ( ) )
. wrap ( Wrap { trim : false } )
tui(wallet): chain/daemon honesty, view-only badge, address copy (OSC 52)
- Screen::Wallet.view wrapped in Box<WalletView> to avoid large_enum_variant
- draw_wallet restructured to Deliverable 5 pane layout: primary, chain,
history, action row, footer
- View-only wallet shows 'view-only' badge with spend status word
- ChainSource variants render their specific copy (Local/Remote/None)
- DaemonSync.reachable=false renders 'sync: unknown' with no balance claim
- Address copy via OSC 52 escape sequence; 'y' key; fallback hint on screen
- QR modal resized to fit 80x24 without clipping
- wallet_screen_at_with() test helper for copy_note parameter
- 33 new tests covering receive-only, local synced/syncing, remote
unreachable, view-only badge, QR modal, address copy escape sequence
All 52 TUI tests pass (10 tui_frames + 19 tui_chrome + 23 tui_spec).
Clippy clean on lib and all three test targets.
2026-09-15 19:57:29 -04:00
. block (
apply_chrome_borders ( Block ::default ( ) )
. border_style ( style_border ( ) )
. title ( " history " ) ,
) ,
cols [ 3 ] ,
2026-09-12 22:53:58 -04:00
) ;
tui(wallet): chain/daemon honesty, view-only badge, address copy (OSC 52)
- Screen::Wallet.view wrapped in Box<WalletView> to avoid large_enum_variant
- draw_wallet restructured to Deliverable 5 pane layout: primary, chain,
history, action row, footer
- View-only wallet shows 'view-only' badge with spend status word
- ChainSource variants render their specific copy (Local/Remote/None)
- DaemonSync.reachable=false renders 'sync: unknown' with no balance claim
- Address copy via OSC 52 escape sequence; 'y' key; fallback hint on screen
- QR modal resized to fit 80x24 without clipping
- wallet_screen_at_with() test helper for copy_note parameter
- 33 new tests covering receive-only, local synced/syncing, remote
unreachable, view-only badge, QR modal, address copy escape sequence
All 52 TUI tests pass (10 tui_frames + 19 tui_chrome + 23 tui_spec).
Clippy clean on lib and all three test targets.
2026-09-15 19:57:29 -04:00
// 5. Footer — status note (from copy) or action hints
let footer_text = if let Some ( note ) = copy_note {
note . to_string ( )
} else {
" s chain n start/stop c create i import r qr y copy Esc back " . to_string ( )
} ;
f . render_widget (
Paragraph ::new ( footer_text )
. style ( style_dim ( ) ) ,
cols [ 4 ] ,
) ;
2026-09-15 12:29:16 -04:00
}
tui(history): payment history and tx detail screen (card t_935bf84e)
Add Screen::History with draw_history, history_row_text, history_detail.
- Per-friend payment list: direction marker, amount, verified state, age, txid
- Enter opens detail view; Esc closes
- h key from main + wallet opens history via Node::list_payments
- Empty state: 'no payments with this friend yet'
- ASCII fallback: drops ✓/✗ glyphs, uses words only
- Peer text (memo, address) sanitized via display_text
- Tests: 5 new in tui_spec.rs (row text, detail, empty, ascii), 2 frame dumps in tui_frames.rs
Signed-off-by: tui-design <tui-design@hermes>
2026-09-15 21:29:40 -04:00
/// Payment-history helpers (card t_935bf84e).
///
/// These are pure: they take `&[Payment]` fixtures and render parameters so
/// the tests never need to reach into the store. Every peer-supplied field
/// (memo, address) is run through `sanitize::display_text` before it touches
/// a `Paragraph`.
/// Age string derived from `created_at` relative to `now`: just-seconds,
/// minutes, hours, or a date fallback for older entries.
fn payment_age ( created_at : i64 , now : i64 ) -> String {
let delta = now . saturating_sub ( created_at ) . max ( 0 ) ;
if delta < 60 {
format! ( " {delta} s " )
} else if delta < 3600 {
format! ( " {} m " , delta / 60 )
} else if delta < 86400 {
format! ( " {} h " , delta / 3600 )
} else {
format! ( " {} d " , delta / 86400 )
}
}
/// Human-readable direction word for a `Payment` row.
fn payment_direction ( p : & Payment ) -> & 'static str {
if p . dir = = " out " { " outbound " } else { " inbound " }
}
/// Verified glyph + word — never colour-only. ASCII chrome drops the glyph.
fn verified_text ( p : & Payment ) -> String {
if ascii_chrome ( ) {
if p . verified { " verified " } else { " unverified " } . to_string ( )
} else {
format! ( " {} {} " , if p . verified { " ✓ " } else { " ✗ " } , if p . verified { " verified " } else { " unverified " } )
}
}
/// The txid column: truncated on the row, full in the detail view.
fn txid_display ( p : & Payment , max : usize ) -> String {
match & p . txid {
Some ( txid ) = > truncate_chars ( txid , max ) ,
None = > " awaiting receipt " . to_string ( ) ,
}
}
/// Build one history list row from a `Payment`. Direction marker (`> `/`< `),
/// amount through `pay::atomic_to_xmr_str`, verified word + glyph, and a
/// truncated txid (or `awaiting receipt`). The result is truncated to `width`.
pub fn history_row_text ( p : & Payment , width : usize , now : i64 ) -> String {
let dir_mark = if p . dir = = " out " { " > " } else { " < " } ;
let xmr = crate ::pay ::atomic_to_xmr_str ( & p . amount_atomic ) ;
let verified = verified_text ( p ) ;
let txid = txid_display ( p , 16 ) ;
let age = payment_age ( p . created_at , now ) ;
let raw = format! ( " {dir_mark} {xmr} XMR {verified} {txid} {age} " ) ;
truncate_chars ( & raw , width )
}
/// Build the detail-view lines for a single `Payment`. Every peer-supplied
/// field (memo, address) goes through `sanitize::display_text` first.
pub fn history_detail ( p : & Payment , width : usize , now : i64 ) -> Vec < String > {
let xmr = crate ::pay ::atomic_to_xmr_str ( & p . amount_atomic ) ;
let dir_word = payment_direction ( p ) ;
let verified_word = if p . verified { " verified " } else { " unverified " } ;
let txid_line = match & p . txid {
Some ( txid ) = > format! ( " txid {} " , sanitize ::display_text ( txid . as_bytes ( ) ) ) ,
None = > " txid awaiting receipt " . to_string ( ) ,
} ;
let memo_line = if p . memo . is_empty ( ) {
" memo (none) " . to_string ( )
} else {
let clean = sanitize ::display_text ( p . memo . as_bytes ( ) ) ;
let wrapped = wrap_text ( & clean , width . saturating_sub ( 6 ) . max ( 1 ) ) ;
format! ( " memo {} " , wrapped . join ( " \n " ) )
} ;
let address_line = if p . address . is_empty ( ) {
" address (none) " . to_string ( )
} else {
let addr_w = width . saturating_sub ( 10 ) . max ( 1 ) ;
let clean = sanitize ::display_text ( p . address . as_bytes ( ) ) ;
format! ( " address {} " , truncate_chars ( & clean , addr_w ) )
} ;
let amount_line = format! ( " amount {xmr} XMR " ) ;
let kind_line = format! ( " kind {} " , p . kind ) ;
let dir_line = format! ( " direction {dir_word} " ) ;
let verified_line = format! ( " verified {verified_word} " ) ;
let age = payment_age ( p . created_at , now ) ;
let ts_line = format! ( " timestamp {} ( {} ago) " , p . created_at , age ) ;
vec! [
truncate_chars ( & txid_line , width ) ,
truncate_chars ( & address_line , width ) ,
truncate_chars ( & memo_line , width ) ,
truncate_chars ( & amount_line , width ) ,
truncate_chars ( & kind_line , width ) ,
truncate_chars ( & dir_line , width ) ,
truncate_chars ( & verified_line , width ) ,
truncate_chars ( & ts_line , width ) ,
]
}
/// Wrap text at `width` columns to whole words, truncating the last chunk with
/// an ellipsis if a word is too long. Used for the memo line in the detail view.
fn wrap_text ( s : & str , width : usize ) -> Vec < String > {
if width = = 0 {
return vec! [ s . to_string ( ) ] ;
}
let mut lines : Vec < String > = Vec ::new ( ) ;
let mut current = String ::new ( ) ;
for word in s . split_whitespace ( ) {
let w = word . chars ( ) . count ( ) ;
if current . is_empty ( ) {
if w > width {
lines . push ( truncate_chars ( word , width ) ) ;
} else {
current = word . to_string ( ) ;
}
} else if char_len ( & current ) + 1 + w < = width {
current . push ( ' ' ) ;
current . push_str ( word ) ;
} else {
lines . push ( std ::mem ::take ( & mut current ) ) ;
if w > width {
lines . push ( truncate_chars ( word , width ) ) ;
} else {
current = word . to_string ( ) ;
}
}
}
if ! current . is_empty ( ) {
lines . push ( current ) ;
}
if lines . is_empty ( ) {
lines . push ( String ::new ( ) ) ;
}
lines
}
/// Full-screen draw for the payment-history list (or detail view when
/// `show_detail` is true). `friend_name` is the petname or fingerprint of the
/// selected friend, already sanitized upstream.
pub fn draw_history (
f : & mut Frame ,
payments : & [ Payment ] ,
selected : usize ,
show_detail : bool ,
friend_name : & str ,
now : i64 ,
) {
let area = f . area ( ) ;
let width = area . width ;
let inner_w = width . saturating_sub ( 2 ) as usize ;
let title = if show_detail & & ! payments . is_empty ( ) {
format! ( " history {friend_name} detail " )
} else {
format! ( " history {friend_name} " )
} ;
let block = pane_block_for ( & title , true ) ;
let cols = Layout ::vertical ( [
Constraint ::Min ( 1 ) ,
Constraint ::Length ( 1 ) ,
] )
. split ( area ) ;
if payments . is_empty ( ) {
let body = wrap_text ( " no payments with this friend yet " , inner_w . max ( 1 ) ) . join ( " \n " ) ;
f . render_widget (
Paragraph ::new ( body )
. style ( style_text ( ) )
. wrap ( Wrap { trim : false } )
. block ( block ) ,
cols [ 0 ] ,
) ;
f . render_widget (
Paragraph ::new ( " Enter detail Esc back ? help " ) . style ( style_dim ( ) ) ,
cols [ 1 ] ,
) ;
return ;
}
let idx = selected . min ( payments . len ( ) - 1 ) ;
if show_detail {
let detail = history_detail ( & payments [ idx ] , inner_w , now ) ;
f . render_widget (
Paragraph ::new ( detail . join ( " \n " ) )
. style ( style_text ( ) )
. wrap ( Wrap { trim : false } )
. block ( block ) ,
cols [ 0 ] ,
) ;
f . render_widget (
Paragraph ::new ( " Esc back ? help " ) . style ( style_dim ( ) ) ,
cols [ 1 ] ,
) ;
return ;
}
let items : Vec < ListItem > = payments
. iter ( )
. enumerate ( )
. map ( | ( i , p ) | {
let row = history_row_text ( p , inner_w , now ) ;
let style = if i = = selected {
style_highlight ( )
} else {
style_text ( )
} ;
ListItem ::new ( row ) . style ( style )
} )
. collect ( ) ;
let mut list_state = ListState ::default ( ) ;
list_state . select ( Some ( idx ) ) ;
f . render_stateful_widget (
List ::new ( items )
. highlight_style ( style_highlight ( ) )
. block ( block ) ,
cols [ 0 ] ,
& mut list_state ,
) ;
f . render_widget (
Paragraph ::new ( " Enter detail Esc back ? help " ) . style ( style_dim ( ) ) ,
cols [ 1 ] ,
) ;
}
2026-09-15 12:29:16 -04:00
/// The chain-source picker and the remote-daemon trust shift, before anything
/// is saved.
fn draw_chain_setup ( f : & mut Frame , setup : & ChainSetup ) {
let ( title , body ) = match setup {
ChainSetup ::Choose { index } = > {
let mut lines = vec! [
" where should the chain come from? " . to_string ( ) ,
String ::new ( ) ,
] ;
for ( i , choice ) in ChainChoice ::ALL . iter ( ) . enumerate ( ) {
let mark = if i = = * index { " > " } else { " " } ;
lines . push ( format! ( " {mark} {} " , choice . label ( ) ) ) ;
lines . push ( format! ( " {} " , choice . detail ( ) ) ) ;
}
lines . push ( String ::new ( ) ) ;
lines . push ( " receive-only needs no wallet file and no daemon. " . into ( ) ) ;
lines . push ( " spend always needs the create/import flow and " . into ( ) ) ;
lines . push ( " its SPEND warning — there is no shortcut key. " . into ( ) ) ;
lines . push ( String ::new ( ) ) ;
lines . push ( " Up/Down choose Enter select Esc back " . into ( ) ) ;
( " chain source " , lines . join ( " \n " ) )
}
ChainSetup ::RemoteAddr { buf , err } = > {
let mut lines = vec! [
" daemon address, as host:port " . to_string ( ) ,
" e.g. 127.0.0.1:18081 or yournode.onion:18089 " . to_string ( ) ,
String ::new ( ) ,
format! ( " > {buf} " ) ,
String ::new ( ) ,
] ;
if let Some ( e ) = err {
lines . push ( e . clone ( ) ) ;
} else {
lines . push ( " Enter continues Esc goes back " . into ( ) ) ;
}
( " enter daemon address " , lines . join ( " \n " ) )
}
ChainSetup ::RemoteWarn {
host ,
port ,
onion ,
} = > {
let mut lines = vec! [
format! ( " use {host} : {port} for chain traffic? " ) ,
String ::new ( ) ,
" the daemon operator sees your addresses during sync, " . into ( ) ,
" and every spend. a remote daemon is untrusted: this " . into ( ) ,
" app never passes --trusted-daemon. " . into ( ) ,
String ::new ( ) ,
] ;
if * onion {
lines . push ( " this is a .onion host, so Tor would hide the transport. " . into ( ) ) ;
lines . push ( " it still does not hide your addresses from the operator. " . into ( ) ) ;
lines . push ( String ::new ( ) ) ;
lines . extend ( ONION_NO_SOCKS_MSG . lines ( ) . map ( str ::to_string ) ) ;
} else {
lines . push ( " this is a clearnet host: your ISP can also see that " . into ( ) ) ;
lines . push ( " this device talks to a Monero node, and which one. " . into ( ) ) ;
}
lines . push ( String ::new ( ) ) ;
lines . push ( " Enter saves it Esc cancels " . into ( ) ) ;
( " trust shift " , lines . join ( " \n " ) )
}
} ;
draw_text_overlay ( f , title , & body ) ;
2026-09-12 22:53:58 -04:00
}
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 \n Type 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 \n Enter submits Esc cancels " . into ( )
} else {
" set a passphrase for the wallet file \n \n Enter continues Esc cancels " . into ( )
} ,
) ,
WalletSetup ::CreateSeed { seed , typed } = > (
" write down this seed " ,
format! (
" {} \n \n this is shown once. anyone with it can spend. \n Type 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 \n Enter continues Esc cancels " ,
buf . as_str ( )
) ,
) ,
WalletSetup ::ImportPass { entry , .. } = > (
" wallet passphrase " ,
if entry . first ( ) . is_some ( ) {
" re-type passphrase \n \n Enter submits Esc cancels " . into ( )
} else {
" passphrase for the imported wallet file \n \n Enter continues Esc cancels " . into ( )
} ,
) ,
} ;
draw_text_overlay ( f , title , & body ) ;
}
tui: F7 wallet config screen + wallet/chain setup redesign + doc sync
Implement the F7 wallet-endpoint config screen (Screen::WalletConfig):
- Fields: rpc_url, rpc_login masked with reveal toggle, no_spend checkbox
- Test connection (t → PingResult::line), Save (s → wallet_save_config)
- Status line: 'saved · not connected', 'connected — ...', 'error: ...'
- NO_COLOR distinguishability: '·' bullets, username visible, password masked
- Password never leaks: WalletConfig::secret() redaction on all status lines
- ConfigField cycle (Tab/Esc), footer hints, help overlay entries
Redraw draw_wallet_setup (CreateWarn→CreatePass→CreateSeed→ImportPass,
CreateWarn→ImportSeq→ImportPass) with spend-authority warning, SEEN
challenge, zeroizing buffers preserved on submit/mismatch/Esc.
Update help_overlay_text() with F6 h, F7, copy key; main_footer_hints()
for F7. Extend tui_chrome.rs needle list (F6 h, F7 added).
Reconcile docs: README key table gains F6 s/n/h and F7; WALLET.md
wallet-screen paragraph updated; TUI.md Deliverable 5 marked implemented
with after frames for each config state at 80x24 and 120x40.
Tests: 30 tui_spec (incl. 7 new wallet-config tests), tui_chrome green.
cargo test --locked: 0 failures. cargo clippy --all-targets: clean.
2026-09-15 23:01:56 -04:00
/// F7: the wallet-endpoint config screen. Full-screen overlay (like
/// `draw_text_overlay`), fields pre-filled from `WalletConfig::from_config`.
///
/// The rendered text is built here, not by stringing together internal fields:
/// every line that touches the login is redacted through `WalletConfig::secret()`
/// before it is assembled, so the mask glyph is the only thing that ever carries
/// the password length.
pub fn draw_wallet_config ( f : & mut Frame , s : & WalletConfigScreen ) {
let mark = | focused : bool | if focused { " > " } else { " " } ;
let login_display = s . login_display ( ) ;
let no_spend_mark = if s . no_spend { " [x] " } else { " [ ] " } ;
let status_line = s . status . line ( & s . rpc_login ) ;
let body = format! (
" {} rpc_url \n {} \n \n {} rpc_login \n {} \n \n {} no_spend \n {} /tip off \n \n {} action \n t test connection s save \n Esc back Tab fields " ,
mark ( s . focus = = ConfigField ::RpcUrl ) ,
s . rpc_url ,
mark ( s . focus = = ConfigField ::RpcLogin ) ,
login_display ,
mark ( s . focus = = ConfigField ::NoSpend ) ,
no_spend_mark ,
mark ( s . focus = = ConfigField ::Action ) ,
) ;
let body = if status_line . is_empty ( ) {
body
} else {
let glyph = if status_line . contains ( " error " ) | | status_line . contains ( " not connected " ) {
" ! "
} else {
" "
} ;
format! ( " {body} \n \n --- \n {glyph} {status_line} " )
} ;
draw_text_overlay ( f , " wallet config " , & 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
#[ 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() "
) ;
}
}