Move notebook cell editor refs out of effect

This commit is contained in:
Neil
2026-05-29 03:22:39 -07:00
parent ccd0cc1d09
commit bd280c00f4
@@ -248,6 +248,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)))
@@ -273,11 +277,6 @@ function CodeCell({
})
}, [])
useEffect(() => {
onDeactivateRef.current = onDeactivate
onSaveRequestRef.current = onSaveRequest
}, [onDeactivate, onSaveRequest])
useEffect(() => {
monaco.editor.setTheme(isDark ? 'vs-dark' : 'vs')
}, [isDark])