Skip to content

fix: make workspace buttons less confusing when errors happen #10609

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

Closed
wants to merge 16 commits into from
Closed
Show file tree
Hide file tree
Changes from 3 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
38 changes: 31 additions & 7 deletions site/src/pages/WorkspacePage/Workspace.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ export const Workspace: FC<React.PropsWithChildren<WorkspaceProps>> = ({
}) => {
const navigate = useNavigate();
const { saveLocal, getLocal } = useLocalStorage();

const [showAlertPendingInQueue, setShowAlertPendingInQueue] = useState(false);

// 2023-11-08 - MES - This effect will be called every single render because
Expand Down Expand Up @@ -146,9 +147,18 @@ export const Workspace: FC<React.PropsWithChildren<WorkspaceProps>> = ({
setShowAlertPendingInQueue(true);
}, t);

return () => clearTimeout(showTimer);
return () => {
clearTimeout(showTimer);
};
}, [workspace, now, showAlertPendingInQueue]);

const updateRequired =
(workspace.template_require_active_version ||
workspace.automatic_updates === "always") &&
workspace.outdated;
const autoStartFailing = workspace.autostart_schedule && !canAutostart;
const requiresManualUpdate = updateRequired && autoStartFailing;

const transitionStats =
template !== undefined ? ActiveTransition(template, workspace) : undefined;

