diff --git a/Cargo.lock b/Cargo.lock index 94fa375..24dd4b2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1067,8 +1067,6 @@ dependencies = [ "maestro-config", "maestro-protocol", "nix", - "reqwest", - "serde", "serde_json", "tempfile", "thiserror 1.0.69", @@ -1172,7 +1170,6 @@ dependencies = [ "maestro-config", "maestro-protocol", "ratatui", - "reqwest", "serde_json", "thiserror 1.0.69", "tokio", @@ -1193,6 +1190,7 @@ dependencies = [ "futures-util", "include_dir", "maestro-config", + "maestro-protocol", "mime_guess", "reqwest", "serde_json", diff --git a/crates/maestro-tui/src/lib.rs b/crates/maestro-tui/src/lib.rs index ef02836..c0f0783 100644 --- a/crates/maestro-tui/src/lib.rs +++ b/crates/maestro-tui/src/lib.rs @@ -62,14 +62,15 @@ pub async fn run(cfg: RunConfig) -> Result<(), TuiError> { let base_url = cfg.daemon_url.trim_end_matches('/').to_string(); - let daemon = DaemonClient::with_timeouts( + // Health check — fail fast if no daemon is reachable. + health_check(&DaemonClient::with_timeouts( &base_url, HEALTH_TIMEOUT, - maestro_protocol::client::DEFAULT_REQUEST_TIMEOUT, - ); + HEALTH_TIMEOUT, + )) + .await?; - // Health check — fail fast if no daemon is reachable. - health_check(&daemon).await?; + let daemon = DaemonClient::with_timeouts(&base_url, REQUEST_TIMEOUT, REQUEST_TIMEOUT); // Load runtime config: explicit `--config ` wins, then // `$MAESTRO_CONFIG`, then the platform default. Missing file is fine — @@ -105,10 +106,15 @@ pub async fn run(cfg: RunConfig) -> Result<(), TuiError> { app.run(&mut terminal).await } -/// Startup probe budget. Deliberately far below the client default: the user is +/// Startup probe budget, applied to connect *and* the whole request: the user is /// staring at a terminal, so an unreachable daemon must fail in under a second. const HEALTH_TIMEOUT: Duration = Duration::from_millis(500); +/// Budget for the TUI's own calls once it is up. Tighter than the client +/// default — a spawn or kill that stalls should surface as a toast, not hang +/// the interface. +const REQUEST_TIMEOUT: Duration = Duration::from_secs(5); + async fn health_check(daemon: &DaemonClient) -> Result<(), TuiError> { for _ in 0..3 { if daemon.daemon_info().await.is_ok() {