Skip to content

fix: keep markdown preview in sync on local edits#8832

Merged
mscolnick merged 2 commits intomarimo-team:mainfrom
peter-gy:ptr/fix-last-typed-md-character-out-of-sync
Mar 23, 2026
Merged

fix: keep markdown preview in sync on local edits#8832
mscolnick merged 2 commits intomarimo-team:mainfrom
peter-gy:ptr/fix-last-typed-md-character-out-of-sync

Conversation

@peter-gy
Copy link
Copy Markdown
Contributor

Summary

Fixes the below-illustrated markdown preview sync bug where the preview could miss the last typed character or stay stale after local edits.

last-char-md-sync.mp4.mov

Details

  • Kept the local markdown autorun fix in the frontend editor path.
  • Marked Loro's initial reconciliation dispatch as RTC sync, the same way later sync updates are marked.
  • Markdown autorun now:
    • runs for local edit transactions (input, delete, undo, redo)
    • ignores formatting-only changes
    • ignores RTC sync transactions, including init sync
  • Testing:
    • markdown autorun gating
    • RTC init-sync annotation

Copilot AI review requested due to automatic review settings March 23, 2026 11:52
@peter-gy peter-gy added the bug Something isn't working label Mar 23, 2026
@vercel
Copy link
Copy Markdown

vercel bot commented Mar 23, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
marimo-docs Ready Ready Preview, Comment Mar 23, 2026 3:14pm

Request Review

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Fixes a markdown preview sync issue by ensuring markdown autorun triggers on true local edit transactions while ignoring RTC sync (including initial reconciliation) and formatting-only changes, keeping preview updates consistent.

Changes:

  • Annotate Loro’s initial reconciliation dispatch with the existing RTC sync annotation.
  • Refactor markdown autorun gating into a reusable helper that filters by local user events, focus fallback, formatting changes, and RTC sync annotations.
  • Add Vitest coverage for both RTC init-sync annotation and markdown autorun gating behavior.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
frontend/src/core/codemirror/rtc/loro/sync.ts Marks the initial reconciliation dispatch as RTC sync via loroSyncAnnotation.
frontend/src/core/codemirror/rtc/loro/tests/sync.test.ts Adds a test asserting init reconciliation dispatch is annotated as RTC sync.
frontend/src/core/codemirror/cells/extensions.ts Implements shouldAutorunMarkdownUpdate and updates markdown autorun to use it (including RTC sync/formatting filters).
frontend/src/core/codemirror/cells/tests/extensions.test.ts Adds focused tests for markdown autorun gating logic (local events, formatting, RTC sync, predicate, focus fallback).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@mscolnick mscolnick merged commit 3580d12 into marimo-team:main Mar 23, 2026
24 checks passed
@github-actions
Copy link
Copy Markdown

🚀 Development release published. You may be able to view the changes at https://marimo.app?v=0.21.2-dev39

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants