From c930220042fecc98e933463d4e4f079a6b595062 Mon Sep 17 00:00:00 2001 From: Laxmi Prasanna Date: Mon, 4 May 2026 11:00:53 +0530 Subject: [PATCH 1/3] fix - not saving editor state to convex when closing/ moving to other file --- src/features/editor/components/editor-view.tsx | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/features/editor/components/editor-view.tsx b/src/features/editor/components/editor-view.tsx index 0673c76..76f5b7a 100644 --- a/src/features/editor/components/editor-view.tsx +++ b/src/features/editor/components/editor-view.tsx @@ -17,6 +17,7 @@ export const EditorView = ({ projectId }: { projectId: Id<"projects"> }) => { const activeFile = useFile(activeTabId); const updateFile = useUpdateFile(); const timeoutRef = useRef(null); + const pendingContentRef = useRef(null); const isActiveFileBinary = activeFile && activeFile.storageId; const isActiveFileText = activeFile && !activeFile.storageId; @@ -27,8 +28,12 @@ export const EditorView = ({ projectId }: { projectId: Id<"projects"> }) => { if (timeoutRef.current) { clearTimeout(timeoutRef.current); } + if (pendingContentRef.current && activeFile) { + updateFile({ id: activeFile._id, content: pendingContentRef.current }); + pendingContentRef.current = null; + } }; - }, [activeTabId]); + }, [activeTabId, activeFile, updateFile]); return (
@@ -54,12 +59,15 @@ export const EditorView = ({ projectId }: { projectId: Id<"projects"> }) => { fileName={activeFile.name} initialValue={activeFile.content} onChange={(content: string) => { + pendingContentRef.current = content; + if (timeoutRef.current) { clearTimeout(timeoutRef.current); } timeoutRef.current = setTimeout(() => { updateFile({ id: activeFile._id, content }); + pendingContentRef.current = null; }, DEBOUNCE_MS); }} /> From 9d053f7625dbf3e3530dd9673a6db1c1bfcd07d4 Mon Sep 17 00:00:00 2001 From: Laxmi Prasanna Date: Mon, 4 May 2026 11:32:30 +0530 Subject: [PATCH 2/3] fix- removing activeFile and updateFile from dependecy as per code rabbit suggestion --- src/features/editor/components/editor-view.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/features/editor/components/editor-view.tsx b/src/features/editor/components/editor-view.tsx index 76f5b7a..3a4e9bf 100644 --- a/src/features/editor/components/editor-view.tsx +++ b/src/features/editor/components/editor-view.tsx @@ -33,7 +33,7 @@ export const EditorView = ({ projectId }: { projectId: Id<"projects"> }) => { pendingContentRef.current = null; } }; - }, [activeTabId, activeFile, updateFile]); + }, [activeTabId]); return (
From 6fe1c3d1dac68e7dfc7c1fcdb51b04a250e8883e Mon Sep 17 00:00:00 2001 From: Laxmi Prasanna Date: Tue, 5 May 2026 14:56:11 +0530 Subject: [PATCH 3/3] fix- updated the fix related to editor debouce issue --- src/features/editor/components/editor-view.tsx | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/features/editor/components/editor-view.tsx b/src/features/editor/components/editor-view.tsx index 3a4e9bf..11ec5ea 100644 --- a/src/features/editor/components/editor-view.tsx +++ b/src/features/editor/components/editor-view.tsx @@ -28,12 +28,14 @@ export const EditorView = ({ projectId }: { projectId: Id<"projects"> }) => { if (timeoutRef.current) { clearTimeout(timeoutRef.current); } - if (pendingContentRef.current && activeFile) { - updateFile({ id: activeFile._id, content: pendingContentRef.current }); + if (pendingContentRef.current !== null && activeTabId) { + updateFile({ id: activeTabId, content: pendingContentRef.current }); pendingContentRef.current = null; } }; - }, [activeTabId]); + }, [ + activeTabId + ]); return (