From 989f1dfa345ea2bbbb89e003246d03865ff16d1d Mon Sep 17 00:00:00 2001 From: bunker-admin Date: Sun, 8 Mar 2026 23:42:48 -0600 Subject: [PATCH] Fix docs editor not loading content on first file click Add editorReady state flag to resolve race condition where Y.js sync completes before Monaco editor mounts, causing the MonacoBinding effect to skip binding creation on the initial file selection. Bunker Admin --- admin/src/pages/DocsPage.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/admin/src/pages/DocsPage.tsx b/admin/src/pages/DocsPage.tsx index 37d9ee6f..c31d51d7 100644 --- a/admin/src/pages/DocsPage.tsx +++ b/admin/src/pages/DocsPage.tsx @@ -623,6 +623,7 @@ export default function DocsPage() { const monacoEditorRef = useRef(null); const monacoRef = useRef(null); const monacoBindingRef = useRef(null); + const [editorReady, setEditorReady] = useState(false); // --- Collaboration state --- const [collabEnabled, setCollabEnabled] = useState(false); @@ -803,6 +804,7 @@ export default function DocsPage() { const handleEditorMount: OnMount = useCallback((ed, monaco) => { monacoEditorRef.current = ed; monacoRef.current = monaco; + setEditorReady(true); // Register keyboard shortcuts only (no context menu items — we use a custom menu) SNIPPETS.filter(s => s.keybinding).forEach(snippet => { @@ -856,7 +858,7 @@ export default function DocsPage() { binding.destroy(); monacoBindingRef.current = null; }; - }, [collab.active, collab.yText, collab.provider, selectedFile]); + }, [collab.active, collab.yText, collab.provider, selectedFile, editorReady]); // Auto-refresh preview when remote changes arrive in collab mode useEffect(() => {