From 6ec3c165b3c1e0baa5595ae57c536b0bbd87c86e Mon Sep 17 00:00:00 2001 From: Chad Curtis Date: Wed, 20 Aug 2025 15:45:09 +0000 Subject: [PATCH] simplify build action check somewhat --- src/components/ai/AssistantContent.tsx | 59 ++++++++++++++------------ 1 file changed, 33 insertions(+), 26 deletions(-) diff --git a/src/components/ai/AssistantContent.tsx b/src/components/ai/AssistantContent.tsx index 5e7bc190..3093960c 100644 --- a/src/components/ai/AssistantContent.tsx +++ b/src/components/ai/AssistantContent.tsx @@ -67,36 +67,43 @@ export const AssistantContent = memo(({ content, toolResults = [] }: AssistantCo return { isError: toolResult.isError || false }; }; - // Helper function to check and render build action + // Helper function to check if text represents a build action + const isBuildAction = (text: string): boolean => { + return /(βœ…|❌|⏸️|πŸŽ‰)/.test(text) && /(Agent completed successfully|Auto-build|Build|Deploy|Building|Deploying)/i.test(text); + }; + + // Helper function to determine build action type + const getActionType = (text: string): 'BUILD' | 'DEPLOY' | 'AUTO_BUILD' => { + if (text.includes('Auto-build') || text.includes('Auto-building') || + (text.includes('Agent completed successfully') && text.includes('built'))) { + return 'AUTO_BUILD'; + } + if (text.includes('Deploy') || text.includes('Deploying')) { + return 'DEPLOY'; + } + return 'BUILD'; + }; + + // Helper function to determine build action status + const getActionStatus = (text: string): { isError: boolean; isLoading: boolean } => { + const icon = text.match(/(βœ…|❌|⏸️|πŸŽ‰)/)?.[1]; + const hasFailed = icon === '❌' || text.toLowerCase().includes('failed'); + const isRunning = icon === '⏸️' || /(Building|Deploying)/i.test(text); + + return { + isError: hasFailed, + isLoading: isRunning && !hasFailed + }; + }; + + // Helper function to render build action const renderBuildAction = (text: string, key: number | string) => { - if (!/(βœ…|❌|⏸️|πŸ”„|πŸŽ‰|πŸŽ‰)/.test(text) || !/(Agent completed successfully|Auto-build|Build|Deploy|Building|Deploying)/i.test(text)) { + if (!isBuildAction(text)) { return null; } - const getActionType = (): 'BUILD' | 'DEPLOY' | 'AUTO_BUILD' => { - if (text.includes('Auto-build') || text.includes('Auto-building') || (text.includes('Agent completed successfully') && text.includes('built'))) { - return 'AUTO_BUILD'; - } - if (text.includes('Deploy') || text.includes('Deploying')) { - return 'DEPLOY'; - } - return 'BUILD'; - }; - - const getStatus = () => { - const icon = text.match(/(βœ…|❌|⏸️|πŸ”„|πŸŽ‰)/)?.[1]; - - if (icon === '❌' || text.includes('failed')) { - return { isError: true, isLoading: false }; - } - if (icon === '⏸️' || icon === 'πŸ”„' || /(Building|Deploying)/i.test(text)) { - return { isError: false, isLoading: true }; - } - return { isError: false, isLoading: false }; - }; - - const actionType = getActionType(); - const { isError, isLoading } = getStatus(); + const actionType = getActionType(text); + const { isError, isLoading } = getActionStatus(text); return (