AI platform insights monitoring and website analysis monitoring services added

This commit is contained in:
ajaysi
2025-11-11 15:57:45 +05:30
parent d99c7c83a7
commit 7191c7e7f0
81 changed files with 10860 additions and 1567 deletions

View File

@@ -1,4 +1,4 @@
import React, { useState, useRef } from 'react';
import React, { useState, useRef, useEffect } from 'react';
import { useCopilotAction } from '@copilotkit/react-core';
import { blogWriterApi, BlogResearchRequest, BlogResearchResponse } from '../../services/blogWriterApi';
import { useResearchPolling } from '../../hooks/usePolling';
@@ -60,6 +60,27 @@ export const ResearchAction: React.FC<ResearchActionProps> = ({ onResearchComple
}
});
// Close modal when research completes (status becomes 'completed' or polling stops with result)
useEffect(() => {
if (showProgressModal && (
polling.currentStatus === 'completed' ||
(!polling.isPolling && polling.result && polling.currentStatus !== 'failed')
)) {
console.info('[ResearchAction] Closing modal - research completed', {
status: polling.currentStatus,
isPolling: polling.isPolling,
hasResult: !!polling.result
});
// Small delay to show completion message before closing
const timer = setTimeout(() => {
setShowProgressModal(false);
setCurrentTaskId(null);
setCurrentMessage('');
}, 500);
return () => clearTimeout(timer);
}
}, [polling.currentStatus, polling.isPolling, polling.result, showProgressModal]);
useCopilotActionTyped({
name: 'showResearchForm',
description: 'Show keyword input form for blog research',
@@ -235,12 +256,16 @@ export const ResearchAction: React.FC<ResearchActionProps> = ({ onResearchComple
<>
{showProgressModal && (
<ResearchProgressModal
open={showProgressModal}
open={showProgressModal && polling.currentStatus !== 'completed'}
title={"Research in progress"}
status={polling.currentStatus}
messages={polling.progressMessages}
error={polling.error}
onClose={() => setShowProgressModal(false)}
onClose={() => {
console.info('[ResearchAction] Modal closed manually');
setShowProgressModal(false);
setCurrentTaskId(null);
}}
/>
)}
</>