fix(web): change URL when renaming session (#4299)
* fix(web): change URL when renaming session * style(fmt): rustfmt
This commit is contained in:
parent
19c159175c
commit
9fd7a02023
5 changed files with 24 additions and 2 deletions
|
|
@ -61,6 +61,7 @@ pub(crate) enum ClientInstruction {
|
|||
QueryTerminalSize,
|
||||
WriteConfigToDisk { config: String },
|
||||
StartWebServer,
|
||||
RenamedSession(String), // String -> new session name
|
||||
}
|
||||
|
||||
impl From<ServerToClientMsg> for ClientInstruction {
|
||||
|
|
@ -86,6 +87,7 @@ impl From<ServerToClientMsg> 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,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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<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 {
|
||||
client_id,
|
||||
|
|
|
|||
|
|
@ -478,6 +478,7 @@ pub enum ClientContext {
|
|||
QueryTerminalSize,
|
||||
WriteConfigToDisk,
|
||||
StartWebServer,
|
||||
RenamedSession,
|
||||
}
|
||||
|
||||
/// Stack call representations corresponding to the different types of [`ServerInstruction`]s.
|
||||
|
|
|
|||
|
|
@ -116,6 +116,7 @@ pub enum ServerToClientMsg {
|
|||
QueryTerminalSize,
|
||||
WriteConfigToDisk { config: String },
|
||||
StartWebServer,
|
||||
RenamedSession(String), // String -> new session name
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, Clone)]
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue