From c776ea3e0c3ddb52ad668d2cc703617b1a63c20b Mon Sep 17 00:00:00 2001 From: agent Date: Sun, 27 Sep 2026 23:16:10 -0400 Subject: [PATCH] tui: the chain row says when this build has no in-process daemon MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit cuprate::available() was never consulted in the TUI, so the 'chain' row offered 'in-process node · cuprate in this app' in a build whose only possible answer is cuprate::NO_FEATURE_MSG. The row now carries that wording where the choice is made, the same way prune_display()/network_display() carry theirs. The choice stays in the picker: builds with the feature exist, and a stored in-process source must still be readable. --- src/tui.rs | 62 +++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 61 insertions(+), 1 deletion(-) diff --git a/src/tui.rs b/src/tui.rs index a210c30..782b107 100644 --- a/src/tui.rs +++ b/src/tui.rs @@ -1727,6 +1727,23 @@ impl WalletSetupConfigState { } } + /// The value the `chain` row prints, including the one thing this build may + /// not be able to do: without `cuprate-daemon` the in-process choice cannot + /// start anything at all, so the row says so where the choice is made rather + /// than leaving the refusal for the start (`crate::cuprate::NO_FEATURE_MSG`). + /// The choice itself is never removed — builds with the feature exist. + fn chain_display(&self) -> String { + if self.source == SetupSource::InProcess && !crate::cuprate::available() { + format!( + "{} — {}", + self.source.word(), + crate::cuprate::NO_FEATURE_MSG + ) + } else { + self.source.word().to_string() + } + } + fn status_display(&self) -> String { self.note .clone() @@ -4856,7 +4873,7 @@ pub fn wallet_setup_config_lines(width: u16, s: &WalletSetupConfigState) -> Vec< s, SETUP_ROW_CHAIN, "chain", - &format!("{} (space changes)", s.source.word()), + &format!("{} (space changes)", s.chain_display()), )); if s.source == SetupSource::Remote { out.push(Line::from( @@ -7882,6 +7899,49 @@ mod wallet_setup_config_tests { ); } + /// A build without `cuprate-daemon` cannot start the in-process daemon at + /// all, so the `chain` row has to say that where the choice is made rather + /// than offering one whose only answer is `cuprate::NO_FEATURE_MSG`. + #[cfg(not(feature = "cuprate-daemon"))] + #[test] + fn a_build_without_the_daemon_says_so_on_the_chain_row() { + let dir = tempfile::tempdir().unwrap(); + let (mut app, _rt) = app(&dir.path().join("home")); + app.handle_key(key(KeyCode::F(7))).expect("F7"); + pick_source(&mut app, SetupSource::InProcess); + + let body = wallet_setup_config_text(200, state_of(&app)); + assert!( + body.contains("in-process node"), + "the choice is still offered:\n{body}" + ); + assert!( + body.contains("--features cuprate-daemon"), + "the row must name the feature this build lacks:\n{body}" + ); + } + + /// The same row in a build that *can* start it: no unavailable wording, and + /// the choice still reaches the store. + #[cfg(feature = "cuprate-daemon")] + #[test] + fn a_build_with_the_daemon_does_not_disown_the_in_process_choice() { + let dir = tempfile::tempdir().unwrap(); + let (mut app, _rt) = app(&dir.path().join("home")); + app.handle_key(key(KeyCode::F(7))).expect("F7"); + pick_source(&mut app, SetupSource::InProcess); + + let body = wallet_setup_config_text(200, state_of(&app)); + assert!( + body.contains("in-process node · cuprate in this app"), + "the row keeps the plain wording:\n{body}" + ); + assert!( + !body.contains("rebuild with --features cuprate-daemon"), + "a build that can start it must not say it cannot:\n{body}" + ); + } + /// F6 is the wallet again: the chain picker and the child's start/stop keys /// moved to F7, so pressing them there changes nothing and the store is not /// touched behind the user's back.