From f74495765f763fab9d16349025675725423f4b2a Mon Sep 17 00:00:00 2001 From: DuProcess <273172371+DuProcess@users.noreply.github.com> Date: Sun, 12 Jul 2026 21:08:37 -0400 Subject: [PATCH] Retry wake repaint quickly --- Cargo.lock | 2 +- Cargo.toml | 2 +- src/bin/dosh-client.rs | 29 ++++++++++++++++++++++++----- 3 files changed, 26 insertions(+), 7 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d7e6868..6709a6a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -436,7 +436,7 @@ dependencies = [ [[package]] name = "dosh" -version = "1.0.0-rc37" +version = "1.0.0-rc38" dependencies = [ "anyhow", "base64", diff --git a/Cargo.toml b/Cargo.toml index a801ea2..1f9f5ab 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "dosh" -version = "1.0.0-rc37" +version = "1.0.0-rc38" edition = "2024" license = "MIT" diff --git a/src/bin/dosh-client.rs b/src/bin/dosh-client.rs index 9aadbc6..dc7371a 100644 --- a/src/bin/dosh-client.rs +++ b/src/bin/dosh-client.rs @@ -75,6 +75,7 @@ const POST_RECONNECT_STALE_INPUT_GRACE: Duration = Duration::from_secs(5); const FOCUS_REPAINT_COOLDOWN: Duration = Duration::from_secs(1); const ALT_SCREEN_IDLE_REPAINT_AFTER: Duration = Duration::from_secs(15); const LOCAL_SLEEP_REPAINT_AFTER: Duration = Duration::from_secs(5); +const LOCAL_SLEEP_REPAINT_RETRY_AFTER: Duration = Duration::from_secs(1); /// Sentinel `target_host` the server uses on a server-initiated `StreamOpen` that /// represents an SSH-agent connection (rather than a TCP target). The client @@ -7324,10 +7325,13 @@ fn should_repaint_idle_terminal( status_tick_gap: Duration, now: Instant, ) -> bool { - (alternate_screen - && now.duration_since(last_terminal_frame_at) >= ALT_SCREEN_IDLE_REPAINT_AFTER - || status_tick_gap >= LOCAL_SLEEP_REPAINT_AFTER) - && now.duration_since(last_attempt_at) >= ALT_SCREEN_IDLE_REPAINT_AFTER + let sleep_wake_gap = status_tick_gap >= LOCAL_SLEEP_REPAINT_AFTER; + let stale_alternate_screen = alternate_screen + && now.duration_since(last_terminal_frame_at) >= ALT_SCREEN_IDLE_REPAINT_AFTER; + if sleep_wake_gap { + return now.duration_since(last_attempt_at) >= LOCAL_SLEEP_REPAINT_RETRY_AFTER; + } + stale_alternate_screen && now.duration_since(last_attempt_at) >= ALT_SCREEN_IDLE_REPAINT_AFTER } fn arm_stale_terminal_input_suppression(suppress_until: &mut Option) { @@ -11376,6 +11380,7 @@ mod tests { let now = Instant::now(); let stale = now - ALT_SCREEN_IDLE_REPAINT_AFTER - Duration::from_secs(1); let recent = now - Duration::from_secs(1); + let just_attempted = now - Duration::from_millis(500); assert!(should_repaint_idle_terminal( true, stale, @@ -11390,6 +11395,20 @@ mod tests { LOCAL_SLEEP_REPAINT_AFTER + Duration::from_secs(1), now )); + assert!(should_repaint_idle_terminal( + false, + recent, + recent, + LOCAL_SLEEP_REPAINT_AFTER + Duration::from_secs(1), + now + )); + assert!(!should_repaint_idle_terminal( + false, + recent, + just_attempted, + LOCAL_SLEEP_REPAINT_AFTER + Duration::from_secs(1), + now + )); assert!(!should_repaint_idle_terminal( false, stale, @@ -11404,7 +11423,7 @@ mod tests { Duration::from_secs(1), now )); - assert!(!should_repaint_idle_terminal( + assert!(should_repaint_idle_terminal( true, stale, recent,