diff --git a/coderd/workspaces.go b/coderd/workspaces.go index 67fdd76981445..d1c08b9e52c83 100644 --- a/coderd/workspaces.go +++ b/coderd/workspaces.go @@ -791,6 +791,7 @@ func (api *API) putExtendWorkspace(rw http.ResponseWriter, r *http.Request) { if err != nil { api.Logger.Info(ctx, "extending workspace", slog.Error(err)) } + api.publishWorkspaceUpdate(ctx, workspace.ID) httpapi.Write(ctx, rw, code, resp) } diff --git a/site/src/pages/WorkspacePage/WorkspaceReadyPage.tsx b/site/src/pages/WorkspacePage/WorkspaceReadyPage.tsx index ec0c96b402ca8..fed1b811b3abc 100644 --- a/site/src/pages/WorkspacePage/WorkspaceReadyPage.tsx +++ b/site/src/pages/WorkspacePage/WorkspaceReadyPage.tsx @@ -1,7 +1,7 @@ import { useActor, useSelector } from "@xstate/react" import { FeatureNames } from "api/types" import dayjs from "dayjs" -import { useContext } from "react" +import { useContext, useEffect } from "react" import { Helmet } from "react-helmet-async" import { useTranslation } from "react-i18next" import { @@ -64,6 +64,11 @@ export const WorkspaceReadyPage = ({ const { t } = useTranslation("workspacePage") const favicon = getFaviconByStatus(workspace.latest_build) + // keep banner machine in sync with workspace + useEffect(() => { + bannerSend({ type: "REFRESH_WORKSPACE", workspace }) + }, [bannerSend, workspace]) + return ( <> diff --git a/site/src/xServices/workspace/workspaceXService.ts b/site/src/xServices/workspace/workspaceXService.ts index 13b8afa1b8b77..18480de9ccacb 100644 --- a/site/src/xServices/workspace/workspaceXService.ts +++ b/site/src/xServices/workspace/workspaceXService.ts @@ -473,9 +473,6 @@ export const workspaceMachine = createMachine( template: (context: WorkspaceContext) => context.template, }, }, - on: { - REFRESH_WORKSPACE: { actions: "sendWorkspaceToSchedule" }, - }, }, }, }, @@ -594,13 +591,6 @@ export const workspaceMachine = createMachine( ) displayError(message) }, - sendWorkspaceToSchedule: send( - (context) => ({ - type: "REFRESH_WORKSPACE", - workspace: context.workspace, - }), - { to: "scheduleBannerMachine" }, - ), // 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.