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

Unexpected ANSI styling in GIF output #249

Closed
picatz opened this issue Mar 7, 2023 · 11 comments
Closed

Unexpected ANSI styling in GIF output #249

picatz opened this issue Mar 7, 2023 · 11 comments

Comments

@picatz
Copy link

picatz commented Mar 7, 2023

Suggested by @muesli, I tried using vhs to record a demo GIF for a project I'm working on. It didn't come out quite right, and the code isn't open source yet (very soon!). But, I figured I'd open an issue.

Output demo.gif

Set FontSize 32
Set Width 1920
Set Height 1080

Type "./hal"
Tab
Sleep 4s
Enter
Sleep 4s
Enter
Sleep 4s
Type "Write a Go program to print hello world"
Sleep 3s
Escape
Sleep 8s

Which generated this GIF:

demo

I would expect to see something like this:

Screenshot 2023-03-07 at 12 08 41 AM

1. The list view title is showing as a full bar in the GIF, but not in the CLI when I look at it. This is just using the list bubble.
2. The status bar isn't showing fully when using a space character and a foreground lipgloss color for empty space.
3. The characters in the status bar are wonky, not properly spaced.

Using version 0.3.0.

@picatz
Copy link
Author

picatz commented Mar 8, 2023

This is the code for the status bar that isn't rendering properly:
https://github.com/picatz/hal/blob/75379b00c27855fe3c217320a46397a732a6fe6c/statusbar.go#L52-L81

@maaslalani
Copy link
Contributor

Thanks so much @picatz! Going to take a look soon! 😄

@picatz
Copy link
Author

picatz commented Mar 8, 2023

While continuing to work on HAL tonight, the status bar being hidden thing seemed to resolve itself, mostly?

But, the list view title is still rendering wonky. So is the spacing in the status bar "blocks" showing the messages/tokens/spinner/etc.

demo

📄 https://github.com/picatz/hal/blob/5a17e974b659a7714b91f61f837450d010ee3d24/pkg/statusbar/model.go#L87-L123

@maaslalani
Copy link
Contributor

This is a strange one, looks like it's having problems when the first cell is a space (non-character) and if it has a background color. I think it might be due to some environment variables or width issues in VHS or ttyd. I will play around some more and debug this a little. I'll see if I can produce a minimal example.

@maaslalani
Copy link
Contributor

I believe it is related to this issue: xtermjs/xterm.js#4120

@picatz
Copy link
Author

picatz commented Mar 15, 2023

Interesting! So ttyd needs to be bumped to xterm 5.2.0 (when it's released) for this to be fixed?

https://github.com/tsl0922/ttyd/blob/a767971836c451fbc22e23fd01f78d1b372e9207/html/yarn.lock#L10089-L10094

@maaslalani
Copy link
Contributor

Yes, I believe when 5.2.0 is released this should solve the issue. This issue #256 was also causing problems and I was able to reproduce it without VHS (using only ttyd -t rendererType=canvas) so I believe issue with xterm should be the fix.

@maaslalani
Copy link
Contributor

The bug is reproducible without VHS:

ttyd -t rendererType=canvas zsh

image

@maaslalani
Copy link
Contributor

It is working with -t rendererType=webgl so I believe that the fix merged into xterm.js will make everything work again with canvas. We use canvas rendering in VHS because it is much faster to stream the images instead of using browser screenshotting.

image

@picatz
Copy link
Author

picatz commented Mar 15, 2023

Awesome!

@maaslalani
Copy link
Contributor

Great news! If you use vhs@main:

go install github.com/charmbracelet/vhs@main

and ttyd@master:

brew install ttyd --HEAD

this issue should be fixed!

Feel free to reopen this issue if you still encounter problems! Thank you so much for reporting this ❤️

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

No branches or pull requests

2 participants