Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 6 additions & 8 deletions server/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1728,20 +1728,18 @@ apiRoutes.post('/documents/:slug/ops', opsRateLimiter, async (req: Request, res:

if (result.status >= 200 && result.status < 300) {
// Collab mutations for rewrite.apply are committed through the canonical Yjs path.
// Other ops still need explicit projection sync into the live room.
// Other (engine-backed) ops only refresh presence/cursor coupling below; they do not
// push a DB snapshot into the live room.
if (op !== 'rewrite.apply') {
try {
const collabRuntime = getCollabRuntime();
if (collabRuntime.enabled) {
const updatedDoc = getDocumentBySlug(slug);
if (updatedDoc) {
const applyOptions = {
markdown: typeof updatedDoc.markdown === 'string' ? updatedDoc.markdown : undefined,
marks: parseJson(updatedDoc.marks),
source: 'rest-ops',
};
await applyCanonicalDocumentToCollab(slug, applyOptions);

// Route-level reapplication from the DB can replay stale markdown over concurrent
// live edits that are not yet persisted, so engine-backed (non-rewrite.apply) ops
// no longer push a broad DB snapshot into the live room. Only the narrow,
// non-content presence/cursor coupling below is synced.
if (participation) {
try {
applyAgentPresenceToLoadedCollab(slug, participation.presenceEntry, {
Expand Down