From 1435ca6baae943525f8cfcbe2a3a8353d1758117 Mon Sep 17 00:00:00 2001 From: Killian Colla Date: Wed, 12 Aug 2026 16:05:26 +0200 Subject: [PATCH] feat(devops-copilot): remove cluster troubleshoot button (#2863) * feat(devops-copilot): remove cluster troubleshoot button * change truncate rules and sidebar size * send clusterid instead of deploymentid * update test --- .../src/lib/cluster-card/cluster-card.tsx | 71 ++++--------------- .../cluster-last-deployment-section.spec.tsx | 3 +- .../cluster-last-deployment-section.tsx | 3 +- .../cluster-header-logs.tsx | 1 + .../environment-last-deployment-section.tsx | 1 + .../list-deployment-logs.tsx | 1 + .../service-last-deployment.tsx | 1 + .../devops-copilot-history.tsx | 10 +-- .../devops-copilot-panel.tsx | 2 +- .../devops-copilot-panel/header/header.tsx | 2 +- ...vops-copilot-troubleshoot-trigger.spec.tsx | 1 + .../devops-copilot-troubleshoot-trigger.tsx | 1 + 12 files changed, 31 insertions(+), 66 deletions(-) diff --git a/libs/domains/clusters/feature/src/lib/cluster-card/cluster-card.tsx b/libs/domains/clusters/feature/src/lib/cluster-card/cluster-card.tsx index 3937a509daf..86c1ea05406 100644 --- a/libs/domains/clusters/feature/src/lib/cluster-card/cluster-card.tsx +++ b/libs/domains/clusters/feature/src/lib/cluster-card/cluster-card.tsx @@ -1,13 +1,9 @@ import { Link, useRouter } from '@tanstack/react-router' -import posthog from 'posthog-js' import { type Cluster, type ClusterStatus } from 'qovery-typescript-axios' -import { useContext } from 'react' import { match } from 'ts-pattern' -import { DevopsCopilotContext } from '@qovery/shared/devops-copilot/feature' import { AnimatedGradientText, Badge, - Button, Icon, Indicator, Link as LinkUI, @@ -24,20 +20,6 @@ import { ClusterRunningStatusIndicator } from '../cluster-running-status-indicat import { useClusterRunningStatusSocket } from '../hooks/use-cluster-running-status-socket/use-cluster-running-status-socket' function Subtitle({ cluster, clusterDeploymentStatus }: { cluster: Cluster; clusterDeploymentStatus?: ClusterStatus }) { - const { setDevopsCopilotOpen, sendMessageRef } = useContext(DevopsCopilotContext) - - const handleLaunchDiagnostic = () => { - posthog.capture('ai-copilot-troubleshoot-triggered', { - source: 'cluster-card', - cluster_id: cluster.id, - trigger_reason: 'error', - }) - - const message = `Why did my cluster deployment fail? (cluster id: ${cluster.id})` - setDevopsCopilotOpen(true) - sendMessageRef?.current?.(message) - } - return match(clusterDeploymentStatus?.status) .with('DEPLOYMENT_QUEUED', 'DELETE_QUEUED', 'STOP_QUEUED', 'RESTART_QUEUED', (s) => ( {upperCaseFirstLetter(s).replace('_', ' ')}... @@ -64,46 +46,21 @@ function Subtitle({ cluster, clusterDeploymentStatus }: { cluster: Cluster; clus )) .with('BUILD_ERROR', 'DELETE_ERROR', 'DEPLOYMENT_ERROR', 'STOP_ERROR', 'RESTART_ERROR', () => ( - { - e.preventDefault() - e.stopPropagation() - handleLaunchDiagnostic() - }} - > - - Ask for diagnostic - - - } + e.stopPropagation()} > - - + Last deployment failed + + )) .with('INVALID_CREDENTIALS', () => ( { screen.getByRole('button', { name: 'Launch diagnostic' }).click() expect(mockSetDevopsCopilotOpen).toHaveBeenCalledWith(true) - expect(mockSendMessage).toHaveBeenCalledWith('Why did my cluster deployment fail? (deployment id: execution-1)') + expect(mockSendMessage).toHaveBeenCalledWith('Why did my cluster deployment fail? (cluster id: cluster-1)') expect(posthog.capture).toHaveBeenCalledWith('ai-copilot-troubleshoot-triggered', { source: 'cluster-last-deployment', + troubleshoot_type: 'cluster', deployment_id: 'execution-1', cluster_id: 'cluster-1', trigger_reason: 'error', diff --git a/libs/domains/clusters/feature/src/lib/cluster-last-deployment-section/cluster-last-deployment-section.tsx b/libs/domains/clusters/feature/src/lib/cluster-last-deployment-section/cluster-last-deployment-section.tsx index ca047f6bfba..ced2772079b 100644 --- a/libs/domains/clusters/feature/src/lib/cluster-last-deployment-section/cluster-last-deployment-section.tsx +++ b/libs/domains/clusters/feature/src/lib/cluster-last-deployment-section/cluster-last-deployment-section.tsx @@ -116,12 +116,13 @@ export function ClusterLastDeploymentSection({ posthog.capture('ai-copilot-troubleshoot-triggered', { source: 'cluster-last-deployment', + troubleshoot_type: 'cluster', deployment_id: clusterStatus.last_execution_id, cluster_id: clusterId, trigger_reason: 'error', }) - const message = `Why did my cluster deployment fail?${clusterStatus.last_execution_id ? ` (deployment id: ${clusterStatus.last_execution_id})` : ''}` + const message = `Why did my cluster deployment fail? (cluster id: ${clusterId})` setDevopsCopilotOpen(true) sendMessageRef?.current?.(message) diff --git a/libs/domains/clusters/feature/src/lib/cluster-logs/cluster-header-logs/cluster-header-logs.tsx b/libs/domains/clusters/feature/src/lib/cluster-logs/cluster-header-logs/cluster-header-logs.tsx index ec5ecb61b86..eea4795c52a 100644 --- a/libs/domains/clusters/feature/src/lib/cluster-logs/cluster-header-logs/cluster-header-logs.tsx +++ b/libs/domains/clusters/feature/src/lib/cluster-logs/cluster-header-logs/cluster-header-logs.tsx @@ -83,6 +83,7 @@ export function ClusterHeaderLogs({ cluster, clusterStatus, refScrollSection, da onClick={() => { posthog.capture('ai-copilot-troubleshoot-triggered', { source: 'cluster-logs', + troubleshoot_type: 'cluster', cluster_id: cluster.id, }) const message = `Why did my cluster deployment fail? (cluster id: ${cluster.id})` diff --git a/libs/domains/environments/feature/src/lib/environment-last-deployment-section/environment-last-deployment-section.tsx b/libs/domains/environments/feature/src/lib/environment-last-deployment-section/environment-last-deployment-section.tsx index d8c2738e815..f4923313785 100644 --- a/libs/domains/environments/feature/src/lib/environment-last-deployment-section/environment-last-deployment-section.tsx +++ b/libs/domains/environments/feature/src/lib/environment-last-deployment-section/environment-last-deployment-section.tsx @@ -111,6 +111,7 @@ const EnvironmentLastDeploymentContent = () => { posthog.capture('ai-copilot-troubleshoot-triggered', { source: 'environment-last-deployment', + troubleshoot_type: 'deployment', deployment_id: lastDeployment.identifier.execution_id, trigger_reason: 'error', }) diff --git a/libs/domains/service-logs/feature/src/lib/list-deployment-logs/list-deployment-logs.tsx b/libs/domains/service-logs/feature/src/lib/list-deployment-logs/list-deployment-logs.tsx index 672e04370f4..812c361b1f7 100644 --- a/libs/domains/service-logs/feature/src/lib/list-deployment-logs/list-deployment-logs.tsx +++ b/libs/domains/service-logs/feature/src/lib/list-deployment-logs/list-deployment-logs.tsx @@ -481,6 +481,7 @@ function DeploymentLogsBody({ onClick={() => { posthog.capture('ai-copilot-troubleshoot-triggered', { source: 'deployment-logs', + troubleshoot_type: 'deployment', deployment_id: executionId, trigger_reason: isCrashLoopDetected ? 'crash-loop' : 'error', }) diff --git a/libs/domains/services/feature/src/lib/service-overview/service-last-deployment/service-last-deployment.tsx b/libs/domains/services/feature/src/lib/service-overview/service-last-deployment/service-last-deployment.tsx index 87b9d0da349..63a1a8535a4 100644 --- a/libs/domains/services/feature/src/lib/service-overview/service-last-deployment/service-last-deployment.tsx +++ b/libs/domains/services/feature/src/lib/service-overview/service-last-deployment/service-last-deployment.tsx @@ -193,6 +193,7 @@ function ServiceLastDeploymentContent({ serviceId, serviceType, service }: Servi const handleLaunchDiagnostic = () => { posthog.capture('ai-copilot-troubleshoot-triggered', { source: 'service-last-deployment', + troubleshoot_type: 'deployment', deployment_id: lastDeployment.identifier.execution_id, trigger_reason: 'error', }) diff --git a/libs/shared/devops-copilot/feature/src/lib/devops-copilot-panel/devops-copilot-history.tsx b/libs/shared/devops-copilot/feature/src/lib/devops-copilot-panel/devops-copilot-history.tsx index f04be0a5305..1c452be9f69 100644 --- a/libs/shared/devops-copilot/feature/src/lib/devops-copilot-panel/devops-copilot-history.tsx +++ b/libs/shared/devops-copilot/feature/src/lib/devops-copilot-panel/devops-copilot-history.tsx @@ -1,6 +1,6 @@ import clsx from 'clsx' import { memo } from 'react' -import { Button, Icon, LoaderSpinner, Tooltip, truncateText } from '@qovery/shared/ui' +import { Button, Icon, LoaderSpinner, Tooltip } from '@qovery/shared/ui' import { type Thread } from '../hooks/use-threads/use-threads' import { isToday, isWithinLastSevenDays, isWithinLastThirtyDays, isYesterday } from '../utils/date-utils/date-utils' @@ -64,13 +64,13 @@ export const DevopsCopilotHistory = ({
setThreadId(thread.id)} className={clsx( - 'cursor-pointer rounded-md p-2 text-sm text-neutral transition-colors hover:bg-surface-neutral-subtle', + 'cursor-pointer truncate rounded-md p-2 text-sm text-neutral transition-colors hover:bg-surface-neutral-subtle', { 'bg-surface-brand-subtle text-brand': threadId === thread.id, } )} > - {thread.title.length >= 28 ? `${truncateText(thread.title, 28)}...` : thread.title} + {thread.title}
))} @@ -80,7 +80,7 @@ export const DevopsCopilotHistory = ({ if ((isLoading && threads.length === 0) || error) { return ( -
+
{error ? {error} : }
) @@ -89,7 +89,7 @@ export const DevopsCopilotHistory = ({ const groupedThreads = groupThreadsByTimeAgo(threads) return ( -
+
History diff --git a/libs/shared/devops-copilot/feature/src/lib/devops-copilot-panel/devops-copilot-panel.tsx b/libs/shared/devops-copilot/feature/src/lib/devops-copilot-panel/devops-copilot-panel.tsx index dc84c49f41f..569cdf11617 100644 --- a/libs/shared/devops-copilot/feature/src/lib/devops-copilot-panel/devops-copilot-panel.tsx +++ b/libs/shared/devops-copilot/feature/src/lib/devops-copilot-panel/devops-copilot-panel.tsx @@ -362,7 +362,7 @@ export function DevopsCopilotPanel({ onClose, style }: DevopsCopilotPanelProps) organizationId={organizationId} /> )} -
+
-
+
diff --git a/libs/shared/devops-copilot/feature/src/lib/devops-copilot-troubleshoot-trigger/devops-copilot-troubleshoot-trigger.spec.tsx b/libs/shared/devops-copilot/feature/src/lib/devops-copilot-troubleshoot-trigger/devops-copilot-troubleshoot-trigger.spec.tsx index 51044382bf6..5319bae12be 100644 --- a/libs/shared/devops-copilot/feature/src/lib/devops-copilot-troubleshoot-trigger/devops-copilot-troubleshoot-trigger.spec.tsx +++ b/libs/shared/devops-copilot/feature/src/lib/devops-copilot-troubleshoot-trigger/devops-copilot-troubleshoot-trigger.spec.tsx @@ -85,6 +85,7 @@ describe('DevopsCopilotTroubleshootTrigger', () => { expect(mockSendMessage).toHaveBeenCalledWith('Why did my deployment fail? (execution id: exec-123)') expect(posthog.capture).toHaveBeenCalledWith('ai-copilot-troubleshoot-triggered', { source: 'service-deployment-list', + troubleshoot_type: 'deployment', deployment_id: 'exec-123', }) }) diff --git a/libs/shared/devops-copilot/feature/src/lib/devops-copilot-troubleshoot-trigger/devops-copilot-troubleshoot-trigger.tsx b/libs/shared/devops-copilot/feature/src/lib/devops-copilot-troubleshoot-trigger/devops-copilot-troubleshoot-trigger.tsx index 4d0ae6a75be..50aba5b84ff 100644 --- a/libs/shared/devops-copilot/feature/src/lib/devops-copilot-troubleshoot-trigger/devops-copilot-troubleshoot-trigger.tsx +++ b/libs/shared/devops-copilot/feature/src/lib/devops-copilot-troubleshoot-trigger/devops-copilot-troubleshoot-trigger.tsx @@ -19,6 +19,7 @@ export function DevopsCopilotTroubleshootTrigger({ const openTroubleshoot = () => { posthog.capture('ai-copilot-troubleshoot-triggered', { source, + troubleshoot_type: 'deployment', deployment_id: deploymentId, })