Skip to content

feat(site): Show warning if startup script is running #7326

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 6 commits into from
May 2, 2023
Merged
Changes from 1 commit
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
Prev Previous commit
Refresh session and get error message
  • Loading branch information
BrunoQuaresma committed May 2, 2023
commit 36d5d7d09231ebf61f7fd4c89251f95ee239dc9a
37 changes: 31 additions & 6 deletions site/src/pages/TerminalPage/TerminalPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { MONOSPACE_FONT_FAMILY } from "../../theme/constants"
import { pageTitle } from "../../utils/page"
import { terminalMachine } from "../../xServices/terminal/terminalXService"
import { useProxy } from "contexts/ProxyContext"
import { combineClasses } from "utils/combineClasses"

export const Language = {
workspaceErrorMessagePrefix: "Unable to fetch workspace: ",
Expand Down Expand Up @@ -78,9 +79,10 @@ const TerminalPage: FC<
} = terminalState.context
const reloading = useReloading(isDisconnected)
const shouldDisplayStartupWarning = workspaceAgent
? ["starting", "starting_timeout", "start_error"].includes(
workspaceAgent.lifecycle_state,
)
? ["starting", "starting_timeout"].includes(workspaceAgent.lifecycle_state)
: false
const shouldDisplayStartupError = workspaceAgent
? workspaceAgent.lifecycle_state === "start_error"
: false

// handleWebLink handles opening of URLs in the terminal!
Expand Down Expand Up @@ -296,6 +298,21 @@ const TerminalPage: FC<
</Stack>
)}
</div>
{shouldDisplayStartupError && (
<div
className={combineClasses([styles.alert, styles.alertError])}
role="alert"
>
<WarningIcon className={styles.alertIcon} />
<div>
<div className={styles.alertTitle}>Startup script failed</div>
<div className={styles.alertMessage}>
You can continue using this terminal, but something may be missing
or not fully set up.
</div>
</div>
</div>
)}
{shouldDisplayStartupWarning && (
<div className={styles.alert} role="alert">
<WarningIcon className={styles.alertIcon} />
Expand All @@ -304,18 +321,21 @@ const TerminalPage: FC<
Startup script is still running
</div>
<div className={styles.alertMessage}>
You can continue using this terminal, but something may be missing or not fully set up.
You can continue using this terminal, but something may be missing
or not fully set up.
</div>
</div>
<div className={styles.alertActions}>
<Button
startIcon={<RefreshOutlined />}
size="small"
onClick={() => {
window.location.reload()
// By redirecting the user without the session in the URL we
// create a new one
window.location.href = window.location.pathname
}}
>
Refresh
Refresh session
</Button>
</div>
</div>
Expand Down Expand Up @@ -421,6 +441,11 @@ const useStyles = makeStyles((theme) => ({
color: theme.palette.warning.light,
fontSize: theme.spacing(3),
},
alertError: {
"& $alertIcon": {
color: theme.palette.error.light,
},
},
alertTitle: {
fontWeight: 600,
color: theme.palette.text.primary,
Expand Down