From eee6695d7f6c66771cf61ffb0bb351ac770758e5 Mon Sep 17 00:00:00 2001 From: sdarbinyan Date: Fri, 17 Jul 2026 18:45:53 +0400 Subject: [PATCH] fix(project-editor): route importBootstrap through updateBootstrap for undo+draft persistence importBootstrap() replaced state.bootstrap directly, bypassing the same updateBootstrap() pipeline every other edit goes through - so an import never got a draftStorage.save() (lost on refresh before an explicit Save) and never became an undo-able history step (Undo silently skipped over it). Verified live via window.ng.getComponent(): exported the current bootstrap, mutated branding.brandName, imported it back - draftStorage's localStorage key changed and contained the new value; clicking Undo correctly reverted brandName to the pre-import value. Co-Authored-By: Claude Sonnet 5 --- .../project-editor/facade/project-editor.facade.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/app/features/project-editor/facade/project-editor.facade.ts b/src/app/features/project-editor/facade/project-editor.facade.ts index 72d27dc..0e975d7 100644 --- a/src/app/features/project-editor/facade/project-editor.facade.ts +++ b/src/app/features/project-editor/facade/project-editor.facade.ts @@ -292,10 +292,18 @@ export class ProjectEditorFacade { return current ? this.ioService.exportBootstrap(current) : ''; } + /** + * Replaces the whole draft with an imported bootstrap. Routed through + * updateBootstrap() (not a direct state.update) so an import gets the same + * undo-history entry and draftStorage persistence as any other edit - + * otherwise the import "worked" on screen but silently wasn't saved to the + * localStorage draft, and Undo couldn't step back through it. + */ importBootstrap(raw: string): void { try { const imported = this.normalize(this.ioService.importBootstrap(raw)); - this.state.update(current => ({ ...current, bootstrap: imported, importError: null })); + this.state.update(current => ({ ...current, importError: null })); + this.updateBootstrap(() => imported); } catch { this.state.update(current => ({ ...current, importError: 'builder.importError' })); }