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 startaction of a workspace is overengineered. Basically the problem is theCLI takes too long before moving the workspace into the queued/startingstate, during which the user doesn't have any feedback. To address theissue we:- stopped the main poll loop from updating the environment- moved the environment in the queued state immediately after the startbutton was pushed.- started a poll loop that moved the workspace from queued state tostarting 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 alreadystore the status, and workspace and the agent in the environment. Whenthe start comes in:1. We directly update the env. status to "queued"2. We only change the environment status if there is difference in theexisting workspace&agent status vs the status from the main poll loop3. 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.
context.logger.debug("Overall status for workspace$id is$environmentStatus. Workspace status:${workspace.latestBuild.status}, agent status:${agent.status}, agent lifecycle state:${agent.lifecycleState}, login before ready:${agent.loginBeforeReady}")
284
285
}
285
286
286
287
/**
@@ -310,7 +311,7 @@ class CoderRemoteEnvironment(
310
311
* Returns true if the SSH connection was scheduled to start, false otherwise.
311
312
*/
312
313
funstartSshConnection():Boolean {
313
-
if (wsRawStatus.ready()&&!isConnected.value) {
314
+
if (environmentStatus.ready()&&!isConnected.value) {