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): route resetOrphanedTasks through handleOrphanedTask to prevent over-spawning
Adam Eivyb82052647dbf
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.mdindex eda5fb7b6c..9869be3d15 100644--- a/.changelog/NEXT.md+++ b/.changelog/NEXT.md@@ -38,6 +38,7 @@- Alcohol page summary compressed into a single compact stat bar row to maximize above-the-fold content## Fixed+- CoS orphan retry over-spawning: `resetOrphanedTasks()` was bypassing retry limits by blindly resetting in_progress tasks to pending — now routes through `handleOrphanedTask()` for consistent spawn counting, cooldown, and max-retry enforcement- CoS scheduled improvement tasks (feature-ideas, etc.) never spawning: event listener mismatch (`tasks:user:added`/`tasks:cos:added` vs actual `tasks:changed` event), missing dequeue trigger after improvement check timer, and no improvement queuing after daemon restart until timer fires- App icons in CoS schedule per-app override list rendering at natural image size instead of respecting the `size` prop- Calendar day view current-time red line now updates every 60 seconds instead of only on page loaddiff --git a/server/services/cos.js b/server/services/cos.jsindex 97dfdf5514..b2fd435de6 100644--- a/server/services/cos.js+++ b/server/services/cos.js@@ -817,26 +817,25 @@ async function resetOrphanedTasks() {emitLog('debug', `Running agents: ${runningAgentTaskIds.length}`, { taskIds: runningAgentTaskIds });- // Reset orphaned user tasks- if (userTaskData.exists) {- const inProgressUserTasks = userTaskData.grouped.in_progress || [];- for (const task of inProgressUserTasks) {+ // Route orphaned tasks through handleOrphanedTask for consistent retry counting,+ // cooldown enforcement, and max-spawn limits (prevents runaway respawning)+ const { handleOrphanedTask } = await import('./subAgentSpawner.js');++ const processOrphanedTasks = async (tasks) => {+ for (const task of tasks) {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');+ emitLog('info', `Found orphaned in_progress task ${task.id}, routing through retry handler`, { taskId: task.id });+ await handleOrphanedTask(task.id, 'unknown-reset', getTaskById);}}+ };++ if (userTaskData.exists) {+ await processOrphanedTasks(userTaskData.grouped.in_progress || []);}- // Reset orphaned CoS internal tasksif (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');- }- }+ await processOrphanedTasks(cosTaskData.grouped.in_progress || []);}}diff --git a/server/services/subAgentSpawner.js b/server/services/subAgentSpawner.jsindex b9bbcdf48b..e3b27023bb 100644--- a/server/services/subAgentSpawner.js+++ b/server/services/subAgentSpawner.js@@ -3365,7 +3365,7 @@ export async function cleanupOrphanedAgents() {/*** Handle an orphaned task - retry or create investigation*/-async function handleOrphanedTask(taskId, agentId, getTaskById) {+export async function handleOrphanedTask(taskId, agentId, getTaskById) {const task = await getTaskById(taskId).catch(() => null);if (!task) {emitLog('warn', `Could not find task ${taskId} for orphaned agent ${agentId}`, { taskId, agentId });