everydaycats commited on
Commit
993fdee
·
verified ·
1 Parent(s): 405323f

Update app.js

Browse files
Files changed (1) hide show
  1. app.js +26 -8
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/status`).set("IDLE");
 
 
 
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) await db.ref(`projects/${projectId}/info/status`).set("IDLE");
 
 
 
 
 
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
- if(db) await db.ref(`projects/${projectId}/info/status`).set("working"); // Keep working while plugin picks it up? Or IDLE to wait for plugin?
 
 
 
 
 
 
 
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
- // Ensure status goes back to working or IDLE depending on your loop preference.
433
- // Usually, if we just gave a command, we are 'working' until the plugin polls and finishes.
434
- // But for UI feedback, 'working' usually means "AI is generating".
435
- // Once generated (here), we might want to set it to 'IDLE' or 'waiting_for_plugin'.
436
- if(db) await db.ref(`projects/${projectId}/info/status`).set("idle");
 
 
 
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) {