50% done the cost it right

This commit is contained in:
Pradeep 2025-10-31 08:36:42 +05:30
parent 9adb24799b
commit de9a6e9eb7
3 changed files with 36 additions and 10 deletions

View File

@ -39,12 +39,14 @@ export async function GET(
) )
} }
// Get the file content // Get the file content and content-type from backend
const fileBuffer = await response.arrayBuffer() const fileBuffer = await response.arrayBuffer()
const backendContentType = response.headers.get('content-type') ||
(filename.endsWith('.pdf') ? 'application/pdf' : filename.endsWith('.json') ? 'application/json' : 'application/octet-stream')
// Set headers based on whether it's a download or inline view // Set headers based on whether it's a download or inline view
const headers = new Headers() const headers = new Headers()
headers.set('Content-Type', 'application/pdf') headers.set('Content-Type', backendContentType)
headers.set('Cache-Control', 'no-cache') headers.set('Cache-Control', 'no-cache')
headers.set('X-Content-Type-Options', 'nosniff') headers.set('X-Content-Type-Options', 'nosniff')
headers.set('Accept-Ranges', 'bytes') headers.set('Accept-Ranges', 'bytes')

View File

@ -352,7 +352,12 @@ const GitHubReposPage: React.FC = () => {
console.error('❌ No repository ID tracked for this analysis'); console.error('❌ No repository ID tracked for this analysis');
} }
// Keep dialog open so user can see completion status // Close the progress dialog after a short delay to let user see completion
setTimeout(() => {
setShowProgressDialog(false);
setCurrentAnalysisId(null);
setCurrentRepoId(null);
}, 2000); // Close after 2 seconds
}; };
const handleAnalysisError = (error: string) => { const handleAnalysisError = (error: string) => {

View File

@ -153,20 +153,39 @@ export const AIAnalysisProgressTracker: React.FC<AIAnalysisProgressTrackerProps>
case 'smart_batch_completed': case 'smart_batch_completed':
// Smart Batching: Batch completed // Smart Batching: Batch completed
setProgress(event.data.percent || 70); // Calculate progress from backend percent, or derive from files processed
setCurrentFileNum(event.data.files_processed || 0); const batchPercent = event.data.percent;
const filesProcessed = event.data.files_processed || 0;
const totalFiles = event.data.total_files || 0;
// If percent is provided, use it, otherwise calculate from files
const calculatedProgress = batchPercent !== undefined
? batchPercent
: (totalFiles > 0 ? Math.round((filesProcessed / totalFiles) * 70) : 70);
setProgress(calculatedProgress);
setCurrentFileNum(filesProcessed);
if (event.data.processing_mode === 'smart_batching') { if (event.data.processing_mode === 'smart_batching') {
setPhase(`Smart Batch ${event.data.batch || 0}/${event.data.total_batches || 0} completed (${event.data.files_processed || 0}/${event.data.total_files || 0} files)`); setPhase(`Smart Batch ${event.data.batch || 0}/${event.data.total_batches || 0} completed (${filesProcessed}/${totalFiles} files)`);
} }
break; break;
case 'batch_completed': case 'batch_completed':
// Update progress but don't override phase if we're showing individual files // Update progress but don't override phase if we're showing individual files
setProgress(event.data.percent || 70); const batchCompletedPercent = event.data.percent;
setCurrentFileNum(event.data.files_processed || 0); const batchFilesProcessed = event.data.files_processed || 0;
const batchTotalFiles = event.data.total_files || 0;
// If percent is provided, use it, otherwise calculate from files
const batchCalculatedProgress = batchCompletedPercent !== undefined
? batchCompletedPercent
: (batchTotalFiles > 0 ? Math.round((batchFilesProcessed / batchTotalFiles) * 70) : 70);
setProgress(batchCalculatedProgress);
setCurrentFileNum(batchFilesProcessed);
// Only update phase if no current file is being shown // Only update phase if no current file is being shown
if (!currentFile) { if (!currentFile) {
setPhase(`Completed batch ${event.data.batch || 0}/${event.data.total_batches || 0} (${event.data.files_processed || 0}/${event.data.total_files || 0} files)`); setPhase(`Completed batch ${event.data.batch || 0}/${event.data.total_batches || 0} (${batchFilesProcessed}/${batchTotalFiles} files)`);
} }
break; break;