#!/usr/bin/env node /** * Pro Agent Debug Test Script * سكريبت تشخيص مشاكل Pro Agent */ console.log('🔍 Pro Agent Debug Test'); console.log('='.repeat(50)); // Test 1: Check if Pro Mode toggle works console.log('\n1️⃣ Testing Pro Mode Toggle:'); console.log('✅ Pro Mode state should be saved in localStorage'); console.log('✅ Settings component should show Pro Agent toggle'); console.log('✅ Toggle should be visible with Zap icon'); // Test 2: Check API endpoint console.log('\n2️⃣ Testing API Endpoint:'); console.log('✅ /api/pro-agent should exist'); console.log('✅ Should accept POST requests'); console.log('✅ Should return Server-Sent Events'); // Test 3: Check workflow logic console.log('\n3️⃣ Testing Workflow Logic:'); console.log('✅ callAi should check isProMode'); console.log('✅ Should call runProAgentWorkflow when Pro Mode enabled'); console.log('✅ Should fallback to normal mode on error'); // Test 4: Check conditions console.log('\n4️⃣ Testing Conditions:'); console.log('Pro Mode will activate when:'); console.log(' - isProMode = true'); console.log(' - !redesignMarkdown (not a redesign request)'); console.log(' - (!isFollowUp || isSameHtml) (new request or same HTML)'); // Test 5: Debug steps console.log('\n5️⃣ Debug Steps:'); console.log('1. Open browser console'); console.log('2. Enable Pro Mode in settings'); console.log('3. Type a new prompt (not follow-up)'); console.log('4. Click send button'); console.log('5. Check console logs:'); console.log(' - "🚀 Starting Pro Agent Mode..."'); console.log(' - "🚀 Pro Agent workflow started with prompt:"'); console.log(' - "🚀 Pro Agent API called"'); // Test 6: Common issues console.log('\n6️⃣ Common Issues & Solutions:'); console.log('❌ Pro Mode not activating:'); console.log(' → Check isFollowUp state (should be false for new requests)'); console.log(' → Check isSameHtml state'); console.log(' → Check console for condition logs'); console.log('\n❌ API not responding:'); console.log(' → Check authentication'); console.log(' → Check network tab for /api/pro-agent requests'); console.log(' → Check server logs'); console.log('\n❌ Thinking not showing:'); console.log(' → Check ProAgentThinking component'); console.log(' → Check showProThinking state'); console.log(' → Check SSE data parsing'); // Test 7: Manual test instructions console.log('\n7️⃣ Manual Test Instructions:'); console.log('1. npm run dev'); console.log('2. Open http://localhost:3000'); console.log('3. Login if required'); console.log('4. Click Settings gear icon'); console.log('5. Look for "Pro Agent Mode" toggle with ⚡ icon'); console.log('6. Enable the toggle'); console.log('7. Type: "أريد موقع شخصي حديث"'); console.log('8. Click send (arrow up button)'); console.log('9. Should see:'); console.log(' - Thinking window at top'); console.log(' - Progress indicator at bottom right'); console.log(' - Console logs with 🚀 emojis'); // Test 8: Expected behavior console.log('\n8️⃣ Expected Behavior:'); console.log('✅ Pro Mode ON + New Request → Pro Agent workflow'); console.log('✅ Pro Mode ON + Follow-up → Normal mode'); console.log('✅ Pro Mode OFF → Normal mode'); console.log('✅ Pro Agent error → Fallback to normal mode'); // Test 9: Debugging localStorage console.log('\n9️⃣ Debugging localStorage:'); console.log('In browser console, check:'); console.log('localStorage.getItem("pro-mode")'); console.log('Should return "true" when enabled'); // Test 10: Network debugging console.log('\n🔟 Network Debugging:'); console.log('In Network tab, look for:'); console.log('- POST /api/pro-agent'); console.log('- Content-Type: text/event-stream'); console.log('- Response should be streaming'); console.log('\n' + '='.repeat(50)); console.log('🎯 Quick Test Command:'); console.log('1. Enable Pro Mode'); console.log('2. Open console'); console.log('3. Type prompt and send'); console.log('4. Look for "🚀 Starting Pro Agent Mode..." log'); console.log('5. If not seen, Pro Mode conditions not met'); console.log('\n💡 Pro Tip:'); console.log('Add this to browser console to force Pro Mode:'); console.log('localStorage.setItem("pro-mode", "true");'); console.log('Then refresh page and try again.'); console.log('\n🔧 Troubleshooting:'); console.log('If Pro Mode still not working:'); console.log('1. Check isFollowUp state in React DevTools'); console.log('2. Check isSameHtml state'); console.log('3. Verify API endpoint exists'); console.log('4. Check authentication status'); console.log('5. Look for JavaScript errors in console'); console.log('\n✨ Success Indicators:'); console.log('✅ Console shows Pro Agent logs'); console.log('✅ Thinking window appears at top'); console.log('✅ Progress window appears at bottom right'); console.log('✅ 4 steps execute sequentially'); console.log('✅ Final HTML result is generated'); console.log('\n🚀 Pro Agent is working when you see all above! 🎉');