Skip to content

The open-source agent harness - the runtime layer that turns an LLM into a working agent.

chore: add custom cron expression input for schedule (#1130)

harshil-209628f510524124
diff --git a/.changeset/custom-cron-schedules-ui.md b/.changeset/custom-cron-schedules-ui.md
new file mode 100644
index 000000000..a7d87aef1
--- /dev/null
+++ b/.changeset/custom-cron-schedules-ui.md
@@ -0,0 +1,5 @@
+---
+"@truefoundry/trueforge-ui": patch
+---
+
+Allow entering a custom cron expression when creating or editing a schedule.
diff --git a/.changeset/superseded-ask-user-not-cancelled.md b/.changeset/superseded-ask-user-not-cancelled.md
new file mode 100644
index 000000000..4696438e4
--- /dev/null
+++ b/.changeset/superseded-ask-user-not-cancelled.md
@@ -0,0 +1,5 @@
+---
+"@truefoundry/trueforge-assistant-ui-runtime": patch
+---
+
+Stop showing a "cancelled" banner on a turn that paused for user input when the user sends a new message instead of answering.
diff --git a/packages/assistant-ui-runtime/src/convertTurnMessages.ts b/packages/assistant-ui-runtime/src/convertTurnMessages.ts
index abb02028b..12dcfaea2 100644
--- a/packages/assistant-ui-runtime/src/convertTurnMessages.ts
+++ b/packages/assistant-ui-runtime/src/convertTurnMessages.ts
@@ -1207,7 +1207,7 @@ function stripInteractivePendingFromAssistant(
return {
...message,
content,
- status: { type: 'incomplete', reason: 'cancelled' },
+ status: { type: 'complete', reason: 'stop' },
metadata: {
...message.metadata,
custom,
diff --git a/packages/trueforge-ui/src/atoms/schedules/ScheduleFormDrawer.tsx b/packages/trueforge-ui/src/atoms/schedules/ScheduleFormDrawer.tsx
index 32a14a970..25e8ecfc3 100644
--- a/packages/trueforge-ui/src/atoms/schedules/ScheduleFormDrawer.tsx
+++ b/packages/trueforge-ui/src/atoms/schedules/ScheduleFormDrawer.tsx
@@ -19,6 +19,7 @@ import {
cronToFormValues,
defaultScheduleFormValues,
formatCadenceSummary,
+ hasFiveCronFields,
valuesToCron,
type ScheduleFormValues,
} from './cadence.js';
@@ -133,7 +134,7 @@ function ScheduleFormDrawerBody({
return (
form.name.trim().length > 0 &&
form.task.trim().length > 0 &&
- cron.length > 0 &&
+ hasFiveCronFields(cron) &&
agentId.length > 0 &&
(!isInitialCreate || allowsAgent(agentId, 'USE'))
);
diff --git a/packages/trueforge-ui/src/atoms/schedules/ScheduleFormFields.tsx b/packages/trueforge-ui/src/atoms/schedules/ScheduleFormFields.tsx
index 9ac1ebfea..84b209d8b 100644
--- a/packages/trueforge-ui/src/atoms/schedules/ScheduleFormFields.tsx
+++ b/packages/trueforge-ui/src/atoms/schedules/ScheduleFormFields.tsx
@@ -10,6 +10,7 @@ import {
WEEKDAY_OPTIONS,
formatCadenceSummary,
getTimezoneOptions,
+ hasFiveCronFields,
valuesToCron,
type RecurrenceKind,
type ScheduleFormValues,
@@ -19,6 +20,7 @@ export const RECURRENCE_OPTIONS: Array<{ value: RecurrenceKind; label: string }>
{ value: 'hourly', label: 'Hourly' },
{ value: 'daily', label: 'Daily' },
{ value: 'weekly', label: 'Weekly' },
+ { value: 'custom', label: 'Custom' },
];
const HOUR_OPTIONS = Array.from({ length: 24 }, (_, hour) => ({
@@ -59,6 +61,12 @@ export function ScheduleFormFields({
onChange({ ...values, [key]: value });
};
+ const selectRecurrence = (recurrence: RecurrenceKind) => {
+ // Seed the custom input from the current selection so it is a starting point, not a blank box.
+ const customCron = recurrence === 'custom' && values.recurrence !== 'custom' ? cron : values.customCron;
+ onChange({ ...values, recurrence, customCron });
+ };
+
const toggleWeekday = (day: number) => {
const has = values.weekdays.includes(day);
const weekdays = has ? values.weekdays.filter(d => d !== day) : [...values.weekdays, day];
@@ -108,7 +116,7 @@ export function ScheduleFormFields({
<legend className="mb-1.5 text-sm font-medium">Frequency</legend>
<div className="rounded-t-lg border border-border p-4">
<div className="flex flex-col gap-4">
- <div className="grid grid-cols-3 gap-1 rounded-lg border border-border bg-primary-bg p-1">
+ <div className="grid grid-cols-4 gap-1 rounded-lg border border-border bg-primary-bg p-1">
{RECURRENCE_OPTIONS.map(opt => {
const selected = values.recurrence === opt.value;
return (
@@ -122,7 +130,7 @@ export function ScheduleFormFields({
: 'border-transparent text-text-secondary hover:bg-ghost-button-hover',
)}
aria-pressed={selected}
- onClick={() => set('recurrence', opt.value)}
+ onClick={() => selectRecurrence(opt.value)}
>
{opt.label}
</button>
@@ -131,12 +139,23 @@ export function ScheduleFormFields({
</div>
{values.recurrence === 'custom' ? (
- <div className="rounded-md border border-border bg-secondary-bg/40 px-3 py-2">
- <span className="block text-xs text-text-secondary">Existing custom schedule</span>
- <code className="mt-1 block font-mono text-sm text-text-primary">{values.customCron}</code>
+ <div className="block">
+ <span className="mb-1.5 block text-sm font-medium">Cron expression</span>
+ <input
+ aria-label="Cron expression"
+ value={values.customCron}
+ onChange={e => set('customCron', e.target.value)}
+ placeholder="0 */4 * * *"
+ spellCheck={false}
+ aria-invalid={!hasFiveCronFields(values.customCron)}
+ className={cn(auiInputClass('h-8'), 'font-mono')}
+ />
<span className="mt-1 block text-xs text-text-secondary">
- Select Hourly, Daily, or Weekly to replace this schedule.
+ minute hour day-of-month month day-of-week. Runs must be at least 1 hour apart.
</span>
+ {!hasFiveCronFields(values.customCron) ? (
+ <span className="mt-1 block text-xs text-failure-bg">Enter exactly 5 space-separated fields.</span>
+ ) : null}
</div>
) : null}
diff --git a/packages/trueforge-ui/src/atoms/schedules/cadence.ts b/packages/trueforge-ui/src/atoms/schedules/cadence.ts
index 341c8f9ef..b45905b6c 100644
--- a/packages/trueforge-ui/src/atoms/schedules/cadence.ts
+++ b/packages/trueforge-ui/src/atoms/schedules/cadence.ts
@@ -114,6 +114,11 @@ export function valuesToCron(values: ScheduleFormValues): string {
}
}
+/** Shape check only; the server owns full validation and the minimum-interval rule. */
+export function hasFiveCronFields(cron: string): boolean {
+ return cron.trim().split(/\s+/).length === 5;
+}
+
export function formatCadenceSummary(input: { cron: string; timezone: string }): string {
const abbr = timezoneAbbrev(input.timezone);
const parts = input.cron.trim().split(/\s+/);
diff --git a/packages/trueforge-ui/test/atoms/schedules/ScheduleFormDrawer.test.tsx b/packages/trueforge-ui/test/atoms/schedules/ScheduleFormDrawer.test.tsx
index 5df37623f..bf817b430 100644
--- a/packages/trueforge-ui/test/atoms/schedules/ScheduleFormDrawer.test.tsx
+++ b/packages/trueforge-ui/test/atoms/schedules/ScheduleFormDrawer.test.tsx
@@ -231,7 +231,7 @@ describe('ScheduleFormDrawer', () => {
expect(recurrence.getByRole('button', { name: 'Daily' })).toBeInTheDocument();
expect(recurrence.getByRole('button', { name: 'Weekly' })).toBeInTheDocument();
expect(recurrence.getByLabelText('Timezone')).toBeInTheDocument();
- expect(recurrence.queryByRole('button', { name: 'Custom' })).not.toBeInTheDocument();
+ expect(recurrence.getByRole('button', { name: 'Custom' })).toBeInTheDocument();
expect(recurrence.queryByLabelText('Cron expression')).not.toBeInTheDocument();
expect(recurrence.getByText('Schedule')).toBeInTheDocument();
expect(recurrence.getByText(/^Daily 9:00 AM/)).toBeInTheDocument();
@@ -243,15 +243,28 @@ describe('ScheduleFormDrawer', () => {
).toBeTruthy();
});
- it('keeps a legacy custom cron read-only until its recurrence is replaced', async () => {
+ it('edits an existing custom cron and rejects malformed expressions', async () => {
renderDrawer({
mode: 'edit',
schedule: pausedSchedule({ cron: '0 9 1 * *' }),
});
- expect(await screen.findByText('Existing custom schedule')).toBeInTheDocument();
- expect(screen.getAllByText('0 9 1 * *')).not.toHaveLength(0);
- expect(screen.queryByLabelText('Cron expression')).not.toBeInTheDocument();
+ const input = await screen.findByLabelText('Cron expression');
+ expect(input).toHaveValue('0 9 1 * *');
+
+ fireEvent.change(input, { target: { value: '0 */4 *' } });
+ expect(screen.getByText('Enter exactly 5 space-separated fields.')).toBeInTheDocument();
+ expect(screen.getByRole('button', { name: 'Save' })).toBeDisabled();
+
+ fireEvent.change(input, { target: { value: '0 */4 * * *' } });
+ expect(screen.getByRole('button', { name: 'Save' })).toBeEnabled();
+ });
+
+ it('seeds the custom cron from the current recurrence', async () => {
+ renderDrawer({});
+
+ fireEvent.click(await screen.findByRole('button', { name: 'Custom' }));
+ expect(screen.getByLabelText('Cron expression')).toHaveValue('0 9 * * *');
});
it('blocks create when the selected agent lacks USE', async () => {
diff --git a/packages/trueforge-ui/test/atoms/schedules/cadence.test.ts b/packages/trueforge-ui/test/atoms/schedules/cadence.test.ts
index 5ceda3fbd..6a0f00dab 100644
--- a/packages/trueforge-ui/test/atoms/schedules/cadence.test.ts
+++ b/packages/trueforge-ui/test/atoms/schedules/cadence.test.ts
@@ -5,6 +5,8 @@ import {
defaultScheduleFormValues,
formatCadenceSummary,
getTimezoneOptions,
+ hasFiveCronFields,
+ valuesToCron,
} from '@/atoms/schedules/cadence.js';
afterEach(() => {
@@ -61,3 +63,17 @@ describe('formatCadenceSummary', () => {
).toBe('custom');
});
});
+
+describe('custom cron', () => {
+ it('round-trips an every-4-hours expression through the form values', () => {
+ const values = cronToFormValues({ name: 'n', task: 't', cron: '0 */4 * * *', timezone: 'UTC' });
+ expect(values.recurrence).toBe('custom');
+ expect(valuesToCron(values)).toBe('0 */4 * * *');
+ });
+
+ it('checks only the field count', () => {
+ expect(hasFiveCronFields(' 0 */4 * * * ')).toBe(true);
+ expect(hasFiveCronFields('0 */4 *')).toBe(false);
+ expect(hasFiveCronFields('')).toBe(false);
+ });
+});