tui: wallet selection screen (F6 -> w) with create as the last row #142

Merged
sirius merged 2 commits from wt/t_14ac0a3f into main 2026-09-21 15:10:18 +00:00
Owner

What

Adds the wallet selection screen: Screen::WalletSelect, reachable with F6 then w.

  • one row per persisted wallet — name, identity prefix, locator prefix, creation day — with a dim column head so the day needs no legend
  • the selected row's full identity and locator under the table (the rows carry prefixes; the full values are what a person actually verifies)
  • + create new wallet is the last item of the list — Enter on it starts the same create flow as F6 c, so an empty list still has a way forward
  • j/k or arrows move, Enter takes the choice, Esc back to Main; the focused row carries > and bold, so focus survives a monochrome terminal
  • empty / failed / in-flight reads each get their own copy, and none of them is a blank pane

Copy that was designed, not defaulted

state screen says
no saved wallets no saved wallets yet / create one to get an identity and an onion address
read failed could not read saved wallets / <why> — never no saved wallets
reading reading saved wallets / one moment (create row stays live)
NULL label (unlabelled)
locator not published -
no usable timestamp unknown (not 1970-01-01)

Scope and the one seam

Presentation only. The rows are plain display data (WalletRow); the render path never reads the store, exactly as the F9 menu and the peer-payment history do. Selection is by row index, never by identity key — Store::list_wallets may return two records that share one.

