Repository navigation
Fix Edit post opening blank by switching off live co-editing - #547
Conversation
"Edit post" opened an empty bordered box — no toolbar, no post text, nothing to type into — so the post couldn't be edited at all. Only the edit composer passes `collab` to RichEditor, and RichEditor builds its collaborative kit behind a dynamic import of the Yjs chunk (those packages are optional peers, so plain mode never loads them). When that import fails — a stale Vite dep hash in dev, a chunk missing from a partial OTA bundle — RichEditor catches the error and renders nothing at all. Posting was unaffected, which is why this only ever showed up on edit. MarkdownEditor now checks that an editor actually appeared and, if none did, remounts it without collaboration: live co-editing is what's lost, editing the post keeps working. The deadline keys on the room id rather than the config object, which hosts rebuild on every render. Covered both ways: a unit test for the fallback (including under the re-renders that reset the deadline) and an e2e test that aborts the chunk request the way the browser saw it. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
🗑️ Preview Environment Cleaned UpThe preview container for this PR has been deleted. |
What's in the diff — 204 insertions, 2 deletions, 4 filesThe line count is mostly tests and comments. The behaviour change is 22 lines in one component.
|
Replaces the earlier fallback-with-a-deadline approach on this branch. The edit composer was the only place asking RichEditor for live co-editing, and RichEditor builds that kit behind a dynamic import. When the chunk fails to load it catches the error and renders nothing: an empty bordered box, no toolbar, no post text, no way to edit. RichEditor exposes no error callback or ready state, so an app can only detect this by probing the DOM after an arbitrary delay — a magic number guarding against a library that won't talk. Rather than ship that, stop asking for the feature: `COLLAB_ENABLED = false` in collab.ts, with the reasoning and the one-line path back written down beside it. Live co-editing on the web is what's lost until `@mieweb/ui` handles its own failure (mieweb/ui#480) and we upgrade past it. The relay, the rooms and the `collabRoom` wiring are untouched. Tests: the huddle edit path is covered end to end by edit-post-works, which also asserts the composer never requests the collab chunk, so this fails loudly if the feature comes back without the upstream fix. The Yjs specs are skipped with a note pointing at the flag. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Changed approach on this branchThe earlier version detected the broken editor and remounted it without collaboration. It worked, and the tests proved it, but it rested on a 4-second deadline and a That number doesn't belong in a fix that isn't the real one, so the branch now does the plain thing instead: stop asking for live co-editing until the component can fail safely (mieweb/ui#480). Now:
Net −93 lines against The trade is explicit: web users lose live co-editing until the upgrade, and everyone gets an Edit button that works. It was already off on iOS and Android for a related reason, so the loss is web-only. Restoring it is one flag plus un-skipping one spec. |
The bug
Opening Edit post showed a bordered box with nothing in it: no toolbar, no text, nothing to type into. Writing a new post worked perfectly — same composer component, opposite behaviour.
Root cause
The edit composer is the only place that asks for live co-editing (
collabRoom={post.id}inPostCard).RichEditorbuilds that kit behind a dynamicimport(), because Yjs and friends are optional peers that plain mode never loads.When that import fails,
RichEditorcatches the error and renders nothing:CoreEditor.create()is never reached. The composer chrome renders around an editor that does not exist. New posts never passcollab, so they never load that chunk — which is why only editing broke.Reproduced by aborting that one request: the result is a pixel match for the reported screenshot. A dead
/yjsrelay is not the cause — with the websocket refused the editor mounts fine and keeps its text.The fix
in
src/features/huddle/collab.ts, with the reasoning and the way back written beside it. The composer stops asking for a feature that can cost the user their editor.Why not detect the failure and recover? That was the first version of this branch, and it is what the diff no longer contains.
RichEditorexposes no error callback, no ready state, no ref — nothing that reports setup failure. The only signal available to a consumer is "look at the DOM and see if an editor turned up yet", and yet has to be a number. A 4-second guess against a library that will not talk is not a fix worth carrying, so the feature is off instead of guarded.What's lost: live co-editing on the web, until
@mieweb/uiships the fallback and we upgrade. It was already off on iOS and Android (it wiped post text over a slow LAN), so this affects web only.What's untouched: the relay (
meteor-backend/server/yjs.js), the rooms, and thecollabRoomwiring. Restoring the feature is: upgrade@mieweb/ui, flip the flag, un-skip the Yjs specs.Tests
tests/e2e/huddle/edit-post-works.spec.ts— opens Edit post, checks the editor arrives seeded with the post, types, saves, and asserts the result is in the feed. It also fails if the composer requests the collab chunk at all, so the feature cannot quietly come back without the upstream fix.tests/e2e/huddle/yjs-collab-editing.spec.ts— skipped, with a note pointing at the flag and at Keep RichEditor usable when the collaborative kit fails to load ui#480.Verified:
lint,typecheck,formatclean;test:unit149 passed; thetests/e2e/huddlesuite passes (one unrelated flake — a login timeout inplan-first-clock-flow'sbeforeEachunder suite load, which passes in isolation: 8/8).How this relates to the upstream fix
The real bug is that
RichEditorrenders nothing on a collab-kit failure and gives the host no way to know. That is open as mieweb/ui#480, which falls back to a local editor and reports the failure through a newcollab.onUnavailable. Its tests fail onmieweb/ui@mainand pass with the change; their full suite (900 tests) stays green.Once #480 ships and we upgrade, flipping
COLLAB_ENABLEDback totruerestores live editing — on phones too, since 0.9.x also carries the re-seed repair for the bug that disabled it there.Release notes
Added to
release-notes/1.0.3.md(the note for the currentpackage.jsonversion).🤖 Generated with Claude Code