-
Notifications
You must be signed in to change notification settings - Fork 888
fix: display explicit 'retry' button(s) when a workspace fails #10720
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
Changes from all commits
c28f1d8
c249a40
718972f
6005cec
0f91d44
d635ecd
404e4c7
edecd14
b1f6660
c3edba7
2c55fd8
8d7fe73
91ce668
44f86d5
abc3ae6
fa64932
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,11 +29,13 @@ import { BuildsTable } from "./BuildsTable"; | |
import { WorkspaceDeletedBanner } from "./WorkspaceDeletedBanner"; | ||
import { WorkspaceStats } from "./WorkspaceStats"; | ||
|
||
export enum WorkspaceErrors { | ||
GET_BUILDS_ERROR = "getBuildsError", | ||
BUILD_ERROR = "buildError", | ||
CANCELLATION_ERROR = "cancellationError", | ||
} | ||
export type WorkspaceError = | ||
| "getBuildsError" | ||
| "buildError" | ||
| "cancellationError"; | ||
|
||
export type WorkspaceErrors = Partial<Record<WorkspaceError, unknown>>; | ||
|
||
export interface WorkspaceProps { | ||
scheduleProps: { | ||
onDeadlinePlus: (hours: number) => void; | ||
|
@@ -56,16 +58,17 @@ export interface WorkspaceProps { | |
resources?: TypesGen.WorkspaceResource[]; | ||
canUpdateWorkspace: boolean; | ||
updateMessage?: string; | ||
canRetryDebugMode: boolean; | ||
canChangeVersions: boolean; | ||
hideSSHButton?: boolean; | ||
hideVSCodeDesktopButton?: boolean; | ||
workspaceErrors: Partial<Record<WorkspaceErrors, unknown>>; | ||
workspaceErrors: WorkspaceErrors; | ||
buildInfo?: TypesGen.BuildInfoResponse; | ||
sshPrefix?: string; | ||
template?: TypesGen.Template; | ||
quotaBudget?: number; | ||
canRetryDebugMode: boolean; | ||
handleBuildRetry: () => void; | ||
handleBuildRetryDebug: () => void; | ||
buildLogs?: React.ReactNode; | ||
builds: TypesGen.WorkspaceBuild[] | undefined; | ||
onLoadMoreBuilds: () => void; | ||
|
@@ -87,55 +90,39 @@ export const Workspace: FC<React.PropsWithChildren<WorkspaceProps>> = ({ | |
handleCancel, | ||
handleSettings, | ||
handleChangeVersion, | ||
handleDormantActivate: handleDormantActivate, | ||
handleDormantActivate, | ||
workspace, | ||
isUpdating, | ||
isRestarting, | ||
resources, | ||
builds, | ||
canUpdateWorkspace, | ||
updateMessage, | ||
canRetryDebugMode, | ||
canChangeVersions, | ||
workspaceErrors, | ||
hideSSHButton, | ||
hideVSCodeDesktopButton, | ||
buildInfo, | ||
sshPrefix, | ||
template, | ||
canRetryDebugMode, | ||
handleBuildRetry, | ||
handleBuildRetryDebug, | ||
buildLogs, | ||
onLoadMoreBuilds, | ||
isLoadingMoreBuilds, | ||
hasMoreBuilds, | ||
canAutostart, | ||
}) => { | ||
const navigate = useNavigate(); | ||
const serverVersion = buildInfo?.version || ""; | ||
const { saveLocal, getLocal } = useLocalStorage(); | ||
|
||
const buildError = Boolean(workspaceErrors[WorkspaceErrors.BUILD_ERROR]) && ( | ||
<ErrorAlert | ||
error={workspaceErrors[WorkspaceErrors.BUILD_ERROR]} | ||
dismissible | ||
/> | ||
); | ||
|
||
const cancellationError = Boolean( | ||
workspaceErrors[WorkspaceErrors.CANCELLATION_ERROR], | ||
) && ( | ||
<ErrorAlert | ||
error={workspaceErrors[WorkspaceErrors.CANCELLATION_ERROR]} | ||
dismissible | ||
/> | ||
); | ||
|
||
let transitionStats: TypesGen.TransitionStats | undefined = undefined; | ||
if (template !== undefined) { | ||
transitionStats = ActiveTransition(template, workspace); | ||
} | ||
|
||
const [showAlertPendingInQueue, setShowAlertPendingInQueue] = useState(false); | ||
|
||
// 2023-11-15 - MES - This effect will be called every single render because | ||
// "now" will always change and invalidate the dependency array. Need to | ||
// figure out if this effect really should run every render (possibly meaning | ||
// no dependency array at all), or how to get the array stabilized (ideal) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Having the effect re-run every single render isn't ideal, but I don't think it's breaking anything During the sprint right before Christmas, I'm planning to do an audit for every single |
||
const now = dayjs(); | ||
useEffect(() => { | ||
if ( | ||
|
@@ -174,6 +161,9 @@ export const Workspace: FC<React.PropsWithChildren<WorkspaceProps>> = ({ | |
const autoStartFailing = workspace.autostart_schedule && !canAutostart; | ||
const requiresManualUpdate = updateRequired && autoStartFailing; | ||
|
||
const transitionStats = | ||
template !== undefined ? ActiveTransition(template, workspace) : undefined; | ||
|
||
return ( | ||
<> | ||
<FullWidthPageHeader> | ||
|
@@ -213,8 +203,11 @@ export const Workspace: FC<React.PropsWithChildren<WorkspaceProps>> = ({ | |
handleUpdate={handleUpdate} | ||
handleCancel={handleCancel} | ||
handleSettings={handleSettings} | ||
handleRetry={handleBuildRetry} | ||
handleRetryDebug={handleBuildRetryDebug} | ||
handleChangeVersion={handleChangeVersion} | ||
handleDormantActivate={handleDormantActivate} | ||
canRetryDebug={canRetryDebugMode} | ||
canChangeVersions={canChangeVersions} | ||
isUpdating={isUpdating} | ||
isRestarting={isRestarting} | ||
|
@@ -244,8 +237,15 @@ export const Workspace: FC<React.PropsWithChildren<WorkspaceProps>> = ({ | |
{updateMessage && <AlertDetail>{updateMessage}</AlertDetail>} | ||
</Alert> | ||
))} | ||
{buildError} | ||
{cancellationError} | ||
|
||
{Boolean(workspaceErrors.buildError) && ( | ||
<ErrorAlert error={workspaceErrors.buildError} dismissible /> | ||
)} | ||
|
||
{Boolean(workspaceErrors.cancellationError) && ( | ||
<ErrorAlert error={workspaceErrors.cancellationError} dismissible /> | ||
)} | ||
|
||
{workspace.latest_build.status === "running" && | ||
!workspace.health.healthy && ( | ||
<Alert | ||
|
@@ -311,16 +311,15 @@ export const Workspace: FC<React.PropsWithChildren<WorkspaceProps>> = ({ | |
<Alert | ||
severity="error" | ||
actions={ | ||
canRetryDebugMode && ( | ||
<Button | ||
key={0} | ||
onClick={handleBuildRetry} | ||
variant="text" | ||
size="small" | ||
> | ||
Try in debug mode | ||
</Button> | ||
) | ||
<Button | ||
onClick={ | ||
canRetryDebugMode ? handleBuildRetryDebug : handleBuildRetry | ||
} | ||
variant="text" | ||
size="small" | ||
> | ||
Retry{canRetryDebugMode && " in debug mode"} | ||
</Button> | ||
} | ||
> | ||
<AlertTitle>Workspace build failed</AlertTitle> | ||
|
@@ -357,17 +356,15 @@ export const Workspace: FC<React.PropsWithChildren<WorkspaceProps>> = ({ | |
showBuiltinApps={canUpdateWorkspace} | ||
hideSSHButton={hideSSHButton} | ||
hideVSCodeDesktopButton={hideVSCodeDesktopButton} | ||
serverVersion={serverVersion} | ||
serverVersion={buildInfo?.version || ""} | ||
onUpdateAgent={handleUpdate} // On updating the workspace the agent version is also updated | ||
/> | ||
)} | ||
/> | ||
)} | ||
|
||
{workspaceErrors[WorkspaceErrors.GET_BUILDS_ERROR] ? ( | ||
<ErrorAlert | ||
error={workspaceErrors[WorkspaceErrors.GET_BUILDS_ERROR]} | ||
/> | ||
{workspaceErrors.getBuildsError ? ( | ||
<ErrorAlert error={workspaceErrors.getBuildsError} /> | ||
) : ( | ||
<BuildsTable | ||
builds={builds} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These two error JSX elements were moved into the return value, to bring them closer to where they're actually used