Drop empty paragraphs from canonical document projection - #212
Open
lavaman131 wants to merge 1 commit into
Open
lavaman131 wants to merge 1 commit into
lavaman131 wants to merge 1 commit into
Conversation
|
The preview deployment for chopin is ready. 🟢 Open app | Open Build Logs | Open Application Logs Last updated at: 2026-10-01 15:11:26 CET |
lavaman131
force-pushed
the
fix-trailing-empty-paragraph-description
branch
from
September 28, 2026 22:42
d0e053e to
908f1b7
Compare
MaggieAppleton
added a commit
that referenced
this pull request
Sep 30, 2026
MaggieAppleton
approved these changes
Sep 30, 2026
An empty Lexical paragraph exported as an empty MDAST paragraph, which serializes as an extra blank line that parsing discards. Rooms persisted that non-canonical source, and document-summary jobs then failed with "Document source is not canonical." Projection now drops empty paragraphs at every depth, matching the blocks that addressable() and digests() already count. Checkpoints written before this change still store the former blank lines, so restore accepts a stored source whose canonical form matches the projection. Closes #211 Assistant-model: Claude Opus 5.5 Assistant-workflow: inline Assistant-duration: 15m converged, estimated none given Assistant-verification: bun test unit passed: 1659 pass, 2 skip, 0 fail; new convert and room regression tests failed before the fix Assistant-verification: bun run test:postgres passed: 59 pass Assistant-verification: bun run types passed: all workspaces and E2E Assistant-verification: bun run ci passed: dprint, oxlint, tokens, type scale, Impeccable Assistant-verification: bun run e2e passed: 236 Chromium tests Assistant-verification: agent-browser E2E passed: typing text and two Enters stores canonical "…strings.\n" on this branch versus non-canonical "…strings.\n\n\n\n" on main; a document written by main opens, edits, and re-persists canonically on this branch Co-authored-by: Alex Lavaee <lavaman131@github.com>
lavaman131
force-pushed
the
fix-trailing-empty-paragraph-description
branch
from
October 1, 2026 15:07
8c74c16 to
e1fc8c3
Compare
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.
Closes #211
Problem
An empty Lexical paragraph was exported as an MDAST
paragraphwith no children.serializewrites that as an extra blank line, andparsediscards it. Pressing Enter at the end of a document, or inserting a/researchcard, was enough to make the room persist source that fails its own round trip. Thedocument-summaryjob then failed with "Document source is not canonical." under every harness.Change
packages/dialect/src/convert.ts:$exportPlanTreedrops empty paragraphs at every depth, so projection is canonical. Block addressing already ignored them:addressable()skips root-level empty paragraphs anddigests()goes throughparse. The Lexical tree and browser editing are unchanged; only the server projection differs. Table cells and a container left with only an empty paragraph export exactly as before.apps/server/src/plan/room.ts: existing checkpoints still store the old blank lines, andrestore()required the stored source to match the projection exactly. Without a change, those channels would fail to open with "stored plan source does not match its Yjs checkpoint".restore()now also accepts a stored source whose canonical form,serialize(parse(source)), matches the projection. An unrelated source is still rejected. The next checkpoint rewrites the source in canonical form.Existing documents keep failing description jobs until their next edit re-projects them.
Verification
New regression tests cover export at the root, after a Research card, between blocks and inside a blockquote, plus restoring a legacy checkpoint. Both failed before the fix.
Live check with agent-browser against an
AGENT=offserver: I typed text and pressed Enter twice, then read the stored snapshot.serialize(parse(s)) === smain"The harp needs new strings.\n\n\n\n""The harp needs new strings.\n"A document written by
mainopened on this branch without errors, accepted an edit, and was saved in canonical form ("…strings.\n\nOrder a full set.\n"):The first run of
bun run e2efailed one test,responsive-decisions.e2e.ts"long independent decisions…", on a strict-mode locator. That failure also happens onmain: cold-start runs of that test failed 2 of 3 times onmainand 3 of 3 on this branch, so it is an existing flake. The rerun of the full suite passed.Assistant-verification: bun test unit passed: 1659 pass, 2 skip, 0 fail; new convert and room regression tests failed before the fix
Assistant-verification: bun run test:postgres passed: 59 PostgreSQL contract tests
Assistant-verification: bun run types passed: all workspaces and E2E
Assistant-verification: bun run ci passed: dprint, oxlint, tokens, type scale, Impeccable
Assistant-verification: bun run e2e passed: 236 Chromium tests on rerun; the one earlier failure is an existing cold-start flake that also fails on main
Assistant-verification: agent-browser E2E passed: text plus two Enters stores canonical source on this branch versus non-canonical on main; a main-written document opens, edits, and re-persists canonically
Assistant-model: Claude Opus 5.5
Assistant-workflow: inline
Assistant-duration: 16m converged, estimated none given
Co-authored-by: Alex Lavaee lavaman131@github.com