@@ -21,7 +21,12 @@ import {
2121 INPUT_UUID_TO_OUTPUT_UUID ,
2222 OUTPUT_UUID_TO_OUTPUT_KEY ,
2323} from '../plugins/JupyterInputOutputPlugin' ;
24- import { Output , OutputAdapter , newUuid } from '@datalayer/jupyter-react' ;
24+ import {
25+ Output ,
26+ OutputAdapter ,
27+ newUuid ,
28+ Kernel ,
29+ } from '@datalayer/jupyter-react' ;
2530
2631export type SerializedJupyterOutputNode = Spread <
2732 {
@@ -43,6 +48,7 @@ export class JupyterOutputNode extends DecoratorNode<JSX.Element> {
4348 __jupyterInputNodeUuid : string ;
4449 __jupyterOutputNodeUuid : string ;
4550 __executeTrigger : number ;
51+ __renderTrigger : number ;
4652
4753 /** @override */
4854 static getType ( ) {
@@ -68,7 +74,7 @@ export class JupyterOutputNode extends DecoratorNode<JSX.Element> {
6874 ) : JupyterOutputNode {
6975 return $createJupyterOutputNode (
7076 serializedNode . source ,
71- new OutputAdapter ( newUuid ( ) , undefined , [ ] ) ,
77+ new OutputAdapter ( newUuid ( ) , undefined , serializedNode . outputs ) ,
7278 serializedNode . outputs ,
7379 false ,
7480 serializedNode . jupyterInputNodeUuid ,
@@ -93,10 +99,11 @@ export class JupyterOutputNode extends DecoratorNode<JSX.Element> {
9399 this . __outputs = outputs ;
94100 this . __outputAdapter = outputAdapter ;
95101 this . __executeTrigger = 0 ;
102+ this . __renderTrigger = 0 ;
96103 this . __autoRun = autoRun ;
97104 OUTPUT_UUID_TO_CODE_UUID . set (
98105 this . __jupyterOutputNodeUuid ,
99- jupyterInputNodeUuid ,
106+ this . __jupyterInputNodeUuid ,
100107 ) ;
101108 INPUT_UUID_TO_OUTPUT_KEY . set ( this . __jupyterInputNodeUuid , this . __key ) ;
102109 INPUT_UUID_TO_OUTPUT_UUID . set (
@@ -194,7 +201,7 @@ export class JupyterOutputNode extends DecoratorNode<JSX.Element> {
194201 outputs = { this . __outputs }
195202 adapter = { this . __outputAdapter }
196203 id = { this . __jupyterOutputNodeUuid }
197- executeTrigger = { this . getExecuteTrigger ( ) }
204+ executeTrigger = { this . getExecuteTrigger ( ) + this . __renderTrigger }
198205 autoRun = { this . __autoRun }
199206 />
200207 ) ;
@@ -222,9 +229,41 @@ export class JupyterOutputNode extends DecoratorNode<JSX.Element> {
222229 }
223230
224231 public executeCode ( code : string ) {
232+ console . warn (
233+ '🎯 JupyterOutputNode.executeCode called with:' ,
234+ code . slice ( 0 , 50 ) ,
235+ ) ;
236+ console . warn (
237+ '🔧 OutputAdapter kernel available:' ,
238+ ! ! this . __outputAdapter . kernel ,
239+ ) ;
240+
225241 this . setJupyterInput ( code ) ;
242+
243+ if ( ! this . __outputAdapter . kernel ) {
244+ console . error ( '❌ OutputAdapter has no kernel - cannot execute!' ) ;
245+ return ;
246+ }
247+
248+ console . warn ( '✅ Calling OutputAdapter.execute()' ) ;
226249 this . __outputAdapter . execute ( code ) ;
227- this . setExecuteTrigger ( this . getExecuteTrigger ( ) + 1 ) ;
250+ console . warn ( '✅ OutputAdapter.execute() completed' ) ;
251+ // this.setExecuteTrigger(this.getExecuteTrigger() + 1);
252+ }
253+
254+ public updateKernel ( kernel : Kernel | undefined ) {
255+ console . warn ( '🔄 JupyterOutputNode.updateKernel called with:' , ! ! kernel ) ;
256+ console . warn ( '🔧 Previous kernel:' , ! ! this . __outputAdapter . kernel ) ;
257+
258+ const self = this . getWritable ( ) ;
259+ self . __outputAdapter . kernel = kernel ;
260+ // Don't increment renderTrigger immediately - let execution complete first
261+ // The renderTrigger will be incremented after execution if needed
262+
263+ console . warn (
264+ '✅ Kernel updated, new kernel:' ,
265+ ! ! self . __outputAdapter . kernel ,
266+ ) ;
228267 }
229268}
230269
0 commit comments