Skip to content

A trigger's Delay stores only a whole number of steps - #659

Merged
MerciHanrim merged 2 commits into
mainfrom
delay-field-draft
Nov 24, 2026
Merged

MerciHanrim merged 2 commits into
mainfrom
delay-field-draft

Conversation

@MerciHanrim

@MerciHanrim MerciHanrim commented Nov 24, 2026 •

Copy link
Copy Markdown
Owner

Part of #615 (item 1's trigger delay; the two wizards' header-row fields of item 1 are next).

What was wrong

A Trigger connection's Delay (Inspector.tsx, TriggerFields) was a plain number input that stored Number(v) on every key. Measured on main caa763c5, from a delay of 2 with the run at step 1 (scratch probe, run 3):

Typed Stored Autosave Run reset
- removed (the input reports it as '') removed yes
-2 removed at -, then -2 -2 yes, twice
1.5 1, 1, then 1.5 1.5 yes, at 1 and 5
a real blank removed removed yes
3 3 3 yes

Measured diagnostics: on the next step (the play bar's Step button, waited until the step settled) the run diagnostics showed exactly one line for -2 and for 1.5, the same in the sim store and on screen: "State edge "t_pd_a" delay -2 is not an integer ≥ 0; treated as 0." For -, a blank and 3 there was none.

Read from the code, not measured (step.ts:1064-1074): that such a value is then used as 0, and that a removed delay is also read as 0, without a diagnostic.

The change

The Delay field uses DraftNumberInput (#658's rule):

  • a real blank removes the delay, as before;
  • only a whole number of 0 or more is stored (valid);
  • anything else is a draft that stores nothing: a half-typed - (validity.badInput), -2, 1.5. On leaving, the field shows the stored delay again.

The hint under the field now follows the draft as well as the stored value. "use a whole number ≥ 0." shows for an invalid draft, and still for a delay already stored invalid.

A delay already saved in a file as another number is shown as it is, marked and hinted. The engine still runs it as 0 with its diagnostic; that path is unchanged.

Tests

e2e/number-field-blank.spec.ts (written first; run on main's code first):

Test On main's code With the change
- from 2: stored, autosave, run step kept; aria-invalid and the bad hint while typing; on leaving the field shows 2 and the ok hint fails passes
-2 from 2: the same fails passes
1.5: the 1 is stored and resets the run (rev +1, step 0) as a valid number on the way; then . and 5 change nothing more; aria-invalid and the bad hint; on leaving, the field shows 1 and 1.5 was never stored fails at 5 (. already changed nothing) passes
controls: a blank removes the delay, 3 is stored, both reset the run, the ok hint passes passes
a file with delay -2: shown as -2, marked, the bad hint; the next step's run diagnostics line passes passes

e2e/state-ui.spec.ts:112 pinned the old contract: "the stored value is left exactly as typed" (-1 stored). No spec document states it (searched docs/), and the decision for this item replaces it. The test now expects the stored 2 to stay, with the field still marked and hinted, and its title says "nor stored when invalid".

Checks

  • npx tsc -b: clean.
  • npm run lint: 88 warnings, the baseline.
  • All check:* scripts: pass.
  • Unit suite: 5758 passed, 4 skipped.
  • Related e2e, one worker, no retries:
    • e2e/number-field-blank.spec.ts: 12 passed;
    • e2e/state-ui.spec.ts, e2e/label-timing.spec.ts and e2e/run-diagnostics.spec.ts: 41 passed, 4 skipped (run-diagnostics tests for the other layout).
  • Snapshots: state-ui's 2 screenshot comparisons were compared and passed; the other specs hold none.

The hint's wording (second commit, at Lumi's review)

The bad hint read "use a whole number ≥ 0 — the engine runs any other value as 0 and leaves what you typed untouched." For a typed draft, which is now discarded on leaving the field, "leaves what you typed untouched" was no longer true.

inspector.delay.bad now gives only its rule, in every one of the 18 languages: the part before the dash (before the colon in Spanish, before the double dash in Chinese). In English: "use a whole number ≥ 0." That reads right for a draft and for a value already stored invalid. There is no new key.

Two pinned audits follow:

  • the pt-PT audit over pt-BR: this key now reads the same in both, so the differing-keys count goes 383 → 382, and 358 → 357 outside the password strings;
  • the ru ё-word list: введённое was only in the removed half.

The e2e hint checks now compare the full text.

What it touches

  • Only the Trigger connection's Delay field.
  • The engine, the file format and the stored-invalid path are unchanged.

The Delay field uses DraftNumberInput: a real blank removes the delay, only a whole number >= 0 is stored, and anything else is a draft that stores nothing, with the hint following the draft. A value already stored invalid keeps the engine's 0 and diagnostic. Part of #615.
@MerciHanrim MerciHanrim added the bug Something isn't working label Nov 24, 2026
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

Deploying cozy-loop-studio with  Cloudflare Pages  Cloudflare Pages

Latest commit: cda5fce
Status: ✅  Deploy successful!
Preview URL: https://6be2c717.cozy-loop-studio.pages.dev
Branch Preview URL: https://delay-field-draft.cozy-loop-studio.pages.dev

View logs

inspector.delay.bad in every language drops its second half, that the engine runs any other value as 0 and leaves what was typed untouched: an invalid draft is now discarded on leaving the field, so the rule alone is right for a draft and for a value already stored invalid. The pt-PT audit (now the same as pt-BR on this key) and the ru ё-word list follow. Part of #615.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant