cesjavi commited on
Commit
4aa9189
·
1 Parent(s): 33b7764

Fix: Unified API routing under /api and paused aggressive polling heartbeats (Phase 9)

Browse files
backend/main.py CHANGED
@@ -120,10 +120,10 @@ async def root():
120
  # Placeholder for routers
121
  from routers import orchestrator, monitoring, agent_runner, generator
122
 
123
- app.include_router(agent_runner.router, prefix="/tasks", tags=["Tasks"])
124
  app.include_router(orchestrator.router, prefix="/api/orchestrator", tags=["orchestrator"])
125
  app.include_router(generator.router, prefix="/api/generator", tags=["generator"])
126
- app.include_router(monitoring.router, prefix="/monitoring", tags=["Monitoring"])
127
 
128
  @app.get("/runtime-config.js", include_in_schema=False)
129
  async def runtime_config():
 
120
  # Placeholder for routers
121
  from routers import orchestrator, monitoring, agent_runner, generator
122
 
123
+ app.include_router(agent_runner.router, prefix="/api/tasks", tags=["Tasks"])
124
  app.include_router(orchestrator.router, prefix="/api/orchestrator", tags=["orchestrator"])
125
  app.include_router(generator.router, prefix="/api/generator", tags=["generator"])
126
+ app.include_router(monitoring.router, prefix="/api/monitoring", tags=["Monitoring"])
127
 
128
  @app.get("/runtime-config.js", include_in_schema=False)
129
  async def runtime_config():
frontend/src/components/AgentConsole.tsx CHANGED
@@ -50,7 +50,6 @@ const AgentConsole: React.FC<AgentConsoleProps> = ({ projectId, taskId }) => {
50
 
51
  const apiUrl = getApiUrl();
52
  let eventSource: EventSource | null = null;
53
- let pollInterval: number | undefined;
54
  let channel: ReturnType<typeof supabase.channel> | null = null;
55
  let active = true;
56
 
@@ -84,13 +83,8 @@ const AgentConsole: React.FC<AgentConsoleProps> = ({ projectId, taskId }) => {
84
  }
85
  });
86
  eventSource.addEventListener('error', () => {
87
- setError('Backend log stream unavailable. Falling back to polling.');
88
- fetchLogs();
89
- if (!pollInterval) {
90
- pollInterval = window.setInterval(() => {
91
- if (document.visibilityState === 'visible') fetchLogs();
92
- }, 15000);
93
- }
94
  });
95
  };
96
 
@@ -113,7 +107,7 @@ const AgentConsole: React.FC<AgentConsoleProps> = ({ projectId, taskId }) => {
113
  return () => {
114
  active = false;
115
  if (eventSource) eventSource.close();
116
- if (pollInterval) window.clearInterval(pollInterval);
117
  if (channel) supabase.removeChannel(channel);
118
  };
119
  }, [projectId, taskId]);
 
50
 
51
  const apiUrl = getApiUrl();
52
  let eventSource: EventSource | null = null;
 
53
  let channel: ReturnType<typeof supabase.channel> | null = null;
54
  let active = true;
55
 
 
83
  }
84
  });
85
  eventSource.addEventListener('error', () => {
86
+ setError('Backend log stream disconnected. Polling disabled to save resources.');
87
+ // fetchLogs(); // Manual fetch only or auto-reconnect logic without tight loops
 
 
 
 
 
88
  });
89
  };
90
 
 
107
  return () => {
108
  active = false;
109
  if (eventSource) eventSource.close();
110
+ if (eventSource) eventSource.close();
111
  if (channel) supabase.removeChannel(channel);
112
  };
113
  }, [projectId, taskId]);