Spaces:
Sleeping
Sleeping
Update app.js
Browse files
app.js
CHANGED
|
@@ -284,7 +284,10 @@ async function runBackgroundInitialization(projectId, userId, description) {
|
|
| 284 |
await processAndQueueResponse(projectId, workerResponse);
|
| 285 |
|
| 286 |
// 5. Update Status to IDLE (Ready for user input)
|
| 287 |
-
if(db) await db.ref(`projects/${projectId}/info
|
|
|
|
|
|
|
|
|
|
| 288 |
|
| 289 |
console.log(`[Background] Initialization complete for ${projectId}`);
|
| 290 |
|
|
@@ -336,7 +339,12 @@ app.post('/project/feedback', async (req, res) => {
|
|
| 336 |
const nextInstruction = extractWorkerPrompt(pmResponse);
|
| 337 |
if (!nextInstruction) {
|
| 338 |
await StateManager.updateProject(projectId, { pmHistory: project.pmHistory, status: "IDLE" });
|
| 339 |
-
if(db)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 340 |
return res.json({ success: true, message: "No further tasks. Project Idle." });
|
| 341 |
}
|
| 342 |
|
|
@@ -355,7 +363,14 @@ app.post('/project/feedback', async (req, res) => {
|
|
| 355 |
|
| 356 |
StateManager.queueCommand(projectId, { type: "EXECUTE", payload: "warn('Starting Next Task...')" });
|
| 357 |
await processAndQueueResponse(projectId, workerResponse);
|
| 358 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 359 |
return res.json({ success: true, message: "Next Task Assigned" });
|
| 360 |
}
|
| 361 |
|
|
@@ -429,11 +444,14 @@ app.post('/project/feedback', async (req, res) => {
|
|
| 429 |
});
|
| 430 |
|
| 431 |
await processAndQueueResponse(projectId, response);
|
| 432 |
-
|
| 433 |
-
//
|
| 434 |
-
|
| 435 |
-
|
| 436 |
-
|
|
|
|
|
|
|
|
|
|
| 437 |
|
| 438 |
res.json({ success: true });
|
| 439 |
} catch (err) {
|
|
|
|
| 284 |
await processAndQueueResponse(projectId, workerResponse);
|
| 285 |
|
| 286 |
// 5. Update Status to IDLE (Ready for user input)
|
| 287 |
+
if(db) await db.ref(`projects/${projectId}/info`).update({
|
| 288 |
+
status: "IDLE",
|
| 289 |
+
lastUpdated: Date.now()
|
| 290 |
+
});
|
| 291 |
|
| 292 |
console.log(`[Background] Initialization complete for ${projectId}`);
|
| 293 |
|
|
|
|
| 339 |
const nextInstruction = extractWorkerPrompt(pmResponse);
|
| 340 |
if (!nextInstruction) {
|
| 341 |
await StateManager.updateProject(projectId, { pmHistory: project.pmHistory, status: "IDLE" });
|
| 342 |
+
if(db) {
|
| 343 |
+
await db.ref(`projects/${projectId}/info`).update({
|
| 344 |
+
status: "IDLE",
|
| 345 |
+
lastUpdated: Date.now()
|
| 346 |
+
});
|
| 347 |
+
}
|
| 348 |
return res.json({ success: true, message: "No further tasks. Project Idle." });
|
| 349 |
}
|
| 350 |
|
|
|
|
| 363 |
|
| 364 |
StateManager.queueCommand(projectId, { type: "EXECUTE", payload: "warn('Starting Next Task...')" });
|
| 365 |
await processAndQueueResponse(projectId, workerResponse);
|
| 366 |
+
|
| 367 |
+
// Still working on next task
|
| 368 |
+
if(db) {
|
| 369 |
+
await db.ref(`projects/${projectId}/info`).update({
|
| 370 |
+
status: "working",
|
| 371 |
+
lastUpdated: Date.now()
|
| 372 |
+
});
|
| 373 |
+
}
|
| 374 |
return res.json({ success: true, message: "Next Task Assigned" });
|
| 375 |
}
|
| 376 |
|
|
|
|
| 444 |
});
|
| 445 |
|
| 446 |
await processAndQueueResponse(projectId, response);
|
| 447 |
+
|
| 448 |
+
// --- UPDATED: Set status to IDLE and update lastUpdated ---
|
| 449 |
+
if(db) {
|
| 450 |
+
await db.ref(`projects/${projectId}/info`).update({
|
| 451 |
+
status: "idle",
|
| 452 |
+
lastUpdated: Date.now()
|
| 453 |
+
});
|
| 454 |
+
}
|
| 455 |
|
| 456 |
res.json({ success: true });
|
| 457 |
} catch (err) {
|