Skip to content

fix(collab): keep the cells a doc does not own when the relay persists a row - #504

Draft
DavidBabinec wants to merge 1 commit into
mainfrom
fix/relay-row-cells
Draft

fix(collab): keep the cells a doc does not own when the relay persists a row#504
DavidBabinec wants to merge 1 commit into
mainfrom
fix/relay-row-cells

Conversation

@DavidBabinec

Copy link
Copy Markdown
Contributor

What changed

The collab relay persists a row's derived cells after every doc edit. It used to write only the cells the doc model carries (page: title, slug, body, template cells; component: name, slug, body, params, classIds; layout: name, slug, body, classes) as the WHOLE row, and the draft save replaces cells wholesale. Every other cell on the row was lost on the first relay write after it was set: SEO title and description, featured media, plugin-owned cells.

Now the relay merges: stored cells, minus the keys the doc kind owns, plus the derived cells. OWNED_CELLS in server/collab/relayPersistence.ts is the single list of what each doc kind owns, so a cell the projection stopped emitting (a page that is no longer a template) is still cleared, and everything else survives exactly as stored.

Why

Reproduced on a real site: SEO title and description filled in, open the page in the editor, change one word, and the row's SEO cells are gone. It was noticed through the branch merge review (the branch's copy reported "SEO title: cleared" with no SEO edit made), but it affects every install that edits pages with SEO set: the data is lost on main too.

Impact

Users: SEO, featured media, and plugin cells survive editing. Nothing else changes; rows already stripped are not recovered by this fix (there is nothing left to recover from).

Developers: mergeDerivedCells(existing, derived, owned) is exported from relayPersistence.ts; docs/features/site-shell.md describes the merge in the relay section.

Verification

  • bunx tsc -b clean
  • bun run lint clean
  • bun test full suite passes, including the new regression test in collabRelayIntegration.test.ts (SEO seeded on the row, a label edit through a real socket, the persisted row keeps both SEO cells).

…s a row

The relay derived a row's cells from its Y doc and wrote them as the whole
row. A page doc carries title, slug, body and the template cells; a
component doc carries name, slug, body, params, classIds; a layout doc
carries name, slug, body, classes. Everything else on the row (SEO title
and description, featured media, plugin-owned cells) was dropped on the
first relay write after it was set, because the draft save replaces cells
wholesale. On a site with SEO filled in, opening a page in the editor and
changing one word cleared its SEO.

The relay now merges: the stored cells first, the doc-owned keys cleared,
then the derived cells on top, so an owned cell the projection stopped
emitting (a page that is no longer a template) is still cleared and every
other cell survives exactly as stored. OWNED_CELLS in relayPersistence.ts
is the one list of what each doc kind owns.

Regression test in collabRelayIntegration.test.ts: SEO seeded on the row,
a label edit through a real socket, the persisted row keeps both SEO cells.
docs/features/site-shell.md describes the merge.

Verification:
  bunx tsc -b                      clean
  bun run lint                     clean
  bun test                         full suite, all pass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant