@@ -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 ,
@@ -211,35 +213,39 @@ export const Cell: React.FC<CellProps> = ({
211213 // Route to specialized cell components
212214 if ( cell . cellType === "sql" ) {
213215 return (
214- < SqlCell
215- cell = { cell }
216- onAddCell = { onAddCell }
217- onDeleteCell = { onDeleteCell }
218- onMoveUp = { onMoveUp }
219- onMoveDown = { onMoveDown }
220- onFocusNext = { onFocusNext }
221- onFocusPrevious = { onFocusPrevious }
222- autoFocus = { autoFocus }
223- onFocus = { onFocus }
224- contextSelectionMode = { contextSelectionMode }
225- />
216+ < ErrorBoundary fallback = { < div > Error rendering SQL cell</ div > } >
217+ < SqlCell
218+ cell = { cell }
219+ onAddCell = { onAddCell }
220+ onDeleteCell = { onDeleteCell }
221+ onMoveUp = { onMoveUp }
222+ onMoveDown = { onMoveDown }
223+ onFocusNext = { onFocusNext }
224+ onFocusPrevious = { onFocusPrevious }
225+ autoFocus = { autoFocus }
226+ onFocus = { onFocus }
227+ contextSelectionMode = { contextSelectionMode }
228+ />
229+ </ ErrorBoundary >
226230 ) ;
227231 }
228232
229233 if ( cell . cellType === "ai" ) {
230234 return (
231- < AiCell
232- cell = { cell }
233- onAddCell = { onAddCell }
234- onDeleteCell = { onDeleteCell }
235- onMoveUp = { onMoveUp }
236- onMoveDown = { onMoveDown }
237- onFocusNext = { onFocusNext }
238- onFocusPrevious = { onFocusPrevious }
239- autoFocus = { autoFocus }
240- onFocus = { onFocus }
241- contextSelectionMode = { contextSelectionMode }
242- />
235+ < ErrorBoundary fallback = { < div > Error rendering AI cell</ div > } >
236+ < AiCell
237+ cell = { cell }
238+ onAddCell = { onAddCell }
239+ onDeleteCell = { onDeleteCell }
240+ onMoveUp = { onMoveUp }
241+ onMoveDown = { onMoveDown }
242+ onFocusNext = { onFocusNext }
243+ onFocusPrevious = { onFocusPrevious }
244+ autoFocus = { autoFocus }
245+ onFocus = { onFocus }
246+ contextSelectionMode = { contextSelectionMode }
247+ />
248+ </ ErrorBoundary >
243249 ) ;
244250 }
245251
@@ -363,15 +369,17 @@ export const Cell: React.FC<CellProps> = ({
363369 { /* Editor Content Area */ }
364370 { cell . sourceVisible && (
365371 < div className = "cell-content bg-white py-1 pl-4 transition-colors" >
366- < Editor
367- localSource = { localSource }
368- handleSourceChange = { handleSourceChange }
369- updateSource = { updateSource }
370- handleFocus = { handleFocus }
371- cell = { cell }
372- autoFocus = { autoFocus }
373- keyMap = { keyMap }
374- />
372+ < ErrorBoundary fallback = { < div > Error rendering editor</ div > } >
373+ < Editor
374+ localSource = { localSource }
375+ handleSourceChange = { handleSourceChange }
376+ updateSource = { updateSource }
377+ handleFocus = { handleFocus }
378+ cell = { cell }
379+ autoFocus = { autoFocus }
380+ keyMap = { keyMap }
381+ />
382+ </ ErrorBoundary >
375383 </ div >
376384 ) }
377385 </ div >
@@ -443,8 +451,9 @@ export const Cell: React.FC<CellProps> = ({
443451 </ div >
444452 </ div >
445453 ) }
446-
447- { hasOutputs && renderOutputs ( ) }
454+ < ErrorBoundary FallbackComponent = { OutputsErrorBoundary } >
455+ { hasOutputs && < MaybeOutputs /> }
456+ </ ErrorBoundary >
448457 </ div >
449458 ) }
450459 </ CellContainer >
0 commit comments