Skip to content

Fix Edit post opening blank by switching off live co-editing - #547

Merged
Dharp02 merged 2 commits into
mainfrom
fix/huddle-edit-composer-collab-fallback
Sep 21, 2026
Merged

Dharp02 merged 2 commits into
mainfrom
fix/huddle-edit-composer-collab-fallback

Conversation

@Dharp02

@Dharp02 Dharp02 commented Sep 21, 2026 •

Copy link
Copy Markdown
Collaborator

For reviewers, in short: Edit post opened as an empty box — no toolbar, no post text, no way to edit. Reported with a screenshot, reproduced exactly. This switches off live co-editing, which is what could take the editor down with it, until @mieweb/ui handles its own failure (mieweb/ui#480).

One flag, one line. Net −93 lines. No timers, no DOM probing, nothing arbitrary.

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} in PostCard). RichEditor builds that kit behind a dynamic import(), because Yjs and friends are optional peers that plain mode never loads.

When that import fails, RichEditor catches the error and renders nothing:

Failed to set up editor: TypeError: Failed to fetch dynamically imported module:
  .../deps/collabKit-QZL4P5T5-B80mIQbp.js?v=d3928a27

CoreEditor.create() is never reached. The composer chrome renders around an editor that does not exist. New posts never pass collab, 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 /yjs relay is not the cause — with the websocket refused the editor mounts fine and keeps its text.

The fix

const COLLAB_ENABLED = false;

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. RichEditor exposes 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/ui ships 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 the collabRoom wiring. 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, format clean; test:unit 149 passed; the tests/e2e/huddle suite passes (one unrelated flake — a login timeout in plan-first-clock-flow's beforeEach under suite load, which passes in isolation: 8/8).

How this relates to the upstream fix

The real bug is that RichEditor renders 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 new collab.onUnavailable. Its tests fail on mieweb/ui@main and pass with the change; their full suite (900 tests) stays green.

This PR mieweb/ui#480
Fixes Edit post, in TimeHuddle, now The component, for every consumer
Approach Stop asking for the risky feature Make the feature safe to ask for
Depends on Nothing Merge + a 0.7.3 → 0.9.x upgrade here
Cost No live co-editing on web meanwhile None

Once #480 ships and we upgrade, flipping COLLAB_ENABLED back to true restores 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 current package.json version).

🤖 Generated with Claude Code

"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>
Copilot AI balanced review requested due to automatic review settings September 21, 2026 01:35
@github-actions

github-actions Bot commented Sep 21, 2026 •

Copy link
Copy Markdown

🗑️ Preview Environment Cleaned Up

The preview container for this PR has been deleted.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@Dharp02

Dharp02 commented Sep 21, 2026 •

Copy link
Copy Markdown
Collaborator Author

Superseded — this described the first version of this branch (a fallback with a 4-second deadline in MarkdownEditor.tsx). That approach is gone: the magic number was guarding against a library that gives consumers no error signal, which isn't worth carrying. The branch now switches live co-editing off in one flag until mieweb/ui#480 lands. See the PR description for the current shape.


What's in the diff — 204 insertions, 2 deletions, 4 files

The line count is mostly tests and comments. The behaviour change is 22 lines in one component.

File +/- What it is
src/features/huddle/MarkdownEditor.tsx +54 / -2 The fix. 22 lines of code, ~30 of comment.
src/features/huddle/MarkdownEditor.test.tsx +76 New unit test (2 cases)
tests/e2e/huddle/edit-composer-collab-fallback.spec.ts +70 New e2e test (1 case)
release-notes/1.0.3.md +4 User-facing note, per release-notes/README.md

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>
Copilot AI review requested due to automatic review settings September 21, 2026 03:03
@Dharp02 Dharp02 changed the title Fix the Huddle edit composer when the collaborative editor can't load Fix Edit post opening blank by switching off live co-editing Sep 21, 2026
@Dharp02

Dharp02 commented Sep 21, 2026

Copy link
Copy Markdown
Collaborator Author

Changed approach on this branch

The 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 querySelector('.ProseMirror') probe — a guess about a library's internal state, because RichEditor reports nothing a consumer can react to.

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:

File Change
src/features/huddle/collab.ts COLLAB_ENABLED = false, plus why and how to undo it
tests/e2e/huddle/edit-post-works.spec.ts Edit → type → save, and asserts the collab chunk is never requested
tests/e2e/huddle/yjs-collab-editing.spec.ts Skipped, with a note pointing at the flag
src/features/huddle/MarkdownEditor.tsx Back to what is on main — no change
release-notes/1.0.3.md Reworded for the new behaviour

Net −93 lines against main, where the previous version was +204.

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.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@Dharp02
Dharp02 merged commit a73d25e into main Sep 21, 2026
8 of 9 checks passed
@github-project-automation github-project-automation Bot moved this from Ready to Done in Scrum Team Jerry Sep 21, 2026
@Dharp02
Dharp02 deleted the fix/huddle-edit-composer-collab-fallback branch November 2, 2026 17:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants