Skip to content

Commit ebe0582

Browse files
fix(site): fix web terminal bottom overflow (coder#12228)
1 parent 91c3df7 commit ebe0582

File tree

1 file changed

+16
-113
lines changed

1 file changed

+16
-113
lines changed

site/src/pages/TerminalPage/TerminalPage.tsx

Lines changed: 16 additions & 113 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { type Interpolation, type Theme, useTheme } from "@emotion/react";
1+
import { type Interpolation, type Theme } from "@emotion/react";
22
import { type FC, useCallback, useEffect, useRef, useState } from "react";
33
import { Helmet } from "react-helmet-async";
44
import { useNavigate, useParams, useSearchParams } from "react-router-dom";
@@ -13,9 +13,6 @@ import "xterm/css/xterm.css";
1313
import { MONOSPACE_FONT_FAMILY } from "theme/constants";
1414
import { pageTitle } from "utils/page";
1515
import { useProxy } from "contexts/ProxyContext";
16-
import type { Region } from "api/typesGenerated";
17-
import { getLatencyColor } from "utils/latency";
18-
import { ProxyStatusLatency } from "components/ProxyStatusLatency/ProxyStatusLatency";
1916
import { openMaybePortForwardedURL } from "utils/portForward";
2017
import { terminalWebsocketUrl } from "utils/terminal";
2118
import { getMatchingAgentOrFirst } from "utils/workspace";
@@ -28,11 +25,6 @@ import {
2825
import { useQuery } from "react-query";
2926
import { deploymentConfig } from "api/queries/deployment";
3027
import { workspaceByOwnerAndName } from "api/queries/workspaces";
31-
import {
32-
Popover,
33-
PopoverContent,
34-
PopoverTrigger,
35-
} from "components/Popover/Popover";
3628
import { ThemeOverride } from "contexts/ThemeProvider";
3729
import themes from "theme";
3830

@@ -57,6 +49,7 @@ const TerminalPage: FC = () => {
5749
"connected" | "disconnected" | "initializing"
5850
>("initializing");
5951
const [searchParams] = useSearchParams();
52+
const isDebugging = searchParams.has("debug");
6053
// The reconnection token is a unique token that identifies
6154
// a terminal session. It's generated by the client to reduce
6255
// a round-trip, and must be a UUIDv4.
@@ -316,126 +309,36 @@ const TerminalPage: FC = () => {
316309
prevLifecycleState.current === "starting" && <LoadedScriptsAlert />}
317310
{terminalState === "disconnected" && <DisconnectedAlert />}
318311
<div css={styles.terminal} ref={xtermRef} data-testid="terminal" />
319-
{selectedProxy && latency && (
320-
<BottomBar proxy={selectedProxy} latency={latency.latencyMS} />
321-
)}
322312
</div>
323-
</ThemeOverride>
324-
);
325-
};
326-
327-
interface BottomBarProps {
328-
proxy: Region;
329-
latency?: number;
330-
}
331313

332-
const BottomBar: FC<BottomBarProps> = ({ proxy, latency }) => {
333-
const theme = useTheme();
334-
const color = getLatencyColor(theme, latency);
335-
336-
return (
337-
<div
338-
css={{
339-
padding: "0 16px",
340-
background: theme.palette.background.paper,
341-
display: "flex",
342-
alignItems: "center",
343-
justifyContent: "flex-end",
344-
fontSize: 12,
345-
borderTop: `1px solid ${theme.palette.divider}`,
346-
}}
347-
>
348-
<Popover mode="hover">
349-
<PopoverTrigger>
350-
<button
351-
aria-label="Terminal latency"
352-
aria-haspopup="true"
353-
css={{
354-
background: "none",
355-
cursor: "pointer",
356-
display: "flex",
357-
alignItems: "center",
358-
gap: 8,
359-
border: 0,
360-
padding: 8,
361-
}}
362-
>
363-
<div
364-
css={{
365-
height: 6,
366-
width: 6,
367-
backgroundColor: color,
368-
border: 0,
369-
borderRadius: 3,
370-
}}
371-
/>
372-
<ProxyStatusLatency latency={latency} />
373-
</button>
374-
</PopoverTrigger>
375-
<PopoverContent
376-
id="latency-popover"
377-
disableRestoreFocus
314+
{latency && isDebugging && (
315+
<span
378316
css={{
379-
pointerEvents: "none",
380-
"& .MuiPaper-root": {
381-
padding: "8px 16px",
382-
},
383-
}}
384-
anchorOrigin={{
385-
vertical: "top",
386-
horizontal: "right",
387-
}}
388-
transformOrigin={{
389-
vertical: "bottom",
390-
horizontal: "right",
317+
position: "absolute",
318+
bottom: 24,
319+
right: 24,
320+
color: theme.palette.text.disabled,
321+
fontSize: 14,
391322
}}
392323
>
393-
<div
394-
css={{
395-
fontSize: 13,
396-
color: theme.palette.text.secondary,
397-
fontWeight: 500,
398-
}}
399-
>
400-
Selected proxy
401-
</div>
402-
<div
403-
css={{
404-
fontSize: 14,
405-
display: "flex",
406-
gap: 3,
407-
alignItems: "center",
408-
}}
409-
>
410-
<div css={{ display: "flex", alignItems: "center", gap: 1 }}>
411-
<div css={{ width: 12, height: 12, lineHeight: 0 }}>
412-
<img
413-
src={proxy.icon_url}
414-
alt=""
415-
css={{ objectFit: "contain", width: "100%", height: "100%" }}
416-
/>
417-
</div>
418-
{proxy.display_name}
419-
</div>
420-
<ProxyStatusLatency latency={latency} />
421-
</div>
422-
</PopoverContent>
423-
</Popover>
424-
</div>
324+
Latency: {latency.latencyMS.toFixed(0)}ms
325+
</span>
326+
)}
327+
</ThemeOverride>
425328
);
426329
};
427330

428331
const styles = {
429332
terminal: (theme) => ({
430-
width: "100vw",
333+
width: "100%",
431334
overflow: "hidden",
432335
backgroundColor: theme.palette.background.paper,
433336
flex: 1,
434337
// These styles attempt to mimic the VS Code scrollbar.
435338
"& .xterm": {
436339
padding: 4,
437-
width: "100vw",
438-
height: "100vh",
340+
width: "100%",
341+
height: "100%",
439342
},
440343
"& .xterm-viewport": {
441344
// This is required to force full-width on the terminal.

0 commit comments

Comments
 (0)