+
{
fitAddonRef.current?.fit();
}}
/>
-
+
{latency && isDebugging && (
@@ -328,62 +332,6 @@ const TerminalPage: FC = () => {
);
};
-type TerminalAlertsProps = {
- agent: WorkspaceAgent | undefined;
- state: TerminalState;
- onAlertChange: () => void;
-};
-
-const TerminalAlerts = ({
- agent,
- state,
- onAlertChange,
-}: TerminalAlertsProps) => {
- const lifecycleState = agent?.lifecycle_state;
- const prevLifecycleState = useRef(lifecycleState);
- useEffect(() => {
- prevLifecycleState.current = lifecycleState;
- }, [lifecycleState]);
-
- // We want to observe the children of the wrapper to detect when the alert
- // changes. So the terminal page can resize itself.
- //
- // Would it be possible to just always call fit() when this component
- // re-renders instead of using an observer?
- //
- // This is a good question and the why this does not work is that the .fit()
- // needs to run after the render so in this case, I just think the mutation
- // observer is more reliable. I could use some hacky setTimeout inside of
- // useEffect to do that, I guess, but I don't think it would be any better.
- const wrapperRef = useRef
(null);
- useEffect(() => {
- if (!wrapperRef.current) {
- return;
- }
- const observer = new MutationObserver(onAlertChange);
- observer.observe(wrapperRef.current, { childList: true });
-
- return () => {
- observer.disconnect();
- };
- }, [onAlertChange]);
-
- return (
-
- {state === "disconnected" ? (
-
- ) : lifecycleState === "start_error" ? (
-
- ) : lifecycleState === "starting" ? (
-
- ) : lifecycleState === "ready" &&
- prevLifecycleState.current === "starting" ? (
-
- ) : null}
-
- );
-};
-
const styles = {
terminal: (theme) => ({
width: "100%",
diff --git a/site/src/pages/TerminalPage/types.ts b/site/src/pages/TerminalPage/types.ts
new file mode 100644
index 0000000000..1a8fe3a68e
--- /dev/null
+++ b/site/src/pages/TerminalPage/types.ts
@@ -0,0 +1 @@
+export type ConnectionStatus = "connected" | "disconnected" | "initializing";
diff --git a/site/src/testHelpers/renderHelpers.tsx b/site/src/testHelpers/renderHelpers.tsx
index d79d958846..3697e61360 100644
--- a/site/src/testHelpers/renderHelpers.tsx
+++ b/site/src/testHelpers/renderHelpers.tsx
@@ -22,6 +22,14 @@ export function createTestQueryClient() {
// Helps create one query client for each test case, to make sure that tests
// are isolated and can't affect each other
return new QueryClient({
+ logger: {
+ ...console,
+ // Some tests are designed to throw errors as part of their functionality.
+ // To avoid unnecessary noise from these expected errors, the code is
+ // structured to suppress them. If this suppression becomes problematic,
+ // the code can be refactored to handle query errors on a per-test basis.
+ error: () => {},
+ },
defaultOptions: {
queries: {
retry: false,