Skip to content

Commit 7e68fa5

Browse files
committed
Check for the statuses we want
Instead of ones we do not. This catches unexpected statuses like how right now if there is a redirect Axios will make a GET to the new location and the workspace status becomes undefined because it got an array of builds back instead.
1 parent 214b1a1 commit 7e68fa5

File tree

1 file changed

+16
-14
lines changed

1 file changed

+16
-14
lines changed

src/remote.ts

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -270,15 +270,16 @@ export class Remote {
270270
buildComplete()
271271
}
272272

273-
if (workspace.latest_build.status === "stopped") {
273+
// The workspace should now be running.
274+
if (workspace.latest_build.status !== "running") {
274275
const result = await this.vscodeProposed.window.showInformationMessage(
275-
`This workspace is stopped!`,
276+
`${workspaceName} is ${workspace.latest_build.status}`,
276277
{
277278
modal: true,
278-
detail: `Click below to start and open ${workspaceName}.`,
279+
detail: `Unable to start ${workspaceName}. Click below to try again.`,
279280
useCustom: true,
280281
},
281-
"Start Workspace",
282+
"Reconnect",
282283
)
283284
if (!result) {
284285
await this.closeRemote()
@@ -499,16 +500,17 @@ export class Remote {
499500
this.storage.writeToCoderOutputChannel(`Agent ${agent.name} status is now ${agent.status}`)
500501
}
501502

502-
// Make sure agent did not time out.
503-
// TODO: Seems like maybe we should check for all the good states rather
504-
// than one bad state? Agents can error in many ways.
505-
if (agent.status === "timeout") {
506-
this.storage.writeToCoderOutputChannel(`${workspaceName}/${agent.name} timed out`)
507-
const result = await this.vscodeProposed.window.showErrorMessage("Connection timed out...", {
508-
useCustom: true,
509-
modal: true,
510-
detail: `The ${agent.name} agent didn't connect in time. Try restarting your workspace.`,
511-
})
503+
// Make sure the agent is connected.
504+
// TODO: Should account for the lifecycle state as well?
505+
if (agent.status !== "connected") {
506+
const result = await this.vscodeProposed.window.showErrorMessage(
507+
`${workspaceName}/${agent.name} ${agent.status}`,
508+
{
509+
useCustom: true,
510+
modal: true,
511+
detail: `The ${agent.name} agent failed to connect. Try restarting your workspace.`,
512+
},
513+
)
512514
if (!result) {
513515
await this.closeRemote()
514516
return

0 commit comments

Comments
 (0)