File tree Expand file tree Collapse file tree 3 files changed +15
-6
lines changed Expand file tree Collapse file tree 3 files changed +15
-6
lines changed Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ import { useAppContext } from '../utils/app.context';
33import { OpenInNewTab , XCloseButton } from '../utils/common' ;
44import { CanvasType } from '../utils/types' ;
55import { PlayIcon , StopIcon } from '@heroicons/react/24/outline' ;
6+ import StorageUtils from '../utils/storage' ;
67
78const canInterrupt = typeof SharedArrayBuffer === 'function' ;
89
@@ -54,18 +55,26 @@ const interruptBuffer = canInterrupt
5455 ? new Uint8Array ( new SharedArrayBuffer ( 1 ) )
5556 : null ;
5657
58+ const startWorker = ( ) => {
59+ if ( ! worker ) {
60+ worker = new Worker (
61+ URL . createObjectURL ( new Blob ( [ WORKER_CODE ] , { type : 'text/javascript' } ) )
62+ ) ;
63+ }
64+ } ;
65+
66+ if ( StorageUtils . getConfig ( ) . pyIntepreterEnabled ) {
67+ startWorker ( ) ;
68+ }
69+
5770const runCodeInWorker = (
5871 pyCode : string ,
5972 callbackRunning : ( ) => void
6073) : {
6174 donePromise : Promise < string > ;
6275 interrupt : ( ) => void ;
6376} => {
64- if ( ! worker ) {
65- worker = new Worker (
66- URL . createObjectURL ( new Blob ( [ WORKER_CODE ] , { type : 'text/javascript' } ) )
67- ) ;
68- }
77+ startWorker ( ) ;
6978 const id = Math . random ( ) * 1e8 ;
7079 const context = { } ;
7180 if ( interruptBuffer ) {
Original file line number Diff line number Diff line change @@ -137,7 +137,7 @@ export default function ChatScreen() {
137137 </ div >
138138 </ div >
139139 { canvasData && (
140- < div className = "w-full sticky top-[8em ] h-[calc(100vh-9em)]" >
140+ < div className = "w-full sticky top-[7em ] h-[calc(100vh-9em)]" >
141141 < CanvasPyInterpreter />
142142 </ div >
143143 ) }
You can’t perform that action at this time.
0 commit comments