diff --git a/zellij-client/src/lib.rs b/zellij-client/src/lib.rs index 8bafcc74..60245f94 100644 --- a/zellij-client/src/lib.rs +++ b/zellij-client/src/lib.rs @@ -61,6 +61,7 @@ pub(crate) enum ClientInstruction { QueryTerminalSize, WriteConfigToDisk { config: String }, StartWebServer, + RenamedSession(String), // String -> new session name } impl From for ClientInstruction { @@ -86,6 +87,7 @@ impl From for ClientInstruction { ClientInstruction::WriteConfigToDisk { config } }, ServerToClientMsg::StartWebServer => ClientInstruction::StartWebServer, + ServerToClientMsg::RenamedSession(name) => ClientInstruction::RenamedSession(name), } } } @@ -109,6 +111,7 @@ impl From<&ClientInstruction> for ClientContext { ClientInstruction::QueryTerminalSize => ClientContext::QueryTerminalSize, ClientInstruction::WriteConfigToDisk { .. } => ClientContext::WriteConfigToDisk, ClientInstruction::StartWebServer => ClientContext::StartWebServer, + ClientInstruction::RenamedSession(..) => ClientContext::RenamedSession, } } } diff --git a/zellij-client/src/web_client/server_listener.rs b/zellij-client/src/web_client/server_listener.rs index 458e314b..04ad6e04 100644 --- a/zellij-client/src/web_client/server_listener.rs +++ b/zellij-client/src/web_client/server_listener.rs @@ -142,6 +142,13 @@ pub fn zellij_server_listener( WebServerToWebClientControlMessage::LogError { lines }, ); }, + Some((ServerToClientMsg::RenamedSession(new_session_name), _)) => { + client_connection_bus.send_control( + WebServerToWebClientControlMessage::SwitchedSession { + new_session_name, + }, + ); + }, _ => { // server disconnected, stop trying to listen otherwise we retry // indefinitely and get 100% CPU diff --git a/zellij-server/src/screen.rs b/zellij-server/src/screen.rs index 29dd10bd..44089237 100644 --- a/zellij-server/src/screen.rs +++ b/zellij-server/src/screen.rs @@ -5113,9 +5113,19 @@ pub(crate) fn screen_thread_main( .with_context(err_context)?; // set the env variable - set_session_name(name); + set_session_name(name.clone()); + screen.unblock_input()?; + let connected_client_ids: Vec = + screen.active_tab_indices.keys().copied().collect(); + for client_id in connected_client_ids { + if let Some(os_input) = &mut screen.bus.os_input { + let _ = os_input.send_to_client( + client_id, + ServerToClientMsg::RenamedSession(name.clone()), + ); + } + } } - screen.unblock_input()?; }, ScreenInstruction::Reconfigure { client_id, diff --git a/zellij-utils/src/errors.rs b/zellij-utils/src/errors.rs index 836b5100..10eed658 100644 --- a/zellij-utils/src/errors.rs +++ b/zellij-utils/src/errors.rs @@ -478,6 +478,7 @@ pub enum ClientContext { QueryTerminalSize, WriteConfigToDisk, StartWebServer, + RenamedSession, } /// Stack call representations corresponding to the different types of [`ServerInstruction`]s. diff --git a/zellij-utils/src/ipc.rs b/zellij-utils/src/ipc.rs index a9e374f2..2ec6d8d5 100644 --- a/zellij-utils/src/ipc.rs +++ b/zellij-utils/src/ipc.rs @@ -116,6 +116,7 @@ pub enum ServerToClientMsg { QueryTerminalSize, WriteConfigToDisk { config: String }, StartWebServer, + RenamedSession(String), // String -> new session name } #[derive(Serialize, Deserialize, Debug, Clone)]