From 98e137942af6450c9a15bd02ce8c44155b46ecbd Mon Sep 17 00:00:00 2001 From: Wez Furlong Date: Sat, 25 Mar 2023 20:48:55 -0700 Subject: [PATCH] mux: move-pane-to-new-tab didn't resync structure Resolution is to propagate the MuxNotification to the clients and have them resync. refs: https://github.com/wez/wezterm/issues/3219 --- codec/src/lib.rs | 9 ++++++++- docs/changelog.md | 2 ++ wezterm-client/src/client.rs | 4 ++-- wezterm-mux-server-impl/src/dispatch.rs | 7 ++++++- wezterm-mux-server-impl/src/sessionhandler.rs | 1 + 5 files changed, 19 insertions(+), 4 deletions(-) diff --git a/codec/src/lib.rs b/codec/src/lib.rs index ff2a293f2..574ce6bf6 100644 --- a/codec/src/lib.rs +++ b/codec/src/lib.rs @@ -417,7 +417,7 @@ macro_rules! pdu { /// The overall version of the codec. /// This must be bumped when backwards incompatible changes /// are made to the types and protocol. -pub const CODEC_VERSION: usize = 35; +pub const CODEC_VERSION: usize = 36; // Defines the Pdu enum. // Each struct has an explicit identifying number. @@ -470,6 +470,7 @@ pdu! { GetPaneRenderableDimensionsResponse: 52, PaneFocused: 53, TabResized: 54, + TabAddedToWindow: 55, } impl Pdu { @@ -736,6 +737,12 @@ pub struct NotifyAlert { pub alert: Alert, } +#[derive(Deserialize, Serialize, PartialEq, Debug)] +pub struct TabAddedToWindow { + pub tab_id: TabId, + pub window_id: WindowId, +} + #[derive(Deserialize, Serialize, PartialEq, Debug)] pub struct TabResized { pub tab_id: TabId, diff --git a/docs/changelog.md b/docs/changelog.md index a861cfdb2..8851ce73e 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -78,6 +78,8 @@ As features stabilize some brief notes about them will accumulate here. tab was explicitly resized. #3366 * mux: initial attach and spawn would leave the dpi at the assumed dpi resulting in incorrect image scaling for imgcat. #3366 +* mux: `wezterm cli move-pane-to-new-tab` didn't resync new window structure + and would appear to have had no effect until you detached and re-attached. #3219 #### Updated * Bundled JetBrainsMono to 2.304. #3362 diff --git a/wezterm-client/src/client.rs b/wezterm-client/src/client.rs index 9a74d1a82..3ae4b4663 100644 --- a/wezterm-client/src/client.rs +++ b/wezterm-client/src/client.rs @@ -220,8 +220,8 @@ fn process_unilateral( return Ok(()); } - Pdu::TabResized(TabResized { tab_id }) => { - log::trace!("TabResized {tab_id}"); + Pdu::TabResized(_) | Pdu::TabAddedToWindow(_) => { + log::trace!("resync due to {:?}", decoded.pdu); promise::spawn::spawn_into_main_thread(async move { let mux = Mux::try_get().ok_or_else(|| anyhow!("no more mux"))?; let client_domain = mux diff --git a/wezterm-mux-server-impl/src/dispatch.rs b/wezterm-mux-server-impl/src/dispatch.rs index 470695f7b..1bafbd587 100644 --- a/wezterm-mux-server-impl/src/dispatch.rs +++ b/wezterm-mux-server-impl/src/dispatch.rs @@ -139,7 +139,12 @@ where .await?; stream.flush().await.context("flushing PDU to client")?; } - Ok(Item::Notif(MuxNotification::TabAddedToWindow { .. })) => {} + Ok(Item::Notif(MuxNotification::TabAddedToWindow { tab_id, window_id })) => { + Pdu::TabAddedToWindow(codec::TabAddedToWindow { tab_id, window_id }) + .encode_async(&mut stream, 0) + .await?; + stream.flush().await.context("flushing PDU to client")?; + } Ok(Item::Notif(MuxNotification::WindowRemoved(_window_id))) => {} Ok(Item::Notif(MuxNotification::WindowCreated(_window_id))) => {} Ok(Item::Notif(MuxNotification::WindowInvalidated(_window_id))) => {} diff --git a/wezterm-mux-server-impl/src/sessionhandler.rs b/wezterm-mux-server-impl/src/sessionhandler.rs index 4d1c808df..98e7f2016 100644 --- a/wezterm-mux-server-impl/src/sessionhandler.rs +++ b/wezterm-mux-server-impl/src/sessionhandler.rs @@ -751,6 +751,7 @@ impl SessionHandler { | Pdu::TabResized { .. } | Pdu::GetImageCellResponse { .. } | Pdu::MovePaneToNewTabResponse { .. } + | Pdu::TabAddedToWindow { .. } | Pdu::GetPaneRenderableDimensionsResponse { .. } | Pdu::ErrorResponse { .. } => { send_response(Err(anyhow!("expected a request, got {:?}", decoded.pdu)))