-
Notifications
You must be signed in to change notification settings - Fork 937
fix: reconnect terminal on non-modified key presses #9686
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
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
78ec07b
Listen to web terminal keydown on capture
code-asher 46f2615
Prevent issuing terminal reload when already reloading
code-asher 85ffce8
Ignore modifier keys for reconnecting terminal
code-asher 88db8cc
Swap undefined check for `in`
code-asher 9cab143
Use modifier properties on keydown event
code-asher File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
kind of a nit: this call won't really do anything.
window.location.reload()
will block/kill the execution context before the event loop circles back to this.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I thought the same thing, it could depend on the browser or something, but in Chromium I tested via a
console.log
statement and it will happily run multiple times until the reload "kicks in".There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That said, running
window.location.reload()
multiple times is probably harmless.Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One more thing, setting the status here to
reloading
causes the overlay to display "Reloading...", so whateverwindow.location.reload()
is doing, it appears to not quite be instant, or there is some other trick at play here.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wow, ok 😅 I thought I'd even played with this before and touching
location
instantly killed your codeUh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that said, it seems like this would benefit from being instant, rather than waiting for react to do an update cycle. maybe we should use
useRef
for this?although I guess the ui uses this... maybe it needs to be both 🙃
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lol I know what you mean, I could have sworn I did and saw the same!
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh right, good point. Maybe it would be nice if the UI could update immediately as well since if the reload happens too fast they might never see the
Reloading...
text? Wonder if we can force an update or something.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I experimented a bit to see if I could get the keydown handler firing twice before React updates and the listener is removed but apparently I am not able to mash a key fast enough lol
I did find a bug though, if you ctrl+tab away then come back via click, the page still thinks ctrl is being pressed and nothing will reload until you press and release ctrl again. Not sure if this can be solved with keydown...too bad it is not like the deprecated
keypress
event that would tell you if modifier keys were being held down.Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wait what no
keydown
does have that information. What am I even doing?? Will refactor. It does not cover all the keys listed in documentation as modifiers, but all the ones that really matter imo.