Skip to content

Infinite loop in Kitty+ZelliJ #70

@hasezoey

Description

@hasezoey

viuer v0.9.1
zellij 0.42.0
kitty 0.40.0

Some users in termusic have noticed that with the Kitty+ZelliJ combinations, the TUI gets stuck.
I investigated and narrowed it down to the following infinite loop as it never gets a response or has a timeout:

viuer/src/printer/kitty.rs

Lines 94 to 102 in 56e9e51

while let Ok(key) = term.read_key() {
// The response will end with Esc('x1b'), followed by Backslash('\').
// Also, break if the Unknown key is found, which is returned when we're not in a tty
let should_break = key == Key::UnknownEscSeq(vec!['\\']) || key == Key::Unknown;
response.push(key);
if should_break {
break;
}
}

Note that this executed as TERM is xterm-kitty.

This might be fixed when #67 is implemented and proper querying is done as suggested in https://sw.kovidgoyal.net/kitty/graphics-protocol/#querying-support-and-available-transmission-mediums:

We intend that any terminal emulator that wishes to support it can do so. To check if a terminal emulator supports the graphics protocol the best way is to send the above query action followed by a request for the primary device attributes. If you get back an answer for the device attributes without getting back an answer for the query action the terminal emulator does not support the graphics protocol.

This means that terminal emulators that support the graphics protocol, must reply to query actions immediately without processing other input. Most terminal emulators handle input in a FIFO manner, anyway.

So for example, you could send:

<ESC>_Gi=31,s=1,v=1,a=q,t=d,f=24;AAAA<ESC>\<ESC>[c

If you get back a response to the graphics query, the terminal emulator supports the protocol, if you get back a response to the device attributes query without a response to the graphics query, it does not.

As, to my understanding, any terminal will reply to this, and depending on the response it can be determined what the terminal supports without a temp file.

I might also be completely wrong and with the current implementation ZelliJ should return some escape sequence.

Original issue: tramhao/termusic#451

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions