Update ProgressModal.tsx
This commit is contained in:
@@ -46,13 +46,13 @@ const getSuccessMessage = (functionId?: string, title?: string, stepLogs?: any[]
|
|||||||
const clusterCount = extractCount(/(\d+)\s+cluster/i, stepLogs || []);
|
const clusterCount = extractCount(/(\d+)\s+cluster/i, stepLogs || []);
|
||||||
|
|
||||||
if (keywordCount && clusterCount) {
|
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) {
|
} 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) {
|
} 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')) {
|
if (funcName.includes('idea')) {
|
||||||
const clusterCount = extractCount(/(\d+)\s+cluster/i, stepLogs || []);
|
const clusterCount = extractCount(/(\d+)\s+cluster/i, stepLogs || []);
|
||||||
@@ -235,12 +235,39 @@ export default function ProgressModal({
|
|||||||
|
|
||||||
if (funcName.includes('cluster')) {
|
if (funcName.includes('cluster')) {
|
||||||
if (stepPhase === 'INIT') {
|
if (stepPhase === 'INIT') {
|
||||||
// For INIT: Backend message already includes keyword names (e.g., "Validating keyword1, keyword2, keyword3 and 5 more keywords")
|
// For INIT: Try to extract keyword count from message or stepLogs
|
||||||
// If message doesn't have keywords, try to extract from stepLogs or use default
|
// 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')) {
|
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;
|
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;
|
return defaultLabel;
|
||||||
} else if (stepPhase === 'PREP') {
|
} else if (stepPhase === 'PREP') {
|
||||||
// For PREP: Show count of keywords being loaded
|
// For PREP: Show count of keywords being loaded
|
||||||
@@ -468,9 +495,9 @@ export default function ProgressModal({
|
|||||||
|
|
||||||
{/* Dark success alert box with centered text */}
|
{/* 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">
|
<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}
|
{successMessage}
|
||||||
</p>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|||||||
Reference in New Issue
Block a user