1
1
import Collapse from "@mui/material/Collapse" ;
2
2
import Skeleton from "@mui/material/Skeleton" ;
3
3
import Tooltip from "@mui/material/Tooltip" ;
4
- import { makeStyles } from "@mui/styles " ;
4
+ import { type Interpolation , type Theme } from "@emotion/react " ;
5
5
import * as API from "api/api" ;
6
- import {
6
+ import type {
7
7
Workspace ,
8
8
WorkspaceAgent ,
9
9
WorkspaceAgentLogSource ,
@@ -30,7 +30,6 @@ import {
30
30
import AutoSizer from "react-virtualized-auto-sizer" ;
31
31
import { FixedSizeList as List , ListOnScrollProps } from "react-window" ;
32
32
import { colors } from "theme/colors" ;
33
- import { combineClasses } from "utils/combineClasses" ;
34
33
import { Stack } from "../Stack/Stack" ;
35
34
import { AgentLatency } from "./AgentLatency" ;
36
35
import { AgentMetadata } from "./AgentMetadata" ;
@@ -75,7 +74,6 @@ export const AgentRow: FC<AgentRowProps> = ({
75
74
sshPrefix,
76
75
storybookLogs,
77
76
} ) => {
78
- const styles = useStyles ( ) ;
79
77
const hasAppsToDisplay = ! hideVSCodeDesktopButton || agent . apps . length > 0 ;
80
78
const shouldDisplayApps =
81
79
showApps &&
@@ -159,28 +157,26 @@ export const AgentRow: FC<AgentRowProps> = ({
159
157
key = { agent . id }
160
158
direction = "column"
161
159
spacing = { 0 }
162
- className = { combineClasses ( [
160
+ css = { [
163
161
styles . agentRow ,
164
162
styles [ `agentRow-${ agent . status } ` ] ,
165
163
styles [ `agentRow-lifecycle-${ agent . lifecycle_state } ` ] ,
166
- ] ) }
164
+ ] }
167
165
>
168
- < div className = { styles . agentInfo } >
169
- < div className = { styles . agentNameAndStatus } >
170
- < div className = { styles . agentNameAndInfo } >
166
+ < div css = { styles . agentInfo } >
167
+ < div css = { styles . agentNameAndStatus } >
168
+ < div css = { styles . agentNameAndInfo } >
171
169
< AgentStatus agent = { agent } />
172
- < div className = { styles . agentName } > { agent . name } </ div >
170
+ < div css = { styles . agentName } > { agent . name } </ div >
173
171
< Stack
174
172
direction = "row"
175
173
spacing = { 2 }
176
174
alignItems = "baseline"
177
- className = { styles . agentDescription }
175
+ css = { styles . agentDescription }
178
176
>
179
177
{ agent . status === "connected" && (
180
178
< >
181
- < span className = { styles . agentOS } >
182
- { agent . operating_system }
183
- </ span >
179
+ < span css = { styles . agentOS } > { agent . operating_system } </ span >
184
180
< AgentVersion
185
181
agent = { agent }
186
182
serverVersion = { serverVersion }
@@ -200,7 +196,7 @@ export const AgentRow: FC<AgentRowProps> = ({
200
196
</ div >
201
197
202
198
{ agent . status === "connected" && (
203
- < div className = { styles . agentButtons } >
199
+ < div css = { styles . agentButtons } >
204
200
{ shouldDisplayApps && (
205
201
< >
206
202
{ ( agent . display_apps . includes ( "vscode" ) ||
@@ -258,18 +254,18 @@ export const AgentRow: FC<AgentRowProps> = ({
258
254
) }
259
255
260
256
{ agent . status === "connecting" && (
261
- < div className = { styles . agentButtons } >
257
+ < div css = { styles . agentButtons } >
262
258
< Skeleton
263
259
width = { 80 }
264
260
height = { 32 }
265
261
variant = "rectangular"
266
- className = { styles . buttonSkeleton }
262
+ css = { styles . buttonSkeleton }
267
263
/>
268
264
< Skeleton
269
265
width = { 110 }
270
266
height = { 32 }
271
267
variant = "rectangular"
272
- className = { styles . buttonSkeleton }
268
+ css = { styles . buttonSkeleton }
273
269
/>
274
270
</ div >
275
271
) }
@@ -278,7 +274,7 @@ export const AgentRow: FC<AgentRowProps> = ({
278
274
< AgentMetadata storybookMetadata = { storybookAgentMetadata } agent = { agent } />
279
275
280
276
{ hasStartupFeatures && (
281
- < div className = { styles . logsPanel } >
277
+ < div css = { styles . logsPanel } >
282
278
< Collapse in = { showLogs } >
283
279
< AutoSizer disableHeight >
284
280
{ ( { width } ) => (
@@ -289,7 +285,7 @@ export const AgentRow: FC<AgentRowProps> = ({
289
285
itemCount = { startupLogs . length }
290
286
itemSize = { logLineHeight }
291
287
width = { width }
292
- className = { styles . startupLogs }
288
+ css = { styles . startupLogs }
293
289
onScroll = { handleLogScroll }
294
290
>
295
291
{ ( { index, style } ) => {
@@ -429,13 +425,10 @@ export const AgentRow: FC<AgentRowProps> = ({
429
425
</ AutoSizer >
430
426
</ Collapse >
431
427
432
- < div className = { styles . logsPanelButtons } >
428
+ < div css = { styles . logsPanelButtons } >
433
429
{ showLogs ? (
434
430
< button
435
- className = { combineClasses ( [
436
- styles . logsPanelButton ,
437
- styles . toggleLogsButton ,
438
- ] ) }
431
+ css = { [ styles . logsPanelButton , styles . toggleLogsButton ] }
439
432
onClick = { ( ) => {
440
433
setShowLogs ( ( v ) => ! v ) ;
441
434
} }
@@ -445,10 +438,7 @@ export const AgentRow: FC<AgentRowProps> = ({
445
438
</ button >
446
439
) : (
447
440
< button
448
- className = { combineClasses ( [
449
- styles . logsPanelButton ,
450
- styles . toggleLogsButton ,
451
- ] ) }
441
+ css = { [ styles . logsPanelButton , styles . toggleLogsButton ] }
452
442
onClick = { ( ) => {
453
443
setShowLogs ( ( v ) => ! v ) ;
454
444
} }
@@ -511,68 +501,68 @@ const useAgentLogs = (
511
501
return logs ;
512
502
} ;
513
503
514
- const useStyles = makeStyles ( ( theme ) => ( {
515
- agentRow : {
504
+ const styles = {
505
+ agentRow : ( theme ) => ( {
516
506
backgroundColor : theme . palette . background . paperLight ,
517
507
fontSize : 16 ,
518
508
borderLeft : `2px solid ${ theme . palette . text . secondary } ` ,
519
509
520
510
"&:not(:first-of-type)" : {
521
511
borderTop : `2px solid ${ theme . palette . divider } ` ,
522
512
} ,
523
- } ,
513
+ } ) ,
524
514
525
- "agentRow-connected" : {
515
+ "agentRow-connected" : ( theme ) => ( {
526
516
borderLeftColor : theme . palette . success . light ,
527
- } ,
517
+ } ) ,
528
518
529
- "agentRow-disconnected" : {
519
+ "agentRow-disconnected" : ( theme ) => ( {
530
520
borderLeftColor : theme . palette . text . secondary ,
531
- } ,
521
+ } ) ,
532
522
533
- "agentRow-connecting" : {
523
+ "agentRow-connecting" : ( theme ) => ( {
534
524
borderLeftColor : theme . palette . info . light ,
535
- } ,
525
+ } ) ,
536
526
537
- "agentRow-timeout" : {
527
+ "agentRow-timeout" : ( theme ) => ( {
538
528
borderLeftColor : theme . palette . warning . light ,
539
- } ,
529
+ } ) ,
540
530
541
531
"agentRow-lifecycle-created" : { } ,
542
532
543
- "agentRow-lifecycle-starting" : {
533
+ "agentRow-lifecycle-starting" : ( theme ) => ( {
544
534
borderLeftColor : theme . palette . info . light ,
545
- } ,
535
+ } ) ,
546
536
547
- "agentRow-lifecycle-ready" : {
537
+ "agentRow-lifecycle-ready" : ( theme ) => ( {
548
538
borderLeftColor : theme . palette . success . light ,
549
- } ,
539
+ } ) ,
550
540
551
- "agentRow-lifecycle-start_timeout" : {
541
+ "agentRow-lifecycle-start_timeout" : ( theme ) => ( {
552
542
borderLeftColor : theme . palette . warning . light ,
553
- } ,
543
+ } ) ,
554
544
555
- "agentRow-lifecycle-start_error" : {
545
+ "agentRow-lifecycle-start_error" : ( theme ) => ( {
556
546
borderLeftColor : theme . palette . error . light ,
557
- } ,
547
+ } ) ,
558
548
559
- "agentRow-lifecycle-shutting_down" : {
549
+ "agentRow-lifecycle-shutting_down" : ( theme ) => ( {
560
550
borderLeftColor : theme . palette . info . light ,
561
- } ,
551
+ } ) ,
562
552
563
- "agentRow-lifecycle-shutdown_timeout" : {
553
+ "agentRow-lifecycle-shutdown_timeout" : ( theme ) => ( {
564
554
borderLeftColor : theme . palette . warning . light ,
565
- } ,
555
+ } ) ,
566
556
567
- "agentRow-lifecycle-shutdown_error" : {
557
+ "agentRow-lifecycle-shutdown_error" : ( theme ) => ( {
568
558
borderLeftColor : theme . palette . error . light ,
569
- } ,
559
+ } ) ,
570
560
571
- "agentRow-lifecycle-off" : {
561
+ "agentRow-lifecycle-off" : ( theme ) => ( {
572
562
borderLeftColor : theme . palette . text . secondary ,
573
- } ,
563
+ } ) ,
574
564
575
- agentInfo : {
565
+ agentInfo : ( theme ) => ( {
576
566
padding : theme . spacing ( 2 , 4 ) ,
577
567
display : "flex" ,
578
568
alignItems : "center" ,
@@ -582,9 +572,9 @@ const useStyles = makeStyles((theme) => ({
582
572
[ theme . breakpoints . down ( "md" ) ] : {
583
573
gap : theme . spacing ( 2 ) ,
584
574
} ,
585
- } ,
575
+ } ) ,
586
576
587
- agentNameAndInfo : {
577
+ agentNameAndInfo : ( theme ) => ( {
588
578
display : "flex" ,
589
579
alignItems : "center" ,
590
580
gap : theme . spacing ( 3 ) ,
@@ -593,9 +583,9 @@ const useStyles = makeStyles((theme) => ({
593
583
[ theme . breakpoints . down ( "md" ) ] : {
594
584
gap : theme . spacing ( 1.5 ) ,
595
585
} ,
596
- } ,
586
+ } ) ,
597
587
598
- agentButtons : {
588
+ agentButtons : ( theme ) => ( {
599
589
display : "flex" ,
600
590
gap : theme . spacing ( 1 ) ,
601
591
justifyContent : "flex-end" ,
@@ -606,14 +596,14 @@ const useStyles = makeStyles((theme) => ({
606
596
marginLeft : 0 ,
607
597
justifyContent : "flex-start" ,
608
598
} ,
609
- } ,
599
+ } ) ,
610
600
611
- agentDescription : {
601
+ agentDescription : ( theme ) => ( {
612
602
fontSize : 14 ,
613
603
color : theme . palette . text . secondary ,
614
- } ,
604
+ } ) ,
615
605
616
- startupLogs : {
606
+ startupLogs : ( theme ) => ( {
617
607
maxHeight : 256 ,
618
608
borderBottom : `1px solid ${ theme . palette . divider } ` ,
619
609
backgroundColor : theme . palette . background . paper ,
@@ -623,19 +613,19 @@ const useStyles = makeStyles((theme) => ({
623
613
"& > div" : {
624
614
position : "relative" ,
625
615
} ,
626
- } ,
616
+ } ) ,
627
617
628
- agentNameAndStatus : {
618
+ agentNameAndStatus : ( theme ) => ( {
629
619
display : "flex" ,
630
620
alignItems : "center" ,
631
621
gap : theme . spacing ( 4 ) ,
632
622
633
623
[ theme . breakpoints . down ( "md" ) ] : {
634
624
width : "100%" ,
635
625
} ,
636
- } ,
626
+ } ) ,
637
627
638
- agentName : {
628
+ agentName : ( theme ) => ( {
639
629
whiteSpace : "nowrap" ,
640
630
overflow : "hidden" ,
641
631
textOverflow : "ellipsis" ,
@@ -648,15 +638,15 @@ const useStyles = makeStyles((theme) => ({
648
638
[ theme . breakpoints . down ( "md" ) ] : {
649
639
overflow : "unset" ,
650
640
} ,
651
- } ,
641
+ } ) ,
652
642
653
- agentDataGroup : {
643
+ agentDataGroup : ( theme ) => ( {
654
644
display : "flex" ,
655
645
alignItems : "baseline" ,
656
646
gap : theme . spacing ( 6 ) ,
657
- } ,
647
+ } ) ,
658
648
659
- agentData : {
649
+ agentData : ( theme ) => ( {
660
650
display : "flex" ,
661
651
flexDirection : "column" ,
662
652
fontSize : 12 ,
@@ -665,17 +655,17 @@ const useStyles = makeStyles((theme) => ({
665
655
fontWeight : 500 ,
666
656
color : theme . palette . text . secondary ,
667
657
} ,
668
- } ,
658
+ } ) ,
669
659
670
- logsPanel : {
660
+ logsPanel : ( theme ) => ( {
671
661
borderTop : `1px solid ${ theme . palette . divider } ` ,
672
- } ,
662
+ } ) ,
673
663
674
664
logsPanelButtons : {
675
665
display : "flex" ,
676
666
} ,
677
667
678
- logsPanelButton : {
668
+ logsPanelButton : ( theme ) => ( {
679
669
textAlign : "left" ,
680
670
background : "transparent" ,
681
671
border : 0 ,
@@ -696,7 +686,7 @@ const useStyles = makeStyles((theme) => ({
696
686
"& svg" : {
697
687
color : "inherit" ,
698
688
} ,
699
- } ,
689
+ } ) ,
700
690
701
691
toggleLogsButton : {
702
692
width : "100%" ,
@@ -706,17 +696,17 @@ const useStyles = makeStyles((theme) => ({
706
696
borderRadius : 4 ,
707
697
} ,
708
698
709
- agentErrorMessage : {
699
+ agentErrorMessage : ( theme ) => ( {
710
700
fontSize : 12 ,
711
701
fontWeight : 400 ,
712
702
marginTop : theme . spacing ( 0.5 ) ,
713
703
color : theme . palette . warning . light ,
714
- } ,
704
+ } ) ,
715
705
716
706
agentOS : {
717
707
textTransform : "capitalize" ,
718
708
} ,
719
- } ) ) ;
709
+ } satisfies Record < string , Interpolation < Theme > > ;
720
710
721
711
// These colors were picked at random. Feel free
722
712
// to add more, adjust, or change! Users will not
0 commit comments