feat(frontend): wire ScheduleEditor to UserDraft

Same pattern, keyed on schedule_schedule. ScheduleEditor doesn't track
an originalConfig (its saveDisabled doesn't compare against a baseline)
so ordering is simpler — initialConfig snapshotted from backend, local
autosave overlaid after.

This completes UserDraft wiring across all 11 trigger editors.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Diego Imbert
2026-05-12 17:26:46 +02:00
parent 9adc272437
commit 03a5e98609
@@ -38,6 +38,8 @@
import { runScheduleNow } from '../scheduled/utils'
import { handleConfigChange } from '../utils'
import { withForkConflictRetry } from '$lib/utils/forkConflict'
import { deepEqual } from 'fast-equals'
import { UserDraft } from '$lib/userDraft.svelte'
import TextInput from '$lib/components/text_input/TextInput.svelte'
import { twMerge } from 'tailwind-merge'
import PermissionedAsLine from '../PermissionedAsLine.svelte'
@@ -142,10 +144,14 @@
path = defaultCfg?.path ?? ePath
await loadSchedule(defaultCfg)
edit = true
} finally {
if (!defaultCfg) {
initialConfig = structuredClone($state.snapshot(getScheduleCfg()))
}
const localCfg = UserDraft.get<Record<string, any>>('schedule_schedule', ePath)
if (localCfg && !deepEqual(localCfg, getScheduleCfg())) {
await loadScheduleCfg(localCfg)
}
} finally {
clearTimeout(loadingTimeout)
drawerLoading = false
showLoading = false
@@ -527,10 +533,12 @@
}
async function scheduleScript(): Promise<void> {
const previousPath = initialPath
const scheduleCfg = getScheduleCfg()
deploymentLoading = true
const isSaved = await saveScheduleFromCfg(scheduleCfg, edit, $workspaceStore!)
if (isSaved) {
UserDraft.remove('schedule_schedule', previousPath)
onUpdate?.(scheduleCfg.path)
drawer?.closeDrawer()
}
@@ -654,6 +662,11 @@
handleConfigChange(scheduleCfg, initialConfig, saveDisabled, edit, onConfigChange)
}
})
$effect(() => {
if (drawerLoading || !initialPath) return
UserDraft.save('schedule_schedule', initialPath, scheduleCfg)
})
</script>
<!-- {JSON.stringify({ allowSchedule, path: script_path, validCRON, isValid })} -->