diff options
| author | Aram Drevekenin <aram@poor.dev> | 2024-09-20 15:38:20 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-09-20 15:38:20 +0200 |
| commit | ce8e3995df9e554250543e1a8d90e2e053e3dbec (patch) | |
| tree | 5c2be78e50d0fac36f118931c5112dee5ef6fe16 /src | |
| parent | docs(changelog): break multiple panes APIs (diff) | |
| download | sl0ppij-ce8e3995df9e554250543e1a8d90e2e053e3dbec.tar.gz sl0ppij-ce8e3995df9e554250543e1a8d90e2e053e3dbec.tar.xz sl0ppij-ce8e3995df9e554250543e1a8d90e2e053e3dbec.zip | |
feat(config): allow loading background plugins on startup (#3616)
* remove old partial implementation
* feat(plugins): allow loading background plugins on startup
* add e2e test
* update config
* udpate config merging
* style(fmt): rustfmt
Diffstat (limited to 'src')
| -rw-r--r-- | src/tests/e2e/cases.rs | 52 | ||||
| -rw-r--r-- | src/tests/e2e/remote_runner.rs | 4 | ||||
| -rw-r--r-- | src/tests/e2e/snapshots/zellij__tests__e2e__cases__load_plugins_in_background_on_startup.snap | 29 | ||||
| -rw-r--r-- | src/tests/fixtures/configs/load_background_plugins.kdl | 392 |
4 files changed, 477 insertions, 0 deletions
diff --git a/src/tests/e2e/cases.rs b/src/tests/e2e/cases.rs index eec66096..5103d656 100644 --- a/src/tests/e2e/cases.rs +++ b/src/tests/e2e/cases.rs @@ -2371,3 +2371,55 @@ pub fn send_command_through_the_cli() { let last_snapshot = account_for_races_in_snapshot(last_snapshot); assert_snapshot!(last_snapshot); } + +#[test] +#[ignore] +pub fn load_plugins_in_background_on_startup() { + let fake_win_size = Size { + cols: 120, + rows: 24, + }; + let config_file_name = "load_background_plugins.kdl"; + let mut test_attempts = 10; + let mut test_timed_out = false; + let last_snapshot = loop { + RemoteRunner::kill_running_sessions(fake_win_size); + let mut runner = + RemoteRunner::new_with_config(fake_win_size, config_file_name).add_step(Step { + name: "Wait for plugin to load and request permissions", + instruction: |mut remote_terminal: RemoteTerminal| -> bool { + let mut step_is_complete = false; + if remote_terminal.snapshot_contains("Allow? (y/n)") { + std::thread::sleep(std::time::Duration::from_millis(100)); + remote_terminal.send_key("y".as_bytes()); + step_is_complete = true; + } + step_is_complete + }, + }); + runner.run_all_steps(); + let last_snapshot = runner.take_snapshot_after(Step { + name: "Wait for plugin to disappear after permissions were granted", + instruction: |mut remote_terminal: RemoteTerminal| -> bool { + let mut step_is_complete = false; + if !remote_terminal.snapshot_contains("Allow? (y/n)") { + step_is_complete = true; + } + step_is_complete + }, + }); + if runner.test_timed_out && test_attempts > 0 { + test_attempts -= 1; + continue; + } else { + test_timed_out = runner.test_timed_out; + break last_snapshot; + } + }; + let last_snapshot = account_for_races_in_snapshot(last_snapshot); + assert!( + !test_timed_out, + "Test timed out, possibly waiting for permission request" + ); + assert_snapshot!(last_snapshot); +} diff --git a/src/tests/e2e/remote_runner.rs b/src/tests/e2e/remote_runner.rs index 49cdf64e..40feeb21 100644 --- a/src/tests/e2e/remote_runner.rs +++ b/src/tests/e2e/remote_runner.rs @@ -67,9 +67,13 @@ fn stop_zellij(channel: &mut ssh2::Channel) { channel.write_all(b"rm -rf /tmp/*\n").unwrap(); // remove temporary artifacts from previous // tests channel.write_all(b"rm -rf /tmp/*\n").unwrap(); // remove temporary artifacts from previous + channel.write_all(b"rm -rf /tmp/*\n").unwrap(); // remove temporary artifacts from previous channel .write_all(b"rm -rf ~/.cache/zellij/*/session_info\n") .unwrap(); + channel + .write_all(b"rm -rf ~/.cache/zellij/permissions.kdl\n") + .unwrap(); } fn start_zellij(channel: &mut ssh2::Channel) { diff --git a/src/tests/e2e/snapshots/zellij__tests__e2e__cases__load_plugins_in_background_on_startup.snap b/src/tests/e2e/snapshots/zellij__tests__e2e__cases__load_plugins_in_background_on_startup.snap new file mode 100644 index 00000000..cabf017a --- /dev/null +++ b/src/tests/e2e/snapshots/zellij__tests__e2e__cases__load_plugins_in_background_on_startup.snap @@ -0,0 +1,29 @@ +--- +source: src/tests/e2e/cases.rs +assertion_line: 2426 +expression: last_snapshot +--- + Zellij (e2e-test) Tab #1 +┌ Pane #1 ─────────────────────────────────────────────────────────────────────────────────────────────────────────────┐ +│$ █ │ +│ │ +│ │ +│ │ +│ │ +│ │ +│ │ +│ │ +│ │ +│ │ +│ │ +│ │ +│ │ +│ │ +│ │ +│ │ +│ │ +│ │ +│ │ +│ │ +└──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘ + Ctrl g UNLOCK Alt + <n> New Pane <←↓↑→> Change Focus <f> Floating diff --git a/src/tests/fixtures/configs/load_background_plugins.kdl b/src/tests/fixtures/configs/load_background_plugins.kdl new file mode 100644 index 00000000..dc270d9f --- /dev/null +++ b/src/tests/fixtures/configs/load_background_plugins.kdl @@ -0,0 +1,392 @@ +keybinds clear-defaults=true { + locked { + bind "Ctrl g" { SwitchToMode "normal"; } + } + pane { + bind "left" { MoveFocus "left"; } + bind "down" { MoveFocus "down"; } + bind "up" { MoveFocus "up"; } + bind "right" { MoveFocus "right"; } + bind "c" { SwitchToMode "renamepane"; PaneNameInput 0; } + bind "d" { NewPane "down"; SwitchToMode "locked"; } + bind "e" { TogglePaneEmbedOrFloating; SwitchToMode "locked"; } + bind "f" { ToggleFocusFullscreen; SwitchToMode "locked"; } + bind "h" { MoveFocus "left"; } + bind "j" { MoveFocus "down"; } + bind "k" { MoveFocus "up"; } + bind "l" { MoveFocus "right"; } + bind "n" { NewPane; SwitchToMode "locked"; } + bind "p" { SwitchToMode "normal"; } + bind "r" { NewPane "right"; SwitchToMode "locked"; } + bind "w" { ToggleFloatingPanes; SwitchToMode "locked"; } + bind "x" { CloseFocus; SwitchToMode "locked"; } + bind "z" { TogglePaneFrames; SwitchToMode "locked"; } + bind "tab" { SwitchFocus; } + } + tab { + bind "left" { GoToPreviousTab; } + bind "down" { GoToNextTab; } + bind "up" { GoToPreviousTab; } + bind "right" { GoToNextTab; } + bind "1" { GoToTab 1; SwitchToMode "locked"; } + bind "2" { GoToTab 2; SwitchToMode "locked"; } + bind "3" { GoToTab 3; SwitchToMode "locked"; } + bind "4" { GoToTab 4; SwitchToMode "locked"; } + bind "5" { GoToTab 5; SwitchToMode "locked"; } + bind "6" { GoToTab 6; SwitchToMode "locked"; } + bind "7" { GoToTab 7; SwitchToMode "locked"; } + bind "8" { GoToTab 8; SwitchToMode "locked"; } + bind "9" { GoToTab 9; SwitchToMode "locked"; } + bind "[" { BreakPaneLeft; SwitchToMode "locked"; } + bind "]" { BreakPaneRight; SwitchToMode "locked"; } + bind "b" { BreakPane; SwitchToMode "locked"; } + bind "h" { GoToPreviousTab; } + bind "j" { GoToNextTab; } + bind "k" { GoToPreviousTab; } + bind "l" { GoToNextTab; } + bind "n" { NewTab; SwitchToMode "locked"; } + bind "r" { SwitchToMode "renametab"; TabNameInput 0; } + bind "s" { ToggleActiveSyncTab; SwitchToMode "locked"; } + bind "t" { SwitchToMode "normal"; } + bind "x" { CloseTab; SwitchToMode "locked"; } + bind "tab" { ToggleTab; } + } + resize { + bind "left" { Resize "Increase left"; } + bind "down" { Resize "Increase down"; } + bind "up" { Resize "Increase up"; } + bind "right" { Resize "Increase right"; } + bind "+" { Resize "Increase"; } + bind "-" { Resize "Decrease"; } + bind "=" { Resize "Increase"; } + bind "H" { Resize "Decrease left"; } + bind "J" { Resize "Decrease down"; } + bind "K" { Resize "Decrease up"; } + bind "L" { Resize "Decrease right"; } + bind "h" { Resize "Increase left"; } + bind "j" { Resize "Increase down"; } + bind "k" { Resize "Increase up"; } + bind "l" { Resize "Increase right"; } + bind "r" { SwitchToMode "normal"; } + } + move { + bind "left" { MovePane "left"; } + bind "down" { MovePane "down"; } + bind "up" { MovePane "up"; } + bind "right" { MovePane "right"; } + bind "h" { MovePane "left"; } + bind "j" { MovePane "down"; } + bind "k" { MovePane "up"; } + bind "l" { MovePane "right"; } + bind "m" { SwitchToMode "normal"; } + bind "n" { MovePane; } + bind "p" { MovePaneBackwards; } + bind "tab" { MovePane; } + } + scroll { + bind "e" { EditScrollback; SwitchToMode "locked"; } + bind "f" { SwitchToMode "entersearch"; SearchInput 0; } + bind "s" { SwitchToMode "normal"; } + } + search { + bind "c" { SearchToggleOption "CaseSensitivity"; } + bind "n" { Search "down"; } + bind "o" { SearchToggleOption "WholeWord"; } + bind "p" { Search "up"; } + bind "w" { SearchToggleOption "Wrap"; } + } + session { + bind "c" { + LaunchOrFocusPlugin "configuration" { + floating true + move_to_focused_tab true + } + SwitchToMode "locked" + } + bind "d" { Detach; } + bind "o" { SwitchToMode "normal"; } + bind "Ctrl s" { SwitchToMode "scroll"; } + bind "w" { + LaunchOrFocusPlugin "session-manager" { + floating true + move_to_focused_tab true + } + SwitchToMode "locked" + } + } + shared_among "normal" "locked" { + bind "Alt left" { MoveFocusOrTab "left"; } + bind "Alt down" { MoveFocus "down"; } + bind "Alt up" { MoveFocus "up"; } + bind "Alt right" { MoveFocusOrTab "right"; } + bind "Alt +" { Resize "Increase"; } + bind "Alt -" { Resize "Decrease"; } + bind "Alt =" { Resize "Increase"; } + bind "Alt [" { PreviousSwapLayout; } + bind "Alt ]" { NextSwapLayout; } + bind "Alt f" { ToggleFloatingPanes; } + bind "Alt w" { + LaunchPlugin "filepicker" { + close_on_selection true + } + } + bind "Alt h" { MoveFocusOrTab "left"; } + bind "Alt i" { MoveTab "left"; } + bind "Alt j" { MoveFocus "down"; } + bind "Alt k" { MoveFocus "up"; } + bind "Alt l" { MoveFocusOrTab "right"; } + bind "Alt n" { NewPane; } + bind "Alt o" { MoveTab "right"; } + } + shared_except "locked" "renametab" "renamepane" { + bind "Ctrl g" { SwitchToMode "locked"; } + bind "Ctrl q" { Quit; } + } + shared_except "locked" "entersearch" { + bind "enter" { SwitchToMode "locked"; } + } + shared_except "locked" "entersearch" "renametab" "renamepane" "move" { + bind "m" { SwitchToMode "move"; } + } + shared_except "locked" "entersearch" "search" "renametab" "renamepane" "session" { + bind "o" { SwitchToMode "session"; } + } + shared_except "locked" "tab" "entersearch" "renametab" "renamepane" { + bind "t" { SwitchToMode "tab"; } + } + shared_except "locked" "tab" "scroll" "entersearch" "renametab" "renamepane" { + bind "s" { SwitchToMode "scroll"; } + } + shared_except "locked" "pane" "entersearch" "search" "renametab" "renamepane" "move" { + bind "p" { SwitchToMode "pane"; } + } + shared_except "locked" "resize" "pane" "tab" "entersearch" "renametab" "renamepane" { + bind "r" { SwitchToMode "resize"; } + } + shared_among "scroll" "search" { + bind "PageDown" { PageScrollDown; } + bind "PageUp" { PageScrollUp; } + bind "left" { PageScrollUp; } + bind "down" { ScrollDown; } + bind "up" { ScrollUp; } + bind "right" { PageScrollDown; } + bind "Ctrl b" { PageScrollUp; } + bind "Ctrl c" { ScrollToBottom; SwitchToMode "locked"; } + bind "d" { HalfPageScrollDown; } + bind "Ctrl f" { PageScrollDown; } + bind "h" { PageScrollUp; } + bind "j" { ScrollDown; } + bind "k" { ScrollUp; } + bind "l" { PageScrollDown; } + bind "u" { HalfPageScrollUp; } + } + entersearch { + bind "Ctrl c" { SwitchToMode "scroll"; } + bind "esc" { SwitchToMode "scroll"; } + bind "enter" { SwitchToMode "search"; } + } + renametab { + bind "esc" { UndoRenameTab; SwitchToMode "tab"; } + } + shared_among "renametab" "renamepane" { + bind "Ctrl c" { SwitchToMode "locked"; } + } + renamepane { + bind "esc" { UndoRenamePane; SwitchToMode "pane"; } + } +} +plugins { + compact-bar location="zellij:compact-bar" + configuration location="zellij:configuration" + filepicker location="zellij:strider" { + cwd "/" + } + session-manager location="zellij:session-manager" + status-bar location="zellij:status-bar" + strider location="zellij:strider" + tab-bar location="zellij:tab-bar" + welcome-screen location="zellij:session-manager" { + welcome_screen true + } +} + +load_plugins { + "file:/usr/src/zellij/wasm32-wasi/release/fixture-plugin-for-tests.wasm" { + config_key "config_value" + config_key2 "config_value2" + } +} + +// Use a simplified UI without special fonts (arrow glyphs) +// Options: +// - true +// - false (Default) +// +// simplified_ui true + +// Choose the theme that is specified in the themes section. +// Default: default +// +// theme "default" + +// Choose the base input mode of zellij. +// Default: normal +// +default_mode "locked" + +// Choose the path to the default shell that zellij will use for opening new panes +// Default: $SHELL +// +// default_shell "fish" + +// Choose the path to override cwd that zellij will use for opening new panes +// +// default_cwd "/tmp" + +// The name of the default layout to load on startup +// Default: "default" +// +// default_layout "compact" + +// The folder in which Zellij will look for layouts +// +// layout_dir "/tmp" + +// The folder in which Zellij will look for themes +// +// theme_dir "/tmp" + +// Toggle enabling the mouse mode. +// On certain configurations, or terminals this could +// potentially interfere with copying text. +// Options: +// - true (default) +// - false +// +// mouse_mode false + +// Toggle having pane frames around the panes +// Options: +// - true (default, enabled) +// - false +// +// pane_frames false + +// When attaching to an existing session with other users, +// should the session be mirrored (true) +// or should each user have their own cursor (false) +// Default: false +// +// mirror_session true + +// Choose what to do when zellij receives SIGTERM, SIGINT, SIGQUIT or SIGHUP +// eg. when terminal window with an active zellij session is closed +// Options: +// - detach (Default) +// - quit +// +// on_force_close "quit" + +// Configure the scroll back buffer size +// This is the number of lines zellij stores for each pane in the scroll back +// buffer. Excess number of lines are discarded in a FIFO fashion. +// Valid values: positive integers +// Default value: 10000 +// +// scroll_buffer_size 10000 + +// Provide a command to execute when copying text. The text will be piped to +// the stdin of the program to perform the copy. This can be used with +// terminal emulators which do not support the OSC 52 ANSI control sequence +// that will be used by default if this option is not set. +// Examples: +// +// copy_command "xclip -selection clipboard" // x11 +// copy_command "wl-copy" // wayland +// copy_command "pbcopy" // osx +// + +// Choose the destination for copied text +// Allows using the primary selection buffer (on x11/wayland) instead of the system clipboard. +// Does not apply when using copy_command. +// Options: +// - system (default) +// - primary +// +// copy_clipboard "primary" + +// Enable automatic copying (and clearing) of selection when releasing mouse +// Default: true +// +// copy_on_select true + +// Path to the default editor to use to edit pane scrollbuffer +// Default: $EDITOR or $VISUAL +// scrollback_editor "nvim" + +// A fixed name to always give the Zellij session. +// Consider also setting `attach_to_session true,` +// otherwise this will error if such a session exists. +// Default: <RANDOM> +// +// session_name "My singleton session" + +// When `session_name` is provided, attaches to that session +// if it is already running or creates it otherwise. +// Default: false +// +// attach_to_session true + +// Toggle between having Zellij lay out panes according to a predefined set of layouts whenever possible +// Options: +// - true (default) +// - false +// +// auto_layout false + +// Whether sessions should be serialized to the cache folder (including their tabs/panes, cwds and running commands) so that they can later be resurrected +// Options: +// - true (default) +// - false +// +// session_serialization false + +// Whether pane viewports are serialized along with the session, default is false +// Options: +// - true +// - false (default) +// +// serialize_pane_viewport false + +// Scrollback lines to serialize along with the pane viewport when serializing sessions, 0 +// defaults to the scrollback size. If this number is higher than the scrollback size, it will +// also default to the scrollback size. This does nothing if `serialize_pane_viewport` is not true. +// +// scrollback_lines_to_serialize 10000 + +// Enable or disable the rendering of styled and colored underlines (undercurl). +// May need to be disabled for certain unsupported terminals +// Default: true +// +// styled_underlines false + +// How often in seconds sessions are serialized +// +// serialization_interval 10000 + +// Enable or disable writing of session metadata to disk (if disabled, other sessions might not know +// metadata info on this session) +// Default: false +// +// disable_session_metadata false + +// Enable or disable support for the enhanced Kitty Keyboard Protocol (the host terminal must also support it) +// Default: true (if the host terminal supports it) +// +// support_kitty_keyboard_protocol false + + // ui { + // pane_frames { + // rounded_corners true + // } + // } |
