Mosh: breaks with tmux -CC

Created on 22 Nov 2019  路  7Comments  路  Source: mobile-shell/mosh

Mosh breaks with tmux -CC. After running the command, it freezes and all input is ignored.

Most helpful comment

mosh doesn't just send output from server to client; it uses the output to update a model of what the screen is supposed to look like, and sends a minimal set of changes to make the client's screen look like the server's. This is part of what makes it perform well on low-bandwidth links, but it means anything that doesn't fit in mosh's model (such as scrollback) is hard to support.

It would be theoretically possible for mosh to support tmux -CC, but it would be a big challenge: that "model of your screen" would need to be extended into a "model of every session in the tmux". This requires mosh to understand the tmux control protocol, etc.

I'm curious if any of the mosh maintainers can weigh in on whether they'd be interested in supporting this in mainline mosh, if someone were to write it. If not, there's always forking.

In the meantime, you might want to look into Eternal Terminal https://eternalterminal.dev/ -- it gives you the roaming features of mosh without the clever state compression ones, which mean it's not quite as magical on low-bandwidth links but can support things like scrollback and tmux -CC.

All 7 comments

I think I can reproduce this, but I'm honestly not sure how to use tmux -CC. Can you help explain the best way to test this?

When using SSH, runningecho 'list-clients' | tmux -C seems to do the right thing (I get a bunch of data sent back to my terminal). But using the -CC mode I get:

$ echo "list-clients" | tmux -CC
tcgetattr failed: Inappropriate ioctl for device

But when I run tmux -CC interactively and try to type in "list-clientsret", I don't see any output (which is I think the bug you're reporting)

I don't know of any other terminal emulators that support tmux Control Center outside of iTerm2 https://www.iterm2.com/documentation-tmux-integration.html
If you have a mac, that would be the easiest way to test. Thanks.

Then my login command is essentially this:

ssh -t dev 'tmux -CC new -A -s main'

Which means:
Start a tmux session or attach to the existing one named main and let iTerm2 manage windows and tabs.

You will probably not see anything with tmux -CC because tmux sends an unterminated DCS at the start (\033P1000p) as a marker that control mode has been entered; terminals that don't expect it will hang (at least for a while) waiting for the terminator. I don't remember why that escape sequence is used, I think George suggested it.

If you are parsing escape sequences you will need to recognise this. Other than this sequence at the start, the control mode output should be valid UTF-8.

DCS 1000p was inspired by ReGIS which is entered with DCS [0-3]p and exited with ST.

tmux doesn't send the ST when control mode is exited but it probably should.

Control mode with -CC puts the terminal into raw mode and is only really of use if the end terminal understands it (that is, it is iTerm2).

So would this be possible to fix? It should be possible to delegate that task to iTerm so Mosh doesn't hang no?

mosh doesn't just send output from server to client; it uses the output to update a model of what the screen is supposed to look like, and sends a minimal set of changes to make the client's screen look like the server's. This is part of what makes it perform well on low-bandwidth links, but it means anything that doesn't fit in mosh's model (such as scrollback) is hard to support.

It would be theoretically possible for mosh to support tmux -CC, but it would be a big challenge: that "model of your screen" would need to be extended into a "model of every session in the tmux". This requires mosh to understand the tmux control protocol, etc.

I'm curious if any of the mosh maintainers can weigh in on whether they'd be interested in supporting this in mainline mosh, if someone were to write it. If not, there's always forking.

In the meantime, you might want to look into Eternal Terminal https://eternalterminal.dev/ -- it gives you the roaming features of mosh without the clever state compression ones, which mean it's not quite as magical on low-bandwidth links but can support things like scrollback and tmux -CC.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jiyinyiyong picture jiyinyiyong  路  7Comments

shibumi picture shibumi  路  5Comments

earlchew picture earlchew  路  5Comments

unphased picture unphased  路  5Comments

andschwa picture andschwa  路  4Comments