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

address review (codex): reset pr-watcher execution cooldown on disable

[._.]/ Adam Eivy2fc591779f1e
diff --git a/server/services/apps.js b/server/services/apps.js
index 03383103ab..8efc56a841 100644
--- a/server/services/apps.js
+++ b/server/services/apps.js
@@ -435,11 +435,13 @@ export async function updateAppTaskTypeOverride(id, taskType, { enabled, interva
overrides[taskType] = updated;
}
- // Disabling pr-watcher clears its high-water mark so a later re-enable
- // baselines silently (like first enable) instead of dispatching the backlog
- // of PRs opened while it was off. See prWatcher.js / cosTaskGenerator.js.
+ // Disabling pr-watcher clears its high-water mark AND its execution cooldown
+ // so a later re-enable baselines promptly (like first enable) instead of
+ // dispatching the backlog of PRs opened while it was off. See prWatcher.js /
+ // cosTaskGenerator.js.
if (taskType === 'pr-watcher' && enabled === false) {
delete data.apps[id].prWatcherState;
+ await resetPrWatcherCooldown(id);
}
data.apps[id].taskTypeOverrides = overrides;
@@ -451,6 +453,18 @@ export async function updateAppTaskTypeOverride(id, taskType, { enabled, interva
return { id, ...data.apps[id] };
}
+/**
+ * Reset the schedule execution cooldown for an app's pr-watcher so a re-enable
+ * baselines on the next tick instead of waiting out the prior 30-min custom
+ * interval — otherwise PRs opened in that delayed window slip past the firstRun
+ * baseline. Dynamic import avoids a static apps↔taskSchedule cycle (taskSchedule
+ * already imports this module). Best-effort: a missing history is a no-op.
+ */
+async function resetPrWatcherCooldown(appId) {
+ const { resetExecutionHistory } = await import('./taskSchedule.js');
+ await resetExecutionHistory('pr-watcher', appId).catch(() => {});
+}
+
/**
* Clear the pr-watcher high-water mark on every app. Called when pr-watcher is
* disabled GLOBALLY (CoS → Schedule), the counterpart to the per-app disable
@@ -491,9 +505,10 @@ export async function bulkUpdateAppTaskTypeOverride(taskType, { enabled } = {})
overrides[taskType] = updated;
}
- // See updateAppTaskTypeOverride: clear pr-watcher's high-water mark on disable.
+ // See updateAppTaskTypeOverride: clear pr-watcher's mark + cooldown on disable.
if (taskType === 'pr-watcher' && enabled === false) {
delete data.apps[id].prWatcherState;
+ await resetPrWatcherCooldown(id);
}
data.apps[id].taskTypeOverrides = overrides;
@@ -522,10 +537,11 @@ export async function toggleAllAppTaskTypes(id, enabled) {
overrides[taskType] = { ...existing, enabled };
}
- // Disabling everything disables pr-watcher too — clear its high-water mark so
- // a later re-enable baselines silently. See updateAppTaskTypeOverride.
+ // Disabling everything disables pr-watcher too — clear its mark + cooldown so
+ // a later re-enable baselines promptly. See updateAppTaskTypeOverride.
if (enabled === false) {
delete data.apps[id].prWatcherState;
+ await resetPrWatcherCooldown(id);
}
data.apps[id].taskTypeOverrides = overrides;
diff --git a/server/services/taskSchedule.js b/server/services/taskSchedule.js
index a9d8b91437..c4a31ccb3f 100644
--- a/server/services/taskSchedule.js
+++ b/server/services/taskSchedule.js
@@ -510,6 +510,15 @@ export async function updateTaskInterval(taskType, settings) {
// gets the locked value back in its response.
enforceManagedAgentOptions(taskType, schedule.tasks[taskType]);
+ // Globally disabling pr-watcher also drops its execution cooldown so a later
+ // re-enable baselines on the very next tick rather than waiting out the prior
+ // 30-min interval — otherwise PRs opened in that delayed window slip past the
+ // firstRun baseline and are never dispatched. Paired with clearAllPrWatcherState
+ // below (the per-app disable paths in apps.js do the same via resetExecutionHistory).
+ if (taskType === 'pr-watcher' && settings.enabled === false) {
+ delete schedule.executions['task:pr-watcher'];
+ }
+
await saveSchedule(schedule);
// Globally disabling pr-watcher clears every app's high-water mark, mirroring