Skip to content

Feat: start TUI immediately with async baresip connection#13

Merged
davidborzek merged 1 commit into
davidborzek:mainfrom
jakobhellermann:async-baresip-connect
Jun 15, 2026
Merged

Feat: start TUI immediately with async baresip connection#13
davidborzek merged 1 commit into
davidborzek:mainfrom
jakobhellermann:async-baresip-connect

Conversation

@jakobhellermann

@jakobhellermann jakobhellermann commented May 8, 2026

Copy link
Copy Markdown
Contributor

Summary

Previously, tui::run blocked on wait_for_port (polling baresip's ctrl_tcp port for up to 5s) and TcpStream::connect before the terminal was set up. If baresip was slow to come up, the previous screen stayed visible and the UI was unresponsive for a moment; if it never came up, the user got an opaque error after the timeout.

This change starts the TUI immediately and connects to baresip asynchronously in the background:

  • New run_baresip_io async task: retries TcpStream::connect for up to 10s, then spawns the existing reader/writer tasks.
  • New AppEvent::BaresipConnectFailed { reason } event surfaces connect-timeout failures in the UI as RegStatus::Failed with the reason (including the baresip log path).
  • Status bar's Unknown (now "Connecting") state uses the attention color so the in-progress connection is visible.
  • Removed the now-unused wait_for_port helper and synchronous port-readiness check from Baresip::spawn.
  • Added a unit test covering the connect-failure path (asserts BaresipConnectFailed is emitted with port and log path in the reason).

Test plan

  • cargo build clean
  • cargo test passes (incl. new connect_failure_emits_baresip_connect_failed)
  • Manual: start ringo with a valid profile — TUI shows "Connecting" briefly, then transitions to "Registering" → "Registered"
  • Manual: start ringo with no baresip available (port sabotaged) — TUI shows "Connecting" for 10s, then "Failed: baresip unreachable: ..." with log path

@steinbrueckri

Copy link
Copy Markdown

any update on this @davidborzek?

@davidborzek davidborzek left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@davidborzek davidborzek merged commit ffd2efc into davidborzek:main Jun 15, 2026
1 check passed
@jakobhellermann jakobhellermann deleted the async-baresip-connect branch June 15, 2026 14:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants