File tree 2 files changed +37
-0
lines changed
2 files changed +37
-0
lines changed Original file line number Diff line number Diff line change @@ -494,6 +494,8 @@ export interface ISharedBaseCell<
494
494
toJSON ( ) : nbformat . IBaseCell ;
495
495
}
496
496
497
+ export type IExecutionState = 'running' | 'idle' ;
498
+
497
499
/**
498
500
* Implements an API for nbformat.ICodeCell.
499
501
*/
@@ -509,6 +511,11 @@ export interface ISharedCodeCell
509
511
*/
510
512
execution_count : nbformat . ExecutionCount ;
511
513
514
+ /**
515
+ * The code cell's execution state.
516
+ */
517
+ executionState : IExecutionState ;
518
+
512
519
/**
513
520
* Cell outputs
514
521
*/
@@ -746,6 +753,13 @@ export type CellChange = SourceChange & {
746
753
oldValue ?: number ;
747
754
newValue ?: number ;
748
755
} ;
756
+ /**
757
+ * Cell execution state change
758
+ */
759
+ executionStateChange ?: {
760
+ oldValue ?: IExecutionState ;
761
+ newValue ?: IExecutionState ;
762
+ } ;
749
763
/**
750
764
* Cell metadata change
751
765
*/
Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ import { Awareness } from 'y-protocols/awareness';
10
10
import * as Y from 'yjs' ;
11
11
import type {
12
12
CellChange ,
13
+ IExecutionState ,
13
14
IMapChange ,
14
15
ISharedAttachmentsCell ,
15
16
ISharedBaseCell ,
@@ -749,6 +750,20 @@ export class YCodeCell
749
750
}
750
751
}
751
752
753
+ /**
754
+ * The code cell's execution state.
755
+ */
756
+ get executionState ( ) : IExecutionState {
757
+ return this . ymodel . get ( 'execution_state' ) ?? 'idle' ;
758
+ }
759
+ set executionState ( state : IExecutionState ) {
760
+ if ( this . ymodel . get ( 'execution_state' ) !== state ) {
761
+ this . transact ( ( ) => {
762
+ this . ymodel . set ( 'execution_state' , state ) ;
763
+ } , false ) ;
764
+ }
765
+ }
766
+
752
767
/**
753
768
* Cell outputs.
754
769
*/
@@ -899,6 +914,14 @@ export class YCodeCell
899
914
} ;
900
915
}
901
916
917
+ if ( modelEvent && modelEvent . keysChanged . has ( 'execution_state' ) ) {
918
+ const change = modelEvent . changes . keys . get ( 'execution_state' ) ;
919
+ changes . executionStateChange = {
920
+ oldValue : change ! . oldValue ,
921
+ newValue : this . ymodel . get ( 'execution_state' )
922
+ } ;
923
+ }
924
+
902
925
return changes ;
903
926
}
904
927
You can’t perform that action at this time.
0 commit comments