feat(tui): say so in the status bar when the listener took another port

With the login screen's own attempts no longer holding the port, a
session listens somewhere other than the configured port mainly when
another program already holds it. soulseek-rs still falls back to an
ephemeral port there, which is what lets several clients on one machine
share a configured port, and it advertises the port it really bound. A
manual port forward on the router then points at nothing, though, and
the TUI never said so; the CLI already warns.

After login the TUI compares the bound port with the configured one,
using the CLI's rule, and the status bar's title reads "port X in use,
listening on Y" for the rest of the session. A window attached to a
daemon shows nothing: the daemon owns its listener.

Nicotine+ keeps retrying the configured port every five seconds and
Soulseek.NET refuses it; neither falls back. Keeping the fallback and
making it visible is a deliberate difference.
This commit is contained in:
Michel de Graaf
2026-09-14 13:44:57 +02:00
parent bd502c216a
commit deb846be14
5 changed files with 35 additions and 6 deletions
+9 -4
View File
@@ -502,14 +502,17 @@ fn run_default_tui(
// Best-effort: make ourselves reachable behind a home router so
// firewalled peers can connect back. Mapped only once the listener is
// up, and for the port it really bound. Kept alive for the session.
let _port_mapper = outcome
.client
.listen_port()
.map(crate::port_mapping::PortMapper::spawn);
let bound_port = outcome.client.listen_port();
let _port_mapper =
bound_port.map(crate::port_mapping::PortMapper::spawn);
let store = crate::persist::paths::state_dir()
.map(crate::persist::state::StateStore::new);
let listener_fallback = bound_port
.filter(|&bound| listen_port != 0 && bound != listen_port)
.map(|bound| (listen_port, bound));
let exit = launch_main_tui(
terminal,
Arc::new(outcome.client),
@@ -517,6 +520,7 @@ fn run_default_tui(
Duration::from_secs(resolved.search_timeout),
store,
config_path.clone(),
listener_fallback,
)
.map_err(|e| CliError::new(Exit::Failure, e.to_string()))?;
@@ -592,6 +596,7 @@ fn run_attached_tui(
Duration::from_secs(resolved.search_timeout),
None,
config_path,
None,
)
.map(|_| ())
.map_err(|e| CliError::new(Exit::Failure, e.to_string()))