gravitational / teleport

The easiest, and most secure way to access and protect all of your infrastructure.
https://goteleport.com
GNU Affero General Public License v3.0
17.37k stars 1.74k forks source link

Session Recording Playback is mangled based on terminal resolution size when recording vim #35756

Open pschisa opened 9 months ago

pschisa commented 9 months ago

Expected behavior: Teleport will present a auditable session recording with the tsh play in a terminal when vim is used during the session

Current behavior: If the terminal is smaller than the one used to make the recording and vim is used, the recording becomes mangled upon replay during the vim session.

https://github.com/gravitational/teleport/assets/75806143/17f3bbf8-b269-4e10-b956-ceef23e63e90

Bug details:

pschisa commented 9 months ago

Workaround is to utilize a larger terminal or the web UI for session recording replay

zmb3 commented 7 months ago

I think Teleport is doing the right thing here. We capture the size of the terminal in the session recording (both at startup and any time it changes thereafter), and during playback we emit the ANSI escape codes to resize the window.

It's up the the user's terminal emulator to decide whether or not to react to those codes.

For example, macOS's Terminal.app sees these escape codes and automatically resizes itself before playback starts. Here's what it looks like: https://www.loom.com/share/3ad4078e6ef841ecaad3c07afb5fb1c9?sid=bfea93e1-186b-4d3a-b2a6-3aa4e95e0a73

iTerm2 behaves differently. It has a dedicated setting for Disable session-initiated window resizing, but I was unable to get it to work even with this setting unchecked:

image

tl;dr: in order for console programs like vim to play back correctly, the terminal needs to be the correct size. Teleport is telling the terminal what size it should be, but some terminals choose not to listen to us.