Skip to content

Commit 696a4e1

Browse files
presleyppull[bot]
authored andcommitted
fix: auto-stop bumper works and refreshes (#5162)
* Publish updates to workspace deadline * Fix sync between machines
1 parent a4c87bb commit 696a4e1

File tree

3 files changed

+7
-11
lines changed

3 files changed

+7
-11
lines changed

coderd/workspaces.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -784,6 +784,7 @@ func (api *API) putExtendWorkspace(rw http.ResponseWriter, r *http.Request) {
784784
if err != nil {
785785
api.Logger.Info(ctx, "extending workspace", slog.Error(err))
786786
}
787+
api.publishWorkspaceUpdate(ctx, workspace.ID)
787788
httpapi.Write(ctx, rw, code, resp)
788789
}
789790

site/src/pages/WorkspacePage/WorkspaceReadyPage.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { useActor, useSelector } from "@xstate/react"
22
import { FeatureNames } from "api/types"
33
import dayjs from "dayjs"
4-
import { useContext } from "react"
4+
import { useContext, useEffect } from "react"
55
import { Helmet } from "react-helmet-async"
66
import { useTranslation } from "react-i18next"
77
import { useNavigate } from "react-router-dom"
@@ -66,6 +66,11 @@ export const WorkspaceReadyPage = ({
6666
const favicon = getFaviconByStatus(workspace.latest_build)
6767
const navigate = useNavigate()
6868

69+
// keep banner machine in sync with workspace
70+
useEffect(() => {
71+
bannerSend({ type: "REFRESH_WORKSPACE", workspace })
72+
}, [bannerSend, workspace])
73+
6974
return (
7075
<>
7176
<Helmet>

site/src/xServices/workspace/workspaceXService.ts

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -473,9 +473,6 @@ export const workspaceMachine = createMachine(
473473
template: (context: WorkspaceContext) => context.template,
474474
},
475475
},
476-
on: {
477-
REFRESH_WORKSPACE: { actions: "sendWorkspaceToSchedule" },
478-
},
479476
},
480477
},
481478
},
@@ -594,13 +591,6 @@ export const workspaceMachine = createMachine(
594591
)
595592
displayError(message)
596593
},
597-
sendWorkspaceToSchedule: send(
598-
(context) => ({
599-
type: "REFRESH_WORKSPACE",
600-
workspace: context.workspace,
601-
}),
602-
{ to: "scheduleBannerMachine" },
603-
),
604594
// Optimistically update. So when the user clicks on stop, we can show
605595
// the "pending" state right away without having to wait 0.5s ~ 2s to
606596
// display the visual feedback to the user.

0 commit comments

Comments
 (0)