-
Notifications
You must be signed in to change notification settings - Fork 23
Remove extraneous polling #382
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
Conversation
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
This should never be called directly.
72ac15d
to
5609d21
Compare
kylecarbs
approved these changes
Oct 14, 2024
18352d7
to
59f704d
Compare
Previously, we were polling all the user's workspaces to get information about autostop and deletion so we can notify the user when those things are about to happen. This has a few problems: 1. We really only want to notify for the workspace to which we are actively connected, not all workspaces. 2. It did not account for owners being connected to someone else's workspace. We would have to query all workspaces, which is an even more expensive query. 3. If the sidebar is open, we are running two of the same query every five seconds, which is wasteful. We already had a web socket that was used to notify about the workspace being outdated, so I broke that into a new class and combined all the notification (outdated, autostop, deletion), status bar updates (just shows if the workspace is outdated), and context updates into one place using that web socket.
Now, calling fetchAndRefresh() is a no-op if the view is not visible.
It says the window will reload, but the command has no way of knowing that is the case. Maybe the command could automatically reload, but for now, a second notification will inform the user that the window needs to be reloaded, and they can choose whether they want to do so.
After experimentation, I think this is better. The idea with the notification was that it would not be in the way, but I think this is really something you need to be aware of and ideally you should immediately reload. Also, only show it once.
59f704d
to
9e578dd
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Previously, we were polling all the user's workspaces to get information
about autostop and deletion so we can notify the user when those things
are about to happen.
This has a few problems:
actively connected, not all workspaces.
workspace. We would have to query all workspaces, which is an even
more expensive query.
five seconds, which is wasteful.
We already had a web socket that was used to notify about the workspace
being outdated, so I broke that into a new class and combined all the
notifications (outdated, autostop, deletion), status bar updates (just
shows if the workspace is outdated), and context updates into one place
using that web socket.
Secondly, fix an issue where we immediately start polling when connecting
to a remote even though the Coder sidebar is not visible.
Now, we should only be polling when the sidebar is visible.