1
- import { type Interpolation , type Theme , useTheme } from "@emotion/react" ;
1
+ import { type Interpolation , type Theme } from "@emotion/react" ;
2
2
import { type FC , useCallback , useEffect , useRef , useState } from "react" ;
3
3
import { Helmet } from "react-helmet-async" ;
4
4
import { useNavigate , useParams , useSearchParams } from "react-router-dom" ;
@@ -13,9 +13,6 @@ import "xterm/css/xterm.css";
13
13
import { MONOSPACE_FONT_FAMILY } from "theme/constants" ;
14
14
import { pageTitle } from "utils/page" ;
15
15
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" ;
19
16
import { openMaybePortForwardedURL } from "utils/portForward" ;
20
17
import { terminalWebsocketUrl } from "utils/terminal" ;
21
18
import { getMatchingAgentOrFirst } from "utils/workspace" ;
@@ -28,11 +25,6 @@ import {
28
25
import { useQuery } from "react-query" ;
29
26
import { deploymentConfig } from "api/queries/deployment" ;
30
27
import { workspaceByOwnerAndName } from "api/queries/workspaces" ;
31
- import {
32
- Popover ,
33
- PopoverContent ,
34
- PopoverTrigger ,
35
- } from "components/Popover/Popover" ;
36
28
import { ThemeOverride } from "contexts/ThemeProvider" ;
37
29
import themes from "theme" ;
38
30
@@ -57,6 +49,7 @@ const TerminalPage: FC = () => {
57
49
"connected" | "disconnected" | "initializing"
58
50
> ( "initializing" ) ;
59
51
const [ searchParams ] = useSearchParams ( ) ;
52
+ const isDebugging = searchParams . has ( "debug" ) ;
60
53
// The reconnection token is a unique token that identifies
61
54
// a terminal session. It's generated by the client to reduce
62
55
// a round-trip, and must be a UUIDv4.
@@ -316,126 +309,36 @@ const TerminalPage: FC = () => {
316
309
prevLifecycleState . current === "starting" && < LoadedScriptsAlert /> }
317
310
{ terminalState === "disconnected" && < DisconnectedAlert /> }
318
311
< div css = { styles . terminal } ref = { xtermRef } data-testid = "terminal" />
319
- { selectedProxy && latency && (
320
- < BottomBar proxy = { selectedProxy } latency = { latency . latencyMS } />
321
- ) }
322
312
</ div >
323
- </ ThemeOverride >
324
- ) ;
325
- } ;
326
-
327
- interface BottomBarProps {
328
- proxy : Region ;
329
- latency ?: number ;
330
- }
331
313
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
378
316
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 ,
391
322
} }
392
323
>
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 >
425
328
) ;
426
329
} ;
427
330
428
331
const styles = {
429
332
terminal : ( theme ) => ( {
430
- width : "100vw " ,
333
+ width : "100% " ,
431
334
overflow : "hidden" ,
432
335
backgroundColor : theme . palette . background . paper ,
433
336
flex : 1 ,
434
337
// These styles attempt to mimic the VS Code scrollbar.
435
338
"& .xterm" : {
436
339
padding : 4 ,
437
- width : "100vw " ,
438
- height : "100vh " ,
340
+ width : "100% " ,
341
+ height : "100% " ,
439
342
} ,
440
343
"& .xterm-viewport" : {
441
344
// This is required to force full-width on the terminal.
0 commit comments