Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Detect whether the session is "safe" to attach/detach #5

Open
whisperity opened this issue Oct 24, 2022 · 1 comment
Open

Detect whether the session is "safe" to attach/detach #5

whisperity opened this issue Oct 24, 2022 · 1 comment
Labels
Target: Core 💥 Core architectural support library Target: Plug-in architecture 🔌 Features that should be implemented with a pluginable callback architecture in mind Target: Reference implementation 📃 The "official" Client & Server implementations

Comments

@whisperity
Copy link
Owner

With in-line detachment getting implemented as part of #3, it should be noted that there are cases when detaching from a running session is not safe to the client's terminal (due to us having no terminal emulation and no replay of display buffers...). Most notable of these is the Mouse events:

  • Open vim (with a mouse-capable TERM set) behind monomux
  • Force-exit the session without backgrounding vim
  • Get clicky in the now detached terminal and observe:
2;64;18M2;64;18m2;99;27M0;99;27M2;99

Due to this, it is generally not recommended to detach without backgrounding a "full-fledged" terminal application (like vim or mc) first. Pre-#3, having to explicitly execute another binary sort of forced this behaviour from users. But nothing stops one client from attaching to an existing session where a feature application was running, in which case the new session did NOT receive the terminal state properly (and thus, e.g., mouse events were only happening from one session).

The server should be made capable of intercepting the output stream and understanding some control sequences mostly related to changing modes in the underlying terminal. With this, we could approximate what state the session is in, and be able to mark it as "unsafe". If the session is currently "unsafe", we should not let the user detach, and also show a warning when trying to attach.

@whisperity whisperity added Target: Core 💥 Core architectural support library Target: Reference implementation 📃 The "official" Client & Server implementations Target: Plug-in architecture 🔌 Features that should be implemented with a pluginable callback architecture in mind labels Oct 24, 2022
@christianparpart
Copy link

I'd probably like a configurable option to optionally set SIGSTOP/CONT to the process I am detaching from / reattaching to. That would fix the problem you described wrt. mouse being enabled by the client, as vim e.g. takes care of that internally (and so should other apps)
alternatively (but not fixing the mouse problem) would be to inject a VT sequence to the mux'd process when a client is attaching/detaching. that kinda exists for focus gain/loss already, too. (<-- of course no app would be using that as of right now, but for focus gain/loss they are)

I really highly recommend trying out to get the connected app to force a re-render in a way KDE konsole is doing it (temporarily grow and then regrow back to original terminal main page dimensions), e.g. if current window size is 80x25, temporarily do 80x26 and then go back to 80x25 with a very short amount of ms. It should not be too hard to find it in the KDE konsole's source code to get an inspiration.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Target: Core 💥 Core architectural support library Target: Plug-in architecture 🔌 Features that should be implemented with a pluginable callback architecture in mind Target: Reference implementation 📃 The "official" Client & Server implementations
Projects
None yet
Development

No branches or pull requests

2 participants