@@ -20,6 +20,7 @@ import { getAIAnalyticsEvents } from '@Common/Helper'
2020import { Tooltip } from '@Common/Tooltip'
2121import { ComponentSizeType } from '@Shared/constants'
2222import { getAppDetailsURL } from '@Shared/Helpers'
23+ import { MainContext , useMainContext } from '@Shared/Providers'
2324
2425import { Button , ButtonComponentType , ButtonVariantType } from '../Button'
2526import { DeploymentStatusDetailBreakdown } from '../CICDHistory'
@@ -86,7 +87,10 @@ export const AppStatusBody = ({
8687 deploymentStatusDetailsBreakdownData,
8788 selectedTab,
8889 debugWithAIButton : ExplainWithAIButton ,
90+ handleClose,
8991} : AppStatusBodyProps ) => {
92+ const { aiAgentContext } = useMainContext ( )
93+
9094 const appStatus = appDetails . resourceTree ?. status ?. toUpperCase ( ) || appDetails . appStatus
9195
9296 const getAppStatusInfoCardItems = ( ) : ( Omit < ComponentProps < typeof InfoCardItem > , 'isLast' > & { id : string } ) [ ] => {
@@ -101,6 +105,29 @@ export const AppStatusBody = ({
101105 )
102106 const debugObject = `${ debugNode ?. kind } /${ debugNode ?. name } `
103107
108+ const intelligenceConfig : MainContext [ 'intelligenceConfig' ] = {
109+ clusterId : appDetails . clusterId ,
110+ metadata : {
111+ ...( debugNode ? { object : debugObject } : { message } ) ,
112+ namespace : appDetails . namespace ,
113+ status : debugNode ?. health ?. status ?? appStatus ,
114+ } ,
115+ prompt : `Debug ${ message || 'error' } ${ debugNode ? `of ${ debugObject } ` : '' } in ${ appDetails . namespace } ` ,
116+ analyticsCategory : getAIAnalyticsEvents ( 'APP_STATUS' , appDetails . appType ) ,
117+ }
118+
119+ const debugAgentContext = {
120+ ...aiAgentContext ,
121+ prompt : `Why is application '${ appDetails . appName } ' of '${ appDetails . environmentName } ' env ${ appStatus } ?` ,
122+ data : {
123+ ...aiAgentContext . data ,
124+ ...( debugNode ? { debugNodeKind : debugNode . kind , debugNodeName : debugNode . name } : { } ) ,
125+ ...( message ? { additionalMessage : message } : { } ) ,
126+ namespace : appDetails . namespace ,
127+ status : debugNode ?. health ?. status ?? appStatus ,
128+ } ,
129+ } as MainContext [ 'debugAgentContext' ]
130+
104131 return [
105132 {
106133 id : 'app-status-row' ,
@@ -115,16 +142,9 @@ export const AppStatusBody = ({
115142 appStatus ?. toLowerCase ( ) !== StatusType . HEALTHY . toLowerCase ( ) &&
116143 ( debugNode || message ) ? (
117144 < ExplainWithAIButton
118- intelligenceConfig = { {
119- clusterId : appDetails . clusterId ,
120- metadata : {
121- ...( debugNode ? { object : debugObject } : { message } ) ,
122- namespace : appDetails . namespace ,
123- status : debugNode ?. health ?. status ?? appStatus ,
124- } ,
125- prompt : `Debug ${ message || 'error' } ${ debugNode ? `of ${ debugObject } ` : '' } in ${ appDetails . namespace } ` ,
126- analyticsCategory : getAIAnalyticsEvents ( 'APP_STATUS' , appDetails . appType ) ,
127- } }
145+ intelligenceConfig = { intelligenceConfig }
146+ debugAgentContext = { debugAgentContext }
147+ onClick = { handleClose }
128148 />
129149 ) : null
130150 }
0 commit comments