The store API from the schema card (Store::list_wallets() -> Vec<WalletRecord>, PR #141) is not on main yet, and Node has no wallet-record accessor, so F6 w currently opens the screen on its unavailable state (could not read saved wallets / the wallet store is not wired up yet) rather than fabricating a list. The create new wallet row is real today either way.

WalletRow documents the mapping the integration card needs: name: r.name.unwrap_or_default(), identity_pubkey: hex(r.identity_pubkey) ([u8; 32]), onion_locator: r.onion_locator, created_at: r.created_at. Wiring App::open_wallet_select (one call site) replaces the unavailable state with WalletSelectState::from_rows(...); loading a chosen record into the session, and starting the app on this screen, is t_895853ad (rust-dev) — as its own card body already says.

Evidence

cargo test --locked — 35 test binaries, 0 failures. cargo clippy --locked --all-targets -- -D warnings — clean.

test result: ok. 16 passed; 0 failed   tests/tui_select.rs
test result: ok. 12 passed; 0 failed   tests/tui_frames.rs
test result: ok. 12 passed; 0 failed   tests/tui_payments.rs
test result: ok. 37 passed; 0 failed   tests/tui_spec.rs
test result: ok. 18 passed; 0 failed   tests/tui_chrome.rs

New suite (tests/tui_select.rs), all of it drawn through the real draw_wallet_select path on TestBackend:

  • wallet_select_frame_shows_the_shipped_footer pins the dumped frame's last line to status_footer_phased(w, fp, onion, Some(TorPhase::Ready), None, wallet_select_footer_hint()) — the same calls the app makes, so the dump cannot show a footer the app does not render
  • wallet_select_frames_fit_at_the_three_sizes + wallet_select_columns_drop_before_they_wrap (a sweep from 20 to 200 columns, measured in cells via Span::width, never chars().count()): trailing columns drop instead of wrapping, and 200x60 shows the identity and locator untruncated
  • wallet_select_marks_exactly_one_row_and_puts_create_last, wallet_select_windows_a_long_list_and_keeps_create_visible (40 rows: … N below / … N above, create row never falls off)
  • wallet_select_hostile_label_cannot_reach_the_terminal: ESC/BEL/C1/bidi/newline/tab in a label do not reach the frame and do not split a row
  • format_day_utc_covers_the_calendar_edges: epoch, leap day (2000-02-29), far future — hand-rolled (no date crate; unicode-width was not added either)
  • the_wallet_select_screen_answers_no_function_key_it_does_not_name (in-crate): the screen's hint names no F<n>, so it answers none

No existing test was rewritten: tests/tui_chrome.rs, tests/tui_frames.rs, tests/tui_payments.rs and tests/tui_spec.rs pass untouched.

After — 80x24 (unicode chrome)

┌(o) wallets · 2 saved─────────────────────────────────────────────────────────┐
│  name                          identity     locator      since               │
│> lance                         ab12cd34…    abcdefgh…    2026-09-21          │
│  cold                          ff00aa11…    zyxwvuts…    2025-08-27          │
│                                                                              │
│  id     ab12cd34ef5678901234567890abcdef1234567890abcdef1234567890abcd       │
│  onion  abcdefghijklmnopqrstuvwxyz234567abcdefghijklmnopqrstuvwx             │
│                                                                              │
│  + create new wallet                                                         │
│                                                                              │
└──────────────────────────────────────────────────────────────────────────────┘
✓ TOR ready  me:abcdef01… onion:abcdefgh… Esc back j k select Enter open ? help

Frame dumps: cargo test --locked --test tui_select -- --nocapture wallet_select_frame_dumps
(three sizes × {two wallets, empty, failed read}; the PR comment carries the 120x40 and 200x60 dumps and the same frames under ONIONWIRE_ASCII=1).

After — the empty state (first run, 80x24)

┌(o) wallets───────────────────────────────────────────────────────────────────┐
│  no saved wallets yet                                                        │
│  create one to get an identity and an onion address                          │
│                                                                              │
│> + create new wallet                                                         │
│                                                                              │
└──────────────────────────────────────────────────────────────────────────────┘

Before / after on the F6 wallet screen

Nothing about the wallet screen changed except its footer, which now names the new key:

before: c create  i import  r qr  s/x child  1 pruned  2 full  3 testnet  Esc back  ? help
after:  c create  i import  r qr  w wallets  s/x child  1 pruned  2 full  3 testnet  Esc back  ? help

(status_footer_inner drops hint tokens from the front when the width is tight, so w wallets is placed where it survives rather than in the part that gets cut at 80 columns.)

Files

  • src/tui.rs — the screen (state, grid, windowing, detail strip, states), Screen::WalletSelect, key routing, draw dispatch, F6 w
  • tests/tui_select.rs — the new suite
  • docs/TUI.md — screen table, the F6 w key, a section on the screen, the dump command
## What Adds the wallet selection screen: `Screen::WalletSelect`, reachable with **`F6` then `w`**. - one row per persisted wallet — **name, identity prefix, locator prefix, creation day** — with a dim column head so the day needs no legend - the **selected row's full identity and locator** under the table (the rows carry prefixes; the full values are what a person actually verifies) - **`+ create new wallet` is the last item of the list** — Enter on it starts the same create flow as `F6` `c`, so an empty list still has a way forward - `j`/`k` or arrows move, **Enter takes the choice**, Esc back to Main; the focused row carries `>` **and** bold, so focus survives a monochrome terminal - empty / failed / in-flight reads each get their own copy, and none of them is a blank pane ### Copy that was designed, not defaulted | state | screen says | |---|---| | no saved wallets | `no saved wallets yet` / `create one to get an identity and an onion address` | | read failed | `could not read saved wallets` / `<why>` — **never** `no saved wallets` | | reading | `reading saved wallets` / `one moment` (create row stays live) | | NULL label | `(unlabelled)` | | locator not published | `-` | | no usable timestamp | `unknown` (not `1970-01-01`) | ## Scope and the one seam Presentation only. The rows are plain display data (`WalletRow`); the render path never reads the store, exactly as the F9 menu and the peer-payment history do. Selection is by **row index**, never by identity key — `Store::list_wallets` may return two records that share one. The store API from the schema card (`Store::list_wallets() -> Vec<WalletRecord>`, PR #141) is not on `main` yet, and `Node` has no wallet-record accessor, so `F6` `w` currently opens the screen on its **unavailable** state (`could not read saved wallets` / `the wallet store is not wired up yet`) rather than fabricating a list. The `create new wallet` row is real today either way. `WalletRow` documents the mapping the integration card needs: `name: r.name.unwrap_or_default()`, `identity_pubkey: hex(r.identity_pubkey)` (`[u8; 32]`), `onion_locator: r.onion_locator`, `created_at: r.created_at`. Wiring `App::open_wallet_select` (one call site) replaces the unavailable state with `WalletSelectState::from_rows(...)`; loading a chosen record into the session, and starting the app on this screen, is `t_895853ad` (rust-dev) — as its own card body already says. ## Evidence `cargo test --locked` — 35 test binaries, 0 failures. `cargo clippy --locked --all-targets -- -D warnings` — clean. ``` test result: ok. 16 passed; 0 failed tests/tui_select.rs test result: ok. 12 passed; 0 failed tests/tui_frames.rs test result: ok. 12 passed; 0 failed tests/tui_payments.rs test result: ok. 37 passed; 0 failed tests/tui_spec.rs test result: ok. 18 passed; 0 failed tests/tui_chrome.rs ``` New suite (`tests/tui_select.rs`), all of it drawn through the real `draw_wallet_select` path on `TestBackend`: - `wallet_select_frame_shows_the_shipped_footer` pins the dumped frame's last line to `status_footer_phased(w, fp, onion, Some(TorPhase::Ready), None, wallet_select_footer_hint())` — the same calls the app makes, so the dump cannot show a footer the app does not render - `wallet_select_frames_fit_at_the_three_sizes` + `wallet_select_columns_drop_before_they_wrap` (a sweep from **20 to 200 columns**, measured in cells via `Span::width`, never `chars().count()`): trailing columns drop instead of wrapping, and 200x60 shows the identity and locator untruncated - `wallet_select_marks_exactly_one_row_and_puts_create_last`, `wallet_select_windows_a_long_list_and_keeps_create_visible` (40 rows: `… N below` / `… N above`, create row never falls off) - `wallet_select_hostile_label_cannot_reach_the_terminal`: ESC/BEL/C1/bidi/newline/tab in a label do not reach the frame and do not split a row - `format_day_utc_covers_the_calendar_edges`: epoch, leap day (2000-02-29), far future — hand-rolled (no date crate; `unicode-width` was not added either) - `the_wallet_select_screen_answers_no_function_key_it_does_not_name` (in-crate): the screen's hint names no `F<n>`, so it answers none No existing test was rewritten: `tests/tui_chrome.rs`, `tests/tui_frames.rs`, `tests/tui_payments.rs` and `tests/tui_spec.rs` pass untouched. ### After — 80x24 (unicode chrome) ``` ┌(o) wallets · 2 saved─────────────────────────────────────────────────────────┐ │ name identity locator since │ │> lance ab12cd34… abcdefgh… 2026-09-21 │ │ cold ff00aa11… zyxwvuts… 2025-08-27 │ │ │ │ id ab12cd34ef5678901234567890abcdef1234567890abcdef1234567890abcd │ │ onion abcdefghijklmnopqrstuvwxyz234567abcdefghijklmnopqrstuvwx │ │ │ │ + create new wallet │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ ✓ TOR ready me:abcdef01… onion:abcdefgh… Esc back j k select Enter open ? help ``` Frame dumps: `cargo test --locked --test tui_select -- --nocapture wallet_select_frame_dumps` (three sizes × {two wallets, empty, failed read}; the PR comment carries the 120x40 and 200x60 dumps and the same frames under `ONIONWIRE_ASCII=1`). ### After — the empty state (first run, 80x24) ``` ┌(o) wallets───────────────────────────────────────────────────────────────────┐ │ no saved wallets yet │ │ create one to get an identity and an onion address │ │ │ │> + create new wallet │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ ``` ### Before / after on the `F6` wallet screen Nothing about the wallet screen changed except its footer, which now names the new key: ``` before: c create i import r qr s/x child 1 pruned 2 full 3 testnet Esc back ? help after: c create i import r qr w wallets s/x child 1 pruned 2 full 3 testnet Esc back ? help ``` (`status_footer_inner` drops hint tokens from the front when the width is tight, so `w wallets` is placed where it survives rather than in the part that gets cut at 80 columns.) ## Files - `src/tui.rs` — the screen (state, grid, windowing, detail strip, states), `Screen::WalletSelect`, key routing, draw dispatch, `F6` `w` - `tests/tui_select.rs` — the new suite - `docs/TUI.md` — screen table, the `F6` `w` key, a section on the screen, the dump command
tui: wallet selection screen (F6 -> w) with create as the last row
All checks were successful
ci / test (pull_request) Successful in 5m58s
android-ci / android (pull_request) Successful in 12m2s
ci / sdk (pull_request) Successful in 1m28s
ci / fuzz (pull_request) Successful in 4m46s
99a4ab640e
Screen::WalletSelect: a table of saved wallets — name, identity prefix,
locator prefix, creation day — the selected row's full identity and locator
under it, and a `+ create new wallet` row as the last item. j/k or arrows
move, Enter takes the choice, Esc back. Empty, failed and in-flight reads
each get their own copy; a wallet with a NULL label, no published locator or
no usable timestamp reads `(unlabelled)` / `-` / `unknown` rather than blank.

Presentation only. Rows are plain display data (WalletRow) built by the
caller; the render path never reads the store, and the selection is by row
index because two records may share an identity key. Loading a chosen record
into the session is the wallet-store integration step, so the F6 `w` entry
opens the screen on its unavailable state until that accessor lands, and the
create row works today either way.

Evidence: tests/tui_select.rs (16 tests) drives the real draw path through
TestBackend at 80x24, 120x40 and 200x60, pins the dumped frame's footer to
status_footer_phased(..., wallet_select_footer_hint()), asserts exactly one
focus marker, a cell-width line budget from 20 to 200 columns, the window
disclosure with the create row always visible, hostile labels (ESC/BEL/C1/
bidi/newline/tab) and the crate-local UTC date formatter.
Author
Owner

Frame dump — 120x40, unicode chrome, two wallets

┌(o) wallets · 2 saved─────────────────────────────────────────────────────────────────────────────────────────────────┐
│  name                          identity     locator      since                                                       │
│> lance                         ab12cd34…    abcdefgh…    2026-09-21                                                  │
│  cold                          ff00aa11…    zyxwvuts…    2025-08-27                                                  │
│                                                                                                                      │
│  id     ab12cd34ef5678901234567890abcdef1234567890abcdef1234567890abcd                                               │
│  onion  abcdefghijklmnopqrstuvwxyz234567abcdefghijklmnopqrstuvwx                                                     │
│                                                                                                                      │
│  + create new wallet                                                                                                 │
│                                                                                                                      │
│                                                                                                                      │
│                                                                                                                      │
│                                                                                                                      │
│                                                                                                                      │
│                                                                                                                      │
│                                                                                                                      │
│                                                                                                                      │
│                                                                                                                      │
│                                                                                                                      │
│                                                                                                                      │
│                                                                                                                      │
│                                                                                                                      │
│                                                                                                                      │
│                                                                                                                      │
│                                                                                                                      │
│                                                                                                                      │
│                                                                                                                      │
│                                                                                                                      │
│                                                                                                                      │
│                                                                                                                      │
│                                                                                                                      │
│                                                                                                                      │
│                                                                                                                      │
│                                                                                                                      │
│                                                                                                                      │
│                                                                                                                      │
│                                                                                                                      │
│                                                                                                                      │
└──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
✓ TOR ready  me:abcdef01…  onion:abcdefghijklmnopqrstuvwxyz234567abcdefghijklmnopqrstuvwx.onion  Enter open  ? help

Frame dump — 200x60 (first 10 rows of the box; the full frame is in the dump below)

┌(o) wallets · 2 saved─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│  name                          identity     locator      since                                                                                                                                       │
│> lance                         ab12cd34…    abcdefgh…    2026-09-21                                                                                                                                  │
│  cold                          ff00aa11…    zyxwvuts…    2025-08-27                                                                                                                                  │
│                                                                                                                                                                                                      │
│  id     ab12cd34ef5678901234567890abcdef1234567890abcdef1234567890abcd                                                                                                                               │
│  onion  abcdefghijklmnopqrstuvwxyz234567abcdefghijklmnopqrstuvwx                                                                                                                                     │
│                                                                                                                                                                                                      │
│  + create new wallet                                                                                                                                                                                 │
│                                                                                                                                                                                                      │

Frame dump — 80x24 under ONIONWIRE_ASCII=1 (no box/block glyphs, ... ellipsis)

+(o) wallets · 2 saved---------------------------------------------------------+
|  name                          identity     locator      since               |
|> lance                         ab12cd34...  abcdefgh...  2026-09-21          |
|  cold                          ff00aa11...  zyxwvuts...  2025-08-27          |
|                                                                              |
|  id     ab12cd34ef5678901234567890abcdef1234567890abcdef1234567890abcd       |
|  onion  abcdefghijklmnopqrstuvwxyz234567abcdefghijklmnopqrstuvwx             |
|                                                                              |
|  + create new wallet                                                         |
|                                                                              |
|                                                                              |
|                                                                              |
|                                                                              |
|                                                                              |
|                                                                              |
|                                                                              |
|                                                                              |
|                                                                              |
|                                                                              |
|                                                                              |
|                                                                              |
|                                                                              |
+------------------------------------------------------------------------------+
ok TOR ready  me:abcdef01... onion:abcdefgh... back j k select Enter open ? help

Frame dump — failed read at 80x24 (a different state from no saved wallets, and the create row stays)

┌(o) wallets───────────────────────────────────────────────────────────────────┐
│  could not read saved wallets                                                │
│  store lock poisoned                                                         │
│                                                                              │
│                                                                              │
│                                                                              │
│                                                                              │
│> + create new wallet                                                         │
│                                                                              │
│                                                                              │
│                                                                              │
│                                                                              │
│                                                                              │
│                                                                              │
│                                                                              │
│                                                                              │
│                                                                              │
│                                                                              │
│                                                                              │
│                                                                              │
│                                                                              │
│                                                                              │
└──────────────────────────────────────────────────────────────────────────────┘
✓ TOR ready  me:abcdef01… onion:abcdefgh… Esc back j k select Enter open ? help

Toolchain output

$ cargo test --locked
EXIT=0            # 35 test binaries, 0 failures

$ cargo clippy --locked --all-targets -- -D warnings
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 3.00s
EXIT=0

Every frame above came out of draw_wallet_select on TestBackend, so the footer on the last line is the app's own status_footer_phased output with wallet_select_footer_hint() — the same single source the test pins it to.

## Frame dump — 120x40, unicode chrome, two wallets ``` ┌(o) wallets · 2 saved─────────────────────────────────────────────────────────────────────────────────────────────────┐ │ name identity locator since │ │> lance ab12cd34… abcdefgh… 2026-09-21 │ │ cold ff00aa11… zyxwvuts… 2025-08-27 │ │ │ │ id ab12cd34ef5678901234567890abcdef1234567890abcdef1234567890abcd │ │ onion abcdefghijklmnopqrstuvwxyz234567abcdefghijklmnopqrstuvwx │ │ │ │ + create new wallet │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ └──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘ ✓ TOR ready me:abcdef01… onion:abcdefghijklmnopqrstuvwxyz234567abcdefghijklmnopqrstuvwx.onion Enter open ? help ``` ## Frame dump — 200x60 (first 10 rows of the box; the full frame is in the dump below) ``` ┌(o) wallets · 2 saved─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐ │ name identity locator since │ │> lance ab12cd34… abcdefgh… 2026-09-21 │ │ cold ff00aa11… zyxwvuts… 2025-08-27 │ │ │ │ id ab12cd34ef5678901234567890abcdef1234567890abcdef1234567890abcd │ │ onion abcdefghijklmnopqrstuvwxyz234567abcdefghijklmnopqrstuvwx │ │ │ │ + create new wallet │ │ │ ``` ## Frame dump — 80x24 under `ONIONWIRE_ASCII=1` (no box/block glyphs, `...` ellipsis) ``` +(o) wallets · 2 saved---------------------------------------------------------+ | name identity locator since | |> lance ab12cd34... abcdefgh... 2026-09-21 | | cold ff00aa11... zyxwvuts... 2025-08-27 | | | | id ab12cd34ef5678901234567890abcdef1234567890abcdef1234567890abcd | | onion abcdefghijklmnopqrstuvwxyz234567abcdefghijklmnopqrstuvwx | | | | + create new wallet | | | | | | | | | | | | | | | | | | | | | | | | | | | +------------------------------------------------------------------------------+ ok TOR ready me:abcdef01... onion:abcdefgh... back j k select Enter open ? help ``` ## Frame dump — failed read at 80x24 (a different state from `no saved wallets`, and the create row stays) ``` ┌(o) wallets───────────────────────────────────────────────────────────────────┐ │ could not read saved wallets │ │ store lock poisoned │ │ │ │ │ │ │ │ │ │> + create new wallet │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ ✓ TOR ready me:abcdef01… onion:abcdefgh… Esc back j k select Enter open ? help ``` ## Toolchain output ``` $ cargo test --locked EXIT=0 # 35 test binaries, 0 failures $ cargo clippy --locked --all-targets -- -D warnings Finished `dev` profile [unoptimized + debuginfo] target(s) in 3.00s EXIT=0 ``` Every frame above came out of `draw_wallet_select` on `TestBackend`, so the footer on the last line is the app's own `status_footer_phased` output with `wallet_select_footer_hint()` — the same single source the test pins it to.
Author
Owner

CI on 99a4ab6 — all green

ci / test (pull_request)            success (5m58s)
ci / sdk (pull_request)             success (1m28s)
ci / fuzz (pull_request)            success
android-ci / android (pull_request) success (12m2s)

The ci / test job is the aarch64 one that matters for this change: it runs
cargo test --locked plus cargo clippy --locked --all-targets -- -D warnings
on the same commit this PR would merge. Combined status: success.

## CI on 99a4ab6 — all green ``` ci / test (pull_request) success (5m58s) ci / sdk (pull_request) success (1m28s) ci / fuzz (pull_request) success android-ci / android (pull_request) success (12m2s) ``` The `ci / test` job is the aarch64 one that matters for this change: it runs `cargo test --locked` plus `cargo clippy --locked --all-targets -- -D warnings` on the same commit this PR would merge. Combined status: **success**.
Merge branch 'main' into wt/t_14ac0a3f
Some checks failed
ci / test (pull_request) Successful in 5m56s
android-ci / android (pull_request) Has been cancelled
ci / sdk (pull_request) Successful in 1m30s
ci / fuzz (pull_request) Has been cancelled
49756d2a2d
sirius merged commit 5f1500191e into main 2026-09-21 15:10:18 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
sirius/onionwire!142
No description provided.