diff --git a/zellij-server/src/pty.rs b/zellij-server/src/pty.rs index 041d44aec1..2d4084a77b 100644 --- a/zellij-server/src/pty.rs +++ b/zellij-server/src/pty.rs @@ -9,11 +9,6 @@ use crate::{ ClientId, ServerInstruction, }; use async_std::task::{self, JoinHandle}; -#[cfg(target_os = "linux")] -use std::ops::RangeInclusive; -#[cfg(target_os = "linux")] -use std::os::unix::fs::MetadataExt; -use std::path::Path; use std::sync::Arc; use std::{collections::HashMap, os::unix::io::RawFd, path::PathBuf}; use zellij_utils::data::PaneManifest; @@ -800,7 +795,7 @@ pub(crate) fn pty_thread_main(mut pty: Pty, layout: Box) -> Result<()> { for pane_info in infos.as_mut_slice() { let pid = pty.get_child_pid(pane_info.id); pane_info.pid = pid; - pane_info.cwd = pty + pane_info.startup_cwd = pty .bus .os_input .as_ref() @@ -810,15 +805,6 @@ pub(crate) fn pty_thread_main(mut pty: Pty, layout: Box) -> Result<()> { .map(|x| x.to_string_lossy().to_string()) }) .unwrap_or_default(); - - // Currently, only available on Linux, as it - // depends on the /proc-filesystem - #[cfg(target_os = "linux")] - { - // We can't send PathBufs via protobuf, so we have to convert to String - pane_info.tty = TtyDriver::find_tty_for_pid(pid) - .map(|x| x.to_string_lossy().to_string()); - } } } pty.bus @@ -1653,156 +1639,3 @@ pub fn get_default_shell() -> PathBuf { "/bin/sh".to_string() })) } - -#[cfg(target_os = "linux")] -#[derive(Debug, Clone)] -struct TtyDriver { - path: PathBuf, - major: i32, - minor_range: RangeInclusive, -} - -#[cfg(target_os = "linux")] -impl TtyDriver { - /// Trys to find the TTY for a given process ID. - /// This is unfortunately not straight forward. We have to do: - /// 1. Read the tty_nr from /proc//stat and do some bit-magic to get major and minor - /// 2. Read /proc/tty/drivers to see which path corresponds to which major number and minor range - /// 3. Match those 2 together and find a fitting driver - /// 4. 'Guess' the resulting path (e.g. either /dev/tty/2 or /dev/tty2) - /// 5. Verify the guess is correct by stat-ing the result and comparing major and minor - pub(crate) fn find_tty_for_pid(pid: i32) -> Option { - // 1. Parse major and minor tty_nr - let (tty_major, tty_minor) = TtyDriver::get_tty_nr_for_pid(pid)?; - // 2. Parse /proc/tty/drivers - let drivers = TtyDriver::parse_tty_drivers(); - // 3. Find a match - let driver = TtyDriver::match_drivers_to_tty_nr(drivers, tty_major, tty_minor)?; - // 4. and 5. Guess and verify path - let path = TtyDriver::guess_tty_path(&driver.path, tty_major, tty_minor)?; - Some(path) - } - - fn verify_tty_path(path: &Path, tty_major: i32, tty_minor: i32) -> bool { - if let Ok(metadata) = path.metadata() { - let rdev = metadata.rdev() as i32; - let dev_major = rdev >> 8; - let dev_minor = rdev & 0xff; - if dev_major == tty_major && dev_minor == tty_minor { - return true; - } - } - false - } - - fn guess_tty_path(path: &Path, tty_major: i32, tty_minor: i32) -> Option { - // First, guess seperated by slash: (e.g. /dev/tty/2) - let mut res = path.join(format!("{tty_minor}")); - if res.exists() && TtyDriver::verify_tty_path(&res, tty_major, tty_minor) { - return Some(res); - } - - // Otherwise, guess seperated by directly appending the number: (e.g. /dev/tty2) - let mut second_try = path.as_os_str().to_os_string(); - second_try.push(format!("{tty_minor}")); - res = PathBuf::from(second_try); - if res.exists() && TtyDriver::verify_tty_path(&res, tty_major, tty_minor) { - return Some(res); - } - - // No luck - None - } - - fn match_drivers_to_tty_nr( - drivers: Vec, - tty_major: i32, - tty_minor: i32, - ) -> Option { - drivers - .into_iter() - .find(|driver| driver.major == tty_major && driver.minor_range.contains(&tty_minor)) - } - - fn parse_tty_drivers() -> Vec { - let mut drivers = Vec::new(); - - // example output: - // /dev/tty /dev/tty 5 0 system:/dev/tty - // /dev/console /dev/console 5 1 system:console - // /dev/ptmx /dev/ptmx 5 2 system - // /dev/vc/0 /dev/vc/0 4 0 system:vtmaster - // rfcomm /dev/rfcomm 216 0-255 serial - // serial /dev/ttyS 4 64-95 serial - // pty_slave /dev/pts 136 0-1048575 pty:slave - // pty_master /dev/ptm 128 0-1048575 pty:master - // unknown /dev/tty 4 1-63 console - let drivers_raw = match std::fs::read_to_string(PathBuf::from("/proc/tty/drivers")) { - Ok(x) => x, - Err(_) => { - return drivers; - }, - }; - - for line in drivers_raw.lines() { - let parts: Vec<_> = line.split_whitespace().collect(); - if parts.len() < 4 { - // Something is wrong. Silently ignore this entry - continue; - } - let path = PathBuf::from(parts[1]); - let major = match parts[2].parse::() { - Ok(maj) => maj, - Err(_) => continue, - }; - let tty_minor = parts[3]; - let minor_range = match TtyDriver::parse_minor_range(tty_minor) { - Some(x) => x, - None => { - continue; - }, - }; - let driver = TtyDriver { - path, - major, - minor_range, - }; - drivers.push(driver); - } - drivers - } - - // Getting either "3" or "3-10" and parsing a Range from that - fn parse_minor_range(tty_minor: &str) -> Option> { - let minor_range: Vec<_> = tty_minor.split('-').collect(); - if minor_range.len() == 1 { - let start = minor_range[0].parse::().ok()?; - Some(start..=start) - } else if minor_range.len() == 2 { - let start = minor_range[0].parse::().ok()?; - let end = minor_range[1].parse::().ok()?; - Some(start..=end) - } else { - None - } - } - - fn get_tty_nr_for_pid(pid: i32) -> Option<(i32, i32)> { - if pid == -1 { - return None; - } - let stat = std::fs::read_to_string(PathBuf::from(format!("/proc/{pid}/stat"))).ok()?; - - let tty_nr = stat - .split_whitespace() - .nth(6) - .and_then(|s| s.parse::().ok())?; - // from /usr/include/linux/kdev_t.h - // #define MAJOR(dev) ((dev)>>8) - // #define MINOR(dev) ((dev) & 0xff) - let tty_major = tty_nr >> 8; - let tty_minor = tty_nr & 0xff; - - Some((tty_major, tty_minor)) - } -} diff --git a/zellij-server/src/unit/snapshots/zellij_server__screen__screen_tests__send_cli_edit_action_with_default_parameters.snap b/zellij-server/src/unit/snapshots/zellij_server__screen__screen_tests__send_cli_edit_action_with_default_parameters.snap index f86eda92cb..7a2e5d083a 100644 --- a/zellij-server/src/unit/snapshots/zellij_server__screen__screen_tests__send_cli_edit_action_with_default_parameters.snap +++ b/zellij-server/src/unit/snapshots/zellij_server__screen__screen_tests__send_cli_edit_action_with_default_parameters.snap @@ -3,4 +3,4 @@ source: zellij-server/src/./unit/screen_tests.rs expression: "format!(\"{:?}\", * received_pty_instructions.lock().unwrap())" snapshot_kind: text --- -[SpawnTerminal(Some(OpenFile(OpenFilePayload { path: "/file/to/edit", line_number: None, cwd: Some("."), originating_plugin: None })), Some(false), Some("Editing: /file/to/edit"), None, false, ClientId(10)), UpdatePaneInfo(PaneManifest { panes: {0: [PaneInfo { id: 0, is_plugin: false, is_focused: true, is_fullscreen: false, is_floating: false, is_suppressed: false, title: "Pane #1", exited: false, exit_status: None, is_held: false, pane_x: 0, pane_content_x: 1, pane_y: 0, pane_content_y: 1, pane_rows: 20, pane_content_rows: 18, pane_columns: 61, pane_content_columns: 59, cursor_coordinates_in_pane: Some((1, 1)), terminal_command: None, plugin_url: None, is_selectable: true, pid: 0, cwd: None, tty: None }, PaneInfo { id: 1, is_plugin: false, is_focused: false, is_fullscreen: false, is_floating: false, is_suppressed: false, title: "Pane #2", exited: false, exit_status: None, is_held: false, pane_x: 61, pane_content_x: 62, pane_y: 0, pane_content_y: 1, pane_rows: 20, pane_content_rows: 18, pane_columns: 60, pane_content_columns: 58, cursor_coordinates_in_pane: Some((1, 1)), terminal_command: None, plugin_url: None, is_selectable: true, pid: 0, cwd: None, tty: None }]} }), UpdateActivePane(Some(Terminal(0)), 1), UpdateActivePane(Some(Terminal(0)), 1), Exit] +[SpawnTerminal(Some(OpenFile(OpenFilePayload { path: "/file/to/edit", line_number: None, cwd: Some("."), originating_plugin: None })), Some(false), Some("Editing: /file/to/edit"), None, false, ClientId(10)), UpdatePaneInfo(PaneManifest { panes: {0: [PaneInfo { id: 0, is_plugin: false, is_focused: true, is_fullscreen: false, is_floating: false, is_suppressed: false, title: "Pane #1", exited: false, exit_status: None, is_held: false, pane_x: 0, pane_content_x: 1, pane_y: 0, pane_content_y: 1, pane_rows: 20, pane_content_rows: 18, pane_columns: 61, pane_content_columns: 59, cursor_coordinates_in_pane: Some((1, 1)), terminal_command: None, plugin_url: None, is_selectable: true, pid: 0, startup_cwd: None }, PaneInfo { id: 1, is_plugin: false, is_focused: false, is_fullscreen: false, is_floating: false, is_suppressed: false, title: "Pane #2", exited: false, exit_status: None, is_held: false, pane_x: 61, pane_content_x: 62, pane_y: 0, pane_content_y: 1, pane_rows: 20, pane_content_rows: 18, pane_columns: 60, pane_content_columns: 58, cursor_coordinates_in_pane: Some((1, 1)), terminal_command: None, plugin_url: None, is_selectable: true, pid: 0, startup_cwd: None }]} }), UpdateActivePane(Some(Terminal(0)), 1), UpdateActivePane(Some(Terminal(0)), 1), Exit] diff --git a/zellij-server/src/unit/snapshots/zellij_server__screen__screen_tests__send_cli_edit_action_with_line_number.snap b/zellij-server/src/unit/snapshots/zellij_server__screen__screen_tests__send_cli_edit_action_with_line_number.snap index 101622976d..01b6645142 100644 --- a/zellij-server/src/unit/snapshots/zellij_server__screen__screen_tests__send_cli_edit_action_with_line_number.snap +++ b/zellij-server/src/unit/snapshots/zellij_server__screen__screen_tests__send_cli_edit_action_with_line_number.snap @@ -3,4 +3,4 @@ source: zellij-server/src/./unit/screen_tests.rs expression: "format!(\"{:?}\", * received_pty_instructions.lock().unwrap())" snapshot_kind: text --- -[SpawnTerminal(Some(OpenFile(OpenFilePayload { path: "/file/to/edit", line_number: Some(100), cwd: Some("."), originating_plugin: None })), Some(false), Some("Editing: /file/to/edit"), None, false, ClientId(10)), UpdatePaneInfo(PaneManifest { panes: {0: [PaneInfo { id: 0, is_plugin: false, is_focused: true, is_fullscreen: false, is_floating: false, is_suppressed: false, title: "Pane #1", exited: false, exit_status: None, is_held: false, pane_x: 0, pane_content_x: 1, pane_y: 0, pane_content_y: 1, pane_rows: 20, pane_content_rows: 18, pane_columns: 61, pane_content_columns: 59, cursor_coordinates_in_pane: Some((1, 1)), terminal_command: None, plugin_url: None, is_selectable: true, pid: 0, cwd: None, tty: None }, PaneInfo { id: 1, is_plugin: false, is_focused: false, is_fullscreen: false, is_floating: false, is_suppressed: false, title: "Pane #2", exited: false, exit_status: None, is_held: false, pane_x: 61, pane_content_x: 62, pane_y: 0, pane_content_y: 1, pane_rows: 20, pane_content_rows: 18, pane_columns: 60, pane_content_columns: 58, cursor_coordinates_in_pane: Some((1, 1)), terminal_command: None, plugin_url: None, is_selectable: true, pid: 0, cwd: None, tty: None }]} }), UpdateActivePane(Some(Terminal(0)), 1), UpdateActivePane(Some(Terminal(0)), 1), Exit] +[SpawnTerminal(Some(OpenFile(OpenFilePayload { path: "/file/to/edit", line_number: Some(100), cwd: Some("."), originating_plugin: None })), Some(false), Some("Editing: /file/to/edit"), None, false, ClientId(10)), UpdatePaneInfo(PaneManifest { panes: {0: [PaneInfo { id: 0, is_plugin: false, is_focused: true, is_fullscreen: false, is_floating: false, is_suppressed: false, title: "Pane #1", exited: false, exit_status: None, is_held: false, pane_x: 0, pane_content_x: 1, pane_y: 0, pane_content_y: 1, pane_rows: 20, pane_content_rows: 18, pane_columns: 61, pane_content_columns: 59, cursor_coordinates_in_pane: Some((1, 1)), terminal_command: None, plugin_url: None, is_selectable: true, pid: 0, startup_cwd: None }, PaneInfo { id: 1, is_plugin: false, is_focused: false, is_fullscreen: false, is_floating: false, is_suppressed: false, title: "Pane #2", exited: false, exit_status: None, is_held: false, pane_x: 61, pane_content_x: 62, pane_y: 0, pane_content_y: 1, pane_rows: 20, pane_content_rows: 18, pane_columns: 60, pane_content_columns: 58, cursor_coordinates_in_pane: Some((1, 1)), terminal_command: None, plugin_url: None, is_selectable: true, pid: 0, startup_cwd: None }]} }), UpdateActivePane(Some(Terminal(0)), 1), UpdateActivePane(Some(Terminal(0)), 1), Exit] diff --git a/zellij-server/src/unit/snapshots/zellij_server__screen__screen_tests__send_cli_edit_action_with_split_direction.snap b/zellij-server/src/unit/snapshots/zellij_server__screen__screen_tests__send_cli_edit_action_with_split_direction.snap index 416e2c55d1..ff89d3b88d 100644 --- a/zellij-server/src/unit/snapshots/zellij_server__screen__screen_tests__send_cli_edit_action_with_split_direction.snap +++ b/zellij-server/src/unit/snapshots/zellij_server__screen__screen_tests__send_cli_edit_action_with_split_direction.snap @@ -3,4 +3,4 @@ source: zellij-server/src/./unit/screen_tests.rs expression: "format!(\"{:?}\", * received_pty_instructions.lock().unwrap())" snapshot_kind: text --- -[SpawnTerminalHorizontally(Some(OpenFile(OpenFilePayload { path: "/file/to/edit", line_number: None, cwd: Some("."), originating_plugin: None })), Some("Editing: /file/to/edit"), 10), UpdatePaneInfo(PaneManifest { panes: {0: [PaneInfo { id: 0, is_plugin: false, is_focused: true, is_fullscreen: false, is_floating: false, is_suppressed: false, title: "Pane #1", exited: false, exit_status: None, is_held: false, pane_x: 0, pane_content_x: 1, pane_y: 0, pane_content_y: 1, pane_rows: 20, pane_content_rows: 18, pane_columns: 61, pane_content_columns: 59, cursor_coordinates_in_pane: Some((1, 1)), terminal_command: None, plugin_url: None, is_selectable: true, pid: 0, cwd: None, tty: None }, PaneInfo { id: 1, is_plugin: false, is_focused: false, is_fullscreen: false, is_floating: false, is_suppressed: false, title: "Pane #2", exited: false, exit_status: None, is_held: false, pane_x: 61, pane_content_x: 62, pane_y: 0, pane_content_y: 1, pane_rows: 20, pane_content_rows: 18, pane_columns: 60, pane_content_columns: 58, cursor_coordinates_in_pane: Some((1, 1)), terminal_command: None, plugin_url: None, is_selectable: true, pid: 0, cwd: None, tty: None }]} }), UpdateActivePane(Some(Terminal(0)), 1), UpdateActivePane(Some(Terminal(0)), 1), Exit] +[SpawnTerminalHorizontally(Some(OpenFile(OpenFilePayload { path: "/file/to/edit", line_number: None, cwd: Some("."), originating_plugin: None })), Some("Editing: /file/to/edit"), 10), UpdatePaneInfo(PaneManifest { panes: {0: [PaneInfo { id: 0, is_plugin: false, is_focused: true, is_fullscreen: false, is_floating: false, is_suppressed: false, title: "Pane #1", exited: false, exit_status: None, is_held: false, pane_x: 0, pane_content_x: 1, pane_y: 0, pane_content_y: 1, pane_rows: 20, pane_content_rows: 18, pane_columns: 61, pane_content_columns: 59, cursor_coordinates_in_pane: Some((1, 1)), terminal_command: None, plugin_url: None, is_selectable: true, pid: 0, startup_cwd: None }, PaneInfo { id: 1, is_plugin: false, is_focused: false, is_fullscreen: false, is_floating: false, is_suppressed: false, title: "Pane #2", exited: false, exit_status: None, is_held: false, pane_x: 61, pane_content_x: 62, pane_y: 0, pane_content_y: 1, pane_rows: 20, pane_content_rows: 18, pane_columns: 60, pane_content_columns: 58, cursor_coordinates_in_pane: Some((1, 1)), terminal_command: None, plugin_url: None, is_selectable: true, pid: 0, startup_cwd: None }]} }), UpdateActivePane(Some(Terminal(0)), 1), UpdateActivePane(Some(Terminal(0)), 1), Exit] diff --git a/zellij-server/src/unit/snapshots/zellij_server__screen__screen_tests__send_cli_new_pane_action_with_default_parameters.snap b/zellij-server/src/unit/snapshots/zellij_server__screen__screen_tests__send_cli_new_pane_action_with_default_parameters.snap index 927f14f84f..282d7b3a91 100644 --- a/zellij-server/src/unit/snapshots/zellij_server__screen__screen_tests__send_cli_new_pane_action_with_default_parameters.snap +++ b/zellij-server/src/unit/snapshots/zellij_server__screen__screen_tests__send_cli_new_pane_action_with_default_parameters.snap @@ -3,4 +3,4 @@ source: zellij-server/src/./unit/screen_tests.rs expression: "format!(\"{:?}\", * received_pty_instructions.lock().unwrap())" snapshot_kind: text --- -[SpawnTerminal(None, Some(false), None, None, false, ClientId(10)), UpdatePaneInfo(PaneManifest { panes: {0: [PaneInfo { id: 0, is_plugin: false, is_focused: true, is_fullscreen: false, is_floating: false, is_suppressed: false, title: "Pane #1", exited: false, exit_status: None, is_held: false, pane_x: 0, pane_content_x: 1, pane_y: 0, pane_content_y: 1, pane_rows: 20, pane_content_rows: 18, pane_columns: 61, pane_content_columns: 59, cursor_coordinates_in_pane: Some((1, 1)), terminal_command: None, plugin_url: None, is_selectable: true, pid: 0, cwd: None, tty: None }, PaneInfo { id: 1, is_plugin: false, is_focused: false, is_fullscreen: false, is_floating: false, is_suppressed: false, title: "Pane #2", exited: false, exit_status: None, is_held: false, pane_x: 61, pane_content_x: 62, pane_y: 0, pane_content_y: 1, pane_rows: 20, pane_content_rows: 18, pane_columns: 60, pane_content_columns: 58, cursor_coordinates_in_pane: Some((1, 1)), terminal_command: None, plugin_url: None, is_selectable: true, pid: 0, cwd: None, tty: None }]} }), UpdateActivePane(Some(Terminal(0)), 1), UpdateActivePane(Some(Terminal(0)), 1), Exit] +[SpawnTerminal(None, Some(false), None, None, false, ClientId(10)), UpdatePaneInfo(PaneManifest { panes: {0: [PaneInfo { id: 0, is_plugin: false, is_focused: true, is_fullscreen: false, is_floating: false, is_suppressed: false, title: "Pane #1", exited: false, exit_status: None, is_held: false, pane_x: 0, pane_content_x: 1, pane_y: 0, pane_content_y: 1, pane_rows: 20, pane_content_rows: 18, pane_columns: 61, pane_content_columns: 59, cursor_coordinates_in_pane: Some((1, 1)), terminal_command: None, plugin_url: None, is_selectable: true, pid: 0, startup_cwd: None }, PaneInfo { id: 1, is_plugin: false, is_focused: false, is_fullscreen: false, is_floating: false, is_suppressed: false, title: "Pane #2", exited: false, exit_status: None, is_held: false, pane_x: 61, pane_content_x: 62, pane_y: 0, pane_content_y: 1, pane_rows: 20, pane_content_rows: 18, pane_columns: 60, pane_content_columns: 58, cursor_coordinates_in_pane: Some((1, 1)), terminal_command: None, plugin_url: None, is_selectable: true, pid: 0, startup_cwd: None }]} }), UpdateActivePane(Some(Terminal(0)), 1), UpdateActivePane(Some(Terminal(0)), 1), Exit] diff --git a/zellij-server/src/unit/snapshots/zellij_server__screen__screen_tests__send_cli_new_pane_action_with_floating_pane_and_coordinates.snap b/zellij-server/src/unit/snapshots/zellij_server__screen__screen_tests__send_cli_new_pane_action_with_floating_pane_and_coordinates.snap index 175bee32e2..139808c520 100644 --- a/zellij-server/src/unit/snapshots/zellij_server__screen__screen_tests__send_cli_new_pane_action_with_floating_pane_and_coordinates.snap +++ b/zellij-server/src/unit/snapshots/zellij_server__screen__screen_tests__send_cli_new_pane_action_with_floating_pane_and_coordinates.snap @@ -4,4 +4,4 @@ assertion_line: 2371 expression: "format!(\"{:?}\", * received_pty_instructions.lock().unwrap())" snapshot_kind: text --- -[SpawnTerminal(Some(RunCommand(RunCommand { command: "htop", args: [], cwd: Some("/some/folder"), hold_on_close: true, hold_on_start: false, originating_plugin: None })), Some(true), None, Some(FloatingPaneCoordinates { x: Some(Fixed(10)), y: None, width: Some(Percent(20)), height: None, pinned: None }), false, ClientId(10)), UpdatePaneInfo(PaneManifest { panes: {0: [PaneInfo { id: 0, is_plugin: false, is_focused: true, is_fullscreen: false, is_floating: false, is_suppressed: false, title: "Pane #1", exited: false, exit_status: None, is_held: false, pane_x: 0, pane_content_x: 1, pane_y: 0, pane_content_y: 1, pane_rows: 20, pane_content_rows: 18, pane_columns: 61, pane_content_columns: 59, cursor_coordinates_in_pane: Some((1, 1)), terminal_command: None, plugin_url: None, is_selectable: true, pid: 0, cwd: None, tty: None }, PaneInfo { id: 1, is_plugin: false, is_focused: false, is_fullscreen: false, is_floating: false, is_suppressed: false, title: "Pane #2", exited: false, exit_status: None, is_held: false, pane_x: 61, pane_content_x: 62, pane_y: 0, pane_content_y: 1, pane_rows: 20, pane_content_rows: 18, pane_columns: 60, pane_content_columns: 58, cursor_coordinates_in_pane: Some((1, 1)), terminal_command: None, plugin_url: None, is_selectable: true, pid: 0, cwd: None, tty: None }]} }), UpdateActivePane(Some(Terminal(0)), 1), UpdateActivePane(Some(Terminal(0)), 1), Exit] +[SpawnTerminal(Some(RunCommand(RunCommand { command: "htop", args: [], cwd: Some("/some/folder"), hold_on_close: true, hold_on_start: false, originating_plugin: None })), Some(true), None, Some(FloatingPaneCoordinates { x: Some(Fixed(10)), y: None, width: Some(Percent(20)), height: None, pinned: None }), false, ClientId(10)), UpdatePaneInfo(PaneManifest { panes: {0: [PaneInfo { id: 0, is_plugin: false, is_focused: true, is_fullscreen: false, is_floating: false, is_suppressed: false, title: "Pane #1", exited: false, exit_status: None, is_held: false, pane_x: 0, pane_content_x: 1, pane_y: 0, pane_content_y: 1, pane_rows: 20, pane_content_rows: 18, pane_columns: 61, pane_content_columns: 59, cursor_coordinates_in_pane: Some((1, 1)), terminal_command: None, plugin_url: None, is_selectable: true, pid: 0, startup_cwd: None }, PaneInfo { id: 1, is_plugin: false, is_focused: false, is_fullscreen: false, is_floating: false, is_suppressed: false, title: "Pane #2", exited: false, exit_status: None, is_held: false, pane_x: 61, pane_content_x: 62, pane_y: 0, pane_content_y: 1, pane_rows: 20, pane_content_rows: 18, pane_columns: 60, pane_content_columns: 58, cursor_coordinates_in_pane: Some((1, 1)), terminal_command: None, plugin_url: None, is_selectable: true, pid: 0, startup_cwd: None }]} }), UpdateActivePane(Some(Terminal(0)), 1), UpdateActivePane(Some(Terminal(0)), 1), Exit] diff --git a/zellij-server/src/unit/snapshots/zellij_server__screen__screen_tests__send_cli_new_pane_action_with_split_direction.snap b/zellij-server/src/unit/snapshots/zellij_server__screen__screen_tests__send_cli_new_pane_action_with_split_direction.snap index 0695cead11..f56c69168e 100644 --- a/zellij-server/src/unit/snapshots/zellij_server__screen__screen_tests__send_cli_new_pane_action_with_split_direction.snap +++ b/zellij-server/src/unit/snapshots/zellij_server__screen__screen_tests__send_cli_new_pane_action_with_split_direction.snap @@ -3,4 +3,4 @@ source: zellij-server/src/./unit/screen_tests.rs expression: "format!(\"{:?}\", * received_pty_instructions.lock().unwrap())" snapshot_kind: text --- -[SpawnTerminalVertically(None, None, 10), UpdatePaneInfo(PaneManifest { panes: {0: [PaneInfo { id: 0, is_plugin: false, is_focused: true, is_fullscreen: false, is_floating: false, is_suppressed: false, title: "Pane #1", exited: false, exit_status: None, is_held: false, pane_x: 0, pane_content_x: 1, pane_y: 0, pane_content_y: 1, pane_rows: 20, pane_content_rows: 18, pane_columns: 61, pane_content_columns: 59, cursor_coordinates_in_pane: Some((1, 1)), terminal_command: None, plugin_url: None, is_selectable: true, pid: 0, cwd: None, tty: None }, PaneInfo { id: 1, is_plugin: false, is_focused: false, is_fullscreen: false, is_floating: false, is_suppressed: false, title: "Pane #2", exited: false, exit_status: None, is_held: false, pane_x: 61, pane_content_x: 62, pane_y: 0, pane_content_y: 1, pane_rows: 20, pane_content_rows: 18, pane_columns: 60, pane_content_columns: 58, cursor_coordinates_in_pane: Some((1, 1)), terminal_command: None, plugin_url: None, is_selectable: true, pid: 0, cwd: None, tty: None }]} }), UpdateActivePane(Some(Terminal(0)), 1), UpdateActivePane(Some(Terminal(0)), 1), Exit] +[SpawnTerminalVertically(None, None, 10), UpdatePaneInfo(PaneManifest { panes: {0: [PaneInfo { id: 0, is_plugin: false, is_focused: true, is_fullscreen: false, is_floating: false, is_suppressed: false, title: "Pane #1", exited: false, exit_status: None, is_held: false, pane_x: 0, pane_content_x: 1, pane_y: 0, pane_content_y: 1, pane_rows: 20, pane_content_rows: 18, pane_columns: 61, pane_content_columns: 59, cursor_coordinates_in_pane: Some((1, 1)), terminal_command: None, plugin_url: None, is_selectable: true, pid: 0, startup_cwd: None }, PaneInfo { id: 1, is_plugin: false, is_focused: false, is_fullscreen: false, is_floating: false, is_suppressed: false, title: "Pane #2", exited: false, exit_status: None, is_held: false, pane_x: 61, pane_content_x: 62, pane_y: 0, pane_content_y: 1, pane_rows: 20, pane_content_rows: 18, pane_columns: 60, pane_content_columns: 58, cursor_coordinates_in_pane: Some((1, 1)), terminal_command: None, plugin_url: None, is_selectable: true, pid: 0, startup_cwd: None }]} }), UpdateActivePane(Some(Terminal(0)), 1), UpdateActivePane(Some(Terminal(0)), 1), Exit] diff --git a/zellij-utils/assets/prost/api.event.rs b/zellij-utils/assets/prost/api.event.rs index 6c126b1a94..dbebdb8139 100644 --- a/zellij-utils/assets/prost/api.event.rs +++ b/zellij-utils/assets/prost/api.event.rs @@ -256,7 +256,9 @@ pub struct MouseEventPayload { #[prost(enumeration = "MouseEventName", tag = "1")] pub mouse_event_name: i32, #[prost(oneof = "mouse_event_payload::MouseEventPayload", tags = "2, 3")] - pub mouse_event_payload: ::core::option::Option, + pub mouse_event_payload: ::core::option::Option< + mouse_event_payload::MouseEventPayload, + >, } /// Nested message and enum types in `MouseEventPayload`. pub mod mouse_event_payload { @@ -383,9 +385,7 @@ pub struct PaneInfo { #[prost(int32, tag = "23")] pub pid: i32, #[prost(string, optional, tag = "24")] - pub cwd: ::core::option::Option<::prost::alloc::string::String>, - #[prost(string, optional, tag = "25")] - pub tty: ::core::option::Option<::prost::alloc::string::String>, + pub startup_cwd: ::core::option::Option<::prost::alloc::string::String>, } #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] diff --git a/zellij-utils/src/data.rs b/zellij-utils/src/data.rs index 12792b1872..a498de263e 100644 --- a/zellij-utils/src/data.rs +++ b/zellij-utils/src/data.rs @@ -1362,9 +1362,7 @@ pub struct PaneInfo { /// The PID of the process running in this pane pub pid: i32, /// The working dir of the process running in this pane - pub cwd: Option, - /// The used TTY, if we are able to parse it. For now, only available on Linux - pub tty: Option, + pub startup_cwd: Option, } #[derive(Debug, Clone, PartialEq, Eq, Deserialize, Serialize)] diff --git a/zellij-utils/src/kdl/mod.rs b/zellij-utils/src/kdl/mod.rs index a1a8008e83..68da5fdbf0 100644 --- a/zellij-utils/src/kdl/mod.rs +++ b/zellij-utils/src/kdl/mod.rs @@ -4470,8 +4470,7 @@ impl PaneInfo { is_selectable, // These are runtime-dependent and will be filled out by Pty upon request pid: -1, - cwd: None, - tty: None, + startup_cwd: None, }; Ok((tab_position, pane_info)) } @@ -4621,8 +4620,7 @@ fn serialize_and_deserialize_session_info_with_data() { is_selectable: true, // These are runtime-dependent and will be filled out by Pty upon request pid: -1, - cwd: None, - tty: None, + startup_cwd: None, }, PaneInfo { id: 1, @@ -4649,8 +4647,7 @@ fn serialize_and_deserialize_session_info_with_data() { is_selectable: true, // These are runtime-dependent and will be filled out by Pty upon request pid: -1, - cwd: None, - tty: None, + startup_cwd: None, }, ]; let mut panes = HashMap::new(); diff --git a/zellij-utils/src/plugin_api/event.proto b/zellij-utils/src/plugin_api/event.proto index 408ab9a904..1a2f52c183 100644 --- a/zellij-utils/src/plugin_api/event.proto +++ b/zellij-utils/src/plugin_api/event.proto @@ -291,8 +291,7 @@ message PaneInfo { optional string plugin_url = 21; bool is_selectable = 22; int32 pid = 23; - optional string cwd = 24; - optional string tty = 25; + optional string startup_cwd = 24; } message TabInfo { diff --git a/zellij-utils/src/plugin_api/event.rs b/zellij-utils/src/plugin_api/event.rs index 9ab6e2123d..38057140b5 100644 --- a/zellij-utils/src/plugin_api/event.rs +++ b/zellij-utils/src/plugin_api/event.rs @@ -1014,8 +1014,7 @@ impl TryFrom for PaneInfo { plugin_url: protobuf_pane_info.plugin_url, is_selectable: protobuf_pane_info.is_selectable, pid: protobuf_pane_info.pid, - cwd: protobuf_pane_info.cwd, - tty: protobuf_pane_info.tty, + startup_cwd: protobuf_pane_info.startup_cwd, }) } } @@ -1052,8 +1051,7 @@ impl TryFrom for ProtobufPaneInfo { plugin_url: pane_info.plugin_url, is_selectable: pane_info.is_selectable, pid: pane_info.pid, - cwd: pane_info.cwd, - tty: pane_info.tty, + startup_cwd: pane_info.startup_cwd, }) } } @@ -1802,8 +1800,7 @@ fn serialize_session_update_event_with_non_default_values() { is_selectable: true, // These are runtime-dependent and will be filled out by Pty upon request pid: 0, - cwd: None, - tty: None, + startup_cwd: None, }, PaneInfo { id: 1, @@ -1830,8 +1827,7 @@ fn serialize_session_update_event_with_non_default_values() { is_selectable: true, // These are runtime-dependent and will be filled out by Pty upon request pid: 0, - cwd: None, - tty: None, + startup_cwd: None, }, ]; panes.insert(0, panes_list);