Skip to content

fix: update&start outdated workspaces #128

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 5 commits into from
Jun 12, 2025
Merged

Conversation

fioan89
Copy link
Collaborator

@fioan89 fioan89 commented Jun 10, 2025

URI handling was not able to start workspaces that were stopped and also outdated. With this PR we check the ws status and call the proper REST endpoint depending on whether the workspace is outdated or not.

During URI handling we can wait for workspaces to start up. The existing implementation had no visual feedback that we are waiting/doing anything. With this PR the header bar shows a nice work in progress visual. Additionally, the deployment URL was not properly refreshed when switching between different urls via URI handling. This is also fixed by forcing TBX to render a blank page for a very short period of time and then going back to the main page.

fioan89 added 2 commits June 10, 2025 23:04
URI handling was not able to start workspaces that were stopped and also outdated.
During URI handling we can wait for workspaces to start up. The existing implementation
had no visual feedback that we are waiting/doing anything. With this PR the header bar shows
a nice work in progress visual. Additionally, the deployment URL was not properly refreshed
when switching between different urls via URI handling. This is also fixed by forcing TBX
to render a blank page for a very short period of time and then going back to the main page.
@fioan89 fioan89 requested review from matifali and f0ssel June 10, 2025 22:19
*/
suspend fun refreshMainPage() {
ui.showUiPage(CoderPage.emptyPage(this))
delay(10.milliseconds)
Copy link

Choose a reason for hiding this comment

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

Could you add a comment for why we need to do a delay here for the uneducated? 😄

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thank you for the feedback, I've addressed it in the code, but here is a summary:

From testing and decompiling the Toolbox code, it seems that TBX uses an internal shared flow with a buffer of 4 items and a DROP_OLDEST strategy. Both showUiPage and showPluginEnvironmentsPage send events to this flow. If we emit two events back-to-back, the first one often gets dropped and only the second is shown. To reduce this risk, we add a small delay to let the UI coroutine process the first event. Simply yielding the coroutine isn't reliable, especially right after Toolbox starts via URI handling. Based on my testing, a 5–10 ms delay is enough to ensure the blank page is processed, while still short enough to be invisible to users.
It goes without saying that the API is limiting and we don't have the callbacks or the hooks necessary to observer when a page goes active. That would be much cleaner.

In fact the whole thing is necessary because the url/title on the main page is only refreshed if we're navigating to the main env page from another page. If TBX is already on the main page the title is not refreshed hence we force a navigation from a blank page. We've raised a ticket in the past, once that is fixed the blank page workaround will no longer be needed and as a consequence the delay will be dropped as well.

fioan89 added 2 commits June 11, 2025 23:16
Before agent matching we check the state of a workspace and if it is stopped
we automatically start it (if Disable autostart is not enabled). However the
agent matching code still received an old copy of the stopped workspace. Stopped
workspaces don't have resources.
@fioan89 fioan89 marked this pull request as ready for review June 11, 2025 21:06
@fioan89 fioan89 requested review from matifali and f0ssel June 11, 2025 21:06
@fioan89
Copy link
Collaborator Author

fioan89 commented Jun 12, 2025

seems like Azul CDN is down and the tests can't download the jdk. They pass locally so I'm gonna merge this.

@fioan89 fioan89 merged commit 792dba9 into main Jun 12, 2025
6 of 15 checks passed
@fioan89 fioan89 deleted the fix-outdated-workspaces branch June 12, 2025 19:22
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

Successfully merging this pull request may close these issues.

3 participants