Files
ontime/apps
Claude 99a2747705 fix(automation): make a failed save retryable without duplicating triggers
Review found that syncTriggers diffed additions against the snapshot taken when
the form opened, so a save that failed part way through would, on the next
attempt, create a second trigger for every cycle it had already created. The
same held in reverse: deletes were replayed too, and the server rejects a
delete for a trigger that is already gone, so the retry died on its first
request.

The snapshot now advances as each request succeeds. It is still seeded at mount
rather than from the live prop — settings are polled, and a save must not
remove a trigger the user could not see — but once a trigger is created or
deleted it becomes part of what this form knows the server holds. A retry is
then left with only the outstanding work, and unticking a lifecycle whose
trigger was created by the failed attempt now removes it rather than orphaning
it.

Reproducing that turned up a second problem in the same path. A failed save
reports itself through setError('root'), which react-hook-form counts against
isValid, which disabled Save. The retry the error message asks for was
unreachable until the user edited some unrelated field to force revalidation —
and editing a field was also what made the duplicate reachable. A root error on
its own no longer blocks submitting, and a new attempt clears the previous one
rather than leaving it under a successful save.

Verified by intercepting the second trigger request: the failed save leaves one
trigger, the retry adds only the missing one and keeps the first trigger's id.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AfDKsy6PE3Rbyt32Fg4YKf
2026-09-09 15:28:49 +00:00
..
2026-08-28 12:04:02 +02:00
2026-08-28 12:04:02 +02:00
2026-03-08 16:22:12 +01:00