fix(web): change URL when renaming session (#4299)

* fix(web): change URL when renaming session

* style(fmt): rustfmt
This commit is contained in:
Aram Drevekenin 2025-07-17 15:48:07 +02:00 committed by GitHub
parent 19c159175c
commit 9fd7a02023
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 24 additions and 2 deletions

View file

@ -61,6 +61,7 @@ pub(crate) enum ClientInstruction {
QueryTerminalSize, QueryTerminalSize,
WriteConfigToDisk { config: String }, WriteConfigToDisk { config: String },
StartWebServer, StartWebServer,
RenamedSession(String), // String -> new session name
} }
impl From<ServerToClientMsg> for ClientInstruction { impl From<ServerToClientMsg> for ClientInstruction {
@ -86,6 +87,7 @@ impl From<ServerToClientMsg> for ClientInstruction {
ClientInstruction::WriteConfigToDisk { config } ClientInstruction::WriteConfigToDisk { config }
}, },
ServerToClientMsg::StartWebServer => ClientInstruction::StartWebServer, ServerToClientMsg::StartWebServer => ClientInstruction::StartWebServer,
ServerToClientMsg::RenamedSession(name) => ClientInstruction::RenamedSession(name),
} }
} }
} }
@ -109,6 +111,7 @@ impl From<&ClientInstruction> for ClientContext {
ClientInstruction::QueryTerminalSize => ClientContext::QueryTerminalSize, ClientInstruction::QueryTerminalSize => ClientContext::QueryTerminalSize,
ClientInstruction::WriteConfigToDisk { .. } => ClientContext::WriteConfigToDisk, ClientInstruction::WriteConfigToDisk { .. } => ClientContext::WriteConfigToDisk,
ClientInstruction::StartWebServer => ClientContext::StartWebServer, ClientInstruction::StartWebServer => ClientContext::StartWebServer,
ClientInstruction::RenamedSession(..) => ClientContext::RenamedSession,
} }
} }
} }

View file

@ -142,6 +142,13 @@ pub fn zellij_server_listener(
WebServerToWebClientControlMessage::LogError { lines }, 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 // server disconnected, stop trying to listen otherwise we retry
// indefinitely and get 100% CPU // indefinitely and get 100% CPU

View file

@ -5113,9 +5113,19 @@ pub(crate) fn screen_thread_main(
.with_context(err_context)?; .with_context(err_context)?;
// set the env variable // set the env variable
set_session_name(name); set_session_name(name.clone());
screen.unblock_input()?;
let connected_client_ids: Vec<ClientId> =
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 { ScreenInstruction::Reconfigure {
client_id, client_id,

View file

@ -478,6 +478,7 @@ pub enum ClientContext {
QueryTerminalSize, QueryTerminalSize,
WriteConfigToDisk, WriteConfigToDisk,
StartWebServer, StartWebServer,
RenamedSession,
} }
/// Stack call representations corresponding to the different types of [`ServerInstruction`]s. /// Stack call representations corresponding to the different types of [`ServerInstruction`]s.

View file

@ -116,6 +116,7 @@ pub enum ServerToClientMsg {
QueryTerminalSize, QueryTerminalSize,
WriteConfigToDisk { config: String }, WriteConfigToDisk { config: String },
StartWebServer, StartWebServer,
RenamedSession(String), // String -> new session name
} }
#[derive(Serialize, Deserialize, Debug, Clone)] #[derive(Serialize, Deserialize, Debug, Clone)]