{
);
};
-const useReloading = (isDisconnected: boolean) => {
- const [status, setStatus] = useState<"reloading" | "notReloading">(
- "notReloading",
- );
-
- // Retry connection on key press when it is disconnected
- useEffect(() => {
- if (!isDisconnected || status === "reloading") {
- return;
- }
-
- // Modifier keys should not trigger a reload.
- const ignoredKeys = [
- "Alt",
- "AltGraph",
- "CapsLock",
- "Control",
- "Fn",
- "FnLock",
- "Meta",
- "NumLock",
- "ScrollLock",
- "Shift",
- "Symbol",
- "SymbolLock",
- ];
-
- const keyDownHandler = (event: KeyboardEvent) => {
- // In addition to ignored keys, avoid reloading while modifiers are held
- // to cover cases where the terminal unexpectedly tries to reconnect like
- // when pressing ctrl+w, ctrl+r, and so on.
- if (
- !ignoredKeys.includes(event.key) &&
- !event.altKey &&
- !event.ctrlKey &&
- !event.metaKey &&
- !event.shiftKey
- ) {
- setStatus("reloading");
- window.location.reload();
- }
- };
-
- document.addEventListener("keydown", keyDownHandler, true);
-
- return () => {
- document.removeEventListener("keydown", keyDownHandler, true);
- };
- }, [status, isDisconnected]);
-
- return {
- status,
- };
-};
-
const useStyles = makeStyles((theme) => ({
overlay: {
position: "absolute",
diff --git a/site/src/pages/TerminalPage/TerminalPageAlert.stories.tsx b/site/src/pages/TerminalPage/TerminalPageAlert.stories.tsx
deleted file mode 100644
index 265769c5ce..0000000000
--- a/site/src/pages/TerminalPage/TerminalPageAlert.stories.tsx
+++ /dev/null
@@ -1,37 +0,0 @@
-import type { Meta, StoryObj } from "@storybook/react";
-
-import TerminalPageAlert from "./TerminalPageAlert";
-
-const meta: Meta
= {
- component: TerminalPageAlert,
- title: "components/TerminalPageAlert",
- argTypes: {
- alertType: {
- control: {
- type: "radio",
- },
- options: ["error", "starting", "success"],
- },
- },
-};
-type Story = StoryObj;
-
-export const Error: Story = {
- args: {
- alertType: "error",
- },
-};
-
-export const Starting: Story = {
- args: {
- alertType: "starting",
- },
-};
-
-export const Success: Story = {
- args: {
- alertType: "success",
- },
-};
-
-export default meta;
diff --git a/site/src/pages/TerminalPage/TerminalPageAlert.tsx b/site/src/pages/TerminalPage/TerminalPageAlert.tsx
deleted file mode 100644
index 6c5e3862fb..0000000000
--- a/site/src/pages/TerminalPage/TerminalPageAlert.tsx
+++ /dev/null
@@ -1,131 +0,0 @@
-import { AlertColor } from "@mui/material/Alert/Alert";
-import Button from "@mui/material/Button";
-import Link from "@mui/material/Link";
-import { Alert } from "components/Alert/Alert";
-import { ReactNode } from "react";
-import { docs } from "utils/docs";
-
-export type TerminalPageAlertType = "error" | "starting" | "success";
-
-type MapAlertTypeToComponent = {
- [key in TerminalPageAlertType]: {
- severity: AlertColor;
- children: ReactNode | undefined;
- };
-};
-
-const mapAlertTypeToText: MapAlertTypeToComponent = {
- error: {
- severity: "warning",
- children: (
- <>
- The workspace{" "}
-
- startup script has exited with an error
-
- , we recommend reloading this session and{" "}
-
- debugging the startup script
- {" "}
- because{" "}
-
- your workspace may be incomplete.
- {" "}
- >
- ),
- },
- starting: {
- severity: "info",
- children: (
- <>
- Startup scripts are still running. You can continue using this terminal,
- but{" "}
-
- {" "}
- your workspace may be incomplete.
-
- >
- ),
- },
- success: {
- severity: "success",
- children: (
- <>
- Startup scripts have completed successfully. The workspace is ready but
- this{" "}
-
- session was started before the startup script finished.
- {" "}
- To ensure your shell environment is up-to-date, we recommend reloading
- this session.
- >
- ),
- },
-};
-
-export default ({
- alertType,
- onDismiss,
-}: {
- alertType: TerminalPageAlertType;
- onDismiss: () => void;
-}) => {
- const severity = mapAlertTypeToText[alertType].severity;
- return (
- theme.palette.divider,
- backgroundColor: (theme) => theme.palette.background.paperLight,
- borderLeft: (theme) => `3px solid ${theme.palette[severity].light}`,
- marginBottom: 1,
- }}
- onDismiss={onDismiss}
- dismissible
- actions={[
- ,
- ]}
- >
- {mapAlertTypeToText[alertType].children}
-
- );
-};