diff options
| author | Aram Drevekenin <aram@poor.dev> | 2023-08-24 13:36:24 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-08-24 13:36:24 +0200 |
| commit | bc628abc1266cdc0dbce4f19a89727527a3e39a8 (patch) | |
| tree | 6a0fcac6ec35c71a237bca0128a57a5b40afb0e3 /zellij-utils/src | |
| parent | docs(changelog): permission system (diff) | |
| download | sl0ppij-bc628abc1266cdc0dbce4f19a89727527a3e39a8.tar.gz sl0ppij-bc628abc1266cdc0dbce4f19a89727527a3e39a8.tar.xz sl0ppij-bc628abc1266cdc0dbce4f19a89727527a3e39a8.zip | |
feat(sessions): add a session manager to switch between sessions, tabs and panes and create new ones (#2721)
* write/read session metadata to disk for all sessions
* switch session client side
* fix tests
* various adjustments
* fix full screen focus bug in tiled panes
* fix tests
* fix permission sorting issue
* cleanups
* add session manager
* fix tests
* various cleanups
* style(fmt): rustfmt
* clear screen before switching sessions
* I hate you clippy
* truncate controls line to width
* version session cache
* attempt to fix plugin tests
* style(fmt): rustfmt
* another attempt to fix the tests in the ci
Diffstat (limited to 'zellij-utils/src')
18 files changed, 1169 insertions, 35 deletions
diff --git a/zellij-utils/src/consts.rs b/zellij-utils/src/consts.rs index a2c3a42a..43990b4b 100644 --- a/zellij-utils/src/consts.rs +++ b/zellij-utils/src/consts.rs @@ -38,6 +38,8 @@ lazy_static! { .join(format!("{}", Uuid::new_v4())); pub static ref ZELLIJ_PLUGIN_PERMISSIONS_CACHE: PathBuf = ZELLIJ_CACHE_DIR.join("permissions.kdl"); + pub static ref ZELLIJ_SESSION_INFO_CACHE_DIR: PathBuf = + ZELLIJ_CACHE_DIR.join(VERSION).join("session_info"); } pub const FEATURES: &[&str] = &[ @@ -92,6 +94,7 @@ mod not_wasm { add_plugin!(assets, "status-bar.wasm"); add_plugin!(assets, "tab-bar.wasm"); add_plugin!(assets, "strider.wasm"); + add_plugin!(assets, "session-manager.wasm"); assets }; } @@ -104,20 +107,13 @@ pub use unix_only::*; mod unix_only { use super::*; use crate::envs; - use crate::shared::set_permissions; + pub use crate::shared::set_permissions; use lazy_static::lazy_static; use nix::unistd::Uid; - use std::{env::temp_dir, fs}; + use std::env::temp_dir; lazy_static! { static ref UID: Uid = Uid::current(); - pub static ref ZELLIJ_IPC_PIPE: PathBuf = { - let mut sock_dir = ZELLIJ_SOCK_DIR.clone(); - fs::create_dir_all(&sock_dir).unwrap(); - set_permissions(&sock_dir, 0o700).unwrap(); - sock_dir.push(envs::get_session_name().unwrap()); - sock_dir - }; pub static ref ZELLIJ_TMP_DIR: PathBuf = temp_dir().join(format!("zellij-{}", *UID)); pub static ref ZELLIJ_TMP_LOG_DIR: PathBuf = ZELLIJ_TMP_DIR.join("zellij-log"); pub static ref ZELLIJ_TMP_LOG_FILE: PathBuf = ZELLIJ_TMP_LOG_DIR.join("zellij.log"); diff --git a/zellij-utils/src/data.rs b/zellij-utils/src/data.rs index a08e642f..31919136 100644 --- a/zellij-utils/src/data.rs +++ b/zellij-utils/src/data.rs @@ -495,6 +495,7 @@ pub enum Event { FileSystemDelete(Vec<PathBuf>), /// A Result of plugin permission request PermissionRequestResult(PermissionStatus), + SessionUpdate(Vec<SessionInfo>), } #[derive( @@ -734,6 +735,42 @@ impl ModeInfo { } } +#[derive(Debug, Default, Clone, PartialEq, Eq, Deserialize, Serialize)] +pub struct SessionInfo { + pub name: String, + pub tabs: Vec<TabInfo>, + pub panes: PaneManifest, + pub connected_clients: usize, + pub is_current_session: bool, +} + +use std::hash::{Hash, Hasher}; + +#[allow(clippy::derive_hash_xor_eq)] +impl Hash for SessionInfo { + fn hash<H: Hasher>(&self, state: &mut H) { + self.name.hash(state); + } +} + +impl SessionInfo { + pub fn new(name: String) -> Self { + SessionInfo { + name, + ..Default::default() + } + } + pub fn update_tab_info(&mut self, new_tab_info: Vec<TabInfo>) { + self.tabs = new_tab_info; + } + pub fn update_pane_info(&mut self, new_pane_info: PaneManifest) { + self.panes = new_pane_info; + } + pub fn update_connected_clients(&mut self, new_connected_clients: usize) { + self.connected_clients = new_connected_clients; + } +} + /// Contains all the information for a currently opened tab. #[derive(Debug, Default, Clone, PartialEq, Eq, Hash, Deserialize, Serialize)] pub struct TabInfo { @@ -921,6 +958,13 @@ impl CommandToRun { } } +#[derive(Debug, Default, Clone, Serialize, Deserialize)] +pub struct ConnectToSession { + pub name: Option<String>, + pub tab_position: Option<usize>, + pub pane_id: Option<(u32, bool)>, // (id, is_plugin) +} + #[derive(Debug, Default, Clone)] pub struct PluginMessage { pub name: String, @@ -1016,4 +1060,5 @@ pub enum PluginCommand { RenameTab(u32, String), // tab index, new name ReportPanic(String), // stringified panic RequestPluginPermissions(Vec<PermissionType>), + SwitchSession(ConnectToSession), } diff --git a/zellij-utils/src/errors.rs b/zellij-utils/src/errors.rs index 306db448..677cbc42 100644 --- a/zellij-utils/src/errors.rs +++ b/zellij-utils/src/errors.rs @@ -342,6 +342,7 @@ pub enum ScreenContext { BreakPane, BreakPaneRight, BreakPaneLeft, + UpdateSessionInfos, } /// Stack call representations corresponding to the different types of [`PtyInstruction`]s. @@ -396,6 +397,7 @@ pub enum ClientContext { OwnClientId, StartedParsingStdinQuery, DoneParsingStdinQuery, + SwitchSession, } /// Stack call representations corresponding to the different types of [`ServerInstruction`]s. @@ -413,6 +415,7 @@ pub enum ServerContext { ConnStatus, ActiveClients, Log, + SwitchSession, } #[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize)] @@ -429,6 +432,8 @@ pub enum BackgroundJobContext { DisplayPaneError, AnimatePluginLoading, StopPluginLoadingAnimation, + ReadAllSessionInfosOnMachine, + ReportSessionInfo, Exit, } diff --git a/zellij-utils/src/input/permission.rs b/zellij-utils/src/input/permission.rs index 1755fe1e..9ef7182a 100644 --- a/zellij-utils/src/input/permission.rs +++ b/zellij-utils/src/input/permission.rs @@ -27,12 +27,16 @@ impl PermissionCache { pub fn check_permissions( &self, plugin_name: String, - permissions: &Vec<PermissionType>, + permissions_to_check: &Vec<PermissionType>, ) -> bool { if let Some(target) = self.granted.get(&plugin_name) { - if target == permissions { - return true; + let mut all_granted = true; + for permission in permissions_to_check { + if !target.contains(permission) { + all_granted = false; + } } + return all_granted; } false @@ -43,7 +47,10 @@ impl PermissionCache { let granted = match fs::read_to_string(cache_path.clone()) { Ok(raw_string) => PermissionCache::from_string(raw_string).unwrap_or_default(), - Err(_) => GrantedPermission::default(), + Err(e) => { + log::error!("Failed to read permission cache file: {}", e); + GrantedPermission::default() + }, }; PermissionCache { diff --git a/zellij-utils/src/ipc.rs b/zellij-utils/src/ipc.rs index 149a157a..0f341520 100644 --- a/zellij-utils/src/ipc.rs +++ b/zellij-utils/src/ipc.rs @@ -1,7 +1,7 @@ //! IPC stuff for starting to split things into a client and server model. use crate::{ cli::CliArgs, - data::{ClientId, InputMode, Style}, + data::{ClientId, ConnectToSession, InputMode, Style}, errors::{get_current_ctx, prelude::*, ErrorContext}, input::keybinds::Keybinds, input::{actions::Action, layout::Layout, options::Options, plugins::PluginsConfig}, @@ -65,16 +65,6 @@ impl PixelDimensions { #[allow(clippy::large_enum_variant)] #[derive(Serialize, Deserialize, Debug, Clone)] pub enum ClientToServerMsg { - /*// List which sessions are available - ListSessions, - // Create a new session - CreateSession, - // Attach to a running session - AttachToSession(SessionId, ClientType), - // Force detach - DetachSession(SessionId), - // Disconnect from the session we're connected to - DisconnectFromSession,*/ DetachSession(Vec<ClientId>), TerminalPixelDimensions(PixelDimensions), BackgroundColor(String), @@ -88,7 +78,12 @@ pub enum ClientToServerMsg { Box<Layout>, Option<PluginsConfig>, ), - AttachClient(ClientAttributes, Options), + AttachClient( + ClientAttributes, + Options, + Option<usize>, // tab position to focus + Option<(u32, bool)>, // (pane_id, is_plugin) => pane id to focus + ), Action(Action, Option<ClientId>), ClientExited, KillSession, @@ -99,10 +94,6 @@ pub enum ClientToServerMsg { // Types of messages sent from the server to the client #[derive(Serialize, Deserialize, Debug, Clone)] pub enum ServerToClientMsg { - /*// Info about a particular session - SessionInfo(Session), - // A list of sessions - SessionList(HashSet<Session>),*/ Render(String), UnblockInputThread, Exit(ExitReason), @@ -110,6 +101,7 @@ pub enum ServerToClientMsg { Connected, ActiveClients(Vec<ClientId>), Log(Vec<String>), + SwitchSession(ConnectToSession), } #[derive(Serialize, Deserialize, Debug, Clone)] diff --git a/zellij-utils/src/kdl/mod.rs b/zellij-utils/src/kdl/mod.rs index 13a03ad1..af49dbb3 100644 --- a/zellij-utils/src/kdl/mod.rs +++ b/zellij-utils/src/kdl/mod.rs @@ -1,5 +1,8 @@ mod kdl_layout_parser; -use crate::data::{Direction, InputMode, Key, Palette, PaletteColor, PermissionType, Resize}; +use crate::data::{ + Direction, InputMode, Key, Palette, PaletteColor, PaneInfo, PaneManifest, PermissionType, + Resize, SessionInfo, TabInfo, +}; use crate::envs::EnvironmentVariables; use crate::input::config::{Config, ConfigError, KdlError}; use crate::input::keybinds::Keybinds; @@ -325,7 +328,6 @@ macro_rules! actions_from_kdl { pub fn kdl_arguments_that_are_strings<'a>( arguments: impl Iterator<Item = &'a KdlEntry>, ) -> Result<Vec<String>, ConfigError> { - // pub fn kdl_arguments_that_are_strings <'a>(arguments: impl Iterator<Item=&'a KdlValue>) -> Result<Vec<String>, ConfigError> { let mut args: Vec<String> = vec![]; for kdl_entry in arguments { match kdl_entry.value().as_string() { @@ -1841,6 +1843,419 @@ impl PermissionCache { } } +impl SessionInfo { + pub fn from_string(raw_session_info: &str, current_session_name: &str) -> Result<Self, String> { + let kdl_document: KdlDocument = raw_session_info + .parse() + .map_err(|e| format!("Failed to parse kdl document: {}", e))?; + let name = kdl_document + .get("name") + .and_then(|n| n.entries().iter().next()) + .and_then(|e| e.value().as_string()) + .map(|s| s.to_owned()) + .ok_or("Failed to parse session name")?; + let connected_clients = kdl_document + .get("connected_clients") + .and_then(|n| n.entries().iter().next()) + .and_then(|e| e.value().as_i64()) + .map(|c| c as usize) + .ok_or("Failed to parse connected_clients")?; + let tabs: Vec<TabInfo> = kdl_document + .get("tabs") + .and_then(|t| t.children()) + .and_then(|c| { + let mut tab_nodes = vec![]; + for tab_node in c.nodes() { + if let Some(tab) = tab_node.children() { + tab_nodes.push(TabInfo::decode_from_kdl(tab).ok()?); + } + } + Some(tab_nodes) + }) + .ok_or("Failed to parse tabs")?; + let panes: PaneManifest = kdl_document + .get("panes") + .and_then(|p| p.children()) + .map(|p| PaneManifest::decode_from_kdl(p)) + .ok_or("Failed to parse panes")?; + let is_current_session = name == current_session_name; + Ok(SessionInfo { + name, + tabs, + panes, + connected_clients, + is_current_session, + }) + } + pub fn to_string(&self) -> String { + let mut kdl_document = KdlDocument::new(); + + let mut name = KdlNode::new("name"); + name.push(self.name.clone()); + + let mut connected_clients = KdlNode::new("connected_clients"); + connected_clients.push(self.connected_clients as i64); + + let mut tabs = KdlNode::new("tabs"); + let mut tab_children = KdlDocument::new(); + for tab_info in &self.tabs { + let mut tab = KdlNode::new("tab"); + let kdl_tab_info = tab_info.encode_to_kdl(); + tab.set_children(kdl_tab_info); + tab_children.nodes_mut().push(tab); + } + tabs.set_children(tab_children); + + let mut panes = KdlNode::new("panes"); + panes.set_children(self.panes.encode_to_kdl()); + + kdl_document.nodes_mut().push(name); + kdl_document.nodes_mut().push(tabs); + kdl_document.nodes_mut().push(panes); + kdl_document.nodes_mut().push(connected_clients); + kdl_document.fmt(); + kdl_document.to_string() + } +} + +impl TabInfo { + pub fn decode_from_kdl(kdl_document: &KdlDocument) -> Result<Self, String> { + macro_rules! int_node { + ($name:expr, $type:ident) => {{ + kdl_document + .get($name) + .and_then(|n| n.entries().iter().next()) + .and_then(|e| e.value().as_i64()) + .map(|e| e as $type) + .ok_or(format!("Failed to parse tab {}", $name))? + }}; + } + macro_rules! string_node { + ($name:expr) => {{ + kdl_document + .get($name) + .and_then(|n| n.entries().iter().next()) + .and_then(|e| e.value().as_string()) + .map(|s| s.to_owned()) + .ok_or(format!("Failed to parse tab {}", $name))? + }}; + } + macro_rules! optional_string_node { + ($name:expr) => {{ + kdl_document + .get($name) + .and_then(|n| n.entries().iter().next()) + .and_then(|e| e.value().as_string()) + .map(|s| s.to_owned()) + }}; + } + macro_rules! bool_node { + ($name:expr) => {{ + kdl_document + .get($name) + .and_then(|n| n.entries().iter().next()) + .and_then(|e| e.value().as_bool()) + .ok_or(format!("Failed to parse tab {}", $name))? + }}; + } + + let position = int_node!("position", usize); + let name = string_node!("name"); + let active = bool_node!("active"); + let panes_to_hide = int_node!("panes_to_hide", usize); + let is_fullscreen_active = bool_node!("is_fullscreen_active"); + let is_sync_panes_active = bool_node!("is_sync_panes_active"); + let are_floating_panes_visible = bool_node!("are_floating_panes_visible"); + let mut other_focused_clients = vec![]; + if let Some(tab_other_focused_clients) = kdl_document + .get("other_focused_clients") + .map(|n| n.entries()) + { + for entry in tab_other_focused_clients { + if let Some(entry_parsed) = entry.value().as_i64() { + other_focused_clients.push(entry_parsed as u16); + } + } + } + let active_swap_layout_name = optional_string_node!("active_swap_layout_name"); + let is_swap_layout_dirty = bool_node!("is_swap_layout_dirty"); + Ok(TabInfo { + position, + name, + active, + panes_to_hide, + is_fullscreen_active, + is_sync_panes_active, + are_floating_panes_visible, + other_focused_clients, + active_swap_layout_name, + is_swap_layout_dirty, + }) + } + pub fn encode_to_kdl(&self) -> KdlDocument { + let mut kdl_doucment = KdlDocument::new(); + + let mut position = KdlNode::new("position"); + position.push(self.position as i64); + kdl_doucment.nodes_mut().push(position); + + let mut name = KdlNode::new("name"); + name.push(self.name.clone()); + kdl_doucment.nodes_mut().push(name); + + let mut active = KdlNode::new("active"); + active.push(self.active); + kdl_doucment.nodes_mut().push(active); + + let mut panes_to_hide = KdlNode::new("panes_to_hide"); + panes_to_hide.push(self.panes_to_hide as i64); + kdl_doucment.nodes_mut().push(panes_to_hide); + + let mut is_fullscreen_active = KdlNode::new("is_fullscreen_active"); + is_fullscreen_active.push(self.is_fullscreen_active); + kdl_doucment.nodes_mut().push(is_fullscreen_active); + + let mut is_sync_panes_active = KdlNode::new("is_sync_panes_active"); + is_sync_panes_active.push(self.is_sync_panes_active); + kdl_doucment.nodes_mut().push(is_sync_panes_active); + + let mut are_floating_panes_visible = KdlNode::new("are_floating_panes_visible"); + are_floating_panes_visible.push(self.are_floating_panes_visible); + kdl_doucment.nodes_mut().push(are_floating_panes_visible); + + if !self.other_focused_clients.is_empty() { + let mut other_focused_clients = KdlNode::new("other_focused_clients"); + for client_id in &self.other_focused_clients { + other_focused_clients.push(*client_id as i64); + } + kdl_doucment.nodes_mut().push(other_focused_clients); + } + + if let Some(active_swap_layout_name) = self.active_swap_layout_name.as_ref() { + let mut active_swap_layout = KdlNode::new("active_swap_layout_name"); + active_swap_layout.push(active_swap_layout_name.to_string()); + kdl_doucment.nodes_mut().push(active_swap_layout); + } + + let mut is_swap_layout_dirty = KdlNode::new("is_swap_layout_dirty"); + is_swap_layout_dirty.push(self.is_swap_layout_dirty); + kdl_doucment.nodes_mut().push(is_swap_layout_dirty); + + kdl_doucment + } +} + +impl PaneManifest { + pub fn decode_from_kdl(kdl_doucment: &KdlDocument) -> Self { + let mut panes: HashMap<usize, Vec<PaneInfo>> = HashMap::new(); + for node in kdl_doucment.nodes() { + if node.name().to_string() == "pane" { + if let Some(pane_document) = node.children() { + if let Ok((tab_position, pane_info)) = PaneInfo::decode_from_kdl(pane_document) + { + let panes_in_tab_position = + panes.entry(tab_position).or_insert_with(Vec::new); + panes_in_tab_position.push(pane_info); + } + } + } + } + PaneManifest { panes } + } + pub fn encode_to_kdl(&self) -> KdlDocument { + let mut kdl_doucment = KdlDocument::new(); + for (tab_position, panes) in &self.panes { + for pane in panes { + let mut pane_node = KdlNode::new("pane"); + let mut pane = pane.encode_to_kdl(); + + let mut position_node = KdlNode::new("tab_position"); + position_node.push(*tab_position as i64); + pane.nodes_mut().push(position_node); + + pane_node.set_children(pane); + kdl_doucment.nodes_mut().push(pane_node); + } + } + kdl_doucment + } +} + +impl PaneInfo { + pub fn decode_from_kdl(kdl_document: &KdlDocument) -> Result<(usize, Self), String> { + // usize is the tab position + macro_rules! int_node { + ($name:expr, $type:ident) => {{ + kdl_document + .get($name) + .and_then(|n| n.entries().iter().next()) + .and_then(|e| e.value().as_i64()) + .map(|e| e as $type) + .ok_or(format!("Failed to parse pane {}", $name))? + }}; + } + macro_rules! optional_int_node { + ($name:expr, $type:ident) => {{ + kdl_document + .get($name) + .and_then(|n| n.entries().iter().next()) + .and_then(|e| e.value().as_i64()) + .map(|e| e as $type) + }}; + } + macro_rules! bool_node { + ($name:expr) => {{ + kdl_document + .get($name) + .and_then(|n| n.entries().iter().next()) + .and_then(|e| e.value().as_bool()) + .ok_or(format!("Failed to parse pane {}", $name))? + }}; + } + macro_rules! string_node { + ($name:expr) => {{ + kdl_document + .get($name) + .and_then(|n| n.entries().iter().next()) + .and_then(|e| e.value().as_string()) + .map(|s| s.to_owned()) + .ok_or(format!("Failed to parse pane {}", $name))? + }}; + } + macro_rules! optional_string_node { + ($name:expr) => {{ + kdl_document + .get($name) + .and_then(|n| n.entries().iter().next()) + .and_then(|e| e.value().as_string()) + .map(|s| s.to_owned()) + }}; + } + let tab_position = int_node!("tab_position", usize); + let id = int_node!("id", u32); + + let is_plugin = bool_node!("is_plugin"); + let is_focused = bool_node!("is_focused"); + let is_fullscreen = bool_node!("is_fullscreen"); + let is_floating = bool_node!("is_floating"); + let is_suppressed = bool_node!("is_suppressed"); + let title = string_node!("title"); + let exited = bool_node!("exited"); + let exit_status = optional_int_node!("exit_status", i32); + let is_held = bool_node!("is_held"); + let pane_x = int_node!("pane_x", usize); + let pane_content_x = int_node!("pane_content_x", usize); + let pane_y = int_node!("pane_y", usize); + let pane_content_y = int_node!("pane_content_y", usize); + let pane_rows = int_node!("pane_rows", usize); + let pane_content_rows = int_node!("pane_content_rows", usize); + let pane_columns = int_node!("pane_columns", usize); + let pane_content_columns = int_node!("pane_content_columns", usize); + let cursor_coordinates_in_pane = kdl_document + .get("cursor_coordinates_in_pane") + .map(|n| { + let mut entries = n.entries().iter(); + (entries.next(), entries.next()) + }) + .and_then(|(x, y)| { + let x = x.and_then(|x| x.value().as_i64()).map(|x| x as usize); + let y = y.and_then(|y| y.value().as_i64()).map(|y| y as usize); + match (x, y) { + (Some(x), Some(y)) => Some((x, y)), + _ => None, + } + }); + let terminal_command = optional_string_node!("terminal_command"); + let plugin_url = optional_string_node!("plugin_url"); + let is_selectable = bool_node!("is_selectable"); + + let pane_info = PaneInfo { + id, + is_plugin, + is_focused, + is_fullscreen, + is_floating, + is_suppressed, + title, + exited, + exit_status, + is_held, + pane_x, + pane_content_x, + pane_y, + pane_content_y, + pane_rows, + pane_content_rows, + pane_columns, + pane_content_columns, + cursor_coordinates_in_pane, + terminal_command, + plugin_url, + is_selectable, + }; + Ok((tab_position, pane_info)) + } + pub fn encode_to_kdl(&self) -> KdlDocument { + let mut kdl_doucment = KdlDocument::new(); + macro_rules! int_node { + ($name:expr, $val:expr) => {{ + let mut att = KdlNode::new($name); + att.push($val as i64); + kdl_doucment.nodes_mut().push(att); + }}; + } + macro_rules! bool_node { + ($name:expr, $val:expr) => {{ + let mut att = KdlNode::new($name); + att.push($val); + kdl_doucment.nodes_mut().push(att); + }}; + } + macro_rules! string_node { + ($name:expr, $val:expr) => {{ + let mut att = KdlNode::new($name); + att.push($val); + kdl_doucment.nodes_mut().push(att); + }}; + } + + int_node!("id", self.id); + bool_node!("is_plugin", self.is_plugin); + bool_node!("is_focused", self.is_focused); + bool_node!("is_fullscreen", self.is_fullscreen); + bool_node!("is_floating", self.is_floating); + bool_node!("is_suppressed", self.is_suppressed); + string_node!("title", self.title.to_string()); + bool_node!("exited", self.exited); + if let Some(exit_status) = self.exit_status { + int_node!("exit_status", exit_status); + } + bool_node!("is_held", self.is_held); + int_node!("pane_x", self.pane_x); + int_node!("pane_content_x", self.pane_content_x); + int_node!("pane_y", self.pane_y); + int_node!("pane_content_y", self.pane_content_y); + int_node!("pane_rows", self.pane_rows); + int_node!("pane_content_rows", self.pane_content_rows); + int_node!("pane_columns", self.pane_columns); + int_node!("pane_content_columns", self.pane_content_columns); + if let Some((cursor_x, cursor_y)) = self.cursor_coordinates_in_pane { + let mut cursor_coordinates_in_pane = KdlNode::new("cursor_coordinates_in_pane"); + cursor_coordinates_in_pane.push(cursor_x as i64); + cursor_coordinates_in_pane.push(cursor_y as i64); + kdl_doucment.nodes_mut().push(cursor_coordinates_in_pane); + } + if let Some(terminal_command) = &self.terminal_command { + string_node!("terminal_command", terminal_command.to_string()); + } + if let Some(plugin_url) = &self.plugin_url { + string_node!("plugin_url", plugin_url.to_string()); + } + bool_node!("is_selectable", self.is_selectable); + kdl_doucment + } +} + pub fn parse_plugin_user_configuration( plugin_block: &KdlNode, ) -> Result<BTreeMap<String, String>, ConfigError> { @@ -1888,3 +2303,104 @@ pub fn parse_plugin_user_configuration( } Ok(configuration) } + +#[test] +fn serialize_and_deserialize_session_info() { + let session_info = SessionInfo::default(); + let serialized = session_info.to_string(); + let deserealized = SessionInfo::from_string(&serialized, "not this session").unwrap(); + assert_eq!(session_info, deserealized); + insta::assert_snapshot!(serialized); +} + +#[test] +fn serialize_and_deserialize_session_info_with_data() { + let panes_list = vec![ + PaneInfo { + id: 1, + is_plugin: false, + is_focused: true, + is_fullscreen: true, + is_floating: false, + is_suppressed: false, + title: "pane 1".to_owned(), + exited: false, + exit_status: None, + is_held: false, + pane_x: 0, + pane_content_x: 1, + pane_y: 0, + pane_content_y: 1, + pane_rows: 5, + pane_content_rows: 4, + pane_columns: 22, + pane_content_columns: 21, + cursor_coordinates_in_pane: Some((0, 0)), + terminal_command: Some("foo".to_owned()), + plugin_url: None, + is_selectable: true, + }, + PaneInfo { + id: 1, + is_plugin: true, + is_focused: true, + is_fullscreen: true, + is_floating: false, + is_suppressed: false, + title: "pane 1".to_owned(), + exited: false, + exit_status: None, + is_held: false, + pane_x: 0, + pane_content_x: 1, + pane_y: 0, + pane_content_y: 1, + pane_rows: 5, + pane_content_rows: 4, + pane_columns: 22, + pane_content_columns: 21, + cursor_coordinates_in_pane: Some((0, 0)), + terminal_command: None, + plugin_url: Some("i_am_a_fake_plugin".to_owned()), + is_selectable: true, + }, + ]; + let mut panes = HashMap::new(); + panes.insert(0, panes_list); + let session_info = SessionInfo { + name: "my session name".to_owned(), + tabs: vec![ + TabInfo { + position: 0, + name: "tab 1".to_owned(), + active: true, + panes_to_hide: 1, + is_fullscreen_active: true, + is_sync_panes_active: false, + are_floating_panes_visible: true, + other_focused_clients: vec![2, 3], + active_swap_layout_name: Some("BASE".to_owned()), + is_swap_layout_dirty: true, + }, + TabInfo { + position: 1, + name: "tab 2".to_owned(), + active: true, + panes_to_hide: 0, + is_fullscreen_active: false, + is_sync_panes_active: true, + are_floating_panes_visible: true, + other_focused_clients: vec![2, 3], + active_swap_layout_name: None, + is_swap_layout_dirty: false, + }, + ], + panes: PaneManifest { panes }, + connected_clients: 2, + is_current_session: false, + }; + let serialized = session_info.to_string(); + let deserealized = SessionInfo::from_string(&serialized, "not this session").unwrap(); + assert_eq!(session_info, deserealized); + insta::assert_snapshot!(serialized); +} diff --git a/zellij-utils/src/kdl/snapshots/zellij_utils__kdl__serialize_and_deserialize_session_info.snap b/zellij-utils/src/kdl/snapshots/zellij_utils__kdl__serialize_and_deserialize_session_info.snap new file mode 100644 index 00000000..4a231c37 --- /dev/null +++ b/zellij-utils/src/kdl/snapshots/zellij_utils__kdl__serialize_and_deserialize_session_info.snap @@ -0,0 +1,12 @@ +--- +source: zellij-utils/src/kdl/mod.rs +assertion_line: 2284 +expression: serialized +--- +name "" +tabs { +} +panes { +} +connected_clients 0 + diff --git a/zellij-utils/src/kdl/snapshots/zellij_utils__kdl__serialize_and_deserialize_session_info_with_data.snap b/zellij-utils/src/kdl/snapshots/zellij_utils__kdl__serialize_and_deserialize_session_info_with_data.snap new file mode 100644 index 00000000..99e3e03f --- /dev/null +++ b/zellij-utils/src/kdl/snapshots/zellij_utils__kdl__serialize_and_deserialize_session_info_with_data.snap @@ -0,0 +1,81 @@ +--- +source: zellij-utils/src/kdl/mod.rs +assertion_line: 2377 +expression: serialized +--- +name "my session name" +tabs { + tab { + position 0 + name "tab 1" + active true + panes_to_hide 1 + is_fullscreen_active true + is_sync_panes_active false + are_floating_panes_visible true + other_focused_clients 2 3 + active_swap_layout_name "BASE" + is_swap_layout_dirty true + } + tab { + position 1 + name "tab 2" + active true + panes_to_hide 0 + is_fullscreen_active false + is_sync_panes_active true + are_floating_panes_visible true + other_focused_clients 2 3 + is_swap_layout_dirty false + } +} +panes { + pane { + id 1 + is_plugin false + is_focused true + is_fullscreen true + is_floating false + is_suppressed false + title "pane 1" + exited false + is_held false + pane_x 0 + pane_content_x 1 + pane_y 0 + pane_content_y 1 + pane_rows 5 + pane_content_rows 4 + pane_columns 22 + pane_content_columns 21 + cursor_coordinates_in_pane 0 0 + terminal_command "foo" + is_selectable true + tab_position 0 + } + pane { + id 1 + is_plugin true + is_focused true + is_fullscreen true + is_floating false + is_suppressed false + title "pane 1" + exited false + is_held false + pane_x 0 + pane_content_x 1 + pane_y 0 + pane_content_y 1 + pane_rows 5 + pane_content_rows 4 + pane_columns 22 + pane_content_columns 21 + cursor_coordinates_in_pane 0 0 + plugin_url "i_am_a_fake_plugin" + is_selectable true + tab_position 0 + } +} +connected_clients 2 + diff --git a/zellij-utils/src/plugin_api/event.proto b/zellij-utils/src/plugin_api/event.proto index 3a9838fa..4d5b805d 100644 --- a/zellij-utils/src/plugin_api/event.proto +++ b/zellij-utils/src/plugin_api/event.proto @@ -39,6 +39,7 @@ enum EventType { /// A file was deleted somewhere in the Zellij CWD folder FileSystemDelete = 14; PermissionRequestResult = 15; + SessionUpdate = 16; } message EventNameList { @@ -59,9 +60,14 @@ message Event { CustomMessagePayload custom_message_payload = 10; FileListPayload file_list_payload = 11; PermissionRequestResultPayload permission_request_result_payload = 12; + SessionUpdatePayload session_update_payload = 13; } } +message SessionUpdatePayload { + repeated SessionManifest session_manifests = 1; +} + message PermissionRequestResultPayload { bool granted = 1; } @@ -111,6 +117,14 @@ message PaneManifest { repeated PaneInfo panes = 2; } +message SessionManifest { + string name = 1; + repeated TabInfo tabs = 2; + repeated PaneManifest panes = 3; + uint32 connected_clients = 4; + bool is_current_session = 5; +} + message PaneInfo { uint32 id = 1; bool is_plugin = 2; diff --git a/zellij-utils/src/plugin_api/event.rs b/zellij-utils/src/plugin_api/event.rs index 6115fe1e..9b0e9886 100644 --- a/zellij-utils/src/plugin_api/event.rs +++ b/zellij-utils/src/plugin_api/event.rs @@ -6,7 +6,7 @@ pub use super::generated_api::api::{ EventType as ProtobufEventType, InputModeKeybinds as ProtobufInputModeKeybinds, KeyBind as ProtobufKeyBind, ModeUpdatePayload as ProtobufModeUpdatePayload, PaneInfo as ProtobufPaneInfo, PaneManifest as ProtobufPaneManifest, - TabInfo as ProtobufTabInfo, *, + SessionManifest as ProtobufSessionManifest, TabInfo as ProtobufTabInfo, *, }, input_mode::InputMode as ProtobufInputMode, key::Key as ProtobufKey, @@ -14,7 +14,7 @@ pub use super::generated_api::api::{ }; use crate::data::{ CopyDestination, Event, EventType, InputMode, Key, ModeInfo, Mouse, PaneInfo, PaneManifest, - PermissionStatus, PluginCapabilities, Style, TabInfo, + PermissionStatus, PluginCapabilities, SessionInfo, Style, TabInfo, }; use crate::errors::prelude::*; @@ -171,6 +171,18 @@ impl TryFrom<ProtobufEvent> for Event { }, _ => Err("Malformed payload for the file system delete Event"), }, + Some(ProtobufEventType::SessionUpdate) => match protobuf_event.payload { + Some(ProtobufEventPayload::SessionUpdatePayload( + protobuf_session_update_payload, + )) => { + let mut session_infos: Vec<SessionInfo> = vec![]; + for protobuf_session_info in protobuf_session_update_payload.session_manifests { + session_infos.push(SessionInfo::try_from(protobuf_session_info)?); + } + Ok(Event::SessionUpdate(session_infos)) + }, + _ => Err("Malformed payload for the SessionUpdate Event"), + }, None => Err("Unknown Protobuf Event"), } } @@ -313,7 +325,80 @@ impl TryFrom<Event> for ProtobufEvent { )), }) }, + Event::SessionUpdate(session_infos) => { + let mut protobuf_session_manifests = vec![]; + for session_info in session_infos { + protobuf_session_manifests.push(session_info.try_into()?); + } + let session_update_payload = SessionUpdatePayload { + session_manifests: protobuf_session_manifests, + }; + Ok(ProtobufEvent { + name: ProtobufEventType::SessionUpdate as i32, + payload: Some(event::Payload::SessionUpdatePayload(session_update_payload)), + }) + }, + } + } +} + +impl TryFrom<SessionInfo> for ProtobufSessionManifest { + type Error = &'static str; + fn try_from(session_info: SessionInfo) -> Result<Self, &'static str> { + let mut protobuf_pane_manifests = vec![]; + for (tab_index, pane_infos) in session_info.panes.panes { + let mut protobuf_pane_infos = vec![]; + for pane_info in pane_infos { + protobuf_pane_infos.push(pane_info.try_into()?); + } + protobuf_pane_manifests.push(ProtobufPaneManifest { + tab_index: tab_index as u32, + panes: protobuf_pane_infos, + }); + } + Ok(ProtobufSessionManifest { + name: session_info.name, + panes: protobuf_pane_manifests, + tabs: session_info + .tabs + .iter() + .filter_map(|t| t.clone().try_into().ok()) + .collect(), + connected_clients: session_info.connected_clients as u32, + is_current_session: session_info.is_current_session, + }) + } +} + +impl TryFrom<ProtobufSessionManifest> for SessionInfo { + type Error = &'static str; + fn try_from(protobuf_session_manifest: ProtobufSessionManifest) -> Result<Self, &'static str> { + let mut pane_manifest: HashMap<usize, Vec<PaneInfo>> = HashMap::new(); + for protobuf_pane_manifest in protobuf_session_manifest.panes { + let tab_index = protobuf_pane_manifest.tab_index as usize; + let mut panes = vec![]; + for protobuf_pane_info in protobuf_pane_manifest.panes { + panes.push(protobuf_pane_info.try_into()?); + } + if pane_manifest.contains_key(&tab_index) { + return Err("Duplicate tab definition in pane manifest"); + } + pane_manifest.insert(tab_index, panes); } + let panes = PaneManifest { + panes: pane_manifest, + }; + Ok(SessionInfo { + name: protobuf_session_manifest.name, + tabs: protobuf_session_manifest + .tabs + .iter() + .filter_map(|t| t.clone().try_into().ok()) + .collect(), + panes, + connected_clients: protobuf_session_manifest.connected_clients as usize, + is_current_session: protobuf_session_manifest.is_current_session, + }) } } @@ -697,6 +782,7 @@ impl TryFrom<ProtobufEventType> for EventType { ProtobufEventType::FileSystemUpdate => EventType::FileSystemUpdate, ProtobufEventType::FileSystemDelete => EventType::FileSystemDelete, ProtobufEventType::PermissionRequestResult => EventType::PermissionRequestResult, + ProtobufEventType::SessionUpdate => EventType::SessionUpdate, }) } } @@ -721,6 +807,7 @@ impl TryFrom<EventType> for ProtobufEventType { EventType::FileSystemUpdate => ProtobufEventType::FileSystemUpdate, EventType::FileSystemDelete => ProtobufEventType::FileSystemDelete, EventType::PermissionRequestResult => ProtobufEventType::PermissionRequestResult, + EventType::SessionUpdate => ProtobufEventType::SessionUpdate, }) } } @@ -1083,3 +1170,130 @@ fn serialize_file_system_delete_event() { "Event properly serialized/deserialized without change" ); } + +#[test] +fn serialize_session_update_event() { + use prost::Message; + let session_update_event = Event::SessionUpdate(Default::default()); + let protobuf_event: ProtobufEvent = session_update_event.clone().try_into().unwrap(); + let serialized_protobuf_event = protobuf_event.encode_to_vec(); + let deserialized_protobuf_event: ProtobufEvent = + Message::decode(serialized_protobuf_event.as_slice()).unwrap(); + let deserialized_event: Event = deserialized_protobuf_event.try_into().unwrap(); + assert_eq!( + session_update_event, deserialized_event, + "Event properly serialized/deserialized without change" + ); +} + +#[test] +fn serialize_session_update_event_with_non_default_values() { + use prost::Message; + let tab_infos = vec![ + TabInfo { + position: 0, + name: "First tab".to_owned(), + active: true, + panes_to_hide: 2, + is_fullscreen_active: true, + is_sync_panes_active: false, + are_floating_panes_visible: true, + other_focused_clients: vec![2, 3, 4], + active_swap_layout_name: Some("my cool swap layout".to_owned()), + is_swap_layout_dirty: false, + }, + TabInfo { + position: 1, + name: "Secondtab".to_owned(), + active: false, + panes_to_hide: 5, + is_fullscreen_active: false, + is_sync_panes_active: true, + are_floating_panes_visible: true, + other_focused_clients: vec![1, 5, 111], + active_swap_layout_name: None, + is_swap_layout_dirty: true, + }, + TabInfo::default(), + ]; + let mut panes = HashMap::new(); + let panes_list = vec![ + PaneInfo { + id: 1, + is_plugin: false, + is_focused: true, + is_fullscreen: true, + is_floating: false, + is_suppressed: false, + title: "pane 1".to_owned(), + exited: false, + exit_status: None, + is_held: false, + pane_x: 0, + pane_content_x: 1, + pane_y: 0, + pane_content_y: 1, + pane_rows: 5, + pane_content_rows: 4, + pane_columns: 22, + pane_content_columns: 21, + cursor_coordinates_in_pane: Some((0, 0)), + terminal_command: Some("foo".to_owned()), + plugin_url: None, + is_selectable: true, + }, + PaneInfo { + id: 1, + is_plugin: true, + is_focused: true, + is_fullscreen: true, + is_floating: false, + is_suppressed: false, + title: "pane 1".to_owned(), + exited: false, + exit_status: None, + is_held: false, + pane_x: 0, + pane_content_x: 1, + pane_y: 0, + pane_content_y: 1, + pane_rows: 5, + pane_content_rows: 4, + pane_columns: 22, + pane_content_columns: 21, + cursor_coordinates_in_pane: Some((0, 0)), + terminal_command: None, + plugin_url: Some("i_am_a_fake_plugin".to_owned()), + is_selectable: true, + }, + ]; + panes.insert(0, panes_list); + let session_info_1 = SessionInfo { + name: "session 1".to_owned(), + tabs: tab_infos, + panes: PaneManifest { panes }, + connected_clients: 2, + is_current_session: true, + }; + let session_info_2 = SessionInfo { + name: "session 2".to_owned(), + tabs: vec![], + panes: PaneManifest { + panes: HashMap::new(), + }, + connected_clients: 0, + is_current_session: false, + }; + let session_infos = vec![session_info_1, session_info_2]; + + let session_update_event = Event::SessionUpdate(session_infos); + let protobuf_event: ProtobufEvent = session_update_event.clone().try_into().unwrap(); + let serialized_protobuf_event = protobuf_event.encode_to_vec(); + let deserialized_protobuf_event: ProtobufEvent = + Message::decode(serialized_protobuf_event.as_slice()).unwrap(); + let deserialized_event: Event = deserialized_protobuf_event.try_into().unwrap(); + assert_eq!( + session_update_event, deserialized_event, + "Event properly serialized/deserialized without change" + ); +} diff --git a/zellij-utils/src/plugin_api/plugin_command.proto b/zellij-utils/src/plugin_api/plugin_command.proto index 9ba8bb7f..69d4c97b 100644 --- a/zellij-utils/src/plugin_api/plugin_command.proto +++ b/zellij-utils/src/plugin_api/plugin_command.proto @@ -78,6 +78,7 @@ enum CommandName { RenameTab = 64; ReportCrash = 65; RequestPluginPermissions = 66; + SwitchSession = 67; } message PluginCommand { @@ -120,9 +121,17 @@ message PluginCommand { IdAndNewName rename_tab_payload = 36; string report_crash_payload = 37; RequestPluginPermissionPayload request_plugin_permission_payload = 38; + SwitchSessionPayload switch_session_payload = 39; } } +message SwitchSessionPayload { + optional string name = 1; + optional uint32 tab_position = 2; + optional uint32 pane_id = 3; + optional bool pane_id_is_plugin = 4; +} + message RequestPluginPermissionPayload { repeated plugin_permission.PermissionType permissions = 1; } diff --git a/zellij-utils/src/plugin_api/plugin_command.rs b/zellij-utils/src/plugin_api/plugin_command.rs index ff50a6a7..71289a14 100644 --- a/zellij-utils/src/plugin_api/plugin_command.rs +++ b/zellij-utils/src/plugin_api/plugin_command.rs @@ -5,13 +5,13 @@ pub use super::generated_api::api::{ OpenCommandPanePayload, OpenFilePayload, PaneIdAndShouldFloat, PluginCommand as ProtobufPluginCommand, PluginMessagePayload, RequestPluginPermissionPayload, ResizePayload, SetTimeoutPayload, SubscribePayload, - SwitchTabToPayload, SwitchToModePayload, UnsubscribePayload, + SwitchSessionPayload, SwitchTabToPayload, SwitchToModePayload, UnsubscribePayload, }, plugin_permission::PermissionType as ProtobufPermissionType, resize::ResizeAction as ProtobufResizeAction, }; -use crate::data::{PermissionType, PluginCommand}; +use crate::data::{ConnectToSession, PermissionType, PluginCommand}; use std::convert::TryFrom; @@ -500,6 +500,23 @@ impl TryFrom<ProtobufPluginCommand> for PluginCommand { }, _ => Err("Mismatched payload for RequestPluginPermission"), }, + Some(CommandName::SwitchSession) => match protobuf_plugin_command.payload { + Some(Payload::SwitchSessionPayload(payload)) => { + let pane_id = match (payload.pane_id, payload.pane_id_is_plugin) { + (Some(pane_id), Some(is_plugin)) => Some((pane_id, is_plugin)), + (None, None) => None, + _ => { + return Err("Malformed payload for SwitchSession, 'pane_id' and 'is_plugin' must be included together or not at all") + } + }; + Ok(PluginCommand::SwitchSession(ConnectToSession { + name: payload.name, + tab_position: payload.tab_position.map(|p| p as usize), + pane_id, + })) + }, + _ => Err("Mismatched payload for SwitchSession"), + }, None => Err("Unrecognized plugin command"), } } @@ -846,6 +863,15 @@ impl TryFrom<PluginCommand> for ProtobufPluginCommand { }, )), }), + PluginCommand::SwitchSession(switch_to_session) => Ok(ProtobufPluginCommand { + name: CommandName::SwitchSession as i32, + payload: Some(Payload::SwitchSessionPayload(SwitchSessionPayload { + name: switch_to_session.name, + tab_position: switch_to_session.tab_position.map(|t| t as u32), + pane_id: switch_to_session.pane_id.map(|p| p.0), + pane_id_is_plugin: switch_to_session.pane_id.map(|p| p.1), + })), + }), } } } diff --git a/zellij-utils/src/snapshots/zellij_utils__setup__setup_test__default_config_with_no_cli_arguments.snap b/zellij-utils/src/snapshots/zellij_utils__setup__setup_test__default_config_with_no_cli_arguments.snap index 7f681757..367866e0 100644 --- a/zellij-utils/src/snapshots/zellij_utils__setup__setup_test__default_config_with_no_cli_arguments.snap +++ b/zellij-utils/src/snapshots/zellij_utils__setup__setup_test__default_config_with_no_cli_arguments.snap @@ -2489,6 +2489,29 @@ Config { ): [ Detach, ], + Char( + 'w', + ): [ + LaunchOrFocusPlugin( + RunPlugin { + _allow_exec_host_cmd: false, + location: Zellij( + PluginTag( + "session-manager", + ), + ), + configuration: PluginUserConfiguration( + { + "floating": "true", + }, + ), + }, + true, + ), + SwitchToMode( + Normal, + ), + ], Alt( Char( '+', @@ -3587,6 +3610,23 @@ Config { ), }, PluginTag( + "session-manager", + ): PluginConfig { + path: "session-manager", + run: Pane( + None, + ), + _allow_exec_host_cmd: false, + location: Zellij( + PluginTag( + "session-manager", + ), + ), + userspace_configuration: PluginUserConfiguration( + {}, + ), + }, + PluginTag( "status-bar", ): PluginConfig { path: "status-bar", diff --git a/zellij-utils/src/snapshots/zellij_utils__setup__setup_test__layout_env_vars_override_config_env_vars.snap b/zellij-utils/src/snapshots/zellij_utils__setup__setup_test__layout_env_vars_override_config_env_vars.snap index f8cbc413..5af23a0a 100644 --- a/zellij-utils/src/snapshots/zellij_utils__setup__setup_test__layout_env_vars_override_config_env_vars.snap +++ b/zellij-utils/src/snapshots/zellij_utils__setup__setup_test__layout_env_vars_override_config_env_vars.snap @@ -2489,6 +2489,29 @@ Config { ): [ Detach, ], + Char( + 'w', + ): [ + LaunchOrFocusPlugin( + RunPlugin { + _allow_exec_host_cmd: false, + location: Zellij( + PluginTag( + "session-manager", + ), + ), + configuration: PluginUserConfiguration( + { + "floating": "true", + }, + ), + }, + true, + ), + SwitchToMode( + Normal, + ), + ], Alt( Char( '+', @@ -3587,6 +3610,23 @@ Config { ), }, PluginTag( + "session-manager", + ): PluginConfig { + path: "session-manager", + run: Pane( + None, + ), + _allow_exec_host_cmd: false, + location: Zellij( + PluginTag( + "session-manager", + ), + ), + userspace_configuration: PluginUserConfiguration( + {}, + ), + }, + PluginTag( "status-bar", ): PluginConfig { path: "status-bar", diff --git a/zellij-utils/src/snapshots/zellij_utils__setup__setup_test__layout_keybinds_override_config_keybinds.snap b/zellij-utils/src/snapshots/zellij_utils__setup__setup_test__layout_keybinds_override_config_keybinds.snap index bb06be46..0a7f74b7 100644 --- a/zellij-utils/src/snapshots/zellij_utils__setup__setup_test__layout_keybinds_override_config_keybinds.snap +++ b/zellij-utils/src/snapshots/zellij_utils__setup__setup_test__layout_keybinds_override_config_keybinds.snap @@ -103,6 +103,23 @@ Config { ), }, PluginTag( + "session-manager", + ): PluginConfig { + path: "session-manager", + run: Pane( + None, + ), + _allow_exec_host_cmd: false, + location: Zellij( + PluginTag( + "session-manager", + ), + ), + userspace_configuration: PluginUserConfiguration( + {}, + ), + }, + PluginTag( "status-bar", ): PluginConfig { path: "status-bar", diff --git a/zellij-utils/src/snapshots/zellij_utils__setup__setup_test__layout_plugins_override_config_plugins.snap b/zellij-utils/src/snapshots/zellij_utils__setup__setup_test__layout_plugins_override_config_plugins.snap index 43501663..55173c3a 100644 --- a/zellij-utils/src/snapshots/zellij_utils__setup__setup_test__layout_plugins_override_config_plugins.snap +++ b/zellij-utils/src/snapshots/zellij_utils__setup__setup_test__layout_plugins_override_config_plugins.snap @@ -2489,6 +2489,29 @@ Config { ): [ Detach, ], + Char( + 'w', + ): [ + LaunchOrFocusPlugin( + RunPlugin { + _allow_exec_host_cmd: false, + location: Zellij( + PluginTag( + "session-manager", + ), + ), + configuration: PluginUserConfiguration( + { + "floating": "true", + }, + ), + }, + true, + ), + SwitchToMode( + Normal, + ), + ], Alt( Char( '+', @@ -3587,6 +3610,23 @@ Config { ), }, PluginTag( + "session-manager", + ): PluginConfig { + path: "session-manager", + run: Pane( + None, + ), + _allow_exec_host_cmd: false, + location: Zellij( + PluginTag( + "session-manager", + ), + ), + userspace_configuration: PluginUserConfiguration( + {}, + ), + }, + PluginTag( "some-other-plugin", ): PluginConfig { path: "i-am-defined-in-the-layout", diff --git a/zellij-utils/src/snapshots/zellij_utils__setup__setup_test__layout_themes_override_config_themes.snap b/zellij-utils/src/snapshots/zellij_utils__setup__setup_test__layout_themes_override_config_themes.snap index 4159c525..a7613eee 100644 --- a/zellij-utils/src/snapshots/zellij_utils__setup__setup_test__layout_themes_override_config_themes.snap +++ b/zellij-utils/src/snapshots/zellij_utils__setup__setup_test__layout_themes_override_config_themes.snap @@ -2489,6 +2489,29 @@ Config { ): [ Detach, ], + Char( + 'w', + ): [ + LaunchOrFocusPlugin( + RunPlugin { + _allow_exec_host_cmd: false, + location: Zellij( + PluginTag( + "session-manager", + ), + ), + configuration: PluginUserConfiguration( + { + "floating": "true", + }, + ), + }, + true, + ), + SwitchToMode( + Normal, + ), + ], Alt( Char( '+', @@ -3891,6 +3914,23 @@ Config { ), }, PluginTag( + "session-manager", + ): PluginConfig { + path: "session-manager", + run: Pane( + None, + ), + _allow_exec_host_cmd: false, + location: Zellij( + PluginTag( + "session-manager", + ), + ), + userspace_configuration: PluginUserConfiguration( + {}, + ), + }, + PluginTag( "status-bar", ): PluginConfig { path: "status-bar", diff --git a/zellij-utils/src/snapshots/zellij_utils__setup__setup_test__layout_ui_config_overrides_config_ui_config.snap b/zellij-utils/src/snapshots/zellij_utils__setup__setup_test__layout_ui_config_overrides_config_ui_config.snap index ebf3c501..dae91816 100644 --- a/zellij-utils/src/snapshots/zellij_utils__setup__setup_test__layout_ui_config_overrides_config_ui_config.snap +++ b/zellij-utils/src/snapshots/zellij_utils__setup__setup_test__layout_ui_config_overrides_config_ui_config.snap @@ -2489,6 +2489,29 @@ Config { ): [ Detach, ], + Char( + 'w', + ): [ + LaunchOrFocusPlugin( + RunPlugin { + _allow_exec_host_cmd: false, + location: Zellij( + PluginTag( + "session-manager", + ), + ), + configuration: PluginUserConfiguration( + { + "floating": "true", + }, + ), + }, + true, + ), + SwitchToMode( + Normal, + ), + ], Alt( Char( '+', @@ -3587,6 +3610,23 @@ Config { ), }, PluginTag( + "session-manager", + ): PluginConfig { + path: "session-manager", + run: Pane( + None, + ), + _allow_exec_host_cmd: false, + location: Zellij( + PluginTag( + "session-manager", + ), + ), + userspace_configuration: PluginUserConfiguration( + {}, + ), + }, + PluginTag( "status-bar", ): PluginConfig { path: "status-bar", |
