diff options
| author | Aram Drevekenin <aram@poor.dev> | 2024-07-05 15:13:51 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-07-05 15:13:51 +0200 |
| commit | a6d6c0e4ff03c35cafb6f04363ecab856ee3682d (patch) | |
| tree | eadf1c24c4c6a1e4b7499b3cd047351fd29e52de /zellij-server/src/plugins | |
| parent | docs(changelog): wasmer -> wasmtime (diff) | |
| download | sl0ppij-a6d6c0e4ff03c35cafb6f04363ecab856ee3682d.tar.gz sl0ppij-a6d6c0e4ff03c35cafb6f04363ecab856ee3682d.tar.xz sl0ppij-a6d6c0e4ff03c35cafb6f04363ecab856ee3682d.zip | |
feat(ui): status bar redesign (#3475)
* work
* work
* working
* get default mode from server and some ui responsiveness
* work
* finish design and get tests to pass
* get e2e tests to pass
* add classic layout
* add classic layout assets
* fix e2e tests
* style(fmt): rustfmt
* fix plugin system test
* style(fmt): some cleanups
Diffstat (limited to 'zellij-server/src/plugins')
7 files changed, 45 insertions, 6 deletions
diff --git a/zellij-server/src/plugins/mod.rs b/zellij-server/src/plugins/mod.rs index 7b9f7550..639a389e 100644 --- a/zellij-server/src/plugins/mod.rs +++ b/zellij-server/src/plugins/mod.rs @@ -25,8 +25,8 @@ use wasm_bridge::WasmBridge; use zellij_utils::{ async_std::{channel, future::timeout, task}, data::{ - Event, EventType, MessageToPlugin, PermissionStatus, PermissionType, PipeMessage, - PipeSource, PluginCapabilities, + Event, EventType, InputMode, MessageToPlugin, PermissionStatus, PermissionType, + PipeMessage, PipeSource, PluginCapabilities, }, errors::{prelude::*, ContextType, PluginContext}, input::{ @@ -198,6 +198,7 @@ pub(crate) fn plugin_thread_main( client_attributes: ClientAttributes, default_shell: Option<TerminalAction>, plugin_aliases: Box<PluginAliases>, + default_mode: InputMode, ) -> Result<()> { info!("Wasm main thread starts"); let plugin_dir = data_dir.join("plugins/"); @@ -219,6 +220,7 @@ pub(crate) fn plugin_thread_main( default_shell, layout.clone(), layout_dir, + default_mode, ); loop { diff --git a/zellij-server/src/plugins/plugin_loader.rs b/zellij-server/src/plugins/plugin_loader.rs index 0a839b65..6ed36c05 100644 --- a/zellij-server/src/plugins/plugin_loader.rs +++ b/zellij-server/src/plugins/plugin_loader.rs @@ -26,7 +26,7 @@ use crate::{ use zellij_utils::plugin_api::action::ProtobufPluginConfiguration; use zellij_utils::{ consts::{ZELLIJ_CACHE_DIR, ZELLIJ_SESSION_CACHE_DIR, ZELLIJ_TMP_DIR}, - data::PluginCapabilities, + data::{InputMode, PluginCapabilities}, errors::prelude::*, input::command::TerminalAction, input::layout::Layout, @@ -68,6 +68,7 @@ pub struct PluginLoader<'a> { default_shell: Option<TerminalAction>, default_layout: Box<Layout>, layout_dir: Option<PathBuf>, + default_mode: InputMode, } impl<'a> PluginLoader<'a> { @@ -87,6 +88,7 @@ impl<'a> PluginLoader<'a> { default_shell: Option<TerminalAction>, default_layout: Box<Layout>, layout_dir: Option<PathBuf>, + default_mode: InputMode, ) -> Result<()> { let err_context = || format!("failed to reload plugin {plugin_id} from memory"); let mut connected_clients: Vec<ClientId> = @@ -112,6 +114,7 @@ impl<'a> PluginLoader<'a> { default_shell, default_layout, layout_dir, + default_mode, )?; plugin_loader .load_module_from_memory() @@ -148,6 +151,7 @@ impl<'a> PluginLoader<'a> { default_layout: Box<Layout>, skip_cache: bool, layout_dir: Option<PathBuf>, + default_mode: InputMode, ) -> Result<()> { let err_context = || format!("failed to start plugin {plugin_id} for client {client_id}"); let mut plugin_loader = PluginLoader::new( @@ -168,6 +172,7 @@ impl<'a> PluginLoader<'a> { default_shell, default_layout, layout_dir, + default_mode, )?; if skip_cache { plugin_loader @@ -220,6 +225,7 @@ impl<'a> PluginLoader<'a> { default_shell: Option<TerminalAction>, default_layout: Box<Layout>, layout_dir: Option<PathBuf>, + default_mode: InputMode, ) -> Result<()> { let mut new_plugins = HashSet::new(); for plugin_id in plugin_map.lock().unwrap().plugin_ids() { @@ -242,6 +248,7 @@ impl<'a> PluginLoader<'a> { default_shell.clone(), default_layout.clone(), layout_dir.clone(), + default_mode, )?; plugin_loader .load_module_from_memory() @@ -270,6 +277,7 @@ impl<'a> PluginLoader<'a> { default_shell: Option<TerminalAction>, default_layout: Box<Layout>, layout_dir: Option<PathBuf>, + default_mode: InputMode, ) -> Result<()> { let err_context = || format!("failed to reload plugin id {plugin_id}"); @@ -296,6 +304,7 @@ impl<'a> PluginLoader<'a> { default_shell, default_layout, layout_dir, + default_mode, )?; plugin_loader .compile_module() @@ -328,6 +337,7 @@ impl<'a> PluginLoader<'a> { default_shell: Option<TerminalAction>, default_layout: Box<Layout>, layout_dir: Option<PathBuf>, + default_mode: InputMode, ) -> Result<Self> { let plugin_own_data_dir = ZELLIJ_SESSION_CACHE_DIR .join(Url::from(&plugin.location).to_string()) @@ -355,6 +365,7 @@ impl<'a> PluginLoader<'a> { default_shell, default_layout, layout_dir, + default_mode, }) } pub fn new_from_existing_plugin_attributes( @@ -373,6 +384,7 @@ impl<'a> PluginLoader<'a> { default_shell: Option<TerminalAction>, default_layout: Box<Layout>, layout_dir: Option<PathBuf>, + default_mode: InputMode, ) -> Result<Self> { let err_context = || "Failed to find existing plugin"; let (running_plugin, _subscriptions, _workers) = { @@ -407,6 +419,7 @@ impl<'a> PluginLoader<'a> { default_shell, default_layout, layout_dir, + default_mode, ) } pub fn new_from_different_client_id( @@ -425,6 +438,7 @@ impl<'a> PluginLoader<'a> { default_shell: Option<TerminalAction>, default_layout: Box<Layout>, layout_dir: Option<PathBuf>, + default_mode: InputMode, ) -> Result<Self> { let err_context = || "Failed to find existing plugin"; let running_plugin = { @@ -460,6 +474,7 @@ impl<'a> PluginLoader<'a> { default_shell, default_layout, layout_dir, + default_mode, ) } pub fn load_module_from_memory(&mut self) -> Result<Module> { @@ -715,6 +730,7 @@ impl<'a> PluginLoader<'a> { self.default_shell.clone(), self.default_layout.clone(), self.layout_dir.clone(), + self.default_mode, )?; plugin_loader_for_client .load_module_from_memory() @@ -814,6 +830,7 @@ impl<'a> PluginLoader<'a> { input_pipes_to_unblock: Arc::new(Mutex::new(HashSet::new())), input_pipes_to_block: Arc::new(Mutex::new(HashSet::new())), layout_dir: self.layout_dir.clone(), + default_mode: self.default_mode.clone(), subscriptions: Arc::new(Mutex::new(HashSet::new())), stdin_pipe, stdout_pipe, diff --git a/zellij-server/src/plugins/plugin_map.rs b/zellij-server/src/plugins/plugin_map.rs index fb41c89e..c5ac6d5f 100644 --- a/zellij-server/src/plugins/plugin_map.rs +++ b/zellij-server/src/plugins/plugin_map.rs @@ -19,6 +19,7 @@ use crate::{thread_bus::ThreadSenders, ClientId}; use zellij_utils::async_channel::Sender; use zellij_utils::{ data::EventType, + data::InputMode, data::PluginCapabilities, input::command::TerminalAction, input::layout::{Layout, PluginUserConfiguration, RunPlugin, RunPluginLocation}, @@ -284,6 +285,7 @@ pub struct PluginEnv { pub plugin_cwd: PathBuf, pub input_pipes_to_unblock: Arc<Mutex<HashSet<String>>>, pub input_pipes_to_block: Arc<Mutex<HashSet<String>>>, + pub default_mode: InputMode, pub subscriptions: Arc<Mutex<Subscriptions>>, pub stdin_pipe: Arc<Mutex<VecDeque<u8>>>, pub stdout_pipe: Arc<Mutex<VecDeque<u8>>>, diff --git a/zellij-server/src/plugins/unit/plugin_tests.rs b/zellij-server/src/plugins/unit/plugin_tests.rs index 6743d5e7..c1f4fcd5 100644 --- a/zellij-server/src/plugins/unit/plugin_tests.rs +++ b/zellij-server/src/plugins/unit/plugin_tests.rs @@ -7,7 +7,8 @@ use std::path::PathBuf; use tempfile::tempdir; use wasmtime::Engine; use zellij_utils::data::{ - BareKey, Event, KeyWithModifier, PermissionStatus, PermissionType, PluginCapabilities, + BareKey, Event, InputMode, KeyWithModifier, PermissionStatus, PermissionType, + PluginCapabilities, }; use zellij_utils::errors::ErrorContext; use zellij_utils::input::layout::{ @@ -280,6 +281,7 @@ fn create_plugin_thread( client_attributes, default_shell_action, Box::new(plugin_aliases), + InputMode::Normal, ) .expect("TEST") }) @@ -359,6 +361,7 @@ fn create_plugin_thread_with_server_receiver( client_attributes, default_shell_action, Box::new(PluginAliases::default()), + InputMode::Normal, ) .expect("TEST"); }) @@ -444,6 +447,7 @@ fn create_plugin_thread_with_pty_receiver( client_attributes, default_shell_action, Box::new(PluginAliases::default()), + InputMode::Normal, ) .expect("TEST") }) @@ -524,6 +528,7 @@ fn create_plugin_thread_with_background_jobs_receiver( client_attributes, default_shell_action, Box::new(PluginAliases::default()), + InputMode::Normal, ) .expect("TEST") }) diff --git a/zellij-server/src/plugins/unit/snapshots/zellij_server__plugins__plugin_tests__switch_to_mode_plugin_command.snap b/zellij-server/src/plugins/unit/snapshots/zellij_server__plugins__plugin_tests__switch_to_mode_plugin_command.snap index 8d699ae6..36de9362 100644 --- a/zellij-server/src/plugins/unit/snapshots/zellij_server__plugins__plugin_tests__switch_to_mode_plugin_command.snap +++ b/zellij-server/src/plugins/unit/snapshots/zellij_server__plugins__plugin_tests__switch_to_mode_plugin_command.snap @@ -1,12 +1,15 @@ --- source: zellij-server/src/plugins/./unit/plugin_tests.rs -assertion_line: 455 +assertion_line: 1043 expression: "format!(\"{:#?}\", switch_to_mode_event)" --- Some( ChangeMode( ModeInfo { mode: Tab, + base_mode: Some( + Normal, + ), keybinds: [], style: Style { colors: Palette { diff --git a/zellij-server/src/plugins/wasm_bridge.rs b/zellij-server/src/plugins/wasm_bridge.rs index 764b757d..2abc22d3 100644 --- a/zellij-server/src/plugins/wasm_bridge.rs +++ b/zellij-server/src/plugins/wasm_bridge.rs @@ -19,7 +19,7 @@ use wasmtime::{Engine, Module}; use zellij_utils::async_channel::Sender; use zellij_utils::async_std::task::{self, JoinHandle}; use zellij_utils::consts::ZELLIJ_CACHE_DIR; -use zellij_utils::data::{PermissionStatus, PermissionType, PipeMessage, PipeSource}; +use zellij_utils::data::{InputMode, PermissionStatus, PermissionType, PipeMessage, PipeSource}; use zellij_utils::downloader::Downloader; use zellij_utils::input::permission::PermissionCache; use zellij_utils::notify_debouncer_full::{notify::RecommendedWatcher, Debouncer, FileIdMap}; @@ -102,6 +102,7 @@ pub struct WasmBridge { HashMap<RunPluginLocation, HashMap<PluginUserConfiguration, Vec<(PluginId, ClientId)>>>, pending_pipes: PendingPipes, layout_dir: Option<PathBuf>, + default_mode: InputMode, } impl WasmBridge { @@ -116,6 +117,7 @@ impl WasmBridge { default_shell: Option<TerminalAction>, default_layout: Box<Layout>, layout_dir: Option<PathBuf>, + default_mode: InputMode, ) -> Self { let plugin_map = Arc::new(Mutex::new(PluginMap::default())); let connected_clients: Arc<Mutex<Vec<ClientId>>> = Arc::new(Mutex::new(vec![])); @@ -146,6 +148,7 @@ impl WasmBridge { cached_plugin_map: HashMap::new(), pending_pipes: Default::default(), layout_dir, + default_mode, } } pub fn load_plugin( @@ -202,6 +205,7 @@ impl WasmBridge { let default_shell = self.default_shell.clone(); let default_layout = self.default_layout.clone(); let layout_dir = self.layout_dir.clone(); + let default_mode = self.default_mode; async move { let _ = senders.send_to_background_jobs( BackgroundJob::AnimatePluginLoading(plugin_id), @@ -249,6 +253,7 @@ impl WasmBridge { default_layout, skip_cache, layout_dir, + default_mode, ) { Ok(_) => handle_plugin_successful_loading(&senders, plugin_id), Err(e) => handle_plugin_loading_failure( @@ -340,6 +345,7 @@ impl WasmBridge { let default_shell = self.default_shell.clone(); let default_layout = self.default_layout.clone(); let layout_dir = self.layout_dir.clone(); + let default_mode = self.default_mode; async move { match PluginLoader::reload_plugin( first_plugin_id, @@ -357,6 +363,7 @@ impl WasmBridge { default_shell.clone(), default_layout.clone(), layout_dir.clone(), + default_mode, ) { Ok(_) => { handle_plugin_successful_loading(&senders, first_plugin_id); @@ -382,6 +389,7 @@ impl WasmBridge { default_shell.clone(), default_layout.clone(), layout_dir.clone(), + default_mode, ) { Ok(_) => handle_plugin_successful_loading(&senders, *plugin_id), Err(e) => handle_plugin_loading_failure( @@ -434,6 +442,7 @@ impl WasmBridge { self.default_shell.clone(), self.default_layout.clone(), self.layout_dir.clone(), + self.default_mode, ) { Ok(_) => { let _ = self diff --git a/zellij-server/src/plugins/zellij_exports.rs b/zellij-server/src/plugins/zellij_exports.rs index 04569238..a517df06 100644 --- a/zellij-server/src/plugins/zellij_exports.rs +++ b/zellij-server/src/plugins/zellij_exports.rs @@ -61,6 +61,7 @@ macro_rules! apply_action { $env.default_shell.clone(), $env.default_layout.clone(), None, + $env.default_mode.clone(), ) { log::error!("{}: {:?}", $error_message(), e); } |
