zellij-org / zellij

A terminal workspace with batteries included
https://zellij.dev
MIT License
21.99k stars 669 forks source link

bug: `LaunchOrFocusPlugin` creates new plugin instances when using plugin aliases #3409

Open cristiand391 opened 5 months ago

cristiand391 commented 5 months ago

2. Issues with the Zellij UI / behavior / crash

Issue description

both the CLI action launch-or-focus-plugin and keybind action LaunchOrFocusPlugin create a new plugin instance instead of focusing on the existing one when using plugin aliases.

Workaround: use file schema URL

Minimal reproduction

  1. download zj-quit and set up an alias for it:
    plugins {
    zj-quit location="file:/path/to/zj-quit.wasm"
    }
  2. start zellij and launch it from the CLI with the launch-or-focus-plugin action using the plugin alias:
    zellij action launch-or-focus-plugin --floating zj-quit

press Esc to make it hide itself: https://github.com/cristiand391/zj-quit/blob/1ab13ff06af29215bba33ed03b116ef407acc8c1/src/main.rs#L40

repeat that 3 times and then open the session-manager and check the panes in the current tab, you should see this: image

note that there's 3 zj-quit panes instead of just 1.

now repeat step 2 but use the file schema URL:

zellij action launch-or-focus-plugin --floating "file:/path/to/zj-quit.wasm"

check the session-manager again, only 1 zj-quit instance is open.

Other relevant information

I noticed this first when using the keybind action, doesn't seem to affect the zellij: schema.

zellij --version: zellij 0.40.1

pnx commented 2 months ago

This is even present with the default config as it uses an alias for the session manager:

keybinds {
    ...
    session {
        bind "Ctrl o" { SwitchToMode "Normal"; }
        bind "Ctrl s" { SwitchToMode "Scroll"; }
        bind "d" { Detach; }
        bind "w" {
            LaunchOrFocusPlugin "session-manager" {
                floating true
                move_to_focused_tab true
            };
            SwitchToMode "Normal"
        }
    }
}

plugins {
    ...
    session-manager location="zellij:session-manager"
}

you can just do ctr+o w then <esc> 3 times to produce the same result as the screenshot below:

image