Reconnect before stale terminal input
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 / publish-gitea-release (push) Blocked by required conditions
ci / remote-bench (push) Waiting to run

This commit is contained in:
DuProcess
2026-07-12 23:25:43 -04:00
parent 17cc1f6131
commit 7184b42b7a
+57 -30
View File
@@ -5984,6 +5984,7 @@ async fn run_terminal(
if should_reconnect_before_input_for_local_sleep(
forward_only,
input_status_tick_gap,
last_packet_at.elapsed(),
) {
let reconnect_started_at = Instant::now();
if let Some(deadline) =
@@ -7536,8 +7537,11 @@ fn should_strip_stale_terminal_reports(
fn should_reconnect_before_input_for_local_sleep(
forward_only: bool,
status_tick_gap: Duration,
packet_silence: Duration,
) -> bool {
!forward_only && status_tick_gap >= LOCAL_SLEEP_REPAINT_AFTER
!forward_only
&& (status_tick_gap >= LOCAL_SLEEP_REPAINT_AFTER
|| packet_silence >= STALE_TERMINAL_INPUT_AFTER)
}
fn wake_repaint_retry_deadline(now: Instant, status_tick_gap: Duration) -> Option<Instant> {
@@ -9593,31 +9597,31 @@ mod tests {
LOCAL_SLEEP_REPAINT_RETRY_WINDOW, LocalForward, MAX_PENDING_USER_INPUT_BYTES,
NativeIdentityContext, POST_RECONNECT_STALE_INPUT_GRACE, POST_SUBMIT_ALL_INPUT_HOLD,
PendingStreamOpen, PredictMode, Predictor, RESTART_STATUS_SCRIPT, RemoteForward,
STARTUP_INPUT_HOLD, SshConfig, SshPathTokenContext, StartupGateMode, StatusAction,
UpdateOptions, UpdateRole, auth_allows, cache_key, cache_server_prefix,
cleanup_stream_state, clear_cached_credentials, effective_update_artifact_tag,
ensure_tui_safe_status_overlay, expand_ssh_path_tokens, input_contains_focus_in,
input_matches_escape, is_local_status_target, is_resume_response_for_client,
latest_release_download_url, load_first_native_identity_with_prompt,
native_proxy_udp_warning, newest_client_trace_path_from, parse_dynamic_forward,
parse_escape_key, parse_local_forward, parse_remote_forward, parse_single_remote_path,
parse_ssh_config, parse_trace_line, parse_trace_options, parse_trace_report_options,
parse_trace_summary, parse_update_options, post_submit_hold_duration,
queue_pending_user_input, queue_stale_pending_user_input, raw_contains_host_table,
recv_response_until, refresh_live_addr, release_tag_download_url,
release_tag_from_effective_url, release_version_from_tag, render_status_clear,
render_status_overlay, requested_env, resolved_startup_command, retire_stream_state,
retransmit_stream_opens, rewrite_forward_command, sanitize_trace_name,
selected_predict_mode, selected_udp_host, server_version_mismatch,
should_flush_terminal_input_after_contact, should_health_log_client_start,
should_hold_during_startup_gate, should_hold_post_submit_input,
should_reconnect_before_input_for_local_sleep, should_repaint_idle_terminal,
should_strip_unowned_terminal_reports, split_after_command_submit, split_trace_tokens,
ssh_command_target, ssh_config_uses_proxy, ssh_destination_host, ssh_username,
ssh_with_user, startup_command, status_ssh_target, strip_stale_mouse_reports,
strip_terminal_focus_reports, strip_unowned_terminal_reports, summarize_trace_file,
summarize_trace_file_with_mode, terminal_private_mode_transition, toml_bare_key_or_quoted,
top_trace_events, trace_report_warnings, unix_update_script,
STALE_TERMINAL_INPUT_AFTER, STARTUP_INPUT_HOLD, SshConfig, SshPathTokenContext,
StartupGateMode, StatusAction, UpdateOptions, UpdateRole, auth_allows, cache_key,
cache_server_prefix, cleanup_stream_state, clear_cached_credentials,
effective_update_artifact_tag, ensure_tui_safe_status_overlay, expand_ssh_path_tokens,
input_contains_focus_in, input_matches_escape, is_local_status_target,
is_resume_response_for_client, latest_release_download_url,
load_first_native_identity_with_prompt, native_proxy_udp_warning,
newest_client_trace_path_from, parse_dynamic_forward, parse_escape_key,
parse_local_forward, parse_remote_forward, parse_single_remote_path, parse_ssh_config,
parse_trace_line, parse_trace_options, parse_trace_report_options, parse_trace_summary,
parse_update_options, post_submit_hold_duration, queue_pending_user_input,
queue_stale_pending_user_input, raw_contains_host_table, recv_response_until,
refresh_live_addr, release_tag_download_url, release_tag_from_effective_url,
release_version_from_tag, render_status_clear, render_status_overlay, requested_env,
resolved_startup_command, retire_stream_state, retransmit_stream_opens,
rewrite_forward_command, sanitize_trace_name, selected_predict_mode, selected_udp_host,
server_version_mismatch, should_flush_terminal_input_after_contact,
should_health_log_client_start, should_hold_during_startup_gate,
should_hold_post_submit_input, should_reconnect_before_input_for_local_sleep,
should_repaint_idle_terminal, should_strip_unowned_terminal_reports,
split_after_command_submit, split_trace_tokens, ssh_command_target, ssh_config_uses_proxy,
ssh_destination_host, ssh_username, ssh_with_user, startup_command, status_ssh_target,
strip_stale_mouse_reports, strip_terminal_focus_reports, strip_unowned_terminal_reports,
summarize_trace_file, summarize_trace_file_with_mode, terminal_private_mode_transition,
toml_bare_key_or_quoted, top_trace_events, trace_report_warnings, unix_update_script,
update_binary_version_for_installer, update_installer_url, update_version_status,
upsert_managed_block, valid_forward_host, vscode_safe_alias, wake_repaint_retry_deadline,
windows_update_script,
@@ -12008,19 +12012,42 @@ mod tests {
fn local_sleep_gap_reconnects_before_forwarding_input() {
assert!(should_reconnect_before_input_for_local_sleep(
false,
LOCAL_SLEEP_REPAINT_AFTER
LOCAL_SLEEP_REPAINT_AFTER,
Duration::ZERO
));
assert!(should_reconnect_before_input_for_local_sleep(
false,
LOCAL_SLEEP_REPAINT_AFTER + Duration::from_secs(10)
LOCAL_SLEEP_REPAINT_AFTER + Duration::from_secs(10),
Duration::ZERO
));
assert!(!should_reconnect_before_input_for_local_sleep(
false,
LOCAL_SLEEP_REPAINT_AFTER - Duration::from_millis(1)
LOCAL_SLEEP_REPAINT_AFTER - Duration::from_millis(1),
Duration::ZERO
));
assert!(!should_reconnect_before_input_for_local_sleep(
true,
LOCAL_SLEEP_REPAINT_AFTER + Duration::from_secs(10)
LOCAL_SLEEP_REPAINT_AFTER + Duration::from_secs(10),
STALE_TERMINAL_INPUT_AFTER + Duration::from_secs(10)
));
}
#[test]
fn packet_silence_reconnects_before_forwarding_input() {
assert!(should_reconnect_before_input_for_local_sleep(
false,
Duration::from_millis(1),
STALE_TERMINAL_INPUT_AFTER
));
assert!(should_reconnect_before_input_for_local_sleep(
false,
Duration::from_millis(1),
STALE_TERMINAL_INPUT_AFTER + Duration::from_secs(1)
));
assert!(!should_reconnect_before_input_for_local_sleep(
false,
Duration::from_millis(1),
STALE_TERMINAL_INPUT_AFTER - Duration::from_millis(1)
));
}