File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -311,12 +311,18 @@ class TermViewModel implements ViewModel {
311311 }
312312
313313 updateShellProcStatus ( fullStatus : BlockControllerRuntimeStatus ) {
314- globalStore . set ( this . shellProcFullStatus , fullStatus ) ;
315- const status = fullStatus ?. shellprocstatus ?? "init" ;
316- if ( status == "running" ) {
317- this . termRef . current ?. setIsRunning ?.( true ) ;
318- } else {
319- this . termRef . current ?. setIsRunning ?.( false ) ;
314+ if ( fullStatus == null ) {
315+ return ;
316+ }
317+ const curStatus = globalStore . get ( this . shellProcFullStatus ) ;
318+ if ( curStatus == null || curStatus . version < fullStatus . version ) {
319+ globalStore . set ( this . shellProcFullStatus , fullStatus ) ;
320+ const status = fullStatus ?. shellprocstatus ?? "init" ;
321+ if ( status == "running" ) {
322+ this . termRef . current ?. setIsRunning ?.( true ) ;
323+ } else {
324+ this . termRef . current ?. setIsRunning ?.( false ) ;
325+ }
320326 }
321327 }
322328
Original file line number Diff line number Diff line change @@ -56,6 +56,7 @@ declare global {
5656 // blockcontroller.BlockControllerRuntimeStatus
5757 type BlockControllerRuntimeStatus = {
5858 blockid : string ;
59+ version : number ;
5960 shellprocstatus ?: string ;
6061 shellprocconnname ?: string ;
6162 shellprocexitcode : number ;
Original file line number Diff line number Diff line change @@ -79,10 +79,12 @@ type BlockController struct {
7979 ShellProcStatus string
8080 ShellProcExitCode int
8181 RunLock * atomic.Bool
82+ StatusVersion int
8283}
8384
8485type BlockControllerRuntimeStatus struct {
8586 BlockId string `json:"blockid"`
87+ Version int `json:"version"`
8688 ShellProcStatus string `json:"shellprocstatus,omitempty"`
8789 ShellProcConnName string `json:"shellprocconnname,omitempty"`
8890 ShellProcExitCode int `json:"shellprocexitcode"`
@@ -97,6 +99,8 @@ func (bc *BlockController) WithLock(f func()) {
9799func (bc * BlockController ) GetRuntimeStatus () * BlockControllerRuntimeStatus {
98100 var rtn BlockControllerRuntimeStatus
99101 bc .WithLock (func () {
102+ bc .StatusVersion ++
103+ rtn .Version = bc .StatusVersion
100104 rtn .BlockId = bc .BlockId
101105 rtn .ShellProcStatus = bc .ShellProcStatus
102106 if bc .ShellProc != nil {
You can’t perform that action at this time.
0 commit comments