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
Draft
fix(collab): keep the cells a doc does not own when the relay persists a row#504DavidBabinec wants to merge 1 commit into
DavidBabinec wants to merge 1 commit into
Conversation
…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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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_CELLSinserver/collab/relayPersistence.tsis 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 fromrelayPersistence.ts;docs/features/site-shell.mddescribes the merge in the relay section.Verification
bunx tsc -bcleanbun run lintcleanbun testfull suite passes, including the new regression test incollabRelayIntegration.test.ts(SEO seeded on the row, a label edit through a real socket, the persisted row keeps both SEO cells).