File tree Expand file tree Collapse file tree 2 files changed +37
-0
lines changed Expand file tree Collapse file tree 2 files changed +37
-0
lines changed Original file line number Diff line number Diff line change @@ -494,6 +494,8 @@ export interface ISharedBaseCell<
494494 toJSON ( ) : nbformat . IBaseCell ;
495495}
496496
497+ export type IExecutionState = 'running' | 'idle' ;
498+
497499/**
498500 * Implements an API for nbformat.ICodeCell.
499501 */
@@ -509,6 +511,11 @@ export interface ISharedCodeCell
509511 */
510512 execution_count : nbformat . ExecutionCount ;
511513
514+ /**
515+ * The code cell's execution state.
516+ */
517+ executionState : IExecutionState ;
518+
512519 /**
513520 * Cell outputs
514521 */
@@ -746,6 +753,13 @@ export type CellChange = SourceChange & {
746753 oldValue ?: number ;
747754 newValue ?: number ;
748755 } ;
756+ /**
757+ * Cell execution state change
758+ */
759+ executionStateChange ?: {
760+ oldValue ?: IExecutionState ;
761+ newValue ?: IExecutionState ;
762+ } ;
749763 /**
750764 * Cell metadata change
751765 */
Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ import { Awareness } from 'y-protocols/awareness';
1010import * as Y from 'yjs' ;
1111import type {
1212 CellChange ,
13+ IExecutionState ,
1314 IMapChange ,
1415 ISharedAttachmentsCell ,
1516 ISharedBaseCell ,
@@ -749,6 +750,20 @@ export class YCodeCell
749750 }
750751 }
751752
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+
752767 /**
753768 * Cell outputs.
754769 */
@@ -899,6 +914,14 @@ export class YCodeCell
899914 } ;
900915 }
901916
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+
902925 return changes ;
903926 }
904927
You can’t perform that action at this time.
0 commit comments