fix(plugins): standardize should_focus parameter when launching new plugin via pipe (#4309)

* fix(plugins): standardize should_focus parameter when launching new plugins via pipe

* docs(changelog): add PR
This commit is contained in:
Aram Drevekenin 2025-07-21 11:29:27 +02:00 committed by GitHub
parent 7d970c7090
commit 16d8e6d0ab
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 21 additions and 3 deletions

View file

@ -24,6 +24,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
* fix: account for emoji/widechars when double/triple-clicking to mark words (https://github.com/zellij-org/zellij/pull/4302)
* fix: allow pasting and emojis in tab/pane names and pasting in search (https://github.com/zellij-org/zellij/pull/4303)
* fix: stack pane ordering when stacking multiple panes (https://github.com/zellij-org/zellij/pull/4308)
* fix: normalize focusing of plugins launched through pipes (https://github.com/zellij-org/zellij/pull/4309)
## [0.42.2] - 2025-04-15
* refactor(terminal): track scroll_region as tuple rather than Option (https://github.com/zellij-org/zellij/pull/4082)

View file

@ -468,6 +468,7 @@ impl NewPluginScreen {
.new_plugin_instance_should_have_pane_title(
"Select a .wasm file to load as a plugin...",
)
.new_plugin_instance_should_be_focused()
.with_args(args),
);
},

View file

@ -249,6 +249,7 @@ impl State {
.new_plugin_instance_should_have_pane_title(
"Select folder for the new session...",
)
.new_plugin_instance_should_be_focused()
.with_args(args),
);
should_render = true;

View file

@ -715,6 +715,7 @@ pub(crate) fn plugin_thread_main(
&mut wasm_bridge,
&plugin_aliases,
floating_pane_coordinates,
None,
);
},
None => {
@ -777,6 +778,7 @@ pub(crate) fn plugin_thread_main(
&mut wasm_bridge,
&plugin_aliases,
floating_pane_coordinates,
None,
);
},
None => {
@ -842,6 +844,7 @@ pub(crate) fn plugin_thread_main(
&mut wasm_bridge,
&plugin_aliases,
floating_pane_coordinates,
message.new_plugin_args.and_then(|n| n.should_focus),
);
},
(None, Some(destination_plugin_id)) => {
@ -1047,6 +1050,7 @@ fn pipe_to_specific_plugins(
wasm_bridge: &mut WasmBridge,
plugin_aliases: &PluginAliases,
floating_pane_coordinates: Option<FloatingPaneCoordinates>,
should_focus: Option<bool>,
) {
let is_private = true;
let size = Size::default();
@ -1069,6 +1073,7 @@ fn pipe_to_specific_plugins(
pane_id_to_replace.clone(),
cli_client_id,
floating_pane_coordinates,
should_focus.unwrap_or(false),
);
for (plugin_id, client_id) in all_plugin_ids {
pipe_messages.push((

View file

@ -1427,6 +1427,7 @@ impl WasmBridge {
pane_id_to_replace: Option<PaneId>,
cli_client_id: Option<ClientId>,
floating_pane_coordinates: Option<FloatingPaneCoordinates>,
should_focus: bool,
) -> Vec<(PluginId, Option<ClientId>)> {
let run_plugin = run_plugin_or_alias.get_run_plugin();
match run_plugin {
@ -1453,8 +1454,6 @@ impl WasmBridge {
) {
Ok((plugin_id, client_id)) => {
let start_suppressed = false;
let should_focus = Some(false); // we should not focus plugins that
// were started from another plugin
drop(self.senders.send_to_screen(ScreenInstruction::AddPlugin(
Some(should_float),
should_be_open_in_place,
@ -1466,7 +1465,7 @@ impl WasmBridge {
cwd,
start_suppressed,
floating_pane_coordinates,
should_focus,
Some(should_focus),
Some(client_id),
)));
vec![(plugin_id, Some(client_id))]

View file

@ -660,6 +660,8 @@ pub struct NewPluginArgs {
pub cwd: ::core::option::Option<::prost::alloc::string::String>,
#[prost(bool, tag="5")]
pub skip_cache: bool,
#[prost(bool, optional, tag="6")]
pub should_focus: ::core::option::Option<bool>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]

View file

@ -1988,6 +1988,7 @@ pub struct NewPluginArgs {
pub pane_title: Option<String>,
pub cwd: Option<PathBuf>,
pub skip_cache: bool,
pub should_focus: Option<bool>,
}
#[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, Eq, Hash, PartialOrd, Ord)]
@ -2077,6 +2078,11 @@ impl MessageToPlugin {
new_plugin_args.skip_cache = true;
self
}
pub fn new_plugin_instance_should_be_focused(mut self) -> Self {
let new_plugin_args = self.new_plugin_args.get_or_insert_with(Default::default);
new_plugin_args.should_focus = Some(true);
self
}
}
#[derive(Debug, Default, Clone, Serialize, Deserialize)]

View file

@ -545,6 +545,7 @@ message NewPluginArgs {
optional string pane_title = 3;
optional string cwd = 4;
bool skip_cache = 5;
optional bool should_focus = 6;
}
message PaneId {

View file

@ -971,6 +971,7 @@ impl TryFrom<ProtobufPluginCommand> for PluginCommand {
pane_title: protobuf_new_plugin_args.pane_title,
cwd: protobuf_new_plugin_args.cwd.map(|cwd| PathBuf::from(cwd)),
skip_cache: protobuf_new_plugin_args.skip_cache,
should_focus: protobuf_new_plugin_args.should_focus,
})
}),
destination_plugin_id,
@ -2260,6 +2261,7 @@ impl TryFrom<PluginCommand> for ProtobufPluginCommand {
pane_title: m_t_p.pane_title,
cwd: m_t_p.cwd.map(|cwd| cwd.display().to_string()),
skip_cache: m_t_p.skip_cache,
should_focus: m_t_p.should_focus,
}
}),
destination_plugin_id: message_to_plugin.destination_plugin_id,