diff options
| author | Aram Drevekenin <aram@poor.dev> | 2025-12-23 13:41:56 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-12-23 13:41:56 +0100 |
| commit | 3fe48a972c55537502128779116d38d8f8aedb7e (patch) | |
| tree | 350386442db2a46e1d8ba3d9d4dd0c7d53b34c13 /src | |
| parent | Read only web tokens (#4551) (diff) | |
| download | sl0ppij-3fe48a972c55537502128779116d38d8f8aedb7e.tar.gz sl0ppij-3fe48a972c55537502128779116d38d8f8aedb7e.tar.xz sl0ppij-3fe48a972c55537502128779116d38d8f8aedb7e.zip | |
Feature: allow overriding a layout for a currently running tab (change layout at runtime) (#4566)
* add tests for LayoutApplier
* initial untested implementation of override functions
* add override-layout cli action with stub in screen
* filter run instructions to ignore
* implement override-layout roundtrip through plugin and pty threads
* initial full-cycle working override implementation
* fix some bugs (eg. actually start new terminals)
* fix some bugs with focus after override
* fix floating pane matching bug in layout applier
* formatting
* use first tab, error on more than 1 tab
* fix some floating_panes ordering and shell issues
* get new tab name to work
* respect swap layouts
* allow specifying tab properties on main layout node if we just have one tab
* add tests for new override methods
* start work on retaining panes, hard-coded things, kind of working but broken in many places
* fixed most tiled pane override bugs
* reset viewport before reapplying
* revert constraint system changes
* retain-existing-terminal-panes flag
* add retain terminal panes tests
* add retain plugin panes flag
* add keybind
* add retain plugin panes tests
* add override-layout e2e test
* refactor: layout_applier
* style: rustfmt
* some cleanups
* fix cli flags
* no crashy
* formatting and artifacts
* moar cleanups
* fix: respect expanded in stack when overriding
* docs(changelog): add PR
Diffstat (limited to 'src')
| -rw-r--r-- | src/tests/e2e/cases.rs | 49 | ||||
| -rw-r--r-- | src/tests/e2e/remote_runner.rs | 13 | ||||
| -rw-r--r-- | src/tests/e2e/snapshots/zellij__tests__e2e__cases__override_layout_from_default_to_compact.snap | 28 |
3 files changed, 90 insertions, 0 deletions
diff --git a/src/tests/e2e/cases.rs b/src/tests/e2e/cases.rs index eab81039..f7d9ea0d 100644 --- a/src/tests/e2e/cases.rs +++ b/src/tests/e2e/cases.rs @@ -2646,6 +2646,7 @@ pub fn pin_floating_panes() { let last_snapshot = account_for_races_in_snapshot(last_snapshot); assert_snapshot!(last_snapshot); } + #[test] #[ignore] pub fn watcher_client_functionality() { @@ -2849,3 +2850,51 @@ pub fn watcher_client_functionality() { assert_snapshot!(main_client_snapshot); assert_snapshot!(watcher_snapshot); } + +#[test] +#[ignore] +pub fn override_layout_from_default_to_compact() { + let fake_win_size = Size { + cols: 120, + rows: 24, + }; + let mut test_attempts = 10; + let last_snapshot = loop { + RemoteRunner::kill_running_sessions(fake_win_size); + + let mut runner = RemoteRunner::new(fake_win_size) + .add_step(Step { + name: "Wait for default layout to load", + instruction: |remote_terminal: RemoteTerminal| -> bool { + remote_terminal.status_bar_appears() + }, + }) + .add_step(Step { + name: "Override to compact layout", + instruction: |mut remote_terminal: RemoteTerminal| -> bool { + remote_terminal.run_zellij_action("override-layout compact"); + std::thread::sleep(std::time::Duration::from_millis(500)); + remote_terminal.send_key(&ENTER); + true + }, + }); + + runner.run_all_steps(); + let last_snapshot = runner.take_snapshot_after(Step { + name: "Wait for compact layout to appear", + instruction: |remote_terminal: RemoteTerminal| -> bool { + remote_terminal.snapshot_contains("NORMAL") + }, + }); + + if runner.test_timed_out && test_attempts > 0 { + test_attempts -= 1; + continue; + } else { + break last_snapshot; + } + }; + + let last_snapshot = account_for_races_in_snapshot(last_snapshot); + assert_snapshot!(last_snapshot); +} diff --git a/src/tests/e2e/remote_runner.rs b/src/tests/e2e/remote_runner.rs index 377869f9..d4663ac5 100644 --- a/src/tests/e2e/remote_runner.rs +++ b/src/tests/e2e/remote_runner.rs @@ -419,6 +419,19 @@ impl RemoteTerminal { channel.flush().unwrap(); std::thread::sleep(std::time::Duration::from_secs(1)); // wait until Zellij stops parsing startup ANSI codes from the terminal STDIN } + pub fn run_zellij_action(&mut self, action_and_arguments: &str) { + let mut channel = self.channel.lock().unwrap(); + channel + .write_all( + format!( + "{} action {}", + ZELLIJ_EXECUTABLE_LOCATION, action_and_arguments + ) + .as_bytes(), + ) + .unwrap(); + channel.flush().unwrap(); + } pub fn send_command_through_the_cli(&mut self, command: &str) { let mut channel = self.channel.lock().unwrap(); channel diff --git a/src/tests/e2e/snapshots/zellij__tests__e2e__cases__override_layout_from_default_to_compact.snap b/src/tests/e2e/snapshots/zellij__tests__e2e__cases__override_layout_from_default_to_compact.snap new file mode 100644 index 00000000..48724fb5 --- /dev/null +++ b/src/tests/e2e/snapshots/zellij__tests__e2e__cases__override_layout_from_default_to_compact.snap @@ -0,0 +1,28 @@ +--- +source: src/tests/e2e/cases.rs +expression: last_snapshot +--- +┌ Pane #1 ─────────────────────────────────────────────────────────────────────────────────────────────────────────────┐ +│$ /usr/src/zellij/x86_64-unknown-linux-musl/release/zellij action override-layout compact │ +│$ │ +│$ █ │ +│ │ +│ │ +│ │ +│ │ +│ │ +│ │ +│ │ +│ │ +│ │ +│ │ +│ │ +│ │ +│ │ +│ │ +│ │ +│ │ +│ │ +│ │ +└──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘ + Zellij (e2e-test) NORMAL Tab #1 |
