@@ -189,7 +189,7 @@ const ScopeNode = memo<Props>(({ data, id, isConnectable }) => {
189189
190190// FIXME: the resultblock is rendered every time the parent codeNode changes (e.g., dragging), we may set the result number as a state of a pod to memoize the resultblock.
191191
192- function ResultBlock ( { pod, id } ) {
192+ function ResultBlock ( { pod, id, showOutput = true } ) {
193193 const store = useContext ( RepoContext ) ;
194194 if ( ! store ) throw new Error ( "Missing BearContext.Provider in the tree" ) ;
195195 const wsRun = useStore ( store , ( state ) => state . wsRun ) ;
@@ -232,7 +232,7 @@ function ResultBlock({ pod, id }) {
232232 ) }
233233
234234 { pod . running && < CircularProgress /> }
235- < Box overflow = "scroll" maxHeight = "145px" border = "1px" >
235+ { showOutput && < Box overflow = "scroll" maxHeight = "145px" border = "1px" >
236236 { /* <Box bgcolor="lightgray">Error</Box> */ }
237237 { pod . stdout && (
238238 < Box whiteSpace = "pre-wrap" sx = { { fontSize : 10 } } >
@@ -256,7 +256,7 @@ function ResultBlock({ pod, id }) {
256256 </ Box >
257257 </ Box >
258258 ) }
259- </ Box >
259+ </ Box > }
260260 </ Box >
261261 ) ;
262262}
@@ -271,6 +271,7 @@ const CodeNode = memo<Props>(({ data, id, isConnectable }) => {
271271 const [ frame ] = React . useState ( {
272272 translate : [ 0 , 0 ] ,
273273 } ) ;
274+ const [ showOutput , setShowOutput ] = useState ( true ) ;
274275 // right, bottom
275276 const [ layout , setLayout ] = useState ( "bottom" ) ;
276277 const isRightLayout = layout === "right" ;
@@ -325,6 +326,8 @@ const CodeNode = memo<Props>(({ data, id, isConnectable }) => {
325326 case ToolTypes . layout :
326327 setLayout ( layout === "bottom" ? "right" : "bottom" ) ;
327328 break ;
329+ case ToolTypes . fold :
330+ setShowOutput ( ! showOutput ) ;
328331 }
329332 } ;
330333
@@ -378,7 +381,7 @@ const CodeNode = memo<Props>(({ data, id, isConnectable }) => {
378381 { /* The header of code pods. */ }
379382 < Box className = "custom-drag-handle" >
380383 < Box sx = { styles [ "pod-index" ] } > [{ pod . index } ]</ Box >
381- < ToolBox data = { { id } } onRunTask = { runToolBoxTask } > </ ToolBox >
384+ < ToolBox data = { { id, showOutput } } onRunTask = { runToolBoxTask } > </ ToolBox >
382385 </ Box >
383386 < Box
384387 sx = { {
@@ -430,7 +433,7 @@ const CodeNode = memo<Props>(({ data, id, isConnectable }) => {
430433 padding : "0 10px" ,
431434 } }
432435 >
433- < ResultBlock pod = { pod } id = { id } />
436+ < ResultBlock pod = { pod } id = { id } showOutput = { showOutput } />
434437 </ Box >
435438 ) }
436439 </ Box >
0 commit comments