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

Use initial terminal size when creating a terminal #277

Merged
merged 1 commit into from
Jan 30, 2024

Conversation

amisevsk
Copy link
Contributor

Description

When creating a new terminal, queue the initial number of rows/columns in the resize channel after starting to ensure the terminal uses the correct initial size (this requires making the channel buffered).

This should fix eclipse-che/che#22584, except when testing it in the Code editor, the initialDimensions sent to machine-exec are wrong -- resizing the terminal pane by even a few pixels shows the new computed size is 7-9 characters wider.

How to test

These changes are built into quay.io/amisevsk/che-code:terminal-size (with some additional logging to allow debugging terminal size issues).

To test these changes:

  1. Start a Che workspace
  2. In the Code terminal, run the following command to change the che-code image:
    oc get dwt che-code-$DEVWORKSPACE_NAME -o yaml | sed 's|quay.io/che-incubator/che-code.*|quay.io/amisevsk/che-code:terminal-size|' | oc apply -f -
    
  3. Restart the workspace (e.g. using F1 -> restart workspace)
  4. Verify terminal width and height are set correctly in new terminals created via "New terminal (Select a container)" -- text should wrap as normal (see linked issue for the original bug)

When creating a terminal, queue the initial size of the terminal in the
resize channel to ensure the terminal has correct dimensions upon
opening.

Signed-off-by: Angel Misevski <[email protected]>
Copy link
Member

@azatsarynnyy azatsarynnyy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested the PR following the provided steps and can't reproduce eclipse-che/che#22584.
Thanks @amisevsk for fixing it! 👍

@amisevsk
Copy link
Contributor Author

@azatsarynnyy Great to hear, thanks! Sounds like you're not seeing the additional bug (terminal width is off by ~6 chars).

I suspect that my still having the wrapping issue in testing is due to some font rendering weirdness on my system, given its consistency. What I think is happening is:

  1. I click to open a terminal
  2. Code gets the size of the terminal panel and computes a character width based on the pixel width of each monospace character
  3. Code attempts to initialize a terminal using this width
  4. Once the terminal is rendered, for some reason (???) the characters are rendered slightly narrower than the computed pixel width in step 2, so the width is still wrong
  5. On further resize, Code now uses the correct pixel width for the font to get a new width, which is correct.

What I'm still not clear on is why this doesn't occur for the built in terminal, but if it's just a me problem then it might be fine to merge (this should fix the problem in the majority of cases, at least)

Copy link
Member

@azatsarynnyy azatsarynnyy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@amisevsk I tested it more thoroughly and I noticed that the behavior is different depending on what container I opened the terminal to. See the screencast below:

Screen.Recording.2023-11-27.at.11.25.37.mov

Here ^^ I used the Java Sprint Boot sample from the Dashboard.
Changing the editor image to quay.io/amisevsk/che-code:terminal-size has no effect 🤷

@azatsarynnyy azatsarynnyy self-requested a review November 27, 2023 10:45
@amisevsk
Copy link
Contributor Author

This is the same issue I was facing. If you check the output tab for the Che Terminal plugin, you can see that the computed terminal width changes after it's initialized.

For example, here I open a terminal (14 pt font, 129 columns, has wrapping issue), then change the font size to 16 and back to 14pt only to see the newest resize to be 136 columns (still 14pt font, panel width has not changed).

terminal-width.mp4

As far as I can tell, this is coming from somewhere within Code itself; I don't know if it's something we can fix.

@amisevsk
Copy link
Contributor Author

amisevsk commented Nov 27, 2023

Testing it on my end, the mariaDB container also wraps correctly from the start, but the initial terminal size (e.g. 106 chars) is 6 less than the actual size (e.g. 112 chars). However, in the mariaDB container, it seems this wrapping is ignored?

@amisevsk amisevsk merged commit 5593cec into eclipse-che:main Jan 30, 2024
9 checks passed
@devstudio-release
Copy link

Build 3.12 :: machineexec_3.x/176: Console, Changes, Git Data

@devstudio-release
Copy link

@devstudio-release
Copy link

@devstudio-release
Copy link

@devstudio-release
Copy link

@devstudio-release
Copy link

@devstudio-release
Copy link

Build 3.12 :: machineexec_3.x/176: SUCCESS

Upstream sync done; /DS_CI/sync-to-downstream_3.x/6110 triggered

@devstudio-release
Copy link

@devstudio-release
Copy link

@devstudio-release
Copy link

@devstudio-release
Copy link

@devstudio-release
Copy link

Build 3.12 :: copyIIBsToQuay/2458: Console, Changes, Git Data

@devstudio-release
Copy link

Build 3.12 :: sync-to-downstream_3.x/6111: SUCCESS

Build container: devspaces-operator-bundle synced; /DS_CI/get-sources-rhpkg-container-build_3.x/6007 triggered; /job/DS_CI/job/dsc_3.x triggered;

@devstudio-release
Copy link

Build 3.12 :: operator-bundle_3.x/2590: SUCCESS

Upstream sync done; /DS_CI/sync-to-downstream_3.x/6111 triggered

@devstudio-release
Copy link

Build 3.12 :: dsc_3.x/1787: Console, Changes, Git Data

@devstudio-release
Copy link

Build 3.12 :: update-digests_3.x/5713: SUCCESS

Detected new images: rebuild operator-bundle
* machineexec; /DS_CI/operator-bundle_3.x/2590 triggered

@devstudio-release
Copy link

Build 3.12 :: dsc_3.x/1787: SUCCESS

3.12.0-CI

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Terminals created via "New terminal (Select a container)" have incorrect wrapping until the window is resized
4 participants