From ce1ea1c91de683442c1b29b048ba49d5a72c6dce Mon Sep 17 00:00:00 2001 From: David Langley Date: Thu, 5 Mar 2026 21:09:16 +0000 Subject: [PATCH] debug: add __docApplyDelta console helper + fix save_after type - window.__docApplyDelta(base64) lets you manually inject a delta from the browser console on the receiver tab, confirming whether applyDeltaBytes itself works (delivery issue vs rendering issue) - Log warning if onDeltaRef.current is null when injection is attempted --- .../rooms/wysiwyg_composer/DocumentView.tsx | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/apps/web/src/components/views/rooms/wysiwyg_composer/DocumentView.tsx b/apps/web/src/components/views/rooms/wysiwyg_composer/DocumentView.tsx index f55e8325ad..4df1269177 100644 --- a/apps/web/src/components/views/rooms/wysiwyg_composer/DocumentView.tsx +++ b/apps/web/src/components/views/rooms/wysiwyg_composer/DocumentView.tsx @@ -652,9 +652,25 @@ export const DocumentView = memo(function DocumentView({ room }: DocumentViewPro return info; }; + // Expose a test helper to manually inject a base64-encoded Automerge + // delta from the browser console. Useful for confirming that + // applyDeltaBytes works in isolation (to rule out delivery issues). + // Usage: window.__docApplyDelta("") + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (window as any).__docApplyDelta = (base64: string): void => { + logger.info("[DocumentView] __docApplyDelta: manual injection", base64.length, "b base64"); + if (rtc.onDeltaRef.current) { + rtc.onDeltaRef.current(base64Decode(base64)); + } else { + logger.warn("[DocumentView] __docApplyDelta: onDeltaRef.current is null — check wiring"); + } + }; + return () => { // eslint-disable-next-line @typescript-eslint/no-explicit-any delete (window as any).__docDebug; + // eslint-disable-next-line @typescript-eslint/no-explicit-any + delete (window as any).__docApplyDelta; }; }, [composerModel, room, client, ref, rtc]);