Files
webstudio/packages/project-migrations
Oleg Isonen 26408a274e fix: Open projects with cyclic page folders (#6687)
Projects with a saved page-folder cycle currently fail to open. Loading
now repairs the cycle in memory and keeps its folders reachable. New
folder cycles are still rejected on save.

Closes #6686

## Change
- Visit the root folder first to preserve existing page paths. Remove
only child links that close a cycle.
- Visit detached folder trees before isolated cycles. Attach a repaired
tree at its top folder so its pages remain visible.
- Use one shared migration for current, serialized, and legacy page
data. Loading does not write to the database; a normal save persists the
repaired tree.
- This adds 49 net non-test lines. The folder traversal is needed
because the existing asset-folder repair handles database parent links
and writes to a different store.

## Checklist
- [x] Add regression tests for connected, detached, and self-referencing
cycles in current, serialized, and legacy data. Confirm they fail before
the fix and pass after it.
- [x] Confirm new cycles remain rejected on save.
- [x] Import the linked project's saved pages into an isolated local
Builder project and open the Pages panel. The recovered folder appears.
- [x] Review Builder docs. No update is needed: page-folder controls and
normal behavior do not change.
- [x] Review and simplify the repair. The final helper is seven lines
shorter and handles a cycle below a detached parent folder.
- [ ] Complete CI review for the final commit.

## Verification
- Passed: project-migrations tests, typecheck, and build; project-build
page tests and typecheck; Builder load-router tests and typecheck;
project build-patch tests; SDK page-schema tests; repository lint;
formatting and diff checks; fixture pipeline and a later fixture build.
- The linked project's saved page data has 23 pages after legacy
migration and two folders, including one self-reference. A local Builder
E2E opened those pages and displayed the repaired folder. Other site
content was synthetic because the share token cannot export the complete
build.
- Fixture sync pulled an unrelated remote change into two generated
files. Those changes were stashed and excluded from this PR.
- The approved full `pnpm evaluations` rerun exited 1: seven agent cases
passed, two failed in unrelated form or guidance checks, and baselines
were missing or incompatible. No evaluation files are included.
- The production project still returns HTTP 500 until this change is
deployed.
2026-11-13 01:24:41 +01:00
..