Spaces:
Paused
Paused
Create frontend/src/components/BackgroundTasks.tsx
Browse files
frontend/src/components/BackgroundTasks.tsx
CHANGED
|
@@ -5,12 +5,14 @@ const BackgroundTasks: React.FC = () => {
|
|
| 5 |
const [tasks, setTasks] = useState<string[]>([]);
|
| 6 |
|
| 7 |
const pollTasks = async () => {
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
|
|
|
| 11 |
};
|
| 12 |
|
| 13 |
useEffect(() => {
|
|
|
|
| 14 |
const interval = setInterval(pollTasks, 3000);
|
| 15 |
return () => clearInterval(interval);
|
| 16 |
}, []);
|
|
@@ -20,7 +22,7 @@ const BackgroundTasks: React.FC = () => {
|
|
| 20 |
<div style={{ fontWeight: 600, marginBottom: 8 }}>Background Agents</div>
|
| 21 |
{tasks.length === 0 && <div style={{ color: 'var(--text-secondary)', fontSize: 12 }}>No running tasks</div>}
|
| 22 |
{tasks.map(task => (
|
| 23 |
-
<div key={task} style={{ background: 'var(--bg-tertiary)', padding:
|
| 24 |
{task} – running
|
| 25 |
</div>
|
| 26 |
))}
|
|
|
|
| 5 |
const [tasks, setTasks] = useState<string[]>([]);
|
| 6 |
|
| 7 |
const pollTasks = async () => {
|
| 8 |
+
try {
|
| 9 |
+
const res = await axios.get('/api/agent/tasks');
|
| 10 |
+
setTasks(res.data.tasks || []);
|
| 11 |
+
} catch (e) {}
|
| 12 |
};
|
| 13 |
|
| 14 |
useEffect(() => {
|
| 15 |
+
pollTasks();
|
| 16 |
const interval = setInterval(pollTasks, 3000);
|
| 17 |
return () => clearInterval(interval);
|
| 18 |
}, []);
|
|
|
|
| 22 |
<div style={{ fontWeight: 600, marginBottom: 8 }}>Background Agents</div>
|
| 23 |
{tasks.length === 0 && <div style={{ color: 'var(--text-secondary)', fontSize: 12 }}>No running tasks</div>}
|
| 24 |
{tasks.map(task => (
|
| 25 |
+
<div key={task} style={{ background: 'var(--bg-tertiary)', padding: '4px 8px', borderRadius: 4, marginBottom: 4, fontSize: 12 }}>
|
| 26 |
{task} – running
|
| 27 |
</div>
|
| 28 |
))}
|