Skip to content
This repository was archived by the owner on Aug 6, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 2 additions & 10 deletions packages/ui/src/features/loops/components/LoopTriggerEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ import {
type RecurringFrequency,
} from "../loopCron";
import {
defaultLoopScheduleTrigger,
emptyLoopApiTriggerConfig,
emptyLoopGithubTriggerConfig,
emptyLoopScheduleTriggerConfig,
isTriggerDraftValid,
type LoopTriggerDraft,
nextDraftTriggerKey,
} from "../loopFormTypes";
import { LoopRepositoryPicker } from "./LoopRepositoryPicker";

Expand Down Expand Up @@ -97,15 +97,7 @@ export function LoopTriggerEditor({
};

const addTrigger = () => {
onChange([
...triggers,
{
key: nextDraftTriggerKey(),
type: "schedule",
enabled: true,
config: emptyLoopScheduleTriggerConfig(),
},
]);
onChange([...triggers, defaultLoopScheduleTrigger()]);
};

return (
Expand Down
15 changes: 14 additions & 1 deletion packages/ui/src/features/loops/loopFormTypes.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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([
Expand Down Expand Up @@ -128,6 +128,19 @@ describe("isLoopFormValid", () => {
});
});

describe("emptyLoopFormValues", () => {
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 * * 1", timezone: "UTC" },
},
]);
});
});

describe("normalizeLoopFormValues", () => {
it("forces team visibility when a context target is set", () => {
const values = {
Expand Down
13 changes: 11 additions & 2 deletions packages/ui/src/features/loops/loopFormTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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: "",
Expand All @@ -108,7 +117,7 @@ export function emptyLoopFormValues(): LoopFormValues {
model: "",
reasoningEffort: null,
repositories: [],
triggers: [],
triggers: [defaultLoopScheduleTrigger()],
behaviors: defaultLoopBehaviors(),
notifications: defaultLoopNotifications(),
contextTarget: null,
Expand Down
Loading