Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
fix(cos): reset orphaned system tasks, not just user tasks
Adam Eivyf19d73a15cdd
diff --git a/server/services/cos.js b/server/services/cos.jsindex 7d4cded4cc..acce18b2df 100644--- a/server/services/cos.js+++ b/server/services/cos.js@@ -531,6 +531,7 @@ export async function start() {if (cleaned > 0) {emitLog('info', `🧹 Periodic cleanup: ${cleaned} orphaned agent(s)`);}+ await resetOrphanedTasks();const { archived } = await archiveStaleAgents().catch(() => ({ archived: 0 }));if (archived > 0) {emitLog('info', `📦 Auto-archived ${archived} stale agent(s) from state`);@@ -787,15 +788,7 @@ export async function getTaskById(taskId) {*/async function resetOrphanedTasks() {const state = await loadState();- const { user: userTaskData } = await getAllTasks();-- if (!userTaskData.exists) {- emitLog('debug', 'No user tasks file found');- return;- }-- const inProgressTasks = userTaskData.grouped.in_progress || [];- emitLog('debug', `Checking for orphaned tasks: ${inProgressTasks.length} in_progress`);+ const { user: userTaskData, cos: cosTaskData } = await getAllTasks();const runningAgentTaskIds = Object.values(state.agents).filter(a => a.status === 'running')@@ -803,10 +796,25 @@ async function resetOrphanedTasks() {emitLog('debug', `Running agents: ${runningAgentTaskIds.length}`, { taskIds: runningAgentTaskIds });- for (const task of inProgressTasks) {- if (!runningAgentTaskIds.includes(task.id)) {- emitLog('info', `Resetting orphaned task ${task.id} to pending`, { taskId: task.id });- await updateTask(task.id, { status: 'pending' }, 'user');+ // Reset orphaned user tasks+ if (userTaskData.exists) {+ const inProgressUserTasks = userTaskData.grouped.in_progress || [];+ for (const task of inProgressUserTasks) {+ if (!runningAgentTaskIds.includes(task.id)) {+ emitLog('info', `Resetting orphaned user task ${task.id} to pending`, { taskId: task.id });+ await updateTask(task.id, { status: 'pending' }, 'user');+ }+ }+ }++ // Reset orphaned CoS internal tasks+ if (cosTaskData.exists) {+ const inProgressCosTasks = cosTaskData.grouped.in_progress || [];+ for (const task of inProgressCosTasks) {+ if (!runningAgentTaskIds.includes(task.id)) {+ emitLog('info', `Resetting orphaned system task ${task.id} to pending`, { taskId: task.id });+ await updateTask(task.id, { status: 'pending' }, 'internal');+ }}}}