Correct the PRD's claim of an until control, and stop the form erasing one
The PRD said a reader's rule could optionally stop on a date; the until control was deliberately descoped from the form during planning, and the PRD was written as though it shipped. Corrected the PRD to describe what actually ships, and noted that the field still exists in the schema — reachable today only by importing a file that carries one. That gap had a second-order bug behind it: because the edit form rebuilt `repeat` from scratch on every save, hard-coding `until: null`, a rule that already carried a non-null `until` had it silently reset to eternal on any edit at all, including a pure title fix. Extracted the `repeat`-building logic into `repeatFrom`, which now carries `initial?.repeat?.until` forward, and is exported so the behaviour is provable without a submit nothing in this suite's renderToStaticMarkup tests can click. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
This commit is contained in:
co-authored by
Claude Opus 5
parent
d433eeee50
commit
e3c4fae1b9
@@ -72,6 +72,29 @@ export function cadenceLabel(repeat: Repeat | null): string | null {
|
||||
return `every ${repeat.interval} ${repeat.unit}`;
|
||||
}
|
||||
|
||||
/**
|
||||
* The `repeat` a save would write, given what the form's own controls state
|
||||
* plus whatever `until` the record being edited already carries.
|
||||
*
|
||||
* The form has no control for `until` — descoped from the control surface
|
||||
* during planning, not from the schema — so it is never this function's to
|
||||
* set. But a rule reaching the form already carrying one, reachable today
|
||||
* only by importing a file that has it, has to keep it: rebuilding `repeat`
|
||||
* from the unit and interval fields alone would silently turn a terminating
|
||||
* rule eternal on a save as unrelated as a title fix. Exported, and separated
|
||||
* from the component's own state wiring, so that survival is provable without
|
||||
* a submit nothing in this test suite can click.
|
||||
*/
|
||||
export function repeatFrom(
|
||||
unit: RepeatUnit | "never",
|
||||
interval: number,
|
||||
existingUntil: string | null,
|
||||
): Repeat | null {
|
||||
const intervalValid = Number.isInteger(interval) && interval >= 1 && interval <= 365;
|
||||
if (unit === "never" || !intervalValid) return null;
|
||||
return { unit, interval, until: existingUntil };
|
||||
}
|
||||
|
||||
function labelClass(): string {
|
||||
return "block text-xs font-medium text-muted";
|
||||
}
|
||||
@@ -232,10 +255,7 @@ export function EventForm({
|
||||
const interval = Number(repeatInterval);
|
||||
const intervalValid =
|
||||
Number.isInteger(interval) && interval >= 1 && interval <= 365;
|
||||
const repeat =
|
||||
repeatUnit === "never" || !intervalValid
|
||||
? null
|
||||
: { unit: repeatUnit, interval, until: null };
|
||||
const repeat = repeatFrom(repeatUnit, interval, initial?.repeat?.until ?? null);
|
||||
|
||||
// The same predicate the schema refines on, so the form cannot start
|
||||
// refusing saves the schema would accept or promising ones it will reject.
|
||||
|
||||
Reference in New Issue
Block a user