1
- import type { Interpolation , Theme } from "@emotion/react" ;
2
1
import MuiLink from "@mui/material/Link" ;
3
2
import type { Feature } from "api/typesGenerated" ;
4
3
import { ErrorAlert } from "components/Alert/ErrorAlert" ;
@@ -74,13 +73,13 @@ export const ManagedAgentsConsumption: FC<ManagedAgentsConsumptionProps> = ({
74
73
// If no feature is provided or it's disabled, show disabled state
75
74
if ( ! managedAgentFeature ?. enabled ) {
76
75
return (
77
- < div css = { styles . disabledRoot } >
76
+ < div className = "min-h-60 flex items-center justify-center rounded-lg border border-solid p-12" >
78
77
< Stack alignItems = "center" spacing = { 1 } >
79
78
< Stack alignItems = "center" spacing = { 0.5 } >
80
- < span css = { styles . disabledTitle } >
79
+ < span className = "text-base" >
81
80
Managed AI Agents Disabled
82
81
</ span >
83
- < span css = { styles . disabledDescription } >
82
+ < span className = "text-content-secondary text-center max-w-[464px] mt-2" >
84
83
Managed AI agents are not included in your current license.
85
84
Contact{ " " }
86
85
< MuiLink href = "mailto:sales@coder.com" > sales</ MuiLink > to upgrade
@@ -102,6 +101,20 @@ export const ManagedAgentsConsumption: FC<ManagedAgentsConsumptionProps> = ({
102
101
const includedPercentage = Math . min ( ( included / limit ) * 100 , 100 ) ;
103
102
const remainingPercentage = Math . max ( 100 - includedPercentage , 0 ) ;
104
103
104
+ // Determine usage bar color based on percentage
105
+ const getUsageColor = ( ) => {
106
+ const actualUsagePercent = ( usage / limit ) * 100 ;
107
+ if ( actualUsagePercent >= 100 ) {
108
+ return "bg-highlight-red" ; // Critical: at or over limit
109
+ }
110
+ if ( actualUsagePercent >= 80 ) {
111
+ return "bg-surface-orange" ; // Warning: approaching limit
112
+ }
113
+ return "bg-highlight-green" ; // Normal: safe usage
114
+ } ;
115
+
116
+ const usageBarColor = getUsageColor ( ) ;
117
+
105
118
return (
106
119
< section className = "border border-solid rounded" >
107
120
< div className = "p-4" >
@@ -139,7 +152,7 @@ export const ManagedAgentsConsumption: FC<ManagedAgentsConsumptionProps> = ({
139
152
< ul >
140
153
< li className = "flex items-center gap-2" >
141
154
< div
142
- className = " rounded-[2px] bg-highlight-green size-3 inline-block"
155
+ className = { ` rounded-[2px] ${ usageBarColor } size-3 inline-block` }
143
156
aria-label = "Legend for current usage in the chart"
144
157
/>
145
158
Amount of started workspaces with an AI agent.
@@ -175,7 +188,7 @@ export const ManagedAgentsConsumption: FC<ManagedAgentsConsumptionProps> = ({
175
188
176
189
< div className = "relative h-6 bg-surface-secondary rounded overflow-hidden" >
177
190
< div
178
- className = " absolute top-0 left-0 h-full bg-highlight-green transition-all duration-300"
191
+ className = { ` absolute top-0 left-0 h-full ${ usageBarColor } transition-all duration-300` }
179
192
style = { { width : `${ usagePercentage } %` } }
180
193
/>
181
194
@@ -230,26 +243,3 @@ export const ManagedAgentsConsumption: FC<ManagedAgentsConsumptionProps> = ({
230
243
</ section >
231
244
) ;
232
245
} ;
233
-
234
- const styles = {
235
- disabledTitle : {
236
- fontSize : 16 ,
237
- } ,
238
-
239
- disabledRoot : ( theme ) => ( {
240
- minHeight : 240 ,
241
- display : "flex" ,
242
- alignItems : "center" ,
243
- justifyContent : "center" ,
244
- borderRadius : 8 ,
245
- border : `1px solid ${ theme . palette . divider } ` ,
246
- padding : 48 ,
247
- } ) ,
248
-
249
- disabledDescription : ( theme ) => ( {
250
- color : theme . palette . text . secondary ,
251
- textAlign : "center" ,
252
- maxWidth : 464 ,
253
- marginTop : 8 ,
254
- } ) ,
255
- } satisfies Record < string , Interpolation < Theme > > ;
0 commit comments