Priyanshi Saxena commited on
Commit
43c3569
Β·
1 Parent(s): 4c07e01

Fix frontend status checking logic

Browse files

- Improved status check conditions to handle enabled state properly
- Added immediate status check on page load
- Enhanced debugging with DOM element verification
- Simplified status checking flow

Files changed (1) hide show
  1. app.py +32 -21
app.py CHANGED
@@ -1220,24 +1220,27 @@ async def get_homepage(request: Request):
1220
 
1221
  const statusDiv = document.getElementById('status');
1222
 
1223
- if (status.enabled && status.gemini_configured) {
1224
- console.log('βœ… System is fully operational');
1225
- statusDiv.className = 'status online';
1226
- statusDiv.innerHTML = `
1227
- <span>Research systems online</span>
1228
- <div style="margin-top: 0.5rem; font-size: 0.85rem; opacity: 0.8;">
1229
- Tools: ${status.tools_available.join(' β€’ ')}
1230
- </div>
1231
- `;
1232
- } else if (status.enabled) {
1233
- console.log('⚠️ System is in limited mode');
1234
- statusDiv.className = 'status offline';
1235
- statusDiv.innerHTML = `
1236
- <span>Limited mode - Configure GEMINI_API_KEY for full functionality</span>
1237
- <div style="margin-top: 0.5rem; font-size: 0.85rem; opacity: 0.8;">
1238
- Available: ${status.tools_available.join(' β€’ ')}
1239
- </div>
1240
- `;
 
 
 
1241
  } else {
1242
  console.log('❌ System is disabled');
1243
  statusDiv.className = 'status offline';
@@ -1529,13 +1532,21 @@ async def get_homepage(request: Request):
1529
  console.log('πŸ“ Current URL:', window.location.href);
1530
  console.log('🌐 User Agent:', navigator.userAgent.substring(0, 100));
1531
 
 
 
 
 
1532
  initializeTheme();
1533
 
1534
- // Initial status check with delay to ensure server is ready
 
 
 
 
1535
  setTimeout(() => {
1536
- console.log('πŸ” Starting status check...');
1537
  checkStatus();
1538
- }, 1000);
1539
 
1540
  document.getElementById('queryInput').focus();
1541
  console.log('βœ… Application initialization complete');
 
1220
 
1221
  const statusDiv = document.getElementById('status');
1222
 
1223
+ // Check if system is operational (either fully enabled or in limited mode)
1224
+ if (status.enabled) {
1225
+ if (status.gemini_configured) {
1226
+ console.log('βœ… System is fully operational');
1227
+ statusDiv.className = 'status online';
1228
+ statusDiv.innerHTML = `
1229
+ <span>Research systems online</span>
1230
+ <div style="margin-top: 0.5rem; font-size: 0.85rem; opacity: 0.8;">
1231
+ Tools: ${status.tools_available.join(' β€’ ')}
1232
+ </div>
1233
+ `;
1234
+ } else {
1235
+ console.log('⚠️ System is in limited mode');
1236
+ statusDiv.className = 'status offline';
1237
+ statusDiv.innerHTML = `
1238
+ <span>Limited mode - Configure GEMINI_API_KEY for full functionality</span>
1239
+ <div style="margin-top: 0.5rem; font-size: 0.85rem; opacity: 0.8;">
1240
+ Available: ${status.tools_available.join(' β€’ ')}
1241
+ </div>
1242
+ `;
1243
+ }
1244
  } else {
1245
  console.log('❌ System is disabled');
1246
  statusDiv.className = 'status offline';
 
1532
  console.log('πŸ“ Current URL:', window.location.href);
1533
  console.log('🌐 User Agent:', navigator.userAgent.substring(0, 100));
1534
 
1535
+ // Test basic functionality
1536
+ const statusDiv = document.getElementById('status');
1537
+ console.log('πŸ“‹ Status div found:', !!statusDiv);
1538
+
1539
  initializeTheme();
1540
 
1541
+ // Immediate status check for debugging
1542
+ console.log('πŸ” Starting immediate status check...');
1543
+ checkStatus();
1544
+
1545
+ // Also do a delayed check
1546
  setTimeout(() => {
1547
+ console.log('πŸ” Starting delayed status check...');
1548
  checkStatus();
1549
+ }, 2000);
1550
 
1551
  document.getElementById('queryInput').focus();
1552
  console.log('βœ… Application initialization complete');