Skip to content

refactor(site): Remove optimistic workspace status update #7385

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 1 commit into from
May 2, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 4 additions & 25 deletions site/src/xServices/workspace/workspaceXService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ export const workspaceMachine = createMachine(
},
},
requestingStart: {
entry: ["clearBuildError", "updateStatusToPending"],
entry: ["clearBuildError"],
invoke: {
src: "startWorkspace",
id: "startWorkspace",
Expand All @@ -404,7 +404,7 @@ export const workspaceMachine = createMachine(
},
},
requestingStop: {
entry: ["clearBuildError", "updateStatusToPending"],
entry: ["clearBuildError"],
invoke: {
src: "stopWorkspace",
id: "stopWorkspace",
Expand All @@ -423,7 +423,7 @@ export const workspaceMachine = createMachine(
},
},
requestingDelete: {
entry: ["clearBuildError", "updateStatusToPending"],
entry: ["clearBuildError"],
invoke: {
src: "deleteWorkspace",
id: "deleteWorkspace",
Expand All @@ -442,11 +442,7 @@ export const workspaceMachine = createMachine(
},
},
requestingCancel: {
entry: [
"clearCancellationMessage",
"clearCancellationError",
"updateStatusToPending",
],
entry: ["clearCancellationMessage", "clearCancellationError"],
invoke: {
src: "cancelWorkspace",
id: "cancelWorkspace",
Expand Down Expand Up @@ -642,24 +638,7 @@ export const workspaceMachine = createMachine(
)
displayError(message)
},
// Optimistically update. So when the user clicks on stop, we can show
// the "pending" state right away without having to wait 0.5s ~ 2s to
// display the visual feedback to the user.
updateStatusToPending: assign({
workspace: ({ workspace }) => {
if (!workspace) {
throw new Error("Workspace not defined")
}

return {
...workspace,
latest_build: {
...workspace.latest_build,
status: "pending" as TypesGen.WorkspaceStatus,
},
}
},
}),
assignMissedParameters: assign({
missedParameters: (_, { data }) => {
if (!(data instanceof API.MissingBuildParameters)) {
Expand Down