Skip to content

Commit 864a35d

Browse files
committed
fix: preserve editor state after save, match signature to prevent $effect revert
1 parent ada97ad commit 864a35d

File tree

1 file changed

+21
-6
lines changed

1 file changed

+21
-6
lines changed

frontend/src/routes/(app)/projects/[projectId]/+page.svelte

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -386,12 +386,27 @@
386386
}
387387
}
388388
389-
applyProjectDetailsToEditor(savedProject, 'saved');
390-
// Pass the enriched project (with locally-preserved include file
391-
// content) to the query cache so that any reactive re-read after
392-
// save doesn't revert the editor to the lazy-loaded (content-less)
393-
// server response.
394-
await syncProjectQueries(withLoadedProjectFileContent(savedProject));
389+
// Preserve the editor's current values as the new baseline rather
390+
// than re-applying the server response via applyProjectDetailsToEditor,
391+
// which triggers a reactive chain that reverts the editor content.
392+
originalName = $inputs.name.value;
393+
originalComposeContent = $inputs.composeContent.value;
394+
originalEnvContent = $inputs.envContent.value;
395+
originalIncludeFiles = { ...includeFilesState };
396+
397+
// Update the project object for runtime info (status, services, etc.)
398+
// without touching the editor inputs.
399+
const enriched = withLoadedProjectFileContent(savedProject);
400+
project = enriched;
401+
syncIncludeFileUiState(enriched);
402+
403+
await syncProjectQueries(enriched);
404+
405+
// Match the signature to data.project (the stale page-load value)
406+
// so the $effect guard doesn't re-apply old content to the editor.
407+
const currentPageProject = withLoadedProjectFileContent(data.project);
408+
lastSeenProjectSignature = buildProjectSyncSignature(currentPageProject);
409+
395410
toast.success(m.common_update_success({ resource: m.project() }));
396411
}
397412
});

0 commit comments

Comments
 (0)