@@ -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,32 @@ 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+ // Have to add this to handle case of devtron-stack manager and software distribution hub.
120+ const debugAgentContext = aiAgentContext
121+ ? ( {
122+ ...aiAgentContext ,
123+ prompt : `Why is application '${ appDetails . appName } ' of '${ appDetails . environmentName } ' env ${ appStatus } ?` ,
124+ data : {
125+ ...aiAgentContext . data ,
126+ ...( debugNode ? { debugNodeKind : debugNode . kind , debugNodeName : debugNode . name } : { } ) ,
127+ ...( message ? { debugError : message } : { } ) ,
128+ namespace : appDetails . namespace ,
129+ status : debugNode ?. health ?. status ?? appStatus ,
130+ } ,
131+ } as MainContext [ 'debugAgentContext' ] )
132+ : null
133+
104134 return [
105135 {
106136 id : 'app-status-row' ,
@@ -112,19 +142,13 @@ export const AppStatusBody = ({
112142 envId = { appDetails . environmentId }
113143 actionItem = {
114144 ExplainWithAIButton &&
145+ debugAgentContext &&
115146 appStatus ?. toLowerCase ( ) !== StatusType . HEALTHY . toLowerCase ( ) &&
116147 ( debugNode || message ) ? (
117148 < 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- } }
149+ intelligenceConfig = { intelligenceConfig }
150+ debugAgentContext = { debugAgentContext }
151+ onClick = { handleClose }
128152 />
129153 ) : null
130154 }
0 commit comments