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

Terminal size is not respected with profile with ssh. #1708

Open
kierun opened this issue Jan 15, 2025 · 8 comments
Open

Terminal size is not respected with profile with ssh. #1708

kierun opened this issue Jan 15, 2025 · 8 comments
Labels
ssh Everything for ssh connection

Comments

@kierun
Copy link

kierun commented Jan 15, 2025

Contour Terminal version

Contour Terminal Emulator 0.6.1

Installer source

something else (please specify below)

Operating System

Fedora 40

Architecture

x86-64

Other Software

OpenSSH_9.6p1, OpenSSL 3.2.2 4 Jun 2024 — I am pretty sure this is irrelevant, but ¯\_(ツ)_/¯

Steps to reproduce

  1. Create this configuration:
    foo:
        ssh:
            host: foo # ← should be a real host…
            port: 22
            user: yann
        terminal_size:
            columns: 120
            lines: 24
  1. Run contour profile foo
  2. Notice the terminal has 80 character width, not 120.
  3. Remove the ssh segment.
  4. Run contour profile foo
  5. Notice the terminal has 120 character width.

Expected Behavior

The terminal should have a width of 120.

Actual Behavior

The terminal has a width of 80, the default.

Additional notes

No response

@kierun kierun added the bug Something isn't working label Jan 15, 2025
@Yaraslaut
Copy link
Member

Hi @kierun, thanks for the bug report, it might be that ssh served changes the size of the terminal on connection, can you please provide the output of the contour from following debug flags: pty and vt.grid
Command to run : contour debug "pty,vt.grid" profile foo

@kierun
Copy link
Author

kierun commented Jan 16, 2025

@Yaraslaut here goes:

; contour debug "pty,vt.grid" profile anduril
zsh: correct 'profile' to '.profile' [nyae]? n
[2025-01-16 08:53:43.709337] [vt.grid] resize 120x24 -> 80x24 (cursor (23, 0))
[2025-01-16 08:53:43.709405] [vt.grid] resize 120x1 -> 80x1 (cursor (0, 0))
[2025-01-16 08:53:43.709415] [vt.grid] resize 120x1 -> 80x1 (cursor (0, 0))
[2025-01-16 08:53:43.871188] [vt.grid] resize 80x24 -> 86x25 (cursor (23, 4))
[2025-01-16 08:53:43.871576] [vt.grid] resize 80x1 -> 86x1 (cursor (0, 0))
[2025-01-16 08:53:43.871585] [vt.grid] resize 80x1 -> 86x1 (cursor (0, 0))

Well, look at that first line… 😡

So, next question: is there a way to stop this from happening?

If I use the profile large and manually ssh, the window does not automatically resize. It stays at 120 width. 🤔

@Yaraslaut
Copy link
Member

Sorry for the late reply @kierun, I will try to repro this and update on what we can do

@Yaraslaut
Copy link
Member

Hm, i can not reproduce this behaviour @kierun, here is my output when I connect to the remote server

