imsnif/multitask

Does not seem to be working

Closed this issue · 13 comments

I tried this zellij action start-or-reload-plugin file:$HOME/Downloads/multitask.wasm --configuration "shell=$SHELL,cwd=pwd" on zellij 0.40.1 on nixos 24.05.

I get a pane with an editor, but after editing and closing the editor, nothing happens.

@metaspace Depending on how your editor touches files when closing, it may not trigger the multitasks. Can you try manually running "touch .multitask" from another pane to see if that works?

Note, there is a patch that fixes this issue already on main, but it has not been released yet. It will be once I get around to releasing the new package for the newest release of zellij (041.1 at the time of writing this).

EDIT: Potentially relevant issue with the patch I was discussing is located here: #10

Thanks, that seems to work!

I have another problem now though, so hijacking this issue.

I'm loading the thing like so: zellij action start-or-reload-plugin file:~/.zellij-plugins/multitask.wasm --configuration "shell=$SHELL,cwd=pwd", and I get an editor.

I put in the following:

#!/run/current-system/sw/bin/zsh
#
# Hi there! Anything below these lines will be executed on save.
# One command per line.
# Place empty lines between steps that should run in parallel.
# Enjoy!

direnv exec . just l

direnv exec . just l modules 
  • The first command runs in a floating pane and the working directory seems to the current directory of the shell where I loaded the plugin. When the command completes, the pane it is embedded.
  • The second command starts running in a floating pane, but in the wrong directory. I think it starts executing in the directory of the zellij host.

If I do this:

#!/run/current-system/sw/bin/zsh

direnv exec . just l

cd /home/aeh/src/linux-rust && direnv exec .  just l modules

I get the result I expect. Is this a bug or intentional?

Also, I am struggling to bind this to a key, because it does not work without setting shell and cwd. Is there a way to bind to a key?

@metaspace Sorry for the delay here, my day job is really hectic at the moment. What you described sounds like a bug. When I have some time I'll try and reproduce. No promises on a time frame though (sorry).

I usually alias the command, e.g., to something like zm. This follows what zellij does for things like opening a run or edit pane. It doesn't look like this is specifically called out in the documentation anymore, but you can still see zrf and ze used in places like here.

I'd be interested in binding it to a key as well. I have not tried that yet, but again, can look into it when I have some time.

@metaspace I don't see anything obvious in multitask that would be responsible for the cwd-related bug. However, I do see that zellij 0.41 fixed this bug, which sounds like it could be related. When I release the next upgrade for 0.41 I'll check before/after to see if this fixes it.

@metaspace I don't see anything obvious in multitask that would be responsible for the cwd-related bug. However, I do see that zellij 0.41 fixed this bug, which sounds like it could be related. When I release the next upgrade for 0.41 I'll check before/after to see if this fixes it.

Cool. I moved to zellij 0.41, but everything dies when I load multitask. Does it just need to be recompiled, or is it more involved to get a 0.41 version?

@metaspace I don't see anything obvious in multitask that would be responsible for the cwd-related bug. However, I do see that zellij 0.41 fixed this bug, which sounds like it could be related. When I release the next upgrade for 0.41 I'll check before/after to see if this fixes it.

Cool. I moved to zellij 0.41, but everything dies when I load multitask. Does it just need to be recompiled, or is it more involved to get a 0.41 version?

It seems to require a bit more. I built with this patch:

diff --git a/Cargo.toml b/Cargo.toml
index 7e3f9b5..794cbe0 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -5,5 +5,5 @@ authors = ["Aram Drevekenin <aram@poor.dev>"]
 edition = "2018"

 [dependencies]
-zellij-tile = "0.40.1"
+zellij-tile = "0.41.1"

diff --git a/src/main.rs b/src/main.rs
index 87fb492..e5820f0 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -94,7 +94,7 @@ impl State {
                     args: task.args.clone(),
                     cwd: self.cwd.clone()
                 };
-                open_command_pane_floating(cmd, None);
+                open_command_pane_floating(cmd, None, BTreeMap::new());
             }
         }
     }

But I think it needs a bit more than that. When I run it, it gives me an editor to enter commands first time I run it, but then it dies.

Also, I tried building with rust 1.82.0, but that creates binaries that cannot be loaded by zellij 0.41 because of some unsupported wasm features. 1.78.0 produces binaries that can load.

@metaspace I don't see anything obvious in multitask that would be responsible for the cwd-related bug. However, I do see that zellij 0.41 fixed this bug, which sounds like it could be related. When I release the next upgrade for 0.41 I'll check before/after to see if this fixes it.

Cool. I moved to zellij 0.41, but everything dies when I load multitask. Does it just need to be recompiled, or is it more involved to get a 0.41 version?

It seems to require a bit more. I built with this patch:

diff --git a/Cargo.toml b/Cargo.toml
index 7e3f9b5..794cbe0 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -5,5 +5,5 @@ authors = ["Aram Drevekenin <aram@poor.dev>"]
 edition = "2018"

 [dependencies]
-zellij-tile = "0.40.1"
+zellij-tile = "0.41.1"

diff --git a/src/main.rs b/src/main.rs
index 87fb492..e5820f0 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -94,7 +94,7 @@ impl State {
                     args: task.args.clone(),
                     cwd: self.cwd.clone()
                 };
-                open_command_pane_floating(cmd, None);
+                open_command_pane_floating(cmd, None, BTreeMap::new());
             }
         }
     }

But I think it needs a bit more than that. When I run it, it gives me an editor to enter commands first time I run it, but then it dies.

Also, I tried building with rust 1.82.0, but that creates binaries that cannot be loaded by zellij 0.41 because of some unsupported wasm features. 1.78.0 produces binaries that can load.

@metaspace Yeah, I had ~10 minutes this weekend to play with it and got to the same point. I'll need a bit of time to look into this, but unfortunately it may be a few weeks before I have it. My day job and the rest of my life is really busy at the moment. My apologies.

@metaspace Had a little time yesterday evening. I'm actually having some issues with zellij 0.41.1 in general (also with 0.41.0. Things like new pane are not working correctly from keybinds. This could be due to my particular setup though and not an issue at large. I see this, which may be related as I'm using the kitty terminal. This has not been released yet through, i.e., was made after the 0.41.1 release.

Also, noticed that zellij action new-pane --cwd <DIR> isn't working how I'd expect. This opens the new pane at the host location as well. Curious if the cwd issue is something in the core of zellij that needs to be resolved there rather than in any individual plugin. I do see this, which says it is addressing cwd issues in plugins. Again, this has not yet been released.

I'm not having any issues in general in 0.41.0 in alacritty.

Did you try to build zellij master? If not I'll try that when I have some spare cycles. Probably need to build multitask against the same sources?

I'm not having any issues in general in 0.41.0 in alacritty.

Did you try to build zellij master? If not I'll try that when I have some spare cycles. Probably need to build multitask against the same sources?

Good to know, likely a kitty issue then (or FC40 or something else unique to my setup). Will try building zellij master when I have some spare time. If the zellij master has zellij action new-pane --cwd <DIR> fixed then I'll try building multitask against it and see if that fixes this issue too.

also having issues on kitty

Okay, trying to address all the issues in one comment. Tagging @metaspace @schlich

Kitty

The kitty issues were a problem on zellij and have nothing to do with multitask. Building the current main branch of zellij fixes these problems. Note, this includes bug fixes that have not yet been released, i.e., are not part of 0.41.1.

Cwd

This was an issue with multitask and zellij. The multitask problem was cwd is used by zellij internally. Changing this to ccwd fixes the multitask side of things. However, we also need bug fixes on zellij. Here, anything 0.41.1 or later should work. (It's possible 0.41.0 would work, I did not get a chance to test, but I know 0.40.1 does not work). If this is something you need, here is what I recommend:

  1. You need to upgrade to zellij 0.41.1 or later. If you are using kitty this means use main. Otherwise, using 0.41.1 should work.
  2. Use the most recent release of the multitask plugin I made. Note, even if you are using the main trunk of zellij, you do not need to compile the plugin yourself, you can still use the release version.

Touch file vs. saving file

This new version of multitask has the bug fix so that you don't have to touch the file, you can simply save it in your editor. This has been on the main branch of multitask for a while, but was not present in an official release until now.

Keybind

I unfortunately don't have a great answer here. The problem is getting pwd in. Trying something like this:

bind "Alt m" { Run "zellij" "action" "start-or-reload-plugin" "file:/home/leake/.zellij_plugins/multitask.wasm" "--configuration" "shell=/bin/zsh,ccwd=`pwd`";}

runs the plugin, but it doesn't correctly pass pwd to ccwd. I think we may have a fix in the future. I'm planning to refactor the plugin based on #10, and there might be a better way to get cwd to the command than through the --configuration. However, until/if that happens, I don't see a good way to do the keybind. Sorry :(

I'll leave this issue open for a few more days, but will close it if there are not any other issues that pop up.

Zellij 0.41.2 was released, so I just updated this as well. Now, you can just use the newest version of zellij and the newest version of multitask. Everything should work as expected.

As for the keybind, that is something that will still need to wait until we refactor how cwd makes it in. Ideally, we can just read from the pane where you launched the keybind and/or refactor things so we open a pane based on the current pane's location and use that as cwd. Regardless, this is something tagged as future work.