diff options
| author | Aram Drevekenin <aram@poor.dev> | 2026-03-30 16:02:09 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-03-30 16:02:09 +0200 |
| commit | 8ce05f0bbd58acbbca95f95ae14fdc4e866f7391 (patch) | |
| tree | 57c6d9ee2231a556f938df4f2629511a711518df /zellij-utils/src/ipc | |
| parent | docs(changelog): recent windows fixes (diff) | |
| download | sl0ppij-8ce05f0bbd58acbbca95f95ae14fdc4e866f7391.tar.gz sl0ppij-8ce05f0bbd58acbbca95f95ae14fdc4e866f7391.tar.xz sl0ppij-8ce05f0bbd58acbbca95f95ae14fdc4e866f7391.zip | |
Layout string flag (#4956)
* allow sending a stringified layout with --layout-string
* add --tab-id to all the things
* fix windows tests
* add pr
Diffstat (limited to 'zellij-utils/src/ipc')
| -rw-r--r-- | zellij-utils/src/ipc/protobuf_conversion.rs | 44 | ||||
| -rw-r--r-- | zellij-utils/src/ipc/tests/roundtrip_tests.rs | 181 |
2 files changed, 223 insertions, 2 deletions
diff --git a/zellij-utils/src/ipc/protobuf_conversion.rs b/zellij-utils/src/ipc/protobuf_conversion.rs index 5c78a445..189c1370 100644 --- a/zellij-utils/src/ipc/protobuf_conversion.rs +++ b/zellij-utils/src/ipc/protobuf_conversion.rs @@ -1095,6 +1095,8 @@ impl From<crate::input::actions::Action> start_suppressed, coordinates, near_current_pane, + tab_id, + .. } => ActionType::EditFile(EditFileAction { payload: Some(payload.into()), direction: direction.map(|d| direction_to_proto_i32(d)), @@ -1104,17 +1106,21 @@ impl From<crate::input::actions::Action> start_suppressed, coordinates: coordinates.map(|c| c.into()), near_current_pane, + tab_id: tab_id.map(|t| t as u32), }), crate::input::actions::Action::NewFloatingPane { command, pane_name, coordinates, near_current_pane, + tab_id, + .. } => ActionType::NewFloatingPane(NewFloatingPaneAction { command: command.map(|c| c.into()), pane_name, coordinates: coordinates.map(|c| c.into()), near_current_pane, + tab_id: tab_id.map(|t| t as u32), }), crate::input::actions::Action::NewTiledPane { direction, @@ -1122,12 +1128,15 @@ impl From<crate::input::actions::Action> pane_name, near_current_pane, borderless, + tab_id, + .. } => ActionType::NewTiledPane(NewTiledPaneAction { direction: direction.map(|d| direction_to_proto_i32(d)), command: command.map(|c| c.into()), pane_name, near_current_pane, borderless, + tab_id: tab_id.map(|t| t as u32), }), crate::input::actions::Action::NewInPlacePane { command, @@ -1135,21 +1144,27 @@ impl From<crate::input::actions::Action> near_current_pane, pane_id_to_replace, close_replaced_pane, + tab_id, + .. } => ActionType::NewInPlacePane(NewInPlacePaneAction { command: command.map(|c| c.into()), pane_name, near_current_pane, pane_id_to_replace: pane_id_to_replace.and_then(|p| p.try_into().ok()), close_replaced_pane, + tab_id: tab_id.map(|t| t as u32), }), crate::input::actions::Action::NewStackedPane { command, pane_name, near_current_pane, + tab_id, + .. } => ActionType::NewStackedPane(NewStackedPaneAction { command: command.map(|c| c.into()), pane_name, near_current_pane, + tab_id: tab_id.map(|t| t as u32), }), crate::input::actions::Action::NewBlockingPane { placement, @@ -1157,12 +1172,15 @@ impl From<crate::input::actions::Action> command, unblock_condition, near_current_pane, + tab_id, + .. } => ActionType::NewBlockingPane(NewBlockingPaneAction { placement: Some(placement.into()), pane_name, command: command.map(|c| c.into()), unblock_condition: unblock_condition.map(|c| unblock_condition_to_proto_i32(c)), near_current_pane, + tab_id: tab_id.map(|t| t as u32), }), crate::input::actions::Action::TogglePaneEmbedOrFloating => { ActionType::TogglePaneEmbedOrFloating(TogglePaneEmbedOrFloatingAction {}) @@ -1283,6 +1301,8 @@ impl From<crate::input::actions::Action> should_open_in_place, close_replaced_pane, skip_cache, + tab_id, + .. } => ActionType::LaunchOrFocusPlugin(LaunchOrFocusPluginAction { plugin: Some(plugin.into()), should_float, @@ -1290,6 +1310,7 @@ impl From<crate::input::actions::Action> should_open_in_place, close_replaced_pane, skip_cache, + tab_id: tab_id.map(|t| t as u32), }), crate::input::actions::Action::LaunchPlugin { plugin, @@ -1298,6 +1319,8 @@ impl From<crate::input::actions::Action> close_replaced_pane, skip_cache, cwd, + tab_id, + .. } => ActionType::LaunchPlugin(LaunchPluginAction { plugin: Some(plugin.into()), should_float, @@ -1305,6 +1328,7 @@ impl From<crate::input::actions::Action> close_replaced_pane, skip_cache, cwd: cwd.map(|p| p.to_string_lossy().to_string()), + tab_id: tab_id.map(|t| t as u32), }), crate::input::actions::Action::MouseEvent { event } => { ActionType::MouseEvent(MouseEventAction { @@ -1362,11 +1386,14 @@ impl From<crate::input::actions::Action> pane_name, skip_cache, cwd, + tab_id, + .. } => ActionType::NewTiledPluginPane(NewTiledPluginPaneAction { plugin: Some(plugin.into()), pane_name, skip_cache, cwd: cwd.map(|p| p.to_string_lossy().to_string()), + tab_id: tab_id.map(|t| t as u32), }), crate::input::actions::Action::NewFloatingPluginPane { plugin, @@ -1374,23 +1401,29 @@ impl From<crate::input::actions::Action> skip_cache, cwd, coordinates, + tab_id, + .. } => ActionType::NewFloatingPluginPane(NewFloatingPluginPaneAction { plugin: Some(plugin.into()), pane_name, skip_cache, cwd: cwd.map(|p| p.to_string_lossy().to_string()), coordinates: coordinates.map(|c| c.into()), + tab_id: tab_id.map(|t| t as u32), }), crate::input::actions::Action::NewInPlacePluginPane { plugin, pane_name, skip_cache, close_replaced_pane, + tab_id, + .. } => ActionType::NewInPlacePluginPane(NewInPlacePluginPaneAction { plugin: Some(plugin.into()), pane_name, skip_cache, close_replaced_pane, + tab_id: tab_id.map(|t| t as u32), }), crate::input::actions::Action::StartOrReloadPlugin { plugin } => { ActionType::StartOrReloadPlugin(StartOrReloadPluginAction { @@ -1916,6 +1949,7 @@ impl TryFrom<crate::client_server_contract::client_server_contract::Action> .map(|c| c.try_into()) .transpose()?, near_current_pane: edit_file_action.near_current_pane, + tab_id: edit_file_action.tab_id.map(|t| t as usize), }), ActionType::NewFloatingPane(new_floating_action) => { Ok(crate::input::actions::Action::NewFloatingPane { @@ -1929,6 +1963,7 @@ impl TryFrom<crate::client_server_contract::client_server_contract::Action> .map(|c| c.try_into()) .transpose()?, near_current_pane: new_floating_action.near_current_pane, + tab_id: new_floating_action.tab_id.map(|t| t as usize), }) }, ActionType::NewTiledPane(new_tiled_action) => { @@ -1941,6 +1976,7 @@ impl TryFrom<crate::client_server_contract::client_server_contract::Action> pane_name: new_tiled_action.pane_name, near_current_pane: new_tiled_action.near_current_pane, borderless: new_tiled_action.borderless, + tab_id: new_tiled_action.tab_id.map(|t| t as usize), }) }, ActionType::NewInPlacePane(new_in_place_action) => { @@ -1955,6 +1991,7 @@ impl TryFrom<crate::client_server_contract::client_server_contract::Action> .pane_id_to_replace .and_then(|p| p.try_into().ok()), close_replaced_pane: new_in_place_action.close_replaced_pane, + tab_id: new_in_place_action.tab_id.map(|t| t as usize), }) }, ActionType::NewStackedPane(new_stacked_action) => { @@ -1965,6 +2002,7 @@ impl TryFrom<crate::client_server_contract::client_server_contract::Action> .transpose()?, pane_name: new_stacked_action.pane_name, near_current_pane: new_stacked_action.near_current_pane, + tab_id: new_stacked_action.tab_id.map(|t| t as usize), }) }, ActionType::NewBlockingPane(new_blocking_action) => { @@ -1983,6 +2021,7 @@ impl TryFrom<crate::client_server_contract::client_server_contract::Action> .map(|c| proto_i32_to_unblock_condition(c)) .transpose()?, near_current_pane: new_blocking_action.near_current_pane, + tab_id: new_blocking_action.tab_id.map(|t| t as usize), }) }, ActionType::TogglePaneEmbedOrFloating(_) => { @@ -2126,6 +2165,7 @@ impl TryFrom<crate::client_server_contract::client_server_contract::Action> should_open_in_place: launch_plugin_action.should_open_in_place, close_replaced_pane: launch_plugin_action.close_replaced_pane, skip_cache: launch_plugin_action.skip_cache, + tab_id: launch_plugin_action.tab_id.map(|t| t as usize), }) }, ActionType::LaunchPlugin(launch_plugin_action) => { @@ -2139,6 +2179,7 @@ impl TryFrom<crate::client_server_contract::client_server_contract::Action> close_replaced_pane: launch_plugin_action.close_replaced_pane, skip_cache: launch_plugin_action.skip_cache, cwd: launch_plugin_action.cwd.map(PathBuf::from), + tab_id: launch_plugin_action.tab_id.map(|t| t as usize), }) }, ActionType::MouseEvent(mouse_event_action) => { @@ -2210,6 +2251,7 @@ impl TryFrom<crate::client_server_contract::client_server_contract::Action> pane_name: new_tiled_plugin_action.pane_name, skip_cache: new_tiled_plugin_action.skip_cache, cwd: new_tiled_plugin_action.cwd.map(PathBuf::from), + tab_id: new_tiled_plugin_action.tab_id.map(|t| t as usize), }) }, ActionType::NewFloatingPluginPane(new_floating_plugin_action) => { @@ -2225,6 +2267,7 @@ impl TryFrom<crate::client_server_contract::client_server_contract::Action> .coordinates .map(|c| c.try_into()) .transpose()?, + tab_id: new_floating_plugin_action.tab_id.map(|t| t as usize), }) }, ActionType::NewInPlacePluginPane(new_in_place_plugin_action) => { @@ -2236,6 +2279,7 @@ impl TryFrom<crate::client_server_contract::client_server_contract::Action> pane_name: new_in_place_plugin_action.pane_name, skip_cache: new_in_place_plugin_action.skip_cache, close_replaced_pane: new_in_place_plugin_action.close_replaced_pane, + tab_id: new_in_place_plugin_action.tab_id.map(|t| t as usize), }) }, ActionType::StartOrReloadPlugin(start_plugin_action) => { diff --git a/zellij-utils/src/ipc/tests/roundtrip_tests.rs b/zellij-utils/src/ipc/tests/roundtrip_tests.rs index cfe882a1..7ef7ac89 100644 --- a/zellij-utils/src/ipc/tests/roundtrip_tests.rs +++ b/zellij-utils/src/ipc/tests/roundtrip_tests.rs @@ -1,8 +1,8 @@ use super::test_framework::*; use crate::data::{ BareKey, CommandOrPlugin, ConnectToSession, Direction, FloatingPaneCoordinates, InputMode, - KeyModifier, KeyWithModifier, LayoutInfo, LayoutMetadata, OriginatingPlugin, PaneId, PluginTag, - Resize, WebSharing, + KeyModifier, KeyWithModifier, LayoutInfo, LayoutMetadata, NewPanePlacement, OriginatingPlugin, + PaneId, PluginTag, Resize, WebSharing, }; use crate::input::actions::{Action, SearchDirection, SearchOption}; use crate::input::cli_assets::CliAssets; @@ -1054,6 +1054,7 @@ fn test_client_messages() { start_suppressed: false, coordinates: None, near_current_pane: false, + tab_id: None, }, terminal_id: Some(1), client_id: Some(100), @@ -1078,6 +1079,7 @@ fn test_client_messages() { start_suppressed: false, coordinates: None, near_current_pane: false, + tab_id: None, }, terminal_id: Some(1), client_id: Some(100), @@ -1102,6 +1104,7 @@ fn test_client_messages() { start_suppressed: false, coordinates: None, near_current_pane: false, + tab_id: None, }, terminal_id: Some(1), client_id: Some(100), @@ -1126,6 +1129,7 @@ fn test_client_messages() { start_suppressed: true, coordinates: FloatingPaneCoordinates::new(None, None, None, None, None, Some(false)), near_current_pane: false, + tab_id: None, }, terminal_id: Some(1), client_id: Some(100), @@ -1157,6 +1161,7 @@ fn test_client_messages() { Some(false), ), near_current_pane: false, + tab_id: None, }, terminal_id: Some(1), client_id: Some(100), @@ -1188,6 +1193,7 @@ fn test_client_messages() { Some(false), ), near_current_pane: false, + tab_id: None, }, terminal_id: Some(1), client_id: Some(100), @@ -1219,6 +1225,7 @@ fn test_client_messages() { Some(false), ), near_current_pane: false, + tab_id: None, }, terminal_id: Some(1), client_id: Some(100), @@ -1250,6 +1257,7 @@ fn test_client_messages() { Some(false) ), near_current_pane: false, + tab_id: None, }, terminal_id: Some(1), client_id: Some(100), @@ -1261,6 +1269,7 @@ fn test_client_messages() { pane_name: None, coordinates: None, near_current_pane: false, + tab_id: None, }, terminal_id: Some(1), client_id: Some(100), @@ -1288,6 +1297,7 @@ fn test_client_messages() { Some(false), ), near_current_pane: false, + tab_id: None, }, terminal_id: Some(1), client_id: Some(100), @@ -1319,6 +1329,7 @@ fn test_client_messages() { Some(false), ), near_current_pane: false, + tab_id: None, }, terminal_id: Some(1), client_id: Some(100), @@ -1331,6 +1342,7 @@ fn test_client_messages() { pane_name: None, near_current_pane: false, borderless: None, + tab_id: None, }, terminal_id: Some(1), client_id: Some(100), @@ -1356,6 +1368,7 @@ fn test_client_messages() { pane_name: Some("my_pane_name".to_owned()), near_current_pane: false, borderless: Some(true), + tab_id: None, }, terminal_id: Some(1), client_id: Some(100), @@ -1381,6 +1394,7 @@ fn test_client_messages() { near_current_pane: false, pane_id_to_replace: None, close_replaced_pane: false, + tab_id: None, }, terminal_id: Some(1), client_id: Some(100), @@ -1393,6 +1407,7 @@ fn test_client_messages() { near_current_pane: false, pane_id_to_replace: None, close_replaced_pane: false, + tab_id: None, }, terminal_id: Some(1), client_id: Some(100), @@ -1416,6 +1431,7 @@ fn test_client_messages() { }), pane_name: Some("my_pane_name".to_owned()), near_current_pane: false, + tab_id: None, }, terminal_id: Some(1), client_id: Some(100), @@ -1426,6 +1442,7 @@ fn test_client_messages() { command: None, pane_name: None, near_current_pane: false, + tab_id: None, }, terminal_id: Some(1), client_id: Some(100), @@ -2230,6 +2247,7 @@ fn test_client_messages() { should_open_in_place: true, close_replaced_pane: false, skip_cache: true, + tab_id: None, }, terminal_id: Some(1), client_id: Some(100), @@ -2244,6 +2262,7 @@ fn test_client_messages() { should_open_in_place: false, close_replaced_pane: false, skip_cache: false, + tab_id: None, }, terminal_id: Some(1), client_id: Some(100), @@ -2258,6 +2277,7 @@ fn test_client_messages() { close_replaced_pane: false, skip_cache: true, cwd: None, + tab_id: None, }, terminal_id: Some(1), client_id: Some(100), @@ -2272,6 +2292,7 @@ fn test_client_messages() { close_replaced_pane: false, skip_cache: false, cwd: Some(PathBuf::from("/path/to/cwd")), + tab_id: None, }, terminal_id: Some(1), client_id: Some(100), @@ -2438,6 +2459,7 @@ fn test_client_messages() { pane_name: Some("my_pane_name".to_owned()), skip_cache: false, cwd: Some(PathBuf::from("relative/path/to/cwd")), + tab_id: None, }, terminal_id: Some(1), client_id: Some(100), @@ -2450,6 +2472,7 @@ fn test_client_messages() { skip_cache: true, cwd: Some(PathBuf::from("relative/path/to/cwd")), coordinates: None, + tab_id: None, }, terminal_id: Some(1), client_id: Some(100), @@ -2469,6 +2492,7 @@ fn test_client_messages() { Some(true), Some(false), ), + tab_id: None, }, terminal_id: Some(1), client_id: Some(100), @@ -2480,6 +2504,159 @@ fn test_client_messages() { pane_name: Some("my_pane_name".to_owned()), skip_cache: true, close_replaced_pane: false, + tab_id: None, + }, + terminal_id: Some(1), + client_id: Some(100), + is_cli_client: true, + }); + // tab_id roundtrip tests - verify tab_id survives serialization + test_client_roundtrip!(ClientToServerMsg::Action { + action: Action::NewTiledPane { + direction: Some(Direction::Right), + command: None, + pane_name: None, + near_current_pane: false, + borderless: None, + tab_id: Some(3), + }, + terminal_id: Some(1), + client_id: Some(100), + is_cli_client: true, + }); + test_client_roundtrip!(ClientToServerMsg::Action { + action: Action::NewFloatingPane { + command: None, + pane_name: None, + coordinates: None, + near_current_pane: false, + tab_id: Some(5), + }, + terminal_id: Some(1), + client_id: Some(100), + is_cli_client: true, + }); + test_client_roundtrip!(ClientToServerMsg::Action { + action: Action::NewStackedPane { + command: None, + pane_name: None, + near_current_pane: false, + tab_id: Some(2), + }, + terminal_id: Some(1), + client_id: Some(100), + is_cli_client: true, + }); + test_client_roundtrip!(ClientToServerMsg::Action { + action: Action::NewBlockingPane { + placement: NewPanePlacement::Tiled { + direction: None, + borderless: None + }, + pane_name: None, + command: None, + unblock_condition: None, + near_current_pane: false, + tab_id: Some(1), + }, + terminal_id: Some(1), + client_id: Some(100), + is_cli_client: true, + }); + test_client_roundtrip!(ClientToServerMsg::Action { + action: Action::EditFile { + payload: OpenFilePayload { + path: PathBuf::from("/file/path"), + line_number: None, + cwd: None, + originating_plugin: None, + }, + direction: None, + floating: false, + in_place: false, + close_replaced_pane: false, + start_suppressed: false, + coordinates: None, + near_current_pane: false, + tab_id: Some(4), + }, + terminal_id: Some(1), + client_id: Some(100), + is_cli_client: true, + }); + test_client_roundtrip!(ClientToServerMsg::Action { + action: Action::NewInPlacePane { + command: None, + pane_name: None, + near_current_pane: false, + pane_id_to_replace: None, + close_replaced_pane: false, + tab_id: Some(7), + }, + terminal_id: Some(1), + client_id: Some(100), + is_cli_client: true, + }); + test_client_roundtrip!(ClientToServerMsg::Action { + action: Action::LaunchOrFocusPlugin { + plugin: RunPluginOrAlias::RunPlugin(RunPlugin::default()), + should_float: true, + move_to_focused_tab: false, + should_open_in_place: false, + close_replaced_pane: false, + skip_cache: false, + tab_id: Some(2), + }, + terminal_id: Some(1), + client_id: Some(100), + is_cli_client: true, + }); + test_client_roundtrip!(ClientToServerMsg::Action { + action: Action::LaunchPlugin { + plugin: RunPluginOrAlias::RunPlugin(RunPlugin::default()), + should_float: false, + should_open_in_place: false, + close_replaced_pane: false, + skip_cache: false, + cwd: None, + tab_id: Some(6), + }, + terminal_id: Some(1), + client_id: Some(100), + is_cli_client: true, + }); + test_client_roundtrip!(ClientToServerMsg::Action { + action: Action::NewTiledPluginPane { + plugin: RunPluginOrAlias::RunPlugin(RunPlugin::default()), + pane_name: None, + skip_cache: false, + cwd: None, + tab_id: Some(1), + }, + terminal_id: Some(1), + client_id: Some(100), + is_cli_client: true, + }); + test_client_roundtrip!(ClientToServerMsg::Action { + action: Action::NewFloatingPluginPane { + plugin: RunPluginOrAlias::RunPlugin(RunPlugin::default()), + pane_name: None, + skip_cache: false, + cwd: None, + coordinates: None, + tab_id: Some(3), + }, + terminal_id: Some(1), + client_id: Some(100), + is_cli_client: true, + }); + test_client_roundtrip!(ClientToServerMsg::Action { + action: Action::NewInPlacePluginPane { + plugin: RunPluginOrAlias::RunPlugin(RunPlugin::default()), + pane_name: None, + skip_cache: false, + close_replaced_pane: false, + tab_id: Some(2), }, terminal_id: Some(1), client_id: Some(100), |
