zellij-org / zellij

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

Custom keybinds from layout forgotten after detach #3117

Open scabala opened 9 months ago

scabala commented 9 months ago

1. Graphical issue inside a terminal pane (eg. something does not look as it should)

  1. Delete the contents of /tmp/zellij-1000/zellij-log, ie with cd /tmp/zellij-1000/ and rm -fr zellij-log/ (/tmp/ is $TMPDIR/ on OSX)
  2. Run zellij --debug
  3. Run stty size, copy the result and attach it in the bug report
  4. Recreate your issue.
  5. Quit Zellij immediately with ctrl-q (your bug should ideally still be visible on screen)

Please attach the files that were created in /tmp/zellij-1000/zellij-log/ to the extent you are comfortable with.

Basic information

zellij --version: zellij 0.39.2

stty size: 47 212

uname -av or ver(Windows): Linux personal 6.6.13-100.fc38.x86_64 #1 SMP PREEMPT_DYNAMIC Sat Jan 20 17:28:45 UTC 2024 x86_64 GNU/Linux

Further information

Reproduction steps, noticeable behavior, related issues, etc

2. Issues with the Zellij UI / behavior / crash

Issue description

I have a custom layout with custom keybindings. When I create a session, keybinds work. If I detach and attach to it, they does not work - they go to current's pane shell.

Minimal reproduction

  1. Save this as layout.kdl
layout {
        pane size=1 borderless=true {
                plugin location="zellij:tab-bar"
        }
        pane
        pane size=2 borderless=true name="bar" {
                plugin location="zellij:status-bar"
        }

}
keybinds {
        shared_except "locked" {
                bind "Ctrl a" {
                        Run "echo" "If you see me - there's not bug" {
                                floating true
                                close_on_exit false
                        }
                }
        }
}
  1. Create new session: zellij --layout ./layout.kdl --session test
  2. Press Ctrl+a 3.1 It should show new pane with command executed
  3. Detach the session (by default, Ctrl+o, d)
  4. Attach to session using this command: zellij attach test
  5. Press Ctrl+a again 6.1 It will not spawn new pane, just produce character in current pane

Other relevant information

If I had to point a finger on line from logs, it would be this line:

WARN   |zellij_utils::ipc        | 2024-02-07 17:26:23.557 [server_router] [zellij-utils/src/ipc.rs:223]: Error in IpcReceiver.recv(): InvalidMarkerRead(Error { kind: UnexpectedEof, message: "failed to fill whole buffer" })

but I did not make any serious debugging with this.

And here's the zellij.log file in it's entirety:

zellij.log ``` WARN |zellij_utils::input::layo| 2024-02-07 17:26:12.169 [main ] [zellij-utils/src/input/layout.rs:1035]: Failed to read swap layout file: ./layout.swap.kdl. Error: Os { code: 2, kind: NotFound, message: "No such file or directory" } ERROR |zellij::sessions | 2024-02-07 17:26:12.175 [main ] [src/sessions.rs:56]: Failed to read resurrection layout file: Os { code: 2, kind: NotFound, message: "No such file or directory" } ERROR |zellij::sessions | 2024-02-07 17:26:12.175 [main ] [src/sessions.rs:56]: Failed to read resurrection layout file: Os { code: 2, kind: NotFound, message: "No such file or directory" } ERROR |zellij::sessions | 2024-02-07 17:26:12.175 [main ] [src/sessions.rs:56]: Failed to read resurrection layout file: Os { code: 2, kind: NotFound, message: "No such file or directory" } ERROR |zellij::sessions | 2024-02-07 17:26:12.175 [main ] [src/sessions.rs:56]: Failed to read resurrection layout file: Os { code: 2, kind: NotFound, message: "No such file or directory" } ERROR |zellij::sessions | 2024-02-07 17:26:12.175 [main ] [src/sessions.rs:56]: Failed to read resurrection layout file: Os { code: 2, kind: NotFound, message: "No such file or directory" } ERROR |zellij::sessions | 2024-02-07 17:26:12.175 [main ] [src/sessions.rs:56]: Failed to read resurrection layout file: Os { code: 2, kind: NotFound, message: "No such file or directory" } ERROR |zellij::sessions | 2024-02-07 17:26:12.175 [main ] [src/sessions.rs:56]: Failed to read resurrection layout file: Os { code: 2, kind: NotFound, message: "No such file or directory" } ERROR |zellij::sessions | 2024-02-07 17:26:12.175 [main ] [src/sessions.rs:56]: Failed to read resurrection layout file: Os { code: 2, kind: NotFound, message: "No such file or directory" } ERROR |zellij::sessions | 2024-02-07 17:26:12.175 [main ] [src/sessions.rs:56]: Failed to read resurrection layout file: Os { code: 2, kind: NotFound, message: "No such file or directory" } INFO |zellij_client | 2024-02-07 17:26:12.175 [main ] [zellij-client/src/lib.rs:159]: Starting Zellij client! INFO |zellij_server | 2024-02-07 17:26:12.193 [main ] [zellij-server/src/lib.rs:246]: Starting Zellij server! INFO |zellij_server | 2024-02-07 17:26:12.196 [main ] [zellij-server/src/lib.rs:919]: Compiling plugins using Cranelift INFO |zellij_server::plugins | 2024-02-07 17:26:12.198 [wasm ] [zellij-server/src/plugins/mod.rs:149]: Wasm main thread starts INFO |zellij_utils::input::plug| 2024-02-07 17:26:12.212 [async-std/runti] [zellij-utils/src/input/plugins.rs:150]: Plugin 'tab-bar.wasm' exists in the 'PLUGIN DIR' at '/home//.local/share/zellij/plugins/' but is being ignored INFO |zellij_utils::input::plug| 2024-02-07 17:26:12.212 [async-std/runti] [zellij-utils/src/input/plugins.rs:150]: Plugin 'status-bar.wasm' exists in the 'PLUGIN DIR' at '/home//.local/share/zellij/plugins/' but is being ignored INFO |zellij_server::plugins::p| 2024-02-07 17:26:12.229 [async-std/runti] [zellij-server/src/plugins/plugin_loader.rs:495]: Loaded plugin 'tab-bar' from cache folder at '/home//.cache/zellij' in 14.825815ms INFO |zellij_server | 2024-02-07 17:26:12.229 [async-std/runti] [zellij-server/src/lib.rs:919]: Compiling plugins using Cranelift INFO |zellij_server::plugins::p| 2024-02-07 17:26:12.246 [async-std/runti] [zellij-server/src/plugins/plugin_loader.rs:495]: Loaded plugin 'status-bar' from cache folder at '/home//.cache/zellij' in 31.824774ms INFO |zellij_server | 2024-02-07 17:26:12.246 [async-std/runti] [zellij-server/src/lib.rs:919]: Compiling plugins using Cranelift INFO |zellij_client | 2024-02-07 17:26:14.793 [main ] [zellij-client/src/lib.rs:509]: Session detached ERROR |zellij::sessions | 2024-02-07 17:26:19.325 [main ] [src/sessions.rs:56]: Failed to read resurrection layout file: Os { code: 2, kind: NotFound, message: "No such file or directory" } ERROR |zellij::sessions | 2024-02-07 17:26:19.325 [main ] [src/sessions.rs:56]: Failed to read resurrection layout file: Os { code: 2, kind: NotFound, message: "No such file or directory" } ERROR |zellij::sessions | 2024-02-07 17:26:19.325 [main ] [src/sessions.rs:56]: Failed to read resurrection layout file: Os { code: 2, kind: NotFound, message: "No such file or directory" } ERROR |zellij::sessions | 2024-02-07 17:26:19.325 [main ] [src/sessions.rs:56]: Failed to read resurrection layout file: Os { code: 2, kind: NotFound, message: "No such file or directory" } ERROR |zellij::sessions | 2024-02-07 17:26:19.325 [main ] [src/sessions.rs:56]: Failed to read resurrection layout file: Os { code: 2, kind: NotFound, message: "No such file or directory" } ERROR |zellij::sessions | 2024-02-07 17:26:19.325 [main ] [src/sessions.rs:56]: Failed to read resurrection layout file: Os { code: 2, kind: NotFound, message: "No such file or directory" } ERROR |zellij::sessions | 2024-02-07 17:26:19.325 [main ] [src/sessions.rs:56]: Failed to read resurrection layout file: Os { code: 2, kind: NotFound, message: "No such file or directory" } ERROR |zellij::sessions | 2024-02-07 17:26:19.325 [main ] [src/sessions.rs:56]: Failed to read resurrection layout file: Os { code: 2, kind: NotFound, message: "No such file or directory" } ERROR |zellij::sessions | 2024-02-07 17:26:19.325 [main ] [src/sessions.rs:56]: Failed to read resurrection layout file: Os { code: 2, kind: NotFound, message: "No such file or directory" } INFO |zellij_client | 2024-02-07 17:26:19.325 [main ] [zellij-client/src/lib.rs:159]: Starting Zellij client! INFO |zellij_server | 2024-02-07 17:26:19.331 [wasm ] [zellij-server/src/lib.rs:919]: Compiling plugins using Cranelift INFO |zellij_server | 2024-02-07 17:26:19.334 [wasm ] [zellij-server/src/lib.rs:919]: Compiling plugins using Cranelift WARN |zellij_utils::ipc | 2024-02-07 17:26:23.557 [server_router] [zellij-utils/src/ipc.rs:223]: Error in IpcReceiver.recv(): InvalidMarkerRead(Error { kind: UnexpectedEof, message: "failed to fill whole buffer" }) ERROR |zellij_server::route | 2024-02-07 17:26:23.557 [server_router] [zellij-server/src/route.rs:1010]: Received empty message from client, logging client out. ERROR |zellij_server::os_input_o| 2024-02-07 17:26:23.557 [screen ] [zellij-server/src/os_input_output.rs:901]: Failed to cache resizes: failed to send message to pty writer ERROR |zellij_server::os_input_o| 2024-02-07 17:26:23.557 [screen ] [zellij-server/src/os_input_output.rs:912]: Failed to apply cached resizes: failed to send message to pty writer INFO |zellij_server::plugins | 2024-02-07 17:26:23.557 [wasm ] [zellij-server/src/plugins/mod.rs:393]: wasm main thread exits INFO |zellij_server::plugins::w| 2024-02-07 17:26:23.557 [wasm ] [zellij-server/src/plugins/wasm_bridge.rs:231]: Bye from plugin 0 INFO |zellij_client | 2024-02-07 17:26:23.558 [main ] [zellij-client/src/lib.rs:509]: Bye from Zellij! INFO |zellij_server::plugins::w| 2024-02-07 17:26:23.559 [wasm ] [zellij-server/src/plugins/wasm_bridge.rs:231]: Bye from plugin 1 ERROR |zellij::sessions | 2024-02-07 17:32:20.401 [main ] [src/sessions.rs:56]: Failed to read resurrection layout file: Os { code: 2, kind: NotFound, message: "No such file or directory" } ERROR |zellij::sessions | 2024-02-07 17:32:20.401 [main ] [src/sessions.rs:56]: Failed to read resurrection layout file: Os { code: 2, kind: NotFound, message: "No such file or directory" } ERROR |zellij::sessions | 2024-02-07 17:32:20.401 [main ] [src/sessions.rs:56]: Failed to read resurrection layout file: Os { code: 2, kind: NotFound, message: "No such file or directory" } ERROR |zellij::sessions | 2024-02-07 17:32:20.401 [main ] [src/sessions.rs:56]: Failed to read resurrection layout file: Os { code: 2, kind: NotFound, message: "No such file or directory" } ERROR |zellij::sessions | 2024-02-07 17:32:20.401 [main ] [src/sessions.rs:56]: Failed to read resurrection layout file: Os { code: 2, kind: NotFound, message: "No such file or directory" } ERROR |zellij::sessions | 2024-02-07 17:32:20.401 [main ] [src/sessions.rs:56]: Failed to read resurrection layout file: Os { code: 2, kind: NotFound, message: "No such file or directory" } ERROR |zellij::sessions | 2024-02-07 17:32:20.401 [main ] [src/sessions.rs:56]: Failed to read resurrection layout file: Os { code: 2, kind: NotFound, message: "No such file or directory" } ERROR |zellij::sessions | 2024-02-07 17:32:20.401 [main ] [src/sessions.rs:56]: Failed to read resurrection layout file: Os { code: 2, kind: NotFound, message: "No such file or directory" } ERROR |zellij::sessions | 2024-02-07 17:32:20.401 [main ] [src/sessions.rs:56]: Failed to read resurrection layout file: Os { code: 2, kind: NotFound, message: "No such file or directory" } ERROR |zellij::sessions | 2024-02-07 17:34:02.491 [main ] [src/sessions.rs:56]: Failed to read resurrection layout file: Os { code: 2, kind: NotFound, message: "No such file or directory" } ERROR |zellij::sessions | 2024-02-07 17:34:02.491 [main ] [src/sessions.rs:56]: Failed to read resurrection layout file: Os { code: 2, kind: NotFound, message: "No such file or directory" } ERROR |zellij::sessions | 2024-02-07 17:34:02.491 [main ] [src/sessions.rs:56]: Failed to read resurrection layout file: Os { code: 2, kind: NotFound, message: "No such file or directory" } ERROR |zellij::sessions | 2024-02-07 17:34:02.491 [main ] [src/sessions.rs:56]: Failed to read resurrection layout file: Os { code: 2, kind: NotFound, message: "No such file or directory" } ERROR |zellij::sessions | 2024-02-07 17:34:02.491 [main ] [src/sessions.rs:56]: Failed to read resurrection layout file: Os { code: 2, kind: NotFound, message: "No such file or directory" } ERROR |zellij::sessions | 2024-02-07 17:34:02.491 [main ] [src/sessions.rs:56]: Failed to read resurrection layout file: Os { code: 2, kind: NotFound, message: "No such file or directory" } ERROR |zellij::sessions | 2024-02-07 17:34:02.491 [main ] [src/sessions.rs:56]: Failed to read resurrection layout file: Os { code: 2, kind: NotFound, message: "No such file or directory" } ERROR |zellij::sessions | 2024-02-07 17:34:02.491 [main ] [src/sessions.rs:56]: Failed to read resurrection layout file: Os { code: 2, kind: NotFound, message: "No such file or directory" } ERROR |zellij::sessions | 2024-02-07 17:34:02.491 [main ] [src/sessions.rs:56]: Failed to read resurrection layout file: Os { code: 2, kind: NotFound, message: "No such file or directory" } ```
scabala commented 8 months ago

I have a feeling this might be feature - I have seen that when I change keybinds in my zellij.kdl, they are applied when I detach and attach to session - no session killing required. That's very nice feature, keybinds are somehow propagated from zellij client attaching to session.

And it made me think... What if we need to specify layout with keybind when attaching to it? So, in addition to scenario described above, let's try attaching with specifying layout: zellij -l ./layout.kdl attach test and it works just fine.

Honestly, I do not know if this behavior can be called a bug. More like a side effect of zellij client being in charge of keybinds instead of zellij server.

imsnif commented 1 week ago

Hey @scabala - thanks for reminding me about this issue and I'm sorry I did not get to it sooner.

I'll be honest - I'm not sure what the right sort of behavior here should be. Let's say for example that we change this behavior, so that keybindings defined in the layout that started the session will be kept throughout.

There is no indication that this is happening, so if you connect to this session at a later time, you might not understand why the keybindings are different. Furthermore, now with the config live-reloading in place, if you change the configuration file itself, these layout keybindings should be applied on top of the configuration keybindings (as they were when the session was created). So you'll be in a situation where if you change (for example) the configuration keybindings to:

keybindings clear-defaults=true { }

you'll still have keybindings that are coming from... somewhere?

The more I think about it, the more I feel that defining keybindings in layouts might have been a bad idea. Or at least, not fitting with where the project progressed to. What do you think? Would you maybe like to share more about your use-case so that we can figure out a good approach?