fix(web-client): theme not loading (#4265)
Fix theme not getting applied in web client. - Ensure theme is properly read from config - Update config in web server shared state when it gets updated (without this, clients connecting after a config change would still get the old settings)
This commit is contained in:
parent
090b1714b0
commit
be20acaa3e
5 changed files with 28 additions and 28 deletions
|
|
@ -91,7 +91,7 @@ impl From<&Config> for SetConfigPayload {
|
||||||
fn from(config: &Config) -> Self {
|
fn from(config: &Config) -> Self {
|
||||||
let font = config.web_client.font.clone();
|
let font = config.web_client.font.clone();
|
||||||
|
|
||||||
let palette = config.theme_config(None);
|
let palette = config.theme_config(config.options.theme.as_ref());
|
||||||
let web_client_theme_from_config = config.web_client.theme.as_ref();
|
let web_client_theme_from_config = config.web_client.theme.as_ref();
|
||||||
|
|
||||||
let mut theme = SetConfigPayloadTheme::default();
|
let mut theme = SetConfigPayloadTheme::default();
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
|
use crate::web_client::types::AppState;
|
||||||
|
|
||||||
use super::control_message::{SetConfigPayload, WebServerToWebClientControlMessage};
|
use super::control_message::{SetConfigPayload, WebServerToWebClientControlMessage};
|
||||||
use super::types::ConnectionTable;
|
|
||||||
use axum_server::Handle;
|
use axum_server::Handle;
|
||||||
use std::sync::{Arc, Mutex};
|
|
||||||
use tokio::io::AsyncReadExt;
|
use tokio::io::AsyncReadExt;
|
||||||
use tokio::net::{UnixListener, UnixStream};
|
use tokio::net::{UnixListener, UnixStream};
|
||||||
use zellij_utils::consts::WEBSERVER_SOCKET_PATH;
|
use zellij_utils::consts::WEBSERVER_SOCKET_PATH;
|
||||||
|
|
@ -33,11 +33,7 @@ pub async fn receive_webserver_instruction(
|
||||||
.map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e))
|
.map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn listen_to_web_server_instructions(
|
pub async fn listen_to_web_server_instructions(server_handle: Handle, state: AppState, id: &str) {
|
||||||
server_handle: Handle,
|
|
||||||
connection_table: Arc<Mutex<ConnectionTable>>,
|
|
||||||
id: &str,
|
|
||||||
) {
|
|
||||||
loop {
|
loop {
|
||||||
let receiver = create_webserver_receiver(id).await;
|
let receiver = create_webserver_receiver(id).await;
|
||||||
match receiver {
|
match receiver {
|
||||||
|
|
@ -51,8 +47,11 @@ pub async fn listen_to_web_server_instructions(
|
||||||
InstructionForWebServer::ConfigWrittenToDisk(new_config) => {
|
InstructionForWebServer::ConfigWrittenToDisk(new_config) => {
|
||||||
let set_config_payload = SetConfigPayload::from(&new_config);
|
let set_config_payload = SetConfigPayload::from(&new_config);
|
||||||
|
|
||||||
|
let mut config = state.config.lock().unwrap();
|
||||||
|
*config = new_config.clone();
|
||||||
|
|
||||||
let client_ids: Vec<String> = {
|
let client_ids: Vec<String> = {
|
||||||
let connection_table_lock = connection_table.lock().unwrap();
|
let connection_table_lock = state.connection_table.lock().unwrap();
|
||||||
connection_table_lock
|
connection_table_lock
|
||||||
.client_id_to_channels
|
.client_id_to_channels
|
||||||
.keys()
|
.keys()
|
||||||
|
|
@ -71,7 +70,8 @@ pub async fn listen_to_web_server_instructions(
|
||||||
};
|
};
|
||||||
|
|
||||||
for client_id in client_ids {
|
for client_id in client_ids {
|
||||||
if let Some(control_tx) = connection_table
|
if let Some(control_tx) = state
|
||||||
|
.connection_table
|
||||||
.lock()
|
.lock()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.get_client_control_tx(&client_id)
|
.get_client_control_tx(&client_id)
|
||||||
|
|
@ -88,7 +88,8 @@ pub async fn listen_to_web_server_instructions(
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if let Some(os_input) = connection_table
|
if let Some(os_input) = state
|
||||||
|
.connection_table
|
||||||
.lock()
|
.lock()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.get_client_os_api(&client_id)
|
.get_client_os_api(&client_id)
|
||||||
|
|
|
||||||
|
|
@ -54,9 +54,7 @@ use uuid::Uuid;
|
||||||
use websocket_handlers::{ws_handler_control, ws_handler_terminal};
|
use websocket_handlers::{ws_handler_control, ws_handler_terminal};
|
||||||
|
|
||||||
use zellij_utils::{
|
use zellij_utils::{
|
||||||
cli::CliArgs,
|
|
||||||
consts::WEBSERVER_SOCKET_PATH,
|
consts::WEBSERVER_SOCKET_PATH,
|
||||||
ipc::{ClientAttributes, ClientToServerMsg, ExitReason, ServerToClientMsg},
|
|
||||||
web_server_commands::{
|
web_server_commands::{
|
||||||
create_webserver_sender, send_webserver_instruction, InstructionForWebServer,
|
create_webserver_sender, send_webserver_instruction, InstructionForWebServer,
|
||||||
},
|
},
|
||||||
|
|
@ -230,24 +228,23 @@ pub async fn serve_web_client(
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
tokio::spawn({
|
|
||||||
let server_handle = server_handle.clone();
|
|
||||||
let connection_table = connection_table.clone();
|
|
||||||
async move {
|
|
||||||
listen_to_web_server_instructions(server_handle, connection_table, &format!("{}", id))
|
|
||||||
.await;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
let state = AppState {
|
let state = AppState {
|
||||||
connection_table,
|
connection_table: connection_table.clone(),
|
||||||
config,
|
config: Arc::new(Mutex::new(config)),
|
||||||
config_options,
|
config_options,
|
||||||
config_file_path,
|
config_file_path,
|
||||||
session_manager,
|
session_manager,
|
||||||
client_os_api_factory,
|
client_os_api_factory,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
tokio::spawn({
|
||||||
|
let server_handle = server_handle.clone();
|
||||||
|
let state = state.clone();
|
||||||
|
async move {
|
||||||
|
listen_to_web_server_instructions(server_handle, state, &format!("{}", id)).await;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
let app = Router::new()
|
let app = Router::new()
|
||||||
.route("/ws/control", any(ws_handler_control))
|
.route("/ws/control", any(ws_handler_control))
|
||||||
.route("/ws/terminal", any(ws_handler_terminal))
|
.route("/ws/terminal", any(ws_handler_terminal))
|
||||||
|
|
|
||||||
|
|
@ -169,7 +169,7 @@ impl ClientConnectionBus {
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct AppState {
|
pub struct AppState {
|
||||||
pub connection_table: Arc<Mutex<ConnectionTable>>,
|
pub connection_table: Arc<Mutex<ConnectionTable>>,
|
||||||
pub config: Config,
|
pub config: Arc<Mutex<Config>>,
|
||||||
pub config_options: Options,
|
pub config_options: Options,
|
||||||
pub config_file_path: PathBuf,
|
pub config_file_path: PathBuf,
|
||||||
pub session_manager: Arc<dyn SessionManager>,
|
pub session_manager: Arc<dyn SessionManager>,
|
||||||
|
|
|
||||||
|
|
@ -37,8 +37,8 @@ pub async fn ws_handler_terminal(
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn handle_ws_control(socket: WebSocket, state: AppState) {
|
async fn handle_ws_control(socket: WebSocket, state: AppState) {
|
||||||
let config = SetConfigPayload::from(&state.config);
|
let payload = SetConfigPayload::from(&*state.config.lock().unwrap());
|
||||||
let set_config_msg = WebServerToWebClientControlMessage::SetConfig(config);
|
let set_config_msg = WebServerToWebClientControlMessage::SetConfig(payload);
|
||||||
|
|
||||||
let (control_socket_tx, mut control_socket_rx) = socket.split();
|
let (control_socket_tx, mut control_socket_rx) = socket.split();
|
||||||
|
|
||||||
|
|
@ -136,7 +136,7 @@ async fn handle_ws_terminal(
|
||||||
os_input.clone(),
|
os_input.clone(),
|
||||||
state.connection_table.clone(),
|
state.connection_table.clone(),
|
||||||
session_name.map(|p| p.0),
|
session_name.map(|p| p.0),
|
||||||
state.config.clone(),
|
state.config.lock().unwrap().clone(),
|
||||||
state.config_options.clone(),
|
state.config_options.clone(),
|
||||||
Some(state.config_file_path.clone()),
|
Some(state.config_file_path.clone()),
|
||||||
web_client_id.clone(),
|
web_client_id.clone(),
|
||||||
|
|
@ -160,6 +160,8 @@ async fn handle_ws_terminal(
|
||||||
|
|
||||||
let explicitly_disable_kitty_keyboard_protocol = state
|
let explicitly_disable_kitty_keyboard_protocol = state
|
||||||
.config
|
.config
|
||||||
|
.lock()
|
||||||
|
.unwrap()
|
||||||
.options
|
.options
|
||||||
.support_kitty_keyboard_protocol
|
.support_kitty_keyboard_protocol
|
||||||
.map(|e| !e)
|
.map(|e| !e)
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue