diff --git a/packages/core/src/autonomy.ts b/packages/core/src/autonomy.ts index 83f62cf2..48427d8a 100644 --- a/packages/core/src/autonomy.ts +++ b/packages/core/src/autonomy.ts @@ -131,7 +131,7 @@ export async function setAutonomy(db: Db, projectId: number, patch: AutonomyPatc } /** True inside the quiet hours (local time of the machine Peppa runs on). */ -export function inQuietHours(s: Pick, now: Date): boolean { +export function inAutonomyQuietHours(s: Pick, now: Date): boolean { if (s.quietFrom == null || s.quietTo == null || s.quietFrom === s.quietTo) return false; const h = now.getHours(); return s.quietFrom < s.quietTo ? h >= s.quietFrom && h < s.quietTo : h >= s.quietFrom || h < s.quietTo; diff --git a/packages/runner/src/autonomy.ts b/packages/runner/src/autonomy.ts index f964e17f..af6f7ed8 100644 --- a/packages/runner/src/autonomy.ts +++ b/packages/runner/src/autonomy.ts @@ -11,7 +11,7 @@ import { getAutonomy, getSetting, giteaForBot, - inQuietHours, + inAutonomyQuietHours, listProjects, listSessions, listTasks, @@ -269,7 +269,7 @@ async function dispatch(db: Db, project: Project, a: AutonomySettings, now: Date } if (!a.idlePush || working.length > 0 || !backlog.length || limited || state.questionId) return; - if (inQuietHours(a, now)) return; + if (inAutonomyQuietHours(a, now)) return; if ((state.snoozeUntil ?? 0) > now.getTime()) return; if (state.at && now.getTime() - state.at < a.idlePushHours * 3_600_000) return; await offerStory(db, project, backlog[0]!, now); diff --git a/packages/testkit/test/autonomy-levels.test.ts b/packages/testkit/test/autonomy-levels.test.ts index b3fc10eb..3c9afa09 100644 --- a/packages/testkit/test/autonomy-levels.test.ts +++ b/packages/testkit/test/autonomy-levels.test.ts @@ -58,10 +58,10 @@ describe("autonomy settings", () => { test("quiet hours wrap over midnight", () => { const q = { quietFrom: 22, quietTo: 9 }; - assert.equal(core.inQuietHours(q, new Date(2026, 10, 14, 23, 30)), true); - assert.equal(core.inQuietHours(q, new Date(2026, 10, 14, 8, 59)), true); - assert.equal(core.inQuietHours(q, new Date(2026, 10, 14, 12, 0)), false); - assert.equal(core.inQuietHours({ quietFrom: null, quietTo: null }, new Date(2026, 10, 14, 23)), false); + assert.equal(core.inAutonomyQuietHours(q, new Date(2026, 10, 14, 23, 30)), true); + assert.equal(core.inAutonomyQuietHours(q, new Date(2026, 10, 14, 8, 59)), true); + assert.equal(core.inAutonomyQuietHours(q, new Date(2026, 10, 14, 12, 0)), false); + assert.equal(core.inAutonomyQuietHours({ quietFrom: null, quietTo: null }, new Date(2026, 10, 14, 23)), false); }); });