Update ProgressModal.tsx

This commit is contained in:
Desktop
2025-11-11 01:19:02 +05:00
parent f817a80704
commit 2f0c283e51

View File

@@ -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
@@ -468,9 +495,9 @@ export default function ProgressModal({
{/* Dark success alert box with centered text */}
<div className="p-5 rounded-lg bg-green-600 dark:bg-green-700 border border-green-700 dark:border-green-600">
<p className="text-base font-semibold text-white text-center">
<div className="text-base font-semibold text-white text-center whitespace-pre-line">
{successMessage}
</p>
</div>
</div>
</div>
)}