Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@devtron-labs/devtron-fe-common-lib",
"version": "1.22.0-beta-4",
"version": "1.22.0-beta-5",
"description": "Supporting common component library",
"type": "module",
"main": "dist/index.js",
Expand Down
2 changes: 2 additions & 0 deletions src/Common/Constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ export const URLS = {
APP_DEPLOYMNENT_HISTORY: 'deployments',
APP_DETAILS: 'details',
APP_DETAILS_K8: 'k8s-resources', // for V2
EXTERNAL_ARGO_APP: 'eaa',
EXTERNAL_FLUX_APP: 'external-flux',
DETAILS: '/details',
CD_DETAILS: 'cd-details',
APP_TRIGGER: 'trigger',
Expand Down
40 changes: 30 additions & 10 deletions src/Shared/Components/AppStatusModal/AppStatusBody.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import { getAIAnalyticsEvents } from '@Common/Helper'
import { Tooltip } from '@Common/Tooltip'
import { ComponentSizeType } from '@Shared/constants'
import { getAppDetailsURL } from '@Shared/Helpers'
import { MainContext, useMainContext } from '@Shared/Providers'

import { Button, ButtonComponentType, ButtonVariantType } from '../Button'
import { DeploymentStatusDetailBreakdown } from '../CICDHistory'
Expand Down Expand Up @@ -86,7 +87,10 @@ export const AppStatusBody = ({
deploymentStatusDetailsBreakdownData,
selectedTab,
debugWithAIButton: ExplainWithAIButton,
handleClose,
}: AppStatusBodyProps) => {
const { aiAgentContext } = useMainContext()

const appStatus = appDetails.resourceTree?.status?.toUpperCase() || appDetails.appStatus

const getAppStatusInfoCardItems = (): (Omit<ComponentProps<typeof InfoCardItem>, 'isLast'> & { id: string })[] => {
Expand All @@ -101,6 +105,29 @@ export const AppStatusBody = ({
)
const debugObject = `${debugNode?.kind}/${debugNode?.name}`

const intelligenceConfig: MainContext['intelligenceConfig'] = {
clusterId: appDetails.clusterId,
metadata: {
...(debugNode ? { object: debugObject } : { message }),
namespace: appDetails.namespace,
status: debugNode?.health?.status ?? appStatus,
},
prompt: `Debug ${message || 'error'} ${debugNode ? `of ${debugObject}` : ''} in ${appDetails.namespace}`,
analyticsCategory: getAIAnalyticsEvents('APP_STATUS', appDetails.appType),
}

const debugAgentContext = {
...aiAgentContext,
prompt: `Why is application '${appDetails.appName}' of '${appDetails.environmentName}' env ${appStatus}?`,
data: {
...aiAgentContext.data,
...(debugNode ? { debugNodeKind: debugNode.kind, debugNodeName: debugNode.name } : {}),
...(message ? { additionalMessage: message } : {}),
namespace: appDetails.namespace,
status: debugNode?.health?.status ?? appStatus,
},
} as MainContext['debugAgentContext']
Comment thread
AbhishekA1509 marked this conversation as resolved.
Outdated

return [
{
id: 'app-status-row',
Expand All @@ -115,16 +142,9 @@ export const AppStatusBody = ({
appStatus?.toLowerCase() !== StatusType.HEALTHY.toLowerCase() &&
(debugNode || message) ? (
<ExplainWithAIButton
intelligenceConfig={{
clusterId: appDetails.clusterId,
metadata: {
...(debugNode ? { object: debugObject } : { message }),
namespace: appDetails.namespace,
status: debugNode?.health?.status ?? appStatus,
},
prompt: `Debug ${message || 'error'} ${debugNode ? `of ${debugObject}` : ''} in ${appDetails.namespace}`,
analyticsCategory: getAIAnalyticsEvents('APP_STATUS', appDetails.appType),
}}
intelligenceConfig={intelligenceConfig}
debugAgentContext={debugAgentContext}
onClick={handleClose}
/>
) : null
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,7 @@ const AppStatusModal = ({
deploymentStatusDetailsBreakdownData={deploymentStatusDetailsBreakdownData}
selectedTab={selectedTab}
debugWithAIButton={debugWithAIButton}
handleClose={handleClose}
/>

{type === 'stack-manager' && (
Expand Down
9 changes: 7 additions & 2 deletions src/Shared/Components/AppStatusModal/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import { FunctionComponent, PropsWithChildren, ReactNode } from 'react'

import { APIOptions, DeploymentAppTypes } from '@Common/Types'
import { MainContext } from '@Shared/Providers'
import {
AppDetails,
ConfigDriftModalProps,
Expand All @@ -38,7 +39,11 @@ export type AppStatusModalProps = {
processVirtualEnvironmentDeploymentData: (
data?: DeploymentStatusDetailsType,
) => DeploymentStatusDetailsBreakdownDataType
debugWithAIButton: FunctionComponent<{ intelligenceConfig: IntelligenceConfig }>
debugWithAIButton: FunctionComponent<{
intelligenceConfig: IntelligenceConfig
debugAgentContext: MainContext['debugAgentContext']
onClick?: () => void
}>
} & (
| {
type: 'release'
Expand All @@ -59,7 +64,7 @@ export type AppStatusModalProps = {
)

export interface AppStatusBodyProps
extends Required<Pick<AppStatusModalProps, 'appDetails' | 'type' | 'debugWithAIButton'>> {
extends Required<Pick<AppStatusModalProps, 'appDetails' | 'type' | 'debugWithAIButton' | 'handleClose'>> {
handleShowConfigDriftModal: () => void
selectedTab: AppStatusModalTabType
deploymentStatusDetailsBreakdownData: DeploymentStatusDetailsBreakdownDataType
Expand Down
55 changes: 46 additions & 9 deletions src/Shared/Providers/MainContextProvider/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,26 +56,61 @@ export enum AIAgentContextSourceType {
RESOURCE_BROWSER_CLUSTER = 'resource-browser-cluster',
}

export type AIAgentAppType =
| 'devtronApp'
| 'devtronHelmChart'
| 'externalHelmChart'
| 'externalArgoApp'
| 'externalFluxApp'

type AIAgentAppDataMasterType = {
appId: number | string
appName: string
envId: number
envName: string
clusterId: number
namespace: string
appType: AIAgentAppType
fluxAppDeploymentType: string
}

type AIAgentAppDataType<TAppType extends AIAgentAppType, TRequiredFields extends keyof AIAgentAppDataMasterType> = Pick<
AIAgentAppDataMasterType,
TRequiredFields
> & {
[K in Exclude<keyof AIAgentAppDataMasterType, TRequiredFields | 'appType'>]?: never
} & {
appType: TAppType
}

export type AIAgentContextType =
| {
source: AIAgentContextSourceType.APP_DETAILS
data: {
appId: number
envId: number
appName: string
envName: string
clusterId: number
appType: 'devtronApp' | 'devtronHelmChart'
}
data:
| AIAgentAppDataType<
'devtronApp' | 'devtronHelmChart',
'appId' | 'appName' | 'envId' | 'envName' | 'clusterId'
>
| AIAgentAppDataType<'externalHelmChart', 'appId' | 'appName' | 'clusterId' | 'namespace'>
| AIAgentAppDataType<'externalArgoApp', 'appName' | 'clusterId' | 'namespace'>
| (AIAgentAppDataType<
'externalFluxApp',
'appName' | 'clusterId' | 'namespace' | 'fluxAppDeploymentType'
> &
Record<string, unknown>)
}
| {
source: AIAgentContextSourceType.RESOURCE_BROWSER_CLUSTER
data: {
clusterId: number
clusterName: string
}
} & Record<string, unknown>
}

export type DebugAgentContextType = AIAgentContextType & {
prompt?: string
}

export interface TempAppWindowConfig {
/** Whether the temporary window is open */
open: boolean
Expand Down Expand Up @@ -139,6 +174,8 @@ type CommonMainContextProps = {
setLicenseData: Dispatch<SetStateAction<DevtronLicenseInfo>>
canFetchHelmAppStatus: boolean
setIntelligenceConfig: Dispatch<SetStateAction<IntelligenceConfig>>
debugAgentContext: DebugAgentContextType | null
setDebugAgentContext: (aiAgentContext: DebugAgentContextType | null) => void
setAIAgentContext: (aiAgentContext: AIAgentContextType) => void
setSidePanelConfig: Dispatch<SetStateAction<SidePanelConfig>>
} & Pick<EnvironmentDataValuesDTO, 'isResourceRecommendationEnabled'>
Expand Down
2 changes: 1 addition & 1 deletion src/Shared/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1327,7 +1327,7 @@ export interface DeploymentStatusDetailsBreakdownDataType {

export interface IntelligenceConfig {
clusterId: number
metadata: Record<string, string>
metadata: Record<string, string | number>
prompt: string
analyticsCategory: string
}
Expand Down
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ export interface customEnv {
* @default false
*/
FEATURE_STORAGE_ENABLE?: boolean
Comment thread
AbhishekA1509 marked this conversation as resolved.
FEATURE_ATHENA_DEBUG_MODE_ENABLE?: boolean
}
declare global {
interface Window {
Expand Down