From 1058bdeccdc4c403ef4599db0ee74a65a66c715f Mon Sep 17 00:00:00 2001 From: Diego Imbert <70353967+diegoimbert@users.noreply.github.com> Date: Thu, 18 Jun 2026 23:22:46 +0200 Subject: [PATCH] fix(frontend): re-key raw-app autosave on post-deploy navigation (#9646) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The raw-app editor keyed its autosave handle on a non-reactive `path` `let`. SvelteKit does not remount the page on same-route navigation, so the post-deploy `goto` (draft_{uuid} → chosen path) left the handle stuck on the old draft slot. Edits to the just-deployed app then autosaved to a dead key, so autosave appeared broken. Key on the reactive `page.params.path` instead, matching /scripts/edit. Co-authored-by: Claude Opus 4.8 (1M context) --- .../(logged)/apps_raw/edit/[...path]/+page.svelte | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/frontend/src/routes/(root)/(logged)/apps_raw/edit/[...path]/+page.svelte b/frontend/src/routes/(root)/(logged)/apps_raw/edit/[...path]/+page.svelte index 91071f9434..73071a9add 100644 --- a/frontend/src/routes/(root)/(logged)/apps_raw/edit/[...path]/+page.svelte +++ b/frontend/src/routes/(root)/(logged)/apps_raw/edit/[...path]/+page.svelte @@ -84,12 +84,17 @@ * self-destruct by matching a non-existent baseline. */ let deployedBaseline = $state(undefined) - // Page-level draft orchestration. `path` is a mount-scoped plain `let` (the - // editor remounts per path), so this re-keys only on workspace change. + // Page-level draft orchestration. Keyed on the REACTIVE `page.params.path`, + // not the mount-scoped `path` `let`: this page is not remounted on a + // same-route navigation, so the post-deploy `goto` (draft_{uuid} → the + // chosen path) must re-key the autosave handle onto the new path. Keying on + // the non-reactive `path` left the handle stuck on the old draft path, so + // edits to the just-deployed app autosaved to a dead key (autosave appeared + // broken). See /scripts/edit, which derives its draft path the same way. // effectivePath omitted: the live-editor-draft entry is owned by RawAppEditor. const draftSync = usePageDraftSync({ itemKind: 'raw_app', - path: () => path, + path: () => page.params.path ?? '', workspace: () => $workspaceStore, // Autosaves landing back on the deployed raw app become deletes, so // reverting edits clears the draft instead of leaving a no-op behind.