From 2f0c283e51e24c1f8b981bb994c87c83435f9968 Mon Sep 17 00:00:00 2001 From: Desktop Date: Tue, 11 Nov 2025 01:19:02 +0500 Subject: [PATCH] Update ProgressModal.tsx --- .../src/components/common/ProgressModal.tsx | 65 +++++++++++++------ 1 file changed, 46 insertions(+), 19 deletions(-) diff --git a/frontend/src/components/common/ProgressModal.tsx b/frontend/src/components/common/ProgressModal.tsx index fe6c8036..fa453213 100644 --- a/frontend/src/components/common/ProgressModal.tsx +++ b/frontend/src/components/common/ProgressModal.tsx @@ -46,13 +46,13 @@ const getSuccessMessage = (functionId?: string, title?: string, stepLogs?: any[] const clusterCount = extractCount(/(\d+)\s+cluster/i, stepLogs || []); if (keywordCount && clusterCount) { - return `Clustering complete — ${clusterCount} cluster${clusterCount !== '1' ? 's' : ''} created from ${keywordCount} keyword${keywordCount !== '1' ? 's' : ''}.`; + return `Clustering complete\n${clusterCount} cluster${clusterCount !== '1' ? 's' : ''} created from ${keywordCount} keyword${keywordCount !== '1' ? 's' : ''}`; } else if (clusterCount) { - return `Clustering complete — ${clusterCount} cluster${clusterCount !== '1' ? 's' : ''} created.`; + return `Clustering complete\n${clusterCount} cluster${clusterCount !== '1' ? 's' : ''} created`; } else if (keywordCount) { - return `Clustering complete — processed ${keywordCount} keyword${keywordCount !== '1' ? 's' : ''}.`; + return `Clustering complete\nProcessed ${keywordCount} keyword${keywordCount !== '1' ? 's' : ''}`; } - return 'Clustering complete — keywords grouped into meaningful clusters.'; + return 'Clustering complete\nKeywords grouped into meaningful clusters'; } if (funcName.includes('idea')) { const clusterCount = extractCount(/(\d+)\s+cluster/i, stepLogs || []); @@ -235,12 +235,39 @@ export default function ProgressModal({ if (funcName.includes('cluster')) { if (stepPhase === 'INIT') { - // For INIT: Backend message already includes keyword names (e.g., "Validating keyword1, keyword2, keyword3 and 5 more keywords") - // If message doesn't have keywords, try to extract from stepLogs or use default + // For INIT: Try to extract keyword count from message or stepLogs + // Backend message might include keyword names (e.g., "Validating keyword1, keyword2, keyword3 and 5 more keywords") + // Or we need to extract the total count if (message && message !== defaultLabel && message.includes('Validating')) { + // Try to extract total count from message + const countMatch = message.match(/(\d+)\s+more keyword/i); + if (countMatch) { + const moreCount = parseInt(countMatch[1], 10); + // Count keywords before "and X more" - typically 3 + const shownCount = 3; + const totalCount = shownCount + moreCount; + return `Validating ${totalCount} keyword${totalCount !== 1 ? 's' : ''}`; + } + // Try to find total keyword count in any step log + for (const log of allStepLogs) { + const keywordCountMatch = log.message?.match(/(\d+)\s+keyword/i); + if (keywordCountMatch) { + const totalCount = parseInt(keywordCountMatch[1], 10); + return `Validating ${totalCount} keyword${totalCount !== 1 ? 's' : ''}`; + } + } + // If message has keyword names but no count, return as-is return message; } - // Fallback: use default label + // Fallback: try to extract count from stepLogs + for (const log of allStepLogs) { + const keywordCountMatch = log.message?.match(/(\d+)\s+keyword/i); + if (keywordCountMatch) { + const totalCount = parseInt(keywordCountMatch[1], 10); + return `Validating ${totalCount} keyword${totalCount !== 1 ? 's' : ''}`; + } + } + // Final fallback: use default label return defaultLabel; } else if (stepPhase === 'PREP') { // For PREP: Show count of keywords being loaded @@ -434,8 +461,8 @@ export default function ProgressModal({ {/* Header */}

- {title} -

+ {title} + {!showSuccess && status !== 'completed' && (

{message}

)} @@ -450,13 +477,13 @@ export default function ProgressModal({ -
+ )} {/* Success Alert (shown when all steps are visually completed) */} {showSuccess && ( -
+
{/* Big centered check icon */}
@@ -464,13 +491,13 @@ export default function ProgressModal({
-
- +
+ {/* Dark success alert box with centered text */}
-

+

{successMessage} -

+
)} @@ -513,9 +540,9 @@ export default function ProgressModal({ > {item.label} + + ))} - ))} - {/* Footer */} {showSuccess && onClose && ( @@ -541,14 +568,14 @@ export default function ProgressModal({ Cancel - )} + )} {status === 'error' && onClose && (
- )} + )} );