aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Linford <tlinford@users.noreply.github.com>2025-07-28 11:28:04 +0200
committerGitHub <noreply@github.com>2025-07-28 11:28:04 +0200
commitbe20acaa3e185b4a4d74ebea944b4fea2aa0241f (patch)
tree7c634872217300619a1d4352e13cbf7409e38454
parentAdd gruber-darker theme (#4288) (diff)
downloadsl0ppij-be20acaa3e185b4a4d74ebea944b4fea2aa0241f.tar.gz
sl0ppij-be20acaa3e185b4a4d74ebea944b4fea2aa0241f.tar.xz
sl0ppij-be20acaa3e185b4a4d74ebea944b4fea2aa0241f.zip
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)
-rw-r--r--zellij-client/src/web_client/control_message.rs2
-rw-r--r--zellij-client/src/web_client/ipc_listener.rs21
-rw-r--r--zellij-client/src/web_client/mod.rs23
-rw-r--r--zellij-client/src/web_client/types.rs2
-rw-r--r--zellij-client/src/web_client/websocket_handlers.rs8
5 files changed, 28 insertions, 28 deletions
diff --git a/zellij-client/src/web_client/control_message.rs b/zellij-client/src/web_client/control_message.rs
index 63c5edf2..2ddc103e 100644
--- a/zellij-client/src/web_client/control_message.rs
+++ b/zellij-client/src/web_client/control_message.rs
@@ -91,7 +91,7 @@ impl From<&Config> for SetConfigPayload {
fn from(config: &Config) -> Self {
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 mut theme = SetConfigPayloadTheme::default();
diff --git a/zellij-client/src/web_client/ipc_listener.rs b/zellij-client/src/web_client/ipc_listener.rs
index ea8196ab..801be8fc 100644
--- a/zellij-client/src/web_client/ipc_listener.rs
+++ b/zellij-client/src/web_client/ipc_listener.rs
@@ -1,7 +1,7 @@
+use crate::web_client::types::AppState;
+
use super::control_message::{SetConfigPayload, WebServerToWebClientControlMessage};
-use super::types::ConnectionTable;
use axum_server::Handle;
-use std::sync::{Arc, Mutex};
use tokio::io::AsyncReadExt;
use tokio::net::{UnixListener, UnixStream};
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))
}
-pub async fn listen_to_web_server_instructions(
- server_handle: Handle,
- connection_table: Arc<Mutex<ConnectionTable>>,
- id: &str,
-) {
+pub async fn listen_to_web_server_instructions(server_handle: Handle, state: AppState, id: &str) {
loop {
let receiver = create_webserver_receiver(id).await;
match receiver {
@@ -51,8 +47,11 @@ pub async fn listen_to_web_server_instructions(
InstructionForWebServer::ConfigWrittenToDisk(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 connection_table_lock = connection_table.lock().unwrap();
+ let connection_table_lock = state.connection_table.lock().unwrap();
connection_table_lock
.client_id_to_channels
.keys()
@@ -71,7 +70,8 @@ pub async fn listen_to_web_server_instructions(
};
for client_id in client_ids {
- if let Some(control_tx) = connection_table
+ if let Some(control_tx) = state
+ .connection_table
.lock()
.unwrap()
.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()
.unwrap()
.get_client_os_api(&client_id)
diff --git a/zellij-client/src/web_client/mod.rs b/zellij-client/src/web_client/mod.rs
index ed689961..c85caf18 100644
--- a/zellij-client/src/web_client/mod.rs
+++ b/zellij-client/src/web_client/mod.rs
@@ -54,9 +54,7 @@ use uuid::Uuid;
use websocket_handlers::{ws_handler_control, ws_handler_terminal};
use zellij_utils::{
- cli::CliArgs,
consts::WEBSERVER_SOCKET_PATH,
- ipc::{ClientAttributes, ClientToServerMsg, ExitReason, ServerToClientMsg},
web_server_commands::{
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 {
- connection_table,
- config,
+ connection_table: connection_table.clone(),
+ config: Arc::new(Mutex::new(config)),
config_options,
config_file_path,
session_manager,
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()
.route("/ws/control", any(ws_handler_control))
.route("/ws/terminal", any(ws_handler_terminal))
diff --git a/zellij-client/src/web_client/types.rs b/zellij-client/src/web_client/types.rs
index d20edc4b..901923c8 100644
--- a/zellij-client/src/web_client/types.rs
+++ b/zellij-client/src/web_client/types.rs
@@ -169,7 +169,7 @@ impl ClientConnectionBus {
#[derive(Clone)]
pub struct AppState {
pub connection_table: Arc<Mutex<ConnectionTable>>,
- pub config: Config,
+ pub config: Arc<Mutex<Config>>,
pub config_options: Options,
pub config_file_path: PathBuf,
pub session_manager: Arc<dyn SessionManager>,
diff --git a/zellij-client/src/web_client/websocket_handlers.rs b/zellij-client/src/web_client/websocket_handlers.rs
index 6d638c05..e5c476a0 100644
--- a/zellij-client/src/web_client/websocket_handlers.rs
+++ b/zellij-client/src/web_client/websocket_handlers.rs
@@ -37,8 +37,8 @@ pub async fn ws_handler_terminal(
}
async fn handle_ws_control(socket: WebSocket, state: AppState) {
- let config = SetConfigPayload::from(&state.config);
- let set_config_msg = WebServerToWebClientControlMessage::SetConfig(config);
+ let payload = SetConfigPayload::from(&*state.config.lock().unwrap());
+ let set_config_msg = WebServerToWebClientControlMessage::SetConfig(payload);
let (control_socket_tx, mut control_socket_rx) = socket.split();
@@ -136,7 +136,7 @@ async fn handle_ws_terminal(
os_input.clone(),
state.connection_table.clone(),
session_name.map(|p| p.0),
- state.config.clone(),
+ state.config.lock().unwrap().clone(),
state.config_options.clone(),
Some(state.config_file_path.clone()),
web_client_id.clone(),
@@ -160,6 +160,8 @@ async fn handle_ws_terminal(
let explicitly_disable_kitty_keyboard_protocol = state
.config
+ .lock()
+ .unwrap()
.options
.support_kitty_keyboard_protocol
.map(|e| !e)