From 05dd183d0b404b2ef0def5f708cf52f283fbc081 Mon Sep 17 00:00:00 2001 From: Matt Pua Date: Wed, 22 Jul 2026 09:21:01 -0400 Subject: [PATCH 1/2] feat(loops): add a default trigger to new loops Generated-By: PostHog Code Task-Id: 3206bbfa-c081-4ef7-84e7-e7f20ee878c1 --- .../loops/components/LoopTriggerEditor.tsx | 12 ++---------- .../ui/src/features/loops/loopFormTypes.test.ts | 15 ++++++++++++++- packages/ui/src/features/loops/loopFormTypes.ts | 11 ++++++++++- 3 files changed, 26 insertions(+), 12 deletions(-) diff --git a/packages/ui/src/features/loops/components/LoopTriggerEditor.tsx b/packages/ui/src/features/loops/components/LoopTriggerEditor.tsx index 1731d7f6be..eb900993d2 100644 --- a/packages/ui/src/features/loops/components/LoopTriggerEditor.tsx +++ b/packages/ui/src/features/loops/components/LoopTriggerEditor.tsx @@ -18,12 +18,12 @@ import { type RecurringFrequency, } from "../loopCron"; import { + defaultLoopScheduleTrigger, emptyLoopApiTriggerConfig, emptyLoopGithubTriggerConfig, emptyLoopScheduleTriggerConfig, isTriggerDraftValid, type LoopTriggerDraft, - nextDraftTriggerKey, } from "../loopFormTypes"; import { LoopRepositoryPicker } from "./LoopRepositoryPicker"; @@ -97,15 +97,7 @@ export function LoopTriggerEditor({ }; const addTrigger = () => { - onChange([ - ...triggers, - { - key: nextDraftTriggerKey(), - type: "schedule", - enabled: true, - config: emptyLoopScheduleTriggerConfig(), - }, - ]); + onChange([...triggers, defaultLoopScheduleTrigger()]); }; return ( diff --git a/packages/ui/src/features/loops/loopFormTypes.test.ts b/packages/ui/src/features/loops/loopFormTypes.test.ts index 55af79af62..d208e3c6d3 100644 --- a/packages/ui/src/features/loops/loopFormTypes.test.ts +++ b/packages/ui/src/features/loops/loopFormTypes.test.ts @@ -98,7 +98,7 @@ describe("isTriggerDraftValid", () => { describe("isLoopFormValid", () => { it("accepts a named form with instructions and no triggers", () => { - expect(isLoopFormValid(validFormValues())).toBe(true); + expect(isLoopFormValid({ ...validFormValues(), triggers: [] })).toBe(true); }); it.each([ @@ -128,6 +128,19 @@ describe("isLoopFormValid", () => { }); }); +describe("emptyLoopFormValues", () => { + it("starts new loops with an enabled daily schedule trigger", () => { + expect(emptyLoopFormValues().triggers).toEqual([ + { + key: expect.any(String), + type: "schedule", + enabled: true, + config: { cron_expression: "0 9 * * *", timezone: "UTC" }, + }, + ]); + }); +}); + describe("normalizeLoopFormValues", () => { it("forces team visibility when a context target is set", () => { const values = { diff --git a/packages/ui/src/features/loops/loopFormTypes.ts b/packages/ui/src/features/loops/loopFormTypes.ts index b298b93841..fdb7a32424 100644 --- a/packages/ui/src/features/loops/loopFormTypes.ts +++ b/packages/ui/src/features/loops/loopFormTypes.ts @@ -98,6 +98,15 @@ export function nextDraftTriggerKey(): string { return `draft-trigger-${draftKeySeq}`; } +export function defaultLoopScheduleTrigger(): LoopTriggerDraft { + return { + key: nextDraftTriggerKey(), + type: "schedule", + enabled: true, + config: emptyLoopScheduleTriggerConfig(), + }; +} + export function emptyLoopFormValues(): LoopFormValues { return { name: "", @@ -108,7 +117,7 @@ export function emptyLoopFormValues(): LoopFormValues { model: "", reasoningEffort: null, repositories: [], - triggers: [], + triggers: [defaultLoopScheduleTrigger()], behaviors: defaultLoopBehaviors(), notifications: defaultLoopNotifications(), contextTarget: null, From f66822c1d0f4074acc856a25a2f639b5acc1fbc4 Mon Sep 17 00:00:00 2001 From: Matt Pua Date: Wed, 22 Jul 2026 09:25:22 -0400 Subject: [PATCH 2/2] fix(loops): default new triggers to weekly Generated-By: PostHog Code Task-Id: 3206bbfa-c081-4ef7-84e7-e7f20ee878c1 --- packages/ui/src/features/loops/loopFormTypes.test.ts | 4 ++-- packages/ui/src/features/loops/loopFormTypes.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/ui/src/features/loops/loopFormTypes.test.ts b/packages/ui/src/features/loops/loopFormTypes.test.ts index d208e3c6d3..8df75b6dd5 100644 --- a/packages/ui/src/features/loops/loopFormTypes.test.ts +++ b/packages/ui/src/features/loops/loopFormTypes.test.ts @@ -129,13 +129,13 @@ describe("isLoopFormValid", () => { }); describe("emptyLoopFormValues", () => { - it("starts new loops with an enabled daily schedule trigger", () => { + it("starts new loops with an enabled weekly schedule trigger", () => { expect(emptyLoopFormValues().triggers).toEqual([ { key: expect.any(String), type: "schedule", enabled: true, - config: { cron_expression: "0 9 * * *", timezone: "UTC" }, + config: { cron_expression: "0 9 * * 1", timezone: "UTC" }, }, ]); }); diff --git a/packages/ui/src/features/loops/loopFormTypes.ts b/packages/ui/src/features/loops/loopFormTypes.ts index fdb7a32424..e7fbee6ca0 100644 --- a/packages/ui/src/features/loops/loopFormTypes.ts +++ b/packages/ui/src/features/loops/loopFormTypes.ts @@ -45,7 +45,7 @@ export interface LoopFormValues { } export function emptyLoopScheduleTriggerConfig(): LoopSchemas.LoopScheduleTriggerConfig { - return { cron_expression: "0 9 * * *", timezone: "UTC" }; + return { cron_expression: "0 9 * * 1", timezone: "UTC" }; } export function emptyLoopGithubTriggerConfig(): LoopSchemas.LoopGithubTriggerConfig {