aboutsummaryrefslogtreecommitdiffstats
path: root/zellij-server/src
diff options
context:
space:
mode:
authorYacine Hmito <6893840+yacinehmito@users.noreply.github.com>2026-03-09 14:55:14 +0100
committerGitHub <noreply@github.com>2026-03-09 14:55:14 +0100
commit0172836fda1eb97005ec536571714998f48ad2e2 (patch)
tree76aa93a7f7d2bc9e7453a80e2a95af63a63ea68a /zellij-server/src
parentRemove unnecessary winapi features (#4816) (diff)
downloadsl0ppij-0172836fda1eb97005ec536571714998f48ad2e2.tar.gz
sl0ppij-0172836fda1eb97005ec536571714998f48ad2e2.tar.xz
sl0ppij-0172836fda1eb97005ec536571714998f48ad2e2.zip
feat(cli): add --pane-id option to dump-screen action (#4598)
* feat(cli): add --pane-id option to dump-screen action Adds the ability to dump a specific terminal pane's content by passing `--pane-id <ID>` to the `dump-screen` CLI action. When omitted, the existing behavior of dumping the focused pane is preserved. This enables coding agents running inside Zellij to inspect the content of other panes programmatically, without needing complex workarounds. Prior art: https://github.com/theslyprofessor/zellij-pane-tracker, whose design complexity is due to current limitations that this PR addresses. * address review * improve man page entry
Diffstat (limited to 'zellij-server/src')
-rw-r--r--zellij-server/src/route.rs2
-rw-r--r--zellij-server/src/screen.rs41
-rw-r--r--zellij-server/src/unit/screen_tests.rs1
3 files changed, 33 insertions, 11 deletions
diff --git a/zellij-server/src/route.rs b/zellij-server/src/route.rs
index 4289cb6d..f6ee7949 100644
--- a/zellij-server/src/route.rs
+++ b/zellij-server/src/route.rs
@@ -426,12 +426,14 @@ pub(crate) fn route_action(
Action::DumpScreen {
file_path,
include_scrollback,
+ pane_id,
} => {
senders
.send_to_screen(ScreenInstruction::DumpScreen(
file_path,
client_id,
include_scrollback,
+ pane_id.map(|p| p.into()),
Some(NotificationEnd::new(completion_tx)),
))
.with_context(err_context)?;
diff --git a/zellij-server/src/screen.rs b/zellij-server/src/screen.rs
index 2e2e295d..581a98d2 100644
--- a/zellij-server/src/screen.rs
+++ b/zellij-server/src/screen.rs
@@ -300,7 +300,13 @@ pub enum ScreenInstruction {
MovePaneLeft(ClientId, Option<NotificationEnd>),
Exit,
ClearScreen(ClientId, Option<NotificationEnd>),
- DumpScreen(String, ClientId, bool, Option<NotificationEnd>),
+ DumpScreen(
+ String,
+ ClientId,
+ bool,
+ Option<PaneId>,
+ Option<NotificationEnd>,
+ ),
DumpLayout(Option<PathBuf>, ClientId, Option<NotificationEnd>), // PathBuf is the default configured
// shell
SaveSession(ClientId, Option<NotificationEnd>),
@@ -5122,19 +5128,32 @@ pub(crate) fn screen_thread_main(
file,
client_id,
full,
+ pane_id,
_completion_tx, // the action ends here, dropping this will release anything
// waiting for it
) => {
- active_tab_and_connected_client_id!(
- screen,
- client_id,
- |tab: &mut Tab, client_id: ClientId| tab.dump_active_terminal_screen(
- Some(file.to_string()),
- client_id,
- full
- ),
- ?
- );
+ match pane_id {
+ Some(pane_id) => {
+ for tab in screen.get_tabs_mut().values_mut() {
+ if tab.has_pane_with_pid(&pane_id) {
+ tab.dump_terminal_screen(Some(file.clone()), pane_id, full)?;
+ break;
+ }
+ }
+ },
+ None => {
+ active_tab_and_connected_client_id!(
+ screen,
+ client_id,
+ |tab: &mut Tab, client_id: ClientId| tab.dump_active_terminal_screen(
+ Some(file.to_string()),
+ client_id,
+ full
+ ),
+ ?
+ );
+ },
+ }
screen.render(None)?;
},
ScreenInstruction::DumpLayout(default_shell, client_id, completion_tx) => {
diff --git a/zellij-server/src/unit/screen_tests.rs b/zellij-server/src/unit/screen_tests.rs
index 2536ee85..b7a9bb7e 100644
--- a/zellij-server/src/unit/screen_tests.rs
+++ b/zellij-server/src/unit/screen_tests.rs
@@ -2437,6 +2437,7 @@ pub fn send_cli_dump_screen_action() {
let cli_action = CliAction::DumpScreen {
path: PathBuf::from("/tmp/foo"),
full: true,
+ pane_id: None,
};
let _ = mock_screen.to_screen.send(ScreenInstruction::PtyBytes(
0,