Expand Down Expand Up @@ -203,12 +213,25 @@ export const Workspace: FC<React.PropsWithChildren<WorkspaceProps>> = ({

<Margins css={styles.content}>
<Stack direction="column" css={styles.firstColumnSpacer} spacing={4}>
{workspace.outdated && (
<Alert severity="info">
<AlertTitle>An update is available for your workspace</AlertTitle>
{updateMessage && <AlertDetail>{updateMessage}</AlertDetail>}
</Alert>
)}
{workspace.outdated &&
(requiresManualUpdate ? (
<Alert severity="warning">
<AlertTitle>
Autostart has been disabled for your workspace.
</AlertTitle>
<AlertDetail>
Autostart is unable to automatically update your workspace.
Manually update your workspace to reenable Autostart.
</AlertDetail>
</Alert>
) : (
<Alert severity="info">
<AlertTitle>
An update is available for your workspace
</AlertTitle>
{updateMessage && <AlertDetail>{updateMessage}</AlertDetail>}
</Alert>
))}

{Boolean(workspaceErrors.buildError) && (
<ErrorAlert error={workspaceErrors.buildError} dismissible />
Expand Down Expand Up @@ -285,6 +308,7 @@ export const Workspace: FC<React.PropsWithChildren<WorkspaceProps>> = ({
actions={
canRetryDebugMode && (
<Button
key={0}
onClick={handleBuildRetry}
variant="text"
size="small"
Expand Down
11 changes: 7 additions & 4 deletions site/src/pages/WorkspacePage/WorkspaceReadyPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ import {
getMaxDeadlineChange,
getMinDeadline,
} from "utils/schedule";
import { StateFrom } from "xstate";
import { DeleteDialog } from "components/Dialogs/DeleteDialog/DeleteDialog";
import { Workspace } from "./Workspace";
import { pageTitle } from "utils/page";
import { hasJobError } from "utils/workspace";
Expand Down Expand Up @@ -281,8 +279,13 @@ export const WorkspaceReadyPage = ({
hideVSCodeDesktopButton={featureVisibility["browser_only"]}
workspaceErrors={{
getBuildsError: buildsError,
buildError: buildError || restartBuildError,
cancellationError: cancellationError,
buildError:
restartBuildError ??
startWorkspaceMutation.error ??
stopWorkspaceMutation.error ??
deleteWorkspaceMutation.error ??
updateWorkspaceMutation.error,
cancellationError: cancelBuildMutation.error,
}}
buildInfo={buildInfo}
sshPrefix={sshPrefixQuery.data?.hostname_prefix}
Expand Down
37 changes: 37 additions & 0 deletions site/src/xServices/auth/authMethodsXService.typegen.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// This file was automatically generated. Edits will be overwritten

export interface Typegen0 {
"@@xstate/typegen": true;
internalEvents: {
"done.invoke.authMethods.gettingAuthMethods:invocation[0]": {
type: "done.invoke.authMethods.gettingAuthMethods:invocation[0]";
data: unknown;
__tip: "See the XState TS docs to learn how to strongly type this.";
};
"error.platform.authMethods.gettingAuthMethods:invocation[0]": {
type: "error.platform.authMethods.gettingAuthMethods:invocation[0]";
data: unknown;
};
"xstate.init": { type: "xstate.init" };
};
invokeSrcNameMap: {
getAuthMethods: "done.invoke.authMethods.gettingAuthMethods:invocation[0]";
};
missingImplementations: {
actions: never;
delays: never;
guards: never;
services: never;
};
eventsCausingActions: {
assignAuthMethods: "done.invoke.authMethods.gettingAuthMethods:invocation[0]";
setError: "error.platform.authMethods.gettingAuthMethods:invocation[0]";
};
eventsCausingDelays: {};
eventsCausingGuards: {};
eventsCausingServices: {
getAuthMethods: "xstate.init";
};
matchesStates: "gettingAuthMethods" | "idle";
tags: never;
}
104 changes: 104 additions & 0 deletions site/src/xServices/auth/authXService.typegen.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
// This file was automatically generated. Edits will be overwritten

export interface Typegen0 {
"@@xstate/typegen": true;
internalEvents: {
"done.invoke.authState.loadingInitialAuthData:invocation[0]": {
type: "done.invoke.authState.loadingInitialAuthData:invocation[0]";
data: unknown;
__tip: "See the XState TS docs to learn how to strongly type this.";
};
"done.invoke.authState.signedIn.profile.updatingProfile:invocation[0]": {
type: "done.invoke.authState.signedIn.profile.updatingProfile:invocation[0]";
data: unknown;
__tip: "See the XState TS docs to learn how to strongly type this.";
};
"done.invoke.signIn": {
type: "done.invoke.signIn";
data: unknown;
__tip: "See the XState TS docs to learn how to strongly type this.";
};
"done.invoke.signOut": {
type: "done.invoke.signOut";
data: unknown;
__tip: "See the XState TS docs to learn how to strongly type this.";
};
"error.platform.authState.loadingInitialAuthData:invocation[0]": {
type: "error.platform.authState.loadingInitialAuthData:invocation[0]";
data: unknown;
};
"error.platform.authState.signedIn.profile.updatingProfile:invocation[0]": {
type: "error.platform.authState.signedIn.profile.updatingProfile:invocation[0]";
data: unknown;
};
"error.platform.signIn": { type: "error.platform.signIn"; data: unknown };
"error.platform.signOut": { type: "error.platform.signOut"; data: unknown };
"xstate.init": { type: "xstate.init" };
};
invokeSrcNameMap: {
loadInitialAuthData: "done.invoke.authState.loadingInitialAuthData:invocation[0]";
signIn: "done.invoke.signIn";
signOut: "done.invoke.signOut";
updateProfile: "done.invoke.authState.signedIn.profile.updatingProfile:invocation[0]";
};
missingImplementations: {
actions: never;
delays: never;
guards: never;
services: never;
};
eventsCausingActions: {
assignData:
| "done.invoke.authState.loadingInitialAuthData:invocation[0]"
| "done.invoke.signIn";
assignError:
| "error.platform.authState.loadingInitialAuthData:invocation[0]"
| "error.platform.signIn"
| "error.platform.signOut";
assignUpdateProfileError: "error.platform.authState.signedIn.profile.updatingProfile:invocation[0]";
clearData: "done.invoke.signOut";
clearError:
| "SIGN_IN"
| "done.invoke.authState.loadingInitialAuthData:invocation[0]"
| "done.invoke.signOut";
clearUpdateProfileError: "UPDATE_PROFILE";
notifySuccessProfileUpdate: "done.invoke.authState.signedIn.profile.updatingProfile:invocation[0]";
redirect: "done.invoke.signOut";
updateUser: "done.invoke.authState.signedIn.profile.updatingProfile:invocation[0]";
};
eventsCausingDelays: {};
eventsCausingGuards: {
hasRedirectUrl: "done.invoke.signOut";
isAuthenticated: "done.invoke.authState.loadingInitialAuthData:invocation[0]";
needSetup: "done.invoke.authState.loadingInitialAuthData:invocation[0]";
};
eventsCausingServices: {
loadInitialAuthData: "xstate.init";
signIn: "SIGN_IN";
signOut: "SIGN_OUT";
updateProfile: "UPDATE_PROFILE";
};
matchesStates:
| "configuringTheFirstUser"
| "loadingInitialAuthData"
| "signedIn"
| "signedIn.profile"
| "signedIn.profile.idle"
| "signedIn.profile.idle.error"
| "signedIn.profile.idle.noError"
| "signedIn.profile.updatingProfile"
| "signedOut"
| "signingIn"
| "signingOut"
| {
signedIn?:
| "profile"
| {
profile?:
| "idle"
| "updatingProfile"
| { idle?: "error" | "noError" };
};
};
tags: never;
}
Loading