You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
refactor: simplify workspace start status management (#222)
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.
if (wsRawStatus.canStop()) "This will close the workspace and remove all its information, including files, unsaved changes, history, and usage data."
163
+
if (environmentStatus.canStop()) "This will close the workspace and remove all its information, including files, unsaved changes, history, and usage data."
174
164
else"This will remove all information from the workspace, including files, unsaved changes, history, and usage data."
175
165
dialogText +="\n\nType \"${workspace.name}\" below to confirm:"
176
166
177
167
val confirmation = context.ui.showTextInputPopup(
178
-
if (wsRawStatus.canStop()) context.i18n.ptrl("Delete running workspace?") else context.i18n.ptrl("Delete workspace?"),
168
+
if (environmentStatus.canStop()) context.i18n.ptrl("Delete running workspace?") else context.i18n.ptrl(
169
+
"Delete workspace?"
170
+
),
179
171
context.i18n.pnotr(dialogText),
180
172
context.i18n.ptrl("Workspace name"),
181
173
TextType.General,
@@ -185,10 +177,14 @@ class CoderRemoteEnvironment(
185
177
if (confirmation != workspace.name) {
186
178
return@launch
187
179
}
180
+
context.logger.debug("Deleting $id...")
188
181
deleteWorkspace()
189
182
}
190
183
})
191
-
return actions
184
+
185
+
actionsList.update {
186
+
actions
187
+
}
192
188
}
193
189
194
190
privatesuspendfuntryStopSshConnection() {
@@ -264,23 +260,28 @@ class CoderRemoteEnvironment(
264
260
* Update the workspace/agent status to the listeners, if it has changed.
0 commit comments