Repaint terminal after local sleep
ci / test (push) Waiting to run
ci / fuzz-smoke (push) Waiting to run
ci / windows-client (push) Waiting to run
ci / package-release (linux-x86_64, ubuntu-latest) (push) Waiting to run
ci / package-release (macos-aarch64, macos-14) (push) Waiting to run
ci / package-release (macos-x86_64, macos-13) (push) Waiting to run
ci / package-release (windows-x86_64, windows-latest) (push) Waiting to run
ci / remote-bench (push) Waiting to run
ci / test (push) Waiting to run
ci / fuzz-smoke (push) Waiting to run
ci / windows-client (push) Waiting to run
ci / package-release (linux-x86_64, ubuntu-latest) (push) Waiting to run
ci / package-release (macos-aarch64, macos-14) (push) Waiting to run
ci / package-release (macos-x86_64, macos-13) (push) Waiting to run
ci / package-release (windows-x86_64, windows-latest) (push) Waiting to run
ci / remote-bench (push) Waiting to run
This commit is contained in:
Generated
+1
-1
@@ -436,7 +436,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "dosh"
|
name = "dosh"
|
||||||
version = "1.0.0-rc32"
|
version = "1.0.0-rc33"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"base64",
|
"base64",
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "dosh"
|
name = "dosh"
|
||||||
version = "1.0.0-rc32"
|
version = "1.0.0-rc33"
|
||||||
edition = "2024"
|
edition = "2024"
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
|
|
||||||
|
|||||||
+81
-38
@@ -74,6 +74,7 @@ const STALE_TERMINAL_INPUT_AFTER: Duration = Duration::from_secs(2);
|
|||||||
const POST_RECONNECT_STALE_INPUT_GRACE: Duration = Duration::from_secs(2);
|
const POST_RECONNECT_STALE_INPUT_GRACE: Duration = Duration::from_secs(2);
|
||||||
const FOCUS_REPAINT_COOLDOWN: Duration = Duration::from_secs(1);
|
const FOCUS_REPAINT_COOLDOWN: Duration = Duration::from_secs(1);
|
||||||
const ALT_SCREEN_IDLE_REPAINT_AFTER: Duration = Duration::from_secs(15);
|
const ALT_SCREEN_IDLE_REPAINT_AFTER: Duration = Duration::from_secs(15);
|
||||||
|
const LOCAL_SLEEP_REPAINT_AFTER: Duration = Duration::from_secs(5);
|
||||||
|
|
||||||
/// Sentinel `target_host` the server uses on a server-initiated `StreamOpen` that
|
/// Sentinel `target_host` the server uses on a server-initiated `StreamOpen` that
|
||||||
/// represents an SSH-agent connection (rather than a TCP target). The client
|
/// represents an SSH-agent connection (rather than a TCP target). The client
|
||||||
@@ -5506,6 +5507,7 @@ async fn run_terminal(
|
|||||||
let mut last_terminal_frame_at = Instant::now();
|
let mut last_terminal_frame_at = Instant::now();
|
||||||
let mut last_focus_repaint_at = Instant::now() - FOCUS_REPAINT_COOLDOWN;
|
let mut last_focus_repaint_at = Instant::now() - FOCUS_REPAINT_COOLDOWN;
|
||||||
let mut last_idle_repaint_attempt_at = Instant::now() - ALT_SCREEN_IDLE_REPAINT_AFTER;
|
let mut last_idle_repaint_attempt_at = Instant::now() - ALT_SCREEN_IDLE_REPAINT_AFTER;
|
||||||
|
let mut last_status_tick_at = Instant::now();
|
||||||
if let Some(frame) = first_frame {
|
if let Some(frame) = first_frame {
|
||||||
if !forward_only {
|
if !forward_only {
|
||||||
render_frame(&frame)?;
|
render_frame(&frame)?;
|
||||||
@@ -6488,6 +6490,10 @@ async fn run_terminal(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ = status_tick.tick() => {
|
_ = status_tick.tick() => {
|
||||||
|
let status_tick_at = Instant::now();
|
||||||
|
let status_tick_gap = status_tick_at.duration_since(last_status_tick_at);
|
||||||
|
last_status_tick_at = status_tick_at;
|
||||||
|
let mut repainted_this_tick = false;
|
||||||
let stale = last_packet_at.elapsed();
|
let stale = last_packet_at.elapsed();
|
||||||
if stale >= Duration::from_secs(reconnect_timeout_secs.max(1)) {
|
if stale >= Duration::from_secs(reconnect_timeout_secs.max(1)) {
|
||||||
if let Some(frame) = reconnect(
|
if let Some(frame) = reconnect(
|
||||||
@@ -6508,6 +6514,8 @@ async fn run_terminal(
|
|||||||
render_frame(&frame)?;
|
render_frame(&frame)?;
|
||||||
predictor.observe_output(&frame.bytes);
|
predictor.observe_output(&frame.bytes);
|
||||||
last_terminal_frame_at = Instant::now();
|
last_terminal_frame_at = Instant::now();
|
||||||
|
last_idle_repaint_attempt_at = Instant::now();
|
||||||
|
repainted_this_tick = true;
|
||||||
}
|
}
|
||||||
last_packet_at = Instant::now();
|
last_packet_at = Instant::now();
|
||||||
flush_pending_user_input(
|
flush_pending_user_input(
|
||||||
@@ -6550,13 +6558,22 @@ async fn run_terminal(
|
|||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
let now = Instant::now();
|
let now = Instant::now();
|
||||||
if should_repaint_idle_alternate_screen(
|
if !repainted_this_tick && should_repaint_idle_terminal(
|
||||||
predictor.alternate_screen,
|
predictor.alternate_screen,
|
||||||
last_terminal_frame_at,
|
last_terminal_frame_at,
|
||||||
last_idle_repaint_attempt_at,
|
last_idle_repaint_attempt_at,
|
||||||
|
status_tick_gap,
|
||||||
now,
|
now,
|
||||||
) {
|
) {
|
||||||
last_idle_repaint_attempt_at = now;
|
last_idle_repaint_attempt_at = now;
|
||||||
|
dosh::trace::event(
|
||||||
|
"client.idle_repaint_start",
|
||||||
|
&[
|
||||||
|
("alt", predictor.alternate_screen.to_string()),
|
||||||
|
("tick_gap_ms", status_tick_gap.as_millis().to_string()),
|
||||||
|
("silent_ms", stale.as_millis().to_string()),
|
||||||
|
],
|
||||||
|
);
|
||||||
if let Some(frame) = reconnect(
|
if let Some(frame) = reconnect(
|
||||||
&socket,
|
&socket,
|
||||||
&mut cred,
|
&mut cred,
|
||||||
@@ -7021,14 +7038,16 @@ fn strip_terminal_focus_reports(bytes: &[u8]) -> Vec<u8> {
|
|||||||
out
|
out
|
||||||
}
|
}
|
||||||
|
|
||||||
fn should_repaint_idle_alternate_screen(
|
fn should_repaint_idle_terminal(
|
||||||
alternate_screen: bool,
|
alternate_screen: bool,
|
||||||
last_terminal_frame_at: Instant,
|
last_terminal_frame_at: Instant,
|
||||||
last_attempt_at: Instant,
|
last_attempt_at: Instant,
|
||||||
|
status_tick_gap: Duration,
|
||||||
now: Instant,
|
now: Instant,
|
||||||
) -> bool {
|
) -> bool {
|
||||||
alternate_screen
|
(alternate_screen
|
||||||
&& now.duration_since(last_terminal_frame_at) >= ALT_SCREEN_IDLE_REPAINT_AFTER
|
&& 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
|
&& now.duration_since(last_attempt_at) >= ALT_SCREEN_IDLE_REPAINT_AFTER
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -8972,32 +8991,33 @@ const TERMINAL_CLEANUP: &[u8] = concat!(
|
|||||||
mod tests {
|
mod tests {
|
||||||
use super::{
|
use super::{
|
||||||
ALT_SCREEN_IDLE_REPAINT_AFTER, CachedCredential, DisconnectStatus, DynamicForward,
|
ALT_SCREEN_IDLE_REPAINT_AFTER, CachedCredential, DisconnectStatus, DynamicForward,
|
||||||
FRAME_GAP_RESYNC_AFTER_MS, FrameBuffer, LocalForward, MAX_PENDING_USER_INPUT_BYTES,
|
FRAME_GAP_RESYNC_AFTER_MS, FrameBuffer, LOCAL_SLEEP_REPAINT_AFTER, LocalForward,
|
||||||
NativeIdentityContext, POST_SUBMIT_ALL_INPUT_HOLD, PendingStreamOpen, PredictMode,
|
MAX_PENDING_USER_INPUT_BYTES, NativeIdentityContext, POST_SUBMIT_ALL_INPUT_HOLD,
|
||||||
Predictor, RESTART_STATUS_SCRIPT, RemoteForward, STARTUP_INPUT_HOLD, SshConfig,
|
PendingStreamOpen, PredictMode, Predictor, RESTART_STATUS_SCRIPT, RemoteForward,
|
||||||
SshPathTokenContext, StartupGateMode, StatusAction, UpdateOptions, UpdateRole, auth_allows,
|
STARTUP_INPUT_HOLD, SshConfig, SshPathTokenContext, StartupGateMode, StatusAction,
|
||||||
cache_key, cache_server_prefix, cleanup_stream_state, clear_cached_credentials,
|
UpdateOptions, UpdateRole, auth_allows, cache_key, cache_server_prefix,
|
||||||
ensure_tui_safe_status_overlay, expand_ssh_path_tokens, input_contains_focus_in,
|
cleanup_stream_state, clear_cached_credentials, ensure_tui_safe_status_overlay,
|
||||||
input_matches_escape, is_local_status_target, is_resume_response_for_client,
|
expand_ssh_path_tokens, input_contains_focus_in, input_matches_escape,
|
||||||
latest_release_download_url, load_first_native_identity_with_prompt,
|
is_local_status_target, is_resume_response_for_client, latest_release_download_url,
|
||||||
native_proxy_udp_warning, parse_dynamic_forward, parse_escape_key, parse_local_forward,
|
load_first_native_identity_with_prompt, native_proxy_udp_warning, parse_dynamic_forward,
|
||||||
parse_remote_forward, parse_ssh_config, parse_trace_line, parse_trace_options,
|
parse_escape_key, parse_local_forward, parse_remote_forward, parse_ssh_config,
|
||||||
parse_trace_report_options, parse_trace_summary, parse_update_options,
|
parse_trace_line, parse_trace_options, parse_trace_report_options, parse_trace_summary,
|
||||||
post_submit_hold_duration, queue_pending_user_input, queue_stale_pending_user_input,
|
parse_update_options, post_submit_hold_duration, queue_pending_user_input,
|
||||||
raw_contains_host_table, recv_response_until, refresh_live_addr, release_tag_download_url,
|
queue_stale_pending_user_input, raw_contains_host_table, recv_response_until,
|
||||||
release_tag_from_effective_url, release_version_from_tag, render_status_clear,
|
refresh_live_addr, release_tag_download_url, release_tag_from_effective_url,
|
||||||
render_status_overlay, requested_env, resolved_startup_command, retire_stream_state,
|
release_version_from_tag, render_status_clear, render_status_overlay, requested_env,
|
||||||
retransmit_stream_opens, rewrite_forward_command, sanitize_trace_name,
|
resolved_startup_command, retire_stream_state, retransmit_stream_opens,
|
||||||
selected_predict_mode, selected_udp_host, server_version_mismatch,
|
rewrite_forward_command, sanitize_trace_name, selected_predict_mode, selected_udp_host,
|
||||||
should_flush_terminal_input_after_contact, should_hold_during_startup_gate,
|
server_version_mismatch, should_flush_terminal_input_after_contact,
|
||||||
should_hold_post_submit_input, should_repaint_idle_alternate_screen,
|
should_hold_during_startup_gate, should_hold_post_submit_input,
|
||||||
should_strip_unowned_terminal_reports, split_after_command_submit, split_trace_tokens,
|
should_repaint_idle_terminal, should_strip_unowned_terminal_reports,
|
||||||
ssh_command_target, ssh_config_uses_proxy, ssh_destination_host, ssh_username,
|
split_after_command_submit, split_trace_tokens, ssh_command_target, ssh_config_uses_proxy,
|
||||||
ssh_with_user, startup_command, status_ssh_target, strip_stale_mouse_reports,
|
ssh_destination_host, ssh_username, ssh_with_user, startup_command, status_ssh_target,
|
||||||
strip_terminal_focus_reports, strip_unowned_terminal_reports, summarize_trace_file,
|
strip_stale_mouse_reports, strip_terminal_focus_reports, strip_unowned_terminal_reports,
|
||||||
terminal_private_mode_transition, toml_bare_key_or_quoted, top_trace_events,
|
summarize_trace_file, terminal_private_mode_transition, toml_bare_key_or_quoted,
|
||||||
trace_report_warnings, unix_update_script, update_installer_url, update_version_status,
|
top_trace_events, trace_report_warnings, unix_update_script, update_installer_url,
|
||||||
upsert_managed_block, valid_forward_host, vscode_safe_alias, windows_update_script,
|
update_version_status, upsert_managed_block, valid_forward_host, vscode_safe_alias,
|
||||||
|
windows_update_script,
|
||||||
};
|
};
|
||||||
use dosh::config::{ClientConfig, CommandExtension, HostConfig};
|
use dosh::config::{ClientConfig, CommandExtension, HostConfig};
|
||||||
use dosh::native::EnvVar;
|
use dosh::native::EnvVar;
|
||||||
@@ -10979,21 +10999,44 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn idle_repaint_only_runs_for_stale_alternate_screen() {
|
fn idle_repaint_runs_for_stale_alternate_screen_or_sleep_gap() {
|
||||||
let now = Instant::now();
|
let now = Instant::now();
|
||||||
let stale = now - ALT_SCREEN_IDLE_REPAINT_AFTER - Duration::from_secs(1);
|
let stale = now - ALT_SCREEN_IDLE_REPAINT_AFTER - Duration::from_secs(1);
|
||||||
let recent = now - Duration::from_secs(1);
|
let recent = now - Duration::from_secs(1);
|
||||||
assert!(should_repaint_idle_alternate_screen(
|
assert!(should_repaint_idle_terminal(
|
||||||
true, stale, stale, now
|
true,
|
||||||
|
stale,
|
||||||
|
stale,
|
||||||
|
Duration::from_secs(1),
|
||||||
|
now
|
||||||
));
|
));
|
||||||
assert!(!should_repaint_idle_alternate_screen(
|
assert!(should_repaint_idle_terminal(
|
||||||
false, stale, stale, now
|
false,
|
||||||
|
recent,
|
||||||
|
stale,
|
||||||
|
LOCAL_SLEEP_REPAINT_AFTER + Duration::from_secs(1),
|
||||||
|
now
|
||||||
));
|
));
|
||||||
assert!(!should_repaint_idle_alternate_screen(
|
assert!(!should_repaint_idle_terminal(
|
||||||
true, recent, stale, now
|
false,
|
||||||
|
stale,
|
||||||
|
stale,
|
||||||
|
Duration::from_secs(1),
|
||||||
|
now
|
||||||
));
|
));
|
||||||
assert!(!should_repaint_idle_alternate_screen(
|
assert!(!should_repaint_idle_terminal(
|
||||||
true, stale, recent, now
|
true,
|
||||||
|
recent,
|
||||||
|
stale,
|
||||||
|
Duration::from_secs(1),
|
||||||
|
now
|
||||||
|
));
|
||||||
|
assert!(!should_repaint_idle_terminal(
|
||||||
|
true,
|
||||||
|
stale,
|
||||||
|
recent,
|
||||||
|
LOCAL_SLEEP_REPAINT_AFTER + Duration::from_secs(1),
|
||||||
|
now
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user