Skip to content

Commit 93b35e7

Browse files
committed
fix(app-shell): clearing the cron drops any schedule block left with no cadence, untyped { timezone } included
Co-Authored-By: Claude <noreply@anthropic.com>
1 parent c2655e8 commit 93b35e7

3 files changed

Lines changed: 27 additions & 16 deletions

File tree

‎.changeset/31383-flow-designer-cleared-cron-drops-typed-schedule.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ fix(app-shell): clearing a start node's Cron schedule in the flow designer no lo
77
Clause-②: no
88
Metadata-protocol: none
99

10-
Clearing the Cron schedule box on a typed `config.schedule` such as `{ type: 'cron', expression, timezone }` used to store `{ type: 'cron', timezone }`. The engine binds nothing from that block, so a schedule flow silently never ran and a time-relative sweep did not fall back to its daily default the way the field's help says. The published `ScheduleSchema` refuses the same block. The designer now removes `config.schedule` entirely in that case, as it already did for an untyped `{ expression }`. Typing a cron over a typed block still keeps its `type` and `timezone`.
10+
Clearing the Cron schedule box on a typed `config.schedule` such as `{ type: 'cron', expression, timezone }` used to store `{ type: 'cron', timezone }`. The engine binds nothing from that block, so a schedule flow silently never ran and a time-relative sweep did not fall back to its daily default the way the field's help says. The published `ScheduleSchema` refuses the same block. An untyped `{ expression, timezone }` had the same fault: clearing it left `{ timezone }`, which binds nothing either. The designer now removes `config.schedule` entirely whenever clearing the cron leaves no cadence, as it already did for an untyped `{ expression }`. Typing a cron over a typed block still keeps its `type` and `timezone`.

‎ui/packages/app-shell/src/views/metadata-admin/inspectors/flow-node-config.scheduleCadence-12779.test.ts‎

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ describe('a typed cron stores a descriptor that resolves to it (objectui#12779)'
174174
});
175175
});
176176

177-
describe('clearing never leaves a typed schedule block with no cadence (objectstack#31383)', () => {
177+
describe('clearing never leaves a schedule block with no cadence (objectstack#31383)', () => {
178178
// A typed block is judged by the published `ScheduleSchema`, which refuses a
179179
// `type: 'cron'` with no `expression`; the engine binds nothing from it.
180180
const typedCleared: Array<[string, Record<string, unknown>, unknown]> = [
@@ -193,10 +193,23 @@ describe('clearing never leaves a typed schedule block with no cadence (objectst
193193
});
194194
}
195195

196+
it('clearing an untyped { expression } beside a timezone removes the whole schedule', () => {
197+
// `{ timezone }` alone binds nothing, and the flow parse reads nothing from it.
198+
expect(normalizeScheduleCadence({ timezone: 'UTC' })).toBeNull();
199+
expect(scheduleWithExpression({ expression: '0 4 * * *', timezone: 'UTC' }, '')).toBeUndefined();
200+
});
201+
196202
it('CONTROL: clearing an untyped { expression } still removes the whole schedule', () => {
197203
expect(scheduleWithExpression({ expression: '0 4 * * *' }, '')).toBeUndefined();
198204
});
199205

206+
it('CONTROL: a cadence the cron stood in front of is kept when the cron is cleared', () => {
207+
// The engine resolves `expression` ahead of `intervalMs`; with the cron gone the interval binds.
208+
const stored = scheduleWithExpression({ expression: '0 4 * * *', intervalMs: 60000 }, '');
209+
expect(stored).toEqual({ intervalMs: 60000 });
210+
expect(normalizeScheduleCadence(stored)).toEqual({ type: 'interval', intervalMs: 60000 });
211+
});
212+
200213
it('CONTROL: a cron typed over a typed block keeps its type and the other keys', () => {
201214
expect(scheduleWithExpression({ type: 'cron', expression: '0 7 * * *', timezone: 'UTC' }, '0 9 * * *')).toEqual({
202215
type: 'cron',

‎ui/packages/app-shell/src/views/metadata-admin/inspectors/flow-node-config.ts‎

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -527,7 +527,7 @@ const FLOW_NODE_CONFIG: Record<string, FlowConfigField[]> = {
527527
// A commit rewrites the whole block through `scheduleWithExpression`, which
528528
// keeps a bare string a string and an object's `type` / `timezone`, so the
529529
// stored cadence resolves to the cron the field shows; clearing it never
530-
// leaves a typed block with no cadence (objectstack#31383).
530+
// leaves a block with no cadence (objectstack#31383).
531531
//
532532
// objectui#12672 — gated on the flow's RESOLVED kind as well as on the
533533
// select: a `type: 'schedule'` flow, or a start node carrying
@@ -1706,13 +1706,12 @@ const NON_CRON_CADENCE_KEYS = ['intervalMs', 'every', 'at'] as const;
17061706
* only met on a descriptor the engine binds nothing from, since a live
17071707
* interval or once cadence offers no cron edit at all.
17081708
* - Clearing removes `expression` and `cron`, or the whole schedule when it is
1709-
* a string, an interval or once cadence, an object left empty, or a typed
1710-
* block left with no cadence (objectstack#31383). A typed block is judged
1711-
* by the published `ScheduleSchema`, which refuses `{ type: 'cron' }` with no
1712-
* `expression` (a `timezone` beside it does not make it a cadence); the
1713-
* engine binds nothing from it either. So a cleared `{ type: 'cron',
1714-
* expression, timezone }` leaves no schedule, as an untyped `{ expression }`
1715-
* always did.
1709+
* a string, an interval or once cadence, or an object left with no cadence
1710+
* (objectstack#31383). A `type` or `timezone` left behind is not a cadence:
1711+
* the engine binds nothing from `{ type: 'cron', timezone }` or
1712+
* `{ timezone }`, and the published `ScheduleSchema` refuses a typed block
1713+
* with no `expression`. So a cleared `{ type: 'cron', expression, timezone }`
1714+
* leaves no schedule, as an untyped `{ expression }` always did.
17161715
*/
17171716
export function scheduleWithExpression(schedule: unknown, value: unknown): unknown {
17181717
const expression = typeof value === 'string' ? value : '';
@@ -1724,13 +1723,12 @@ export function scheduleWithExpression(schedule: unknown, value: unknown): unkno
17241723
const cadence = normalizeScheduleCadence(schedule);
17251724
if (cadence && cadence.type !== 'cron') return undefined;
17261725
delete next.expression;
1727-
if (next.type !== undefined && normalizeScheduleCadence(next) === null) return undefined;
1728-
} else {
1729-
if (typeof next.type === 'string' && next.type !== 'cron') delete next.type;
1730-
for (const key of NON_CRON_CADENCE_KEYS) delete next[key];
1731-
next.expression = expression;
1726+
return normalizeScheduleCadence(next) === null ? undefined : next;
17321727
}
1733-
return Object.keys(next).length === 0 ? undefined : next;
1728+
if (typeof next.type === 'string' && next.type !== 'cron') delete next.type;
1729+
for (const key of NON_CRON_CADENCE_KEYS) delete next[key];
1730+
next.expression = expression;
1731+
return next;
17341732
}
17351733

17361734
/**

0 commit comments

Comments
 (0)