Skip to content

chore(site): remove terminal xservice #10234

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

Merged
merged 8 commits into from
Oct 20, 2023
Merged

Conversation

code-asher
Copy link
Member

@code-asher code-asher commented Oct 12, 2023

This is a prelude to the change I actually want to make, which is to wait for a fit before connecting the web socket so we can send along the height/width and initialize screen with the right size.

I was having trouble modifying the xservice and it was pretty easy to simply remove it so I opted for the latter since we have been removing them anyway.

Let me know if this seems like a bad idea though.

I did not have such an easy time with the tests though. For reasons I do not understand, calling connected on a web socket created by jest-websocket-mock appears to freeze all updates to the component. I used nextMessage instead since there is always an init message we can use to detect when the socket is connected so it should be fine, but it is still unfortunate.

Part 1 of fixing #9806

Edit: moving to draft while I look into why it sometimes creates the terminal twice. might have been an existing problem but it is fixed now

@code-asher code-asher force-pushed the asher/remove-terminal-xservice branch 3 times, most recently from e0b78cc to 504c797 Compare October 12, 2023 12:26
@code-asher code-asher marked this pull request as draft October 12, 2023 12:35
@code-asher code-asher force-pushed the asher/remove-terminal-xservice branch from 504c797 to 8041609 Compare October 19, 2023 18:03
To make it easier to move away from this service.
To make it easier to move away from this service.
This is a prelude to the change I actually want to make, which is to
send the size of the terminal on the web socket URL after we do a fit.
I have found xstate so confusing that it was easier to just rewrite it.
I am not really sure what ws.connected is doing but it seems to somehow
block updates.  Something to do with `act()` maybe?

Basically, the useEffect creating the terminal never updates once the
config query finishes, so the web socket is never created, and the test
hangs forever.

It might have been working before only because the web socket was
created using xstate rather than useEffect and once it connected it
would unblock and React could update again but this is just a guess.
The terminal only cares about the renderer specifically, no need to
recreate the terminal if something else changes.
@code-asher code-asher force-pushed the asher/remove-terminal-xservice branch from 8041609 to da4a231 Compare October 19, 2023 20:35
@code-asher code-asher marked this pull request as ready for review October 19, 2023 20:46
@code-asher code-asher requested review from a team and BrunoQuaresma and removed request for a team October 19, 2023 20:46
Felt like this could be broken out to reduce the component size.  Also
trying to figure out why it is causing the terminal to create multiple
times.
Depending on the timing, handleWebLink was causing the terminal to get
recreated.  We only need to create the terminal once unless the render
type changes.

Recreating the terminal was also recreating the web socket pointlessly.
@code-asher code-asher force-pushed the asher/remove-terminal-xservice branch from da4a231 to 15d3f58 Compare October 19, 2023 21:46
Copy link
Collaborator

@BrunoQuaresma BrunoQuaresma left a comment

Choose a reason for hiding this comment

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

Really good changes, I think this simplified the code a lot. TY!

@BrunoQuaresma
Copy link
Collaborator

Related to #9942

@code-asher code-asher merged commit 57c9d88 into main Oct 20, 2023
@code-asher code-asher deleted the asher/remove-terminal-xservice branch October 20, 2023 18:18
@github-actions github-actions bot locked and limited conversation to collaborators Oct 20, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants