@@ -21,6 +21,8 @@ import { PlayButton } from "./shared/PlayButton.js";
2121import { CellTypeSelector } from "./shared/CellTypeSelector.js" ;
2222import { CodeToolbar } from "./toolbars/CodeToolbar.js" ;
2323import { MarkdownToolbar } from "./toolbars/MarkdownToolbar.js" ;
24+ import { ErrorBoundary } from "react-error-boundary" ;
25+ import { OutputsErrorBoundary } from "./shared/OutputsErrorBoundary.js" ;
2426
2527type CellType = typeof tables . cells . Type ;
2628
@@ -59,7 +61,7 @@ export const Cell: React.FC<CellProps> = ({
5961 } ) ;
6062
6163 // Use shared outputs hook with code-specific configuration
62- const { outputs, hasOutputs, renderOutputs } = useCellOutputs ( {
64+ const { outputs, hasOutputs, MaybeOutputs } = useCellOutputs ( {
6365 cellId : cell . id ,
6466 groupConsecutiveStreams : true ,
6567 enableErrorOutput : true ,
@@ -223,35 +225,39 @@ export const Cell: React.FC<CellProps> = ({
223225 // Route to specialized cell components
224226 if ( cell . cellType === "sql" ) {
225227 return (
226- < SqlCell
227- cell = { cell }
228- onAddCell = { onAddCell }
229- onDeleteCell = { onDeleteCell }
230- onMoveUp = { onMoveUp }
231- onMoveDown = { onMoveDown }
232- onFocusNext = { onFocusNext }
233- onFocusPrevious = { onFocusPrevious }
234- autoFocus = { autoFocus }
235- onFocus = { onFocus }
236- contextSelectionMode = { contextSelectionMode }
237- />
228+ < ErrorBoundary fallback = { < div > Error rendering SQL cell</ div > } >
229+ < SqlCell
230+ cell = { cell }
231+ onAddCell = { onAddCell }
232+ onDeleteCell = { onDeleteCell }
233+ onMoveUp = { onMoveUp }
234+ onMoveDown = { onMoveDown }
235+ onFocusNext = { onFocusNext }
236+ onFocusPrevious = { onFocusPrevious }
237+ autoFocus = { autoFocus }
238+ onFocus = { onFocus }
239+ contextSelectionMode = { contextSelectionMode }
240+ />
241+ </ ErrorBoundary >
238242 ) ;
239243 }
240244
241245 if ( cell . cellType === "ai" ) {
242246 return (
243- < AiCell
244- cell = { cell }
245- onAddCell = { onAddCell }
246- onDeleteCell = { onDeleteCell }
247- onMoveUp = { onMoveUp }
248- onMoveDown = { onMoveDown }
249- onFocusNext = { onFocusNext }
250- onFocusPrevious = { onFocusPrevious }
251- autoFocus = { autoFocus }
252- onFocus = { onFocus }
253- contextSelectionMode = { contextSelectionMode }
254- />
247+ < ErrorBoundary fallback = { < div > Error rendering AI cell</ div > } >
248+ < AiCell
249+ cell = { cell }
250+ onAddCell = { onAddCell }
251+ onDeleteCell = { onDeleteCell }
252+ onMoveUp = { onMoveUp }
253+ onMoveDown = { onMoveDown }
254+ onFocusNext = { onFocusNext }
255+ onFocusPrevious = { onFocusPrevious }
256+ autoFocus = { autoFocus }
257+ onFocus = { onFocus }
258+ contextSelectionMode = { contextSelectionMode }
259+ />
260+ </ ErrorBoundary >
255261 ) ;
256262 }
257263
@@ -377,15 +383,17 @@ export const Cell: React.FC<CellProps> = ({
377383 { /* Editor Content Area */ }
378384 { cell . sourceVisible && (
379385 < div className = "cell-content bg-white py-1 pl-4 transition-colors" >
380- < Editor
381- localSource = { localSource }
382- handleSourceChange = { handleSourceChange }
383- updateSource = { updateSource }
384- handleFocus = { handleFocus }
385- cell = { cell }
386- autoFocus = { autoFocus }
387- keyMap = { keyMap }
388- />
386+ < ErrorBoundary fallback = { < div > Error rendering editor</ div > } >
387+ < Editor
388+ localSource = { localSource }
389+ handleSourceChange = { handleSourceChange }
390+ updateSource = { updateSource }
391+ handleFocus = { handleFocus }
392+ cell = { cell }
393+ autoFocus = { autoFocus }
394+ keyMap = { keyMap }
395+ />
396+ </ ErrorBoundary >
389397 </ div >
390398 ) }
391399 </ div >
@@ -457,8 +465,9 @@ export const Cell: React.FC<CellProps> = ({
457465 </ div >
458466 </ div >
459467 ) }
460-
461- { hasOutputs && renderOutputs ( ) }
468+ < ErrorBoundary FallbackComponent = { OutputsErrorBoundary } >
469+ { hasOutputs && < MaybeOutputs /> }
470+ </ ErrorBoundary >
462471 </ div >
463472 ) }
464473 </ CellContainer >
0 commit comments