tui: read the wallet list from the store and load the chosen wallet #144
Merged
sirius
merged 2 commits from 2026-09-21 18:40:13 +00:00
wt/t_895853ad into wt/t_511023b6 2026-09-21
tui: read the wallet list from the store and load the chosen wallet
The selection screen shipped as presentation only: `F6 w` opened its unavailable state, the rows were never read, and Enter on a wallet said switching was not wired up. The catalogue, the create path and the screen all existed; nothing joined them. - `App::open_wallet_select` builds its rows from `Node::list_wallets` at the moment the screen opens (never cached from startup), and a failed read is the screen's own error state rather than "no saved wallets". - `App::choose_wallet` resolves `WalletChoice::Open(index)` against the catalogue as it is now — the index is a position, and two saved wallets may share an identity key — then loads it. `+ create new wallet` still starts the existing create flow. - `Node::open_wallet(filename)` is the load: it refuses a file the catalogue does not hold, re-points the sealed wallet-child record with a read-modify-write (the generated RPC creds survive), and restarts a running child onto the new file. An idle child takes the change on its next start. - `App::new` starts on the selection screen when the catalogue is non-empty and on the create flow when it is empty, so a restart lands on the wallets it remembers and a first run has no dead empty list. - The stored identity/locator stay catalogue columns: a locator rotates (F4) and identity is the roster key the node already holds, so the live header keeps reading them from the node. - `SELECT_UNAVAILABLE` is gone with the state it described; docs/TUI.md now describes the wired behaviour. Tests (both new): `Node::open_wallet` over an offline node — the chosen file, the creds kept across the read-modify-write, the choice surviving a reopen, and a non-catalogue file refused; and the app path in src/tui.rs over a real store-backed node — start screen both ways, catalogue mapping, row index over a shared identity, the create row, and a wallet recorded after startup appearing the next time the list opens.
tui: wallet selection screen (F6 -> w) with create as the last row
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.
(cherry picked from commit 99a4ab640e)