yaraslau@Cartan ⇒ ./build/src/contour/contour debug "vt.grid,ssh" profile remote
ninja: no work to do.
QML debugging is enabled. Only use this in a safe environment.
[2025-01-26 17:07:48.812861] [vt.grid] resize 120x24 -> 120x23 (cursor (0, 0))
[2025-01-26 17:07:48.812892] [vt.grid]  -> shrink lines: numLinesToShrink 1, linesAvailableBelowCursorBeforeShrink 23, cutoff 1, pushUp 0/0
[2025-01-26 17:07:48.812901] [ssh] (contour) Resizing PTY to 120x23.
[2025-01-26 17:07:48.812955] [ssh] Starting SSH session to host: [email protected]
[2025-01-26 17:07:48.812962] [ssh] (contour) State transition from Initial to Started.
[2025-01-26 17:07:48.812966] [ssh] (contour) State transition from Started to Connect.
[2025-01-26 17:07:48.839326] [ssh] Connected to 159.65.115.185
[2025-01-26 17:07:48.839347] [ssh] (contour) State transition from Connect to Handshake.
[2025-01-26 17:07:49.043847] [ssh] (contour) State transition from Handshake to VerifyHostKey.
[2025-01-26 17:07:49.043874] [ssh] Skipping host key verification, because no known_hosts file was specified.
[2025-01-26 17:07:49.043881] [ssh] (contour) State transition from VerifyHostKey to AuthenticateAgent.
[2025-01-26 17:07:49.043893] [ssh] (contour) State transition from AuthenticateAgent to AuthenticatePrivateKeyStart.
[2025-01-26 17:07:49.140710] [ssh] Successfully authenticated with private key.
[2025-01-26 17:07:49.140746] [ssh] (contour) State transition from AuthenticatePrivateKeyStart to OpenChannel.
[2025-01-26 17:07:49.280844] [ssh] (contour) State transition from OpenChannel to RequestAuthAgent.
[2025-01-26 17:07:49.280895] [ssh] (contour) State transition from RequestAuthAgent to RequestPty.
[2025-01-26 17:07:49.302509] [ssh] (contour) State transition from RequestPty to SetEnv.
[2025-01-26 17:07:49.302527] [ssh] (contour) State transition from SetEnv to StartShell.
[2025-01-26 17:07:49.326746] [ssh] (contour) State transition from StartShell to Operational.
[2025-01-26 17:07:49.345038] [vt.grid] resize 120x23 -> 120x22 (cursor (22, 0))
[2025-01-26 17:07:49.345050] [vt.grid]  -> shrink lines: numLinesToShrink 1, linesAvailableBelowCursorBeforeShrink 0, cutoff 0, pushUp 1/1
[2025-01-26 17:07:49.345055] [vt.grid]  -> numLinesToPushUp 1
[2025-01-26 17:07:49.345061] [ssh] (contour) Resizing PTY to 120x22.
[2025-01-26 17:07:49.345066] [ssh] (contour) State transition from Operational to ResizeScreen.
[2025-01-26 17:07:49.345089] [ssh] (contour) State transition from ResizeScreen to Operational.
[2025-01-26 17:07:49.370676] [vt.grid] resize 120x22 -> 120x23 (cursor (21, 0))
[2025-01-26 17:07:49.370700] [ssh] (QSGRenderThread) Resizing PTY to 120x23.
[2025-01-26 17:07:49.370707] [ssh] (QSGRenderThread) State transition from Operational to ResizeScreen.
[2025-01-26 17:07:49.370744] [ssh] (QSGRenderThread) State transition from ResizeScreen to Operational.
[2025-01-26 17:07:49.394851] [ssh] (contour) Resizing PTY to 120x23.
[2025-01-26 17:07:49.394889] [ssh] (contour) State transition from Operational to ResizeScreen.
[2025-01-26 17:07:49.394917] [ssh] (contour) State transition from ResizeScreen to Operational.

maybe you can also add ssh debug info?

@kierun
Copy link
Author

kierun commented Jan 27, 2025

@Yaraslaut Ah, that's annoying that you cannot reproduce it. Therefore, the problem is something in my settings… Dammit.

Here's the output, still the same behaviour.

; contour profile anduril debug "vt.grid,ssh"
zsh: correct 'profile' to '.profile' [nyae]? n
[2025-01-27 09:27:29.498658] [ssh] Starting SSH session to host: yann@anduril
[2025-01-27 09:27:29.498686] [ssh] (contour) State transition from Initial to Started.
[2025-01-27 09:27:29.498696] [ssh] (contour) State transition from Started to Connect.
[2025-01-27 09:27:29.512210] [ssh] Connected to anduril (151.236.219.169)
[2025-01-27 09:27:29.512230] [ssh] (contour) State transition from Connect to Handshake.
[2025-01-27 09:27:29.627419] [ssh] (contour) State transition from Handshake to VerifyHostKey.
[2025-01-27 09:27:29.627449] [ssh] Skipping host key verification, because no known_hosts file was specified.
[2025-01-27 09:27:29.627465] [ssh] (contour) State transition from VerifyHostKey to AuthenticateAgent.
[2025-01-27 09:27:29.670271] [ssh] Successfully authenticated with SSH agent with identity: [email protected]
[2025-01-27 09:27:29.670305] [ssh] (contour) State transition from AuthenticateAgent to OpenChannel.
[2025-01-27 09:27:30.313584] [ssh] (contour) State transition from OpenChannel to RequestAuthAgent.
[2025-01-27 09:27:30.313672] [ssh] (contour) State transition from RequestAuthAgent to RequestPty.
[2025-01-27 09:27:30.328497] [ssh] (contour) State transition from RequestPty to SetEnv.
[2025-01-27 09:27:30.328524] [ssh] (contour) State transition from SetEnv to StartShell.
[2025-01-27 09:27:30.343100] [ssh] (contour) State transition from StartShell to Operational.
[2025-01-27 09:27:30.435074] [vt.grid] resize 120x24 -> 80x24 (cursor (23, 0))
[2025-01-27 09:27:30.435137] [vt.grid] resize 120x1 -> 80x1 (cursor (0, 0))
[2025-01-27 09:27:30.435146] [vt.grid] resize 120x1 -> 80x1 (cursor (0, 0))
[2025-01-27 09:27:30.435156] [ssh] (contour) Resizing PTY to 80x24.
[2025-01-27 09:27:30.435164] [ssh] (contour) State transition from Operational to ResizeScreen.
[2025-01-27 09:27:30.435213] [ssh] (contour) State transition from ResizeScreen to Operational.
[2025-01-27 09:27:30.568798] [vt.grid] resize 80x24 -> 86x25 (cursor (23, 4))
[2025-01-27 09:27:30.569425] [vt.grid] resize 80x1 -> 86x1 (cursor (0, 0))
[2025-01-27 09:27:30.569443] [vt.grid] resize 80x1 -> 86x1 (cursor (0, 0))
[2025-01-27 09:27:30.569458] [ssh] (QSGRenderThread) Resizing PTY to 86x25.
[2025-01-27 09:27:30.569475] [ssh] (QSGRenderThread) State transition from Operational to ResizeScreen.
[2025-01-27 09:27:30.569578] [ssh] (QSGRenderThread) State transition from ResizeScreen to Operational.

[2025-01-27 09:27:30.435156] [ssh] (contour) Resizing PTY to 80x24.

I guess this is where the behaviour happens. But, why? What crazy feature do I have that does that? 🤔

@Yaraslaut
Copy link
Member

Thanks for the update, @kierun. I can reproduce this issue if I explicitly add a resize VT sequence to the .bashrc file.
to resize to 80x25 in .bashrc use: printf "\e[8;25;80t"

@Yaraslaut Yaraslaut removed the bug Something isn't working label Jan 27, 2025
@kierun
Copy link
Author

kierun commented Jan 28, 2025

Thanks for the update, @kierun. I can reproduce this issue if I explicitly add a resize VT sequence to the .bashrc file. to resize to 80x25 in .bashrc use: printf "\e[8;25;80t"

😱 Well, that's odd… I tried commenting out ~/.bashrc, .zshrc, and .profile and I still get the same behaviour. 😖 I am at a loss. This happens only on contour, not xterm, rxvt, or alacrity

@Yaraslaut Thank you for your help so far. If you feel this should be closed, please do. I'll try to figure it out and add a comment when (if?) I do. Of course, if you wished to help further, I would be grateful!

@Yaraslaut
Copy link
Member

You can try to check out system wide file /etc/profile maybe something going on there, overall check out man page of the shell that you are using it must tell the the order of files that it uses during startup
The difference between ssh mode of the contour is that we connect directly to the server, without the sshd spawned from a shell in between

@Yaraslaut Yaraslaut added the ssh Everything for ssh connection label Jan 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ssh Everything for ssh connection
Projects
None yet
Development

No branches or pull requests

2 participants