⭐️⭐️⭐️ Open-source, self-hosted alternative to Linear and Plane. Project management and issue tracking where teams and AI agents work side by side to plan and ship products.
TypeScript agenticagileai-agentsbug-reportingbug-trackerganttissue-trackerjirajira-alternativekanbanlinearlinear-alternativeopen-sourceproduct-managementproject-managementroadmapself-hostedsprint-planningteam-collaborationtrello-alternative
fix(api): a schedule patch without a status resumes a paused schedule (#522)
Pasqual Troncone8a33459d1a28
diff --git a/apps/api/src/modules/agents/schedules/__tests__/integration/agent-schedules.test.ts b/apps/api/src/modules/agents/schedules/__tests__/integration/agent-schedules.test.tsindex 6048c5a8..e3db5d86 100644--- a/apps/api/src/modules/agents/schedules/__tests__/integration/agent-schedules.test.ts+++ b/apps/api/src/modules/agents/schedules/__tests__/integration/agent-schedules.test.ts@@ -243,6 +243,18 @@ describe('agent schedules', () => {expect(new Date(resumed.data!.nextRunAt!).getTime()).toBeGreaterThan(Date.now());});+ it('keeps a paused schedule paused when a patch leaves the status out', async () => {+ const { asOwner } = await setup();+ const agentId = await makeAgent(asOwner);+ const created = await createSchedule(asOwner, agentId);+ const schedule = schedules(asOwner)({ scheduleId: created.data!.id });+ expect((await schedule.patch({ status: 'paused' })).data?.status).toBe('paused');++ const edited = await schedule.patch({ prompt: 'Triage the new issues.' });+ expect(edited.status).toBe(200);+ expect(edited.data?.status).toBe('paused');+ });+it('recomputes the next run when the cron changes', async () => {const { asOwner } = await setup();const agentId = await makeAgent(asOwner);diff --git a/apps/api/src/modules/agents/schedules/index.ts b/apps/api/src/modules/agents/schedules/index.tsindex 08cf9502..48e89753 100644--- a/apps/api/src/modules/agents/schedules/index.ts+++ b/apps/api/src/modules/agents/schedules/index.ts@@ -96,7 +96,8 @@ export const agentScheduleRoutes = new Elysia({summary: 'Create an agent schedule',description:'Create a schedule that sends a task to an agent on a cron, on an issue each ' +- 'time one enters a column, or on a type this instance adds.',+ 'time one enters a column, or on a type this instance adds. It starts active ' ++ 'unless status is given.',...mcpTool('create_agent_schedule'),},},diff --git a/apps/api/src/modules/agents/schedules/model.ts b/apps/api/src/modules/agents/schedules/model.tsindex 613e8321..6ba8b2a5 100644--- a/apps/api/src/modules/agents/schedules/model.ts+++ b/apps/api/src/modules/agents/schedules/model.ts@@ -15,6 +15,9 @@ export const scheduleRunParams = t.Object({});export const scheduleStatus = t.UnionEnum(['active', 'paused'], {+ // t.UnionEnum defaults to its first value, which would resume a paused schedule on a+ // PATCH that leaves the status out; the update is partial.+ default: undefined,description: "'active' runs, 'paused' does not run until it is set back to 'active'.",});