From 5587134c19185a5e8c4ca52e5e1a55dd00610da9 Mon Sep 17 00:00:00 2001 From: Neil <4138956+nwparker@users.noreply.github.com> Date: Sat, 30 May 2026 20:13:38 -0700 Subject: [PATCH] Move notebook cell editor refs out of effect (#3077) --- src/renderer/src/components/editor/IpynbViewer.tsx | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/renderer/src/components/editor/IpynbViewer.tsx b/src/renderer/src/components/editor/IpynbViewer.tsx index bebfaedb14d..e1385d882c6 100644 --- a/src/renderer/src/components/editor/IpynbViewer.tsx +++ b/src/renderer/src/components/editor/IpynbViewer.tsx @@ -295,6 +295,10 @@ function CodeCell({ const editorFontZoomLevel = useAppStore((s) => s.editorFontZoomLevel) const onDeactivateRef = useRef(onDeactivate) const onSaveRequestRef = useRef(onSaveRequest) + // Why: Monaco commands/listeners are installed once on mount and need the + // latest callbacks without rebuilding the embedded editor. + onDeactivateRef.current = onDeactivate + onSaveRequestRef.current = onSaveRequest const fontSize = computeEditorFontSize(settings?.terminalFontSize ?? 13, editorFontZoomLevel) const lineCount = Math.max(3, source.split('\n').length + 1) const editorHeight = Math.min(520, Math.max(96, lineCount * (fontSize + 8))) @@ -325,11 +329,6 @@ function CodeCell({ }) }, []) - useEffect(() => { - onDeactivateRef.current = onDeactivate - onSaveRequestRef.current = onSaveRequest - }, [onDeactivate, onSaveRequest]) - useEffect(() => { monaco.editor.setTheme(isDark ? 'vs-dark' : 'vs') }, [isDark])