Skip to content

Conversation

@fioan89
Copy link
Collaborator

@fioan89 fioan89 commented Nov 21, 2025

Current approach with a secondary poll loop that handles the start action of a workspace is overengineered. Basically the problem is the CLI takes too long before moving the workspace into the queued/starting state, during which the user doesn't have any feedback. To address the issue we:

  • stopped the main poll loop from updating the environment
  • moved the environment in the queued state immediately after the start button was pushed.
  • started a poll loop that moved the workspace from queued state to starting space only after that state became available in the backend. The intermediary stopped state is skipped by the secondary poll loop.

@asher pointed out that a better approach can be implemented. We already store the status, and workspace and the agent in the environment. When the start comes in:

  1. We directly update the env. status to "queued"
  2. We only change the environment status if there is difference in the existing workspace&agent status vs the status from the main poll loop
  3. no secondary poll loop is needed.

Current approach with a secondary poll loop that handles the start action
of a workspace is overengineered. Basically the problem is the CLI takes too
long before moving the workspace into the queued/starting state, during which
the user doesn't have any feedback. To address the issue we:
- stopped the main poll loop from updating the environment
- moved the environment in the queued state immediately after the start button was pushed.
- started a poll loop that moved the workspace from queued state to starting space only
after that state became available in the backend. The intermediary stopped state is skipped by
the secondary poll loop.

@asher pointed out that a better approach can be implemented. We already store the status, and workspace
and the agent in the environment. When the start comes in:
1. We directly update the env. status to "queued"
2. We only change the environment status if there is difference in the existing workspace&agent
status vs the status from the main poll loop
3. no secondary poll loop is needed.
And improved debug messages
@fioan89 fioan89 marked this pull request as draft November 21, 2025 21:58
@fioan89 fioan89 requested a review from code-asher November 21, 2025 21:58
Start action was still visible because the action list was not yet refreshed.
@fioan89 fioan89 marked this pull request as ready for review November 21, 2025 22:45
@fioan89 fioan89 requested a review from jcjiang November 21, 2025 22:45
Comment on lines +263 to +267
if (WorkspaceAndAgentStatus.from(this.workspace, this.agent) == WorkspaceAndAgentStatus.from(
workspace,
agent
)
) {
Copy link
Member

@code-asher code-asher Nov 21, 2025

Choose a reason for hiding this comment

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

I think checking the status is subtly different from checking if there is a new build, because imagine this scenario:

  1. Latest build is failed.
  2. The poll runs, so we currently have failed stored as the status.
  3. User starts workspace, we set to queued.
  4. Build fails again (a brand new build, but it is also failing).
  5. Poll runs again, checks failed against the last status, which is also failed, so it leaves the status as queued, even though the workspace is actually failed currently, so really we do want to update the state to failed.

So we could miss updates from one build to another build when both builds end up with the same status.

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.

2 participants