Skip to content

Commit 29e793f

Browse files
committed
feat: enhance AppStatusModal with AI debugging capabilities and update types for improved context handling
1 parent 0fae4b9 commit 29e793f

6 files changed

Lines changed: 48 additions & 15 deletions

File tree

src/Shared/Components/AppStatusModal/AppStatusBody.tsx

Lines changed: 30 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import { getAIAnalyticsEvents } from '@Common/Helper'
2020
import { Tooltip } from '@Common/Tooltip'
2121
import { ComponentSizeType } from '@Shared/constants'
2222
import { getAppDetailsURL } from '@Shared/Helpers'
23+
import { MainContext, useMainContext } from '@Shared/Providers'
2324

2425
import { Button, ButtonComponentType, ButtonVariantType } from '../Button'
2526
import { 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
}

src/Shared/Components/AppStatusModal/AppStatusModal.component.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,7 @@ const AppStatusModal = ({
315315
deploymentStatusDetailsBreakdownData={deploymentStatusDetailsBreakdownData}
316316
selectedTab={selectedTab}
317317
debugWithAIButton={debugWithAIButton}
318+
handleClose={handleClose}
318319
/>
319320

320321
{type === 'stack-manager' && (

src/Shared/Components/AppStatusModal/types.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import { FunctionComponent, PropsWithChildren, ReactNode } from 'react'
1818

1919
import { APIOptions, DeploymentAppTypes } from '@Common/Types'
20+
import { MainContext } from '@Shared/Providers'
2021
import {
2122
AppDetails,
2223
ConfigDriftModalProps,
@@ -38,7 +39,11 @@ export type AppStatusModalProps = {
3839
processVirtualEnvironmentDeploymentData: (
3940
data?: DeploymentStatusDetailsType,
4041
) => DeploymentStatusDetailsBreakdownDataType
41-
debugWithAIButton: FunctionComponent<{ intelligenceConfig: IntelligenceConfig }>
42+
debugWithAIButton: FunctionComponent<{
43+
intelligenceConfig: IntelligenceConfig
44+
debugAgentContext: MainContext['debugAgentContext']
45+
onClick?: () => void
46+
}>
4247
} & (
4348
| {
4449
type: 'release'
@@ -59,7 +64,7 @@ export type AppStatusModalProps = {
5964
)
6065

6166
export interface AppStatusBodyProps
62-
extends Required<Pick<AppStatusModalProps, 'appDetails' | 'type' | 'debugWithAIButton'>> {
67+
extends Required<Pick<AppStatusModalProps, 'appDetails' | 'type' | 'debugWithAIButton' | 'handleClose'>> {
6368
handleShowConfigDriftModal: () => void
6469
selectedTab: AppStatusModalTabType
6570
deploymentStatusDetailsBreakdownData: DeploymentStatusDetailsBreakdownDataType

src/Shared/Providers/MainContextProvider/types.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,16 +66,20 @@ export type AIAgentContextType =
6666
envName: string
6767
clusterId: number
6868
appType: 'devtronApp' | 'devtronHelmChart'
69-
}
69+
} & Record<string, unknown>
7070
}
7171
| {
7272
source: AIAgentContextSourceType.RESOURCE_BROWSER_CLUSTER
7373
data: {
7474
clusterId: number
7575
clusterName: string
76-
}
76+
} & Record<string, unknown>
7777
}
7878

79+
export type DebugAgentContextType = AIAgentContextType & {
80+
prompt?: string
81+
}
82+
7983
export interface TempAppWindowConfig {
8084
/** Whether the temporary window is open */
8185
open: boolean
@@ -139,6 +143,8 @@ type CommonMainContextProps = {
139143
setLicenseData: Dispatch<SetStateAction<DevtronLicenseInfo>>
140144
canFetchHelmAppStatus: boolean
141145
setIntelligenceConfig: Dispatch<SetStateAction<IntelligenceConfig>>
146+
debugAgentContext: DebugAgentContextType | null
147+
setDebugAgentContext: (aiAgentContext: DebugAgentContextType | null) => void
142148
setAIAgentContext: (aiAgentContext: AIAgentContextType) => void
143149
setSidePanelConfig: Dispatch<SetStateAction<SidePanelConfig>>
144150
} & Pick<EnvironmentDataValuesDTO, 'isResourceRecommendationEnabled'>

src/Shared/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1327,7 +1327,7 @@ export interface DeploymentStatusDetailsBreakdownDataType {
13271327

13281328
export interface IntelligenceConfig {
13291329
clusterId: number
1330-
metadata: Record<string, string>
1330+
metadata: Record<string, string | number>
13311331
prompt: string
13321332
analyticsCategory: string
13331333
}

src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,7 @@ export interface customEnv {
187187
* @default false
188188
*/
189189
FEATURE_STORAGE_ENABLE?: boolean
190+
FEATURE_ATHENA_DEBUG_MODE_ENABLE?: boolean
190191
}
191192
declare global {
192193
interface Window {

0 commit comments

Comments
 (0)