aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAram Drevekenin <aram@poor.dev>2025-07-09 16:39:52 +0200
committerGitHub <noreply@github.com>2025-07-09 16:39:52 +0200
commitf8b8d615525e2c27d3e55a03d313dbb374183364 (patch)
tree753c6e46c1392adc2f17e5fc4a8a19cd20c754ac
parentfix(serialization): don't serialize when only UI elements present and provide... (diff)
downloadsl0ppij-f8b8d615525e2c27d3e55a03d313dbb374183364.tar.gz
sl0ppij-f8b8d615525e2c27d3e55a03d313dbb374183364.tar.xz
sl0ppij-f8b8d615525e2c27d3e55a03d313dbb374183364.zip
fix(web-client): use default_layout if configured (#4278)
* fix(web-client): use default_layout if configured * docs(changelog): add PR
-rw-r--r--CHANGELOG.md2
-rw-r--r--zellij-client/src/web_client/server_listener.rs3
-rw-r--r--zellij-client/src/web_client/session_management.rs9
-rw-r--r--zellij-utils/src/data.rs29
-rw-r--r--zellij-utils/src/input/layout.rs21
5 files changed, 54 insertions, 10 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index cf2d9780..cdaa7ec5 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -7,7 +7,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
## [Unreleased]
* feat: multiple select and bulk pane actions (https://github.com/zellij-org/zellij/pull/4169 and https://github.com/zellij-org/zellij/pull/4171 and https://github.com/zellij-org/zellij/pull/4221)
* feat: add an optional key tooltip to show the current keybindings for the compact bar (https://github.com/zellij-org/zellij/pull/4225)
-* feat: web-client, allowing users to share sessions in the browser (https://github.com/zellij-org/zellij/pull/4242 and https://github.com/zellij-org/zellij/pull/4257)
+* feat: web-client, allowing users to share sessions in the browser (https://github.com/zellij-org/zellij/pull/4242, https://github.com/zellij-org/zellij/pull/4257 and https://github.com/zellij-org/zellij/pull/4278)
* performance: consolidate renders (https://github.com/zellij-org/zellij/pull/4245)
* feat: add plugin API to replace a pane with another existing pane (https://github.com/zellij-org/zellij/pull/4246)
* feat: add "stack" keybinding and CLI action to add a stacked pane to the current pane (https://github.com/zellij-org/zellij/pull/4255)
diff --git a/zellij-client/src/web_client/server_listener.rs b/zellij-client/src/web_client/server_listener.rs
index 2ce91ea2..3c5ff504 100644
--- a/zellij-client/src/web_client/server_listener.rs
+++ b/zellij-client/src/web_client/server_listener.rs
@@ -34,7 +34,8 @@ pub fn zellij_server_listener(
move || {
let mut client_connection_bus =
ClientConnectionBus::new(&web_client_id, &connection_table);
- let mut reconnect_to_session = match build_initial_connection(session_name) {
+ let mut reconnect_to_session = match build_initial_connection(session_name, &config)
+ {
Ok(initial_session_connection) => initial_session_connection,
Err(e) => {
log::error!("{}", e);
diff --git a/zellij-client/src/web_client/session_management.rs b/zellij-client/src/web_client/session_management.rs
index cd3e5c7a..718d3f7d 100644
--- a/zellij-client/src/web_client/session_management.rs
+++ b/zellij-client/src/web_client/session_management.rs
@@ -18,8 +18,11 @@ use zellij_utils::{
pub fn build_initial_connection(
session_name: Option<String>,
+ config: &Config,
) -> Result<Option<ConnectToSession>, &'static str> {
let should_start_with_welcome_screen = session_name.is_none();
+ let default_layout_from_config =
+ LayoutInfo::from_config(&config.options.layout_dir, &config.options.default_layout);
if should_start_with_welcome_screen {
let Some(initial_session_name) = session_name.clone().or_else(generate_unique_session_name)
else {
@@ -33,6 +36,12 @@ pub fn build_initial_connection(
} else if let Some(session_name) = session_name {
Ok(Some(ConnectToSession {
name: Some(session_name.clone()),
+ layout: default_layout_from_config,
+ ..Default::default()
+ }))
+ } else if default_layout_from_config.is_some() {
+ Ok(Some(ConnectToSession {
+ layout: default_layout_from_config,
..Default::default()
}))
} else {
diff --git a/zellij-utils/src/data.rs b/zellij-utils/src/data.rs
index 190011f9..91f2c713 100644
--- a/zellij-utils/src/data.rs
+++ b/zellij-utils/src/data.rs
@@ -1,3 +1,4 @@
+use crate::home::default_layout_dir;
use crate::input::actions::Action;
use crate::input::config::ConversionError;
use crate::input::keybinds::Keybinds;
@@ -1672,6 +1673,34 @@ impl LayoutInfo {
LayoutInfo::Stringified(_stringified) => false,
}
}
+ pub fn from_config(
+ layout_dir: &Option<PathBuf>,
+ default_layout: &Option<PathBuf>,
+ ) -> Option<Self> {
+ match default_layout {
+ Some(default_layout) => {
+ if default_layout.extension().is_some() || default_layout.components().count() > 1 {
+ let Some(layout_dir) = layout_dir
+ .as_ref()
+ .map(|l| l.clone())
+ .or_else(default_layout_dir)
+ else {
+ return None;
+ };
+ Some(LayoutInfo::File(
+ layout_dir.join(default_layout).display().to_string(),
+ ))
+ } else if default_layout.starts_with("http://")
+ || default_layout.starts_with("https://")
+ {
+ Some(LayoutInfo::Url(default_layout.display().to_string()))
+ } else {
+ Some(LayoutInfo::BuiltIn(default_layout.display().to_string()))
+ }
+ },
+ None => None,
+ }
+ }
}
use std::hash::{Hash, Hasher};
diff --git a/zellij-utils/src/input/layout.rs b/zellij-utils/src/input/layout.rs
index 67124be1..e29ad94d 100644
--- a/zellij-utils/src/input/layout.rs
+++ b/zellij-utils/src/input/layout.rs
@@ -1163,15 +1163,20 @@ impl Layout {
let mut available_layouts = vec![];
for file in layout_files {
if let Ok(file) = file {
- if Layout::from_path_or_default_without_config(
- Some(&file.path()),
- layout_dir.clone(),
- )
- .is_ok()
+ if file.path().extension().map(|e| e.to_ascii_lowercase())
+ == Some(std::ffi::OsString::from("kdl"))
{
- if let Some(file_name) = file.path().file_stem() {
- available_layouts
- .push(LayoutInfo::File(file_name.to_string_lossy().to_string()))
+ if Layout::from_path_or_default_without_config(
+ Some(&file.path()),
+ layout_dir.clone(),
+ )
+ .is_ok()
+ {
+ if let Some(file_name) = file.path().file_stem() {
+ available_layouts.push(LayoutInfo::File(
+ file_name.to_string_lossy().to_string(),
+ ))
+ }
}
}
}