@@ -80,11 +80,20 @@ export const ResultBlock = memo<any>(function ResultBlock({ id, layout }) {
8080 const result = useStore ( store , ( state ) => state . pods [ id ] ?. result ) ;
8181 const error = useStore ( store , ( state ) => state . pods [ id ] ?. error ) ;
8282 const stdout = useStore ( store , ( state ) => state . pods [ id ] ?. stdout ) ;
83- const running = useStore ( store , ( state ) => state . pods [ id ] ?. running ) ;
83+ const running = useStore ( store , ( state ) => state . pods [ id ] ?. running || false ) ;
8484 const autoLayoutROOT = useStore ( store , ( state ) => state . autoLayoutROOT ) ;
85+ const autoRunLayout = useStore ( store , ( state ) => state . autoRunLayout ) ;
86+
87+ const prevRunning = useRef ( false ) ;
8588 useEffect ( ( ) => {
86- autoLayoutROOT ( ) ;
89+ if ( autoRunLayout ) {
90+ if ( prevRunning . current != running ) {
91+ autoLayoutROOT ( ) ;
92+ prevRunning . current = running ;
93+ }
94+ }
8795 } , [ running ] ) ;
96+
8897 const lastExecutedAt = useStore (
8998 store ,
9099 ( state ) => state . pods [ id ] ?. lastExecutedAt
@@ -474,9 +483,17 @@ export const CodeNode = memo<NodeProps>(function ({
474483
475484 const nodesMap = useStore ( store , ( state ) => state . ydoc . getMap < Node > ( "pods" ) ) ;
476485 const autoLayoutROOT = useStore ( store , ( state ) => state . autoLayoutROOT ) ;
486+ const autoRunLayout = useStore ( store , ( state ) => state . autoRunLayout ) ;
487+
488+ const prevLayout = useRef ( layout ) ;
477489 useEffect ( ( ) => {
478- // Run auto-layout when the output box layout changes.
479- autoLayoutROOT ( ) ;
490+ if ( autoRunLayout ) {
491+ // Run auto-layout when the output box layout changes.
492+ if ( prevLayout . current != layout ) {
493+ autoLayoutROOT ( ) ;
494+ prevLayout . current = layout ;
495+ }
496+ }
480497 } , [ layout ] ) ;
481498
482499 const onResizeStop = useCallback (
@@ -503,7 +520,9 @@ export const CodeNode = memo<NodeProps>(function ({
503520 true
504521 ) ;
505522 updateView ( ) ;
506- autoLayoutROOT ( ) ;
523+ if ( autoRunLayout ) {
524+ autoLayoutROOT ( ) ;
525+ }
507526 }
508527 } ,
509528 [ id , nodesMap , setPodGeo , updateView , autoLayoutROOT ]
0 commit comments