fix(schedules): report what a write actually left diverging, and adopt what it deployed

The enable/disable request carries the enabled flag alone, but claimed to leave
nothing behind — so the host remounted, and a summary or args edit still sitting
on the autosave debounce went with it. It now reports the form's real divergence
from the baseline it just moved.

A save also left `edit` and `draftOnly` to the remount, which is exactly what a
kept edit skips: a draft-only schedule created while the user typed stayed in
draft-only mode, with its path still editable and its next save a create. They
follow the write that deployed it instead.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KcyBRxE8j3ujCYkum9KrC4
This commit is contained in:
Diego Imbert
2026-09-06 08:39:41 +02:00
co-authored by Claude Opus 5
parent 0dd7508eb6
commit 9c20945ad4
@@ -632,6 +632,11 @@
// — and the host must not remount over it, which is the only thing that can
// tell it so.
const keptEdit = !draftValuesEqual(getScheduleCfg(), scheduleCfg)
// The schedule is deployed now, whether it was before or not. Set here rather
// than left to the remount, which a kept edit skips: they decide whether the
// next save updates or creates, and whether a discard removes the item.
edit = true
draftOnly = false
settleDraftAfterWrite(
'trigger_schedule',
scheduleCfg,
@@ -758,7 +763,9 @@
sendUserToast(`${nEnabled ? 'enabled' : 'disabled'} schedule ${path}`)
// Deployed state moved, so the baseline the banner compares against does too.
if (initialConfig) initialConfig.enabled = nEnabled
onUpdate?.(path, path, ws, false)
// This request carried the enabled flag alone: anything else the form has
// diverged into is an edit of the user's, which a remount would drop.
onUpdate?.(path, path, ws, !draftValuesEqual(getScheduleCfg(), initialConfig))
}
}