Skip to content

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

fix(taskSchedule): skip disabled runAfter deps so dependent tasks aren't stuck (#235)

[._.]/ Adam Eivy072296f85706
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.md
index 2155043820..a60416b988 100644
--- a/.changelog/NEXT.md
+++ b/.changelog/NEXT.md
@@ -1032,6 +1032,19 @@
## Fixed
+- **Scheduled tasks no longer block forever on disabled dependencies.** `checkRunAfterDeps`
+ in `server/services/taskSchedule.js` previously required every `runAfter`
+ dependency to have run since the dependent task's last execution — but if a
+ dep was disabled (e.g. `do-replan` globally paused while `feature-ideas` is
+ enabled), it would never run, and the dependent task would wait indefinitely
+ with `reason: 'waiting-on-dependencies'`. The dep gate now skips dependencies
+ that are disabled globally (`enabled: false` or missing from the schedule)
+ or disabled for the requesting app (`isTaskTypeEnabledForApp` returns false),
+ matching the rule that the actual scheduler uses to decide whether a task
+ will ever run. Tests cover the global-disabled and per-app-disabled paths;
+ the existing "blocks when dep is enabled but hasn't run" coverage is
+ preserved with an explicit `do-replan: enabled: true` in the fixture.
+
- **Browser download-UI shell handoffs dead on macOS (Show in Finder / Open file silently no-op).**
`browser/server.js` spawned Chrome as a direct child of `node`/PM2, which
made PM2 the TCC "responsible app" for Chrome's AppleEvent +
diff --git a/server/services/taskSchedule.js b/server/services/taskSchedule.js
index f2befec425..fcd0430309 100644
--- a/server/services/taskSchedule.js
+++ b/server/services/taskSchedule.js
@@ -1741,8 +1741,12 @@ export async function getExecutionHistory(taskType) {
/**
* Check if all runAfter dependencies have completed since this task's last run.
* Returns { satisfied, pending } where pending lists unfinished dependency task types.
+ *
+ * Dependencies that are disabled — either globally (missing from the schedule or
+ * `enabled: false`) or disabled for the requesting app — are skipped, since they
+ * will never run and would otherwise block the dependent task indefinitely.
*/
-function checkRunAfterDeps(schedule, taskType, appId = null) {
+async function checkRunAfterDeps(schedule, taskType, appId = null) {
const interval = schedule.tasks[taskType];
const deps = interval?.runAfter;
if (!deps || deps.length === 0) return { satisfied: true, pending: [] };
@@ -1753,6 +1757,10 @@ function checkRunAfterDeps(schedule, taskType, appId = null) {
const pending = [];
for (const dep of deps) {
+ const depConfig = schedule.tasks[dep];
+ if (!depConfig || !depConfig.enabled) continue;
+ if (appId && !(await isTaskTypeEnabledForApp(appId, dep))) continue;
+
const depKey = `task:${dep}`;
const depExec = schedule.executions[depKey] || { lastRun: null, perApp: {} };
const depLastRun = safeDate(appId ? depExec.perApp[appId]?.lastRun : depExec.lastRun);
@@ -1914,9 +1922,10 @@ export async function shouldRunTask(taskType, appId = null) {
result = { shouldRun: true, reason: 'unknown-default-rotation' };
}
- // If the task would run, check runAfter dependencies — blocked until all deps have run since our last run
+ // If the task would run, check runAfter dependencies — blocked until all enabled deps have run since our last run.
+ // Disabled deps (globally or for this app) are skipped, since they'll never run.
if (result.shouldRun && interval.runAfter?.length > 0) {
- const depCheck = checkRunAfterDeps(schedule, taskType, appId);
+ const depCheck = await checkRunAfterDeps(schedule, taskType, appId);
if (!depCheck.satisfied) {
return { shouldRun: false, reason: 'waiting-on-dependencies', pendingDeps: depCheck.pending };
}
diff --git a/server/services/taskSchedule.test.js b/server/services/taskSchedule.test.js
index 7af94bf61d..50bc008f67 100644
--- a/server/services/taskSchedule.test.js
+++ b/server/services/taskSchedule.test.js
@@ -399,12 +399,15 @@ describe('taskSchedule', () => {
expect(result.reason).toContain('daily-cooldown')
})
- it('feature-ideas waits on do-replan (runAfter default)', async () => {
+ it('feature-ideas waits on do-replan when do-replan is enabled', async () => {
const twoDaysAgo = new Date(Date.now() - 2 * 24 * 60 * 60 * 1000).toISOString()
// Default runAfter:['do-replan'] kicks in since the test doesn't override it
mockSchedule({
- tasks: { 'feature-ideas': { type: 'daily', enabled: true, providerId: null, model: null, prompt: null } },
+ tasks: {
+ 'feature-ideas': { type: 'daily', enabled: true, providerId: null, model: null, prompt: null },
+ 'do-replan': { type: 'weekly', enabled: true, providerId: null, model: null, prompt: null }
+ },
executions: { 'task:feature-ideas': { lastRun: twoDaysAgo, count: 1, perApp: {} } }
})
@@ -414,12 +417,61 @@ describe('taskSchedule', () => {
expect(result.pendingDeps).toContain('do-replan')
})
+ it('feature-ideas runs when do-replan dependency is globally disabled', async () => {
+ const twoDaysAgo = new Date(Date.now() - 2 * 24 * 60 * 60 * 1000).toISOString()
+
+ // do-replan is disabled — feature-ideas would otherwise wait forever, so the dep is skipped
+ mockSchedule({
+ tasks: {
+ 'feature-ideas': { type: 'daily', enabled: true, providerId: null, model: null, prompt: null },
+ 'do-replan': { type: 'weekly', enabled: false, providerId: null, model: null, prompt: null }
+ },
+ executions: { 'task:feature-ideas': { lastRun: twoDaysAgo, count: 1, perApp: {} } }
+ })
+
+ const result = await shouldRunTask('feature-ideas')
+ expect(result.shouldRun).toBe(true)
+ expect(result.reason).toContain('daily-due')
+ })
+
+ it('feature-ideas runs when do-replan dependency is disabled for the app', async () => {
+ const twoDaysAgo = new Date(Date.now() - 2 * 24 * 60 * 60 * 1000).toISOString()
+
+ mockSchedule({
+ tasks: {
+ 'feature-ideas': { type: 'daily', enabled: true, providerId: null, model: null, prompt: null },
+ 'do-replan': { type: 'weekly', enabled: true, providerId: null, model: null, prompt: null }
+ },
+ executions: {
+ 'task:feature-ideas': { lastRun: twoDaysAgo, count: 1, perApp: { 'app-1': { lastRun: twoDaysAgo, count: 1 } } }
+ }
+ })
+ // do-replan is enabled globally but disabled for app-1; feature-ideas is enabled for app-1
+ const originalIsTaskTypeEnabledForApp = isTaskTypeEnabledForApp.getMockImplementation()
+ isTaskTypeEnabledForApp.mockImplementation(async (_appId, taskType) => taskType !== 'do-replan')
+
+ try {
+ const result = await shouldRunTask('feature-ideas', 'app-1')
+ expect(result.shouldRun).toBe(true)
+ expect(result.reason).toContain('daily-due')
+ } finally {
+ if (originalIsTaskTypeEnabledForApp) {
+ isTaskTypeEnabledForApp.mockImplementation(originalIsTaskTypeEnabledForApp)
+ } else {
+ isTaskTypeEnabledForApp.mockReset()
+ }
+ }
+ })
+
it('feature-ideas runs when do-replan has run since its last run', async () => {
const twoDaysAgo = new Date(Date.now() - 2 * 24 * 60 * 60 * 1000).toISOString()
const oneDayAgo = new Date(Date.now() - 24 * 60 * 60 * 1000).toISOString()
mockSchedule({
- tasks: { 'feature-ideas': { type: 'daily', enabled: true, providerId: null, model: null, prompt: null } },
+ tasks: {
+ 'feature-ideas': { type: 'daily', enabled: true, providerId: null, model: null, prompt: null },
+ 'do-replan': { type: 'weekly', enabled: true, providerId: null, model: null, prompt: null }
+ },
executions: {
'task:feature-ideas': { lastRun: twoDaysAgo, count: 1, perApp: {} },
'task:do-replan': { lastRun: oneDayAgo, count: 1, perApp: {} }