Terminal emulator escape sequence passthrough during session resizing
0 reputation · 28 May 2021, 11:31 UTC
0 reputation · 28 May 2021, 11:31 UTC
The tmux server manages session states and client connections, allowing users to detach and re-attach to persistent environments. When a client window is resized, tmux must communicate these changes to the server and propagate them to the active panes.
There is observed inconsistency in how various terminal emulators handle the passthrough of complex escape sequences during these resizing events. This can lead to discrepancies in how the terminal renders the updated pane dimensions or handles the redrawing of the interface.
What are the specific limitations of the tmux server when coordinating resize sequences across different terminal emulator types? Does the current implementation support a standardized method to ensure consistent escape sequence delivery during dynamic window resizing?
31775 reputation · 28 May 2021, 18:24 UTC
The tmux server does not provide a universal, standardized method to guarantee the delivery of arbitrary escape sequences during a resize event because it acts as a terminal emulator itself. Instead of passing raw sequences from the client terminal to the application, tmux intercepts the resize event, calculates the new dimensions for its internal panes, and then issues its own resize commands to the shell processes running within those panes.
The observed discrepancies usually stem from a mismatch in how the client terminal emulator communicates window changes versus how tmux interprets them. While many emulators use SIGWINCH or the \e[8;H;Wt sequence, tmux must translate these into a format the underlying TTY understands. If a terminal emulator sends a non-standard sequence or if the TERM environment variable is misconfigured, the tmux server may fail to trigger the necessary internal redraw or fail to propagate the size change to the child process.
To diagnose whether the issue lies with the terminal emulator's passthrough or the tmux server's propagation, follow these steps:
cat -v in a tmux pane and resize the window. If no characters appear during the resize, the terminal emulator is not sending a sequence that tmux recognizes.stty size before and after a resize. If the output remains unchanged, the tmux server has not successfully updated the TTY dimensions.xterm-256color) and the tmux internal session is set to screen-256color or tmux-256color.To provide a more specific recommendation, please specify the exact terminal emulator and version of tmux being used, as behavior varies significantly between xterm-compatible and proprietary environments.
Use comments to ask for clarification. Post a solution as an answer.
3,840 reputation · 28 May 2021, 17:27 UTC
To build on the discussion of resize coordination, it is important to consider the behavior when multiple clients are attached to the same tmux session. The tmux server does not simply pass through the resize sequence of the active window; it calculates the smallest common denominator for pane dimensions across all attached clients.
If one client is using a small terminal window and another is using a large one, tmux will constrain the internal pane size to the smallest available dimensions to prevent content clipping for the smaller client. This can result in unexpected padding or restricted viewports for the larger terminal, regardless of whether the escape sequences are being delivered correctly.
To verify if this is the cause of rendering discrepancies, you can check the current session dimensions and client status using:
tmux info
If the reported dimensions are smaller than your current terminal window, the limitation is likely due to a second attached client rather than a passthrough failure.