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

conpty: Images rendered by imgcat is cut off by cmd.exe or wsl prompts #3624

Closed
nhat-vo opened this issue Apr 26, 2023 · 12 comments
Closed

conpty: Images rendered by imgcat is cut off by cmd.exe or wsl prompts #3624

nhat-vo opened this issue Apr 26, 2023 · 12 comments
Labels
bug Something isn't working conpty fixed-in-nightly This is (or is assumed to be) fixed in the nightly builds. Windows Issue applies to Microsoft Windows

Comments

@nhat-vo
Copy link

nhat-vo commented Apr 26, 2023

What Operating System(s) are you seeing this problem on?

Windows

Which Wayland compositor or X11 Window manager(s) are you using?

No response

WezTerm version

20230424-110818-dc2cd706

Did you try the latest nightly build to see if the issue is better (or worse!) than your current version?

Yes, and I updated the version box above to show the version of the nightly that I tried

Describe the bug

It seems that in Windows, wezterm imgcat is cutoff by the prompt of cmd.exe or in wsl.
image
image

To Reproduce

On windows, open wezterm in cmd.exe or wsl. Then run wezterm imgcat on a relatively large image.

Configuration

No config.

Expected Behavior

The prompt should be printed below the image instead of cutting it.

Logs

No response

Anything else?

No response

@nhat-vo nhat-vo added the bug Something isn't working label Apr 26, 2023
@wez
Copy link
Owner

wez commented Apr 26, 2023

On Windows, ConPTY can swallow or re-order escape sequences that it doesn't understand in a number of situations.
Relevant upstream issues are:

What I suspect is happening here is that, because conpty doesn't understand the iterm2 image protocol, it doesn't know that the cursor position should have moved, and conpty decides to place the cursor position on the next line.

See: https://wezfurlong.org/wezterm/what-is-a-terminal.html#windows-and-conpty for more information about conpty and how it fits into the architecture.

I'd recommend bypassing conpty when using image protocols on windows and using wezterm ssh to connect directly to an ssh server running in your wsl environment.

@wez wez added the Windows Issue applies to Microsoft Windows label Apr 26, 2023
@wez wez changed the title Images rendered by imgcat is cut off by cmd.exe or wsl prompts conpty: Images rendered by imgcat is cut off by cmd.exe or wsl prompts Apr 26, 2023
@nhat-vo
Copy link
Author

nhat-vo commented Apr 27, 2023

Thanks for the reply. I am trying to connect using wezterm ssh to the server running in wsl environment, but when I do wezterm imgcat image, it gives me a blank space like this
image.

The log give the error

ERROR  wezterm_gui::glyphcache > Unable to move file data to blob manager: Storage has not been initialized

Do you know what might have happened?

wez added a commit that referenced this issue Apr 27, 2023
Move the blob lease init into the common code, rather than just
the bit that runs for the regular gui init.

refs: #3624
@wez
Copy link
Owner

wez commented Apr 27, 2023

Ah, yes; that's a bug that I have now fixed, and that will be available to download within the next hour or so.

@wez
Copy link
Owner

wez commented Apr 27, 2023

To clarify, that fix will be in a nightly download available from https://wezfurlong.org/wezterm/install/windows.html

wez added a commit that referenced this issue May 21, 2023
I want to try out the FTCS flush and any other conpty fixes that may
have been made since our last update.

refs: microsoft/terminal#13710

These other issues may experience improved results, but likely not:

refs: #3748
refs: #3624
refs: #2779
refs: #2902
refs: #3531
refs: #3562
@adelarsq
Copy link

Hello @wez. I have confirmed that its working on nightly for PowerShell:

image

For clink shows like this:

image

I will follow this issue to help on the tests.

wez added a commit that referenced this issue Jul 16, 2023
Neither of these understand image protocols, and both are
an additional processing layer between the application and
wezterm.

This commit detects and wraps OSC sequences in tmux's passthru
sequence so that the data is passed on to wezterm rather than
elided from the data stream.

For image protocols in both tmux and conpty, work a little
smarter and explicitly move the cursor position to the same
location that wezterm would move it to.  That prevents the
display from being as mangled by tmux/conpty due to a diverging
understanding of the cursor position.

The logic isn't perfect, and can result in the x-coordinate
being incorrect, and this won't work with the new --position
argument either in its current state, without adding a lot
of complexity to deal with scrolling and relative and absolute
positioning handling.

To facilitate that, a new termwiz Terminal trait method has
been added to probe the terminal name, version, cell and pixel
dimensions. It's not pretty.

refs: #3624
refs: #3716
@wez
Copy link
Owner

wez commented Jul 16, 2023

@adelarsq I just pushed a commit that I think might help with the presentation you saw with clink.

It typically takes about an hour before commits are available as nightly builds for all platforms.

Please take a few moments to try out the fix and let me know how that works out. You can find the nightly downloads for your system in the wezterm installation docs.

If you prefer to use packages provided by your distribution or package manager of choice and don't want to replace that with a nightly download, keep in mind that you can download portable packages (a .zip file on Windows) that can be run without permanently installing or replacing an existing package, and can then simply be deleted once you no longer need them.

@wez wez added the fixed-in-nightly This is (or is assumed to be) fixed in the nightly builds. label Jul 16, 2023
wez added a commit that referenced this issue Jul 16, 2023
@adelarsq
Copy link

@wez Thanks for looking into that. I did some tests with nightly.

With clink/cmd shows the same behaviour:

image

But there is some odd behaviour with PowerShell. Calling imgcat on the first line shows like this:

image

Environment:

  • Clink
    • Clink v1.5.1.1e9e51
  • PowerShell
Name Value
PSVersion 7.3.6
PSEdition Core
GitCommitId 7.3.6
OS Microsoft Windows 10.0.22621
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0

@wez
Copy link
Owner

wez commented Jul 17, 2023

@adelarsq Thanks! Please confirm the wezterm version you're using; open the debug overlay (CTRL-SHIFT-L) and share the version info from there

@wez
Copy link
Owner

wez commented Jul 17, 2023

For pwsh, if you scroll up, does the scrollback look correct and fully intact?

@wez wez added waiting-on-op Waiting for more information from the original poster and removed fixed-in-nightly This is (or is assumed to be) fixed in the nightly builds. labels Jul 17, 2023
@adelarsq
Copy link

adelarsq commented Jul 17, 2023

@wez I have confirmed that its working on my side, on both cmd and powershell.

CMD:

image

PowerShell:

image

The reason for the bug was a missconfig on my side, with nightly and current conflicting each other.

@wez wez added fixed-in-nightly This is (or is assumed to be) fixed in the nightly builds. and removed waiting-on-op Waiting for more information from the original poster labels Jul 17, 2023
@wez
Copy link
Owner

wez commented Jul 17, 2023

Thanks for confirming! Let's close this!

@wez wez closed this as completed Jul 17, 2023
@github-actions
Copy link
Contributor

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 17, 2023
@wez wez added the conpty label Sep 3, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working conpty fixed-in-nightly This is (or is assumed to be) fixed in the nightly builds. Windows Issue applies to Microsoft Windows
Projects
None yet
Development

No branches or pull requests

3 participants