From 0e01929caa77a0e30dbcdf18a07baa4ab1eea819 Mon Sep 17 00:00:00 2001 From: Wez Furlong Date: Thu, 27 Feb 2020 20:15:04 -0800 Subject: [PATCH] mux: try to avoid shuffling tabs on tls connections If we hit a timeout for a tab we could mark it dead and remove it from the containing window. This isn't desirable for a tls session that we can reconnect, in part because the timeout is likely to happen to the last focused tab if connectivity was suddenly lost (that was the one we were interacting with, so are likely to have PDUs about to go out), so only that one gets marked dead and removed from the GUI. When we re-attach later we may place the tab in the wrong ordinal position, which is annoying. This commit seeks to avoid the annoyance by not marking the tab dead for reconnectable transports. refs: https://github.com/wez/wezterm/issues/127 --- src/server/client.rs | 3 +++ src/server/tab/renderable.rs | 6 +++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/server/client.rs b/src/server/client.rs index 64981359c..d1cc24fd5 100644 --- a/src/server/client.rs +++ b/src/server/client.rs @@ -34,6 +34,7 @@ enum ReaderMessage { pub struct Client { sender: PollableSender, local_domain_id: DomainId, + pub is_reconnectable: bool, } macro_rules! rpc { @@ -644,6 +645,7 @@ impl Reconnectable { impl Client { fn new(local_domain_id: DomainId, mut reconnectable: Reconnectable) -> Self { + let is_reconnectable = reconnectable.reconnectable(); let (sender, mut receiver) = pollable_channel().expect("failed to create pollable_channel"); thread::spawn(move || { @@ -714,6 +716,7 @@ impl Client { Self { sender, local_domain_id, + is_reconnectable, } } diff --git a/src/server/tab/renderable.rs b/src/server/tab/renderable.rs index 7722df68a..30a959726 100644 --- a/src/server/tab/renderable.rs +++ b/src/server/tab/renderable.rs @@ -384,7 +384,11 @@ impl RenderableInner { tab_id: remote_tab_id, }) .await - .is_ok(); + .is_ok() + // if we got a timeout on a reconnectable, don't + // consider the tab to be dead; that helps to + // avoid having a tab get shuffled around + || client.client.is_reconnectable; let mux = Mux::get().unwrap(); let tab = mux