@@ -35,7 +35,7 @@ import {
3535import * as services from "@/store/services" ;
3636import * as keyutil from "@/util/keyutil" ;
3737import { isMacOS , isWindows } from "@/util/platformutil" ;
38- import { boundNumber , stringToBase64 } from "@/util/util" ;
38+ import { boundNumber , fireAndForget , stringToBase64 } from "@/util/util" ;
3939import * as jotai from "jotai" ;
4040import * as React from "react" ;
4141import { getBlockingCommand } from "./shellblocking" ;
@@ -79,6 +79,7 @@ export class TermViewModel implements ViewModel {
7979 isCmdController : jotai . Atom < boolean > ;
8080 isRestarting : jotai . PrimitiveAtom < boolean > ;
8181 termDurableStatus : jotai . Atom < BlockJobStatusData | null > ;
82+ termConfigedDurable : jotai . Atom < null | boolean > ;
8283 searchAtoms ?: SearchAtoms ;
8384
8485 constructor ( blockId : string , nodeModel : BlockNodeModel , tabModel : TabModel ) {
@@ -312,7 +313,7 @@ export class TermViewModel implements ViewModel {
312313 const buttonDecl : IconButtonDecl = {
313314 elemtype : "iconbutton" ,
314315 icon : iconName ,
315- click : this . forceRestartController . bind ( this ) ,
316+ click : ( ) => fireAndForget ( ( ) => this . forceRestartController ( ) ) ,
316317 title : title ,
317318 } ;
318319 rtn . push ( buttonDecl ) ;
@@ -351,6 +352,7 @@ export class TermViewModel implements ViewModel {
351352 }
352353 return blockJobStatus ;
353354 } ) ;
355+ this . termConfigedDurable = getBlockTermDurableAtom ( this . blockId ) ;
354356 this . blockJobStatusAtom = jotai . atom ( null ) as jotai . PrimitiveAtom < BlockJobStatusData > ;
355357 this . blockJobStatusVersionTs = 0 ;
356358 const initialBlockJobStatus = RpcApi . BlockJobStatusCommand ( TabRpcClient , blockId ) ;
@@ -695,7 +697,7 @@ export class TermViewModel implements ViewModel {
695697 }
696698 const shellProcStatus = globalStore . get ( this . shellProcStatus ) ;
697699 if ( ( shellProcStatus == "done" || shellProcStatus == "init" ) && keyutil . checkKeyPressed ( waveEvent , "Enter" ) ) {
698- this . forceRestartController ( ) ;
700+ fireAndForget ( ( ) => this . forceRestartController ( ) ) ;
699701 return false ;
700702 }
701703 const appHandled = appHandleKeyDown ( waveEvent ) ;
@@ -714,28 +716,28 @@ export class TermViewModel implements ViewModel {
714716 } ) ;
715717 }
716718
717- forceRestartController ( ) {
719+ async forceRestartController ( ) {
718720 if ( globalStore . get ( this . isRestarting ) ) {
719721 return ;
720722 }
721723 this . triggerRestartAtom ( ) ;
724+ await RpcApi . ControllerDestroyCommand ( TabRpcClient , this . blockId ) ;
722725 const termsize = {
723726 rows : this . termRef . current ?. terminal ?. rows ,
724727 cols : this . termRef . current ?. terminal ?. cols ,
725728 } ;
726- const prtn = RpcApi . ControllerResyncCommand ( TabRpcClient , {
729+ await RpcApi . ControllerResyncCommand ( TabRpcClient , {
727730 tabid : globalStore . get ( atoms . staticTabId ) ,
728731 blockid : this . blockId ,
729732 forcerestart : true ,
730733 rtopts : { termsize : termsize } ,
731734 } ) ;
732- prtn . catch ( ( e ) => console . log ( "error controller resync (force restart)" , e ) ) ;
733735 }
734736
735- async restartSessionInStandardMode ( ) {
737+ async restartSessionWithDurability ( isDurable : boolean ) {
736738 await RpcApi . SetMetaCommand ( TabRpcClient , {
737739 oref : WOS . makeORef ( "block" , this . blockId ) ,
738- meta : { "term:durable" : false } ,
740+ meta : { "term:durable" : isDurable } ,
739741 } ) ;
740742 await RpcApi . ControllerDestroyCommand ( TabRpcClient , this . blockId ) ;
741743 const termsize = {
@@ -1040,7 +1042,7 @@ export class TermViewModel implements ViewModel {
10401042 } ) ;
10411043 advancedSubmenu . push ( {
10421044 label : "Force Restart Controller" ,
1043- click : this . forceRestartController . bind ( this ) ,
1045+ click : ( ) => fireAndForget ( ( ) => this . forceRestartController ( ) ) ,
10441046 } ) ;
10451047 const isClearOnStart = blockData ?. meta ?. [ "cmd:clearonstart" ] ;
10461048 advancedSubmenu . push ( {
@@ -1145,7 +1147,17 @@ export class TermViewModel implements ViewModel {
11451147 submenu : [
11461148 {
11471149 label : "Restart Session in Standard Mode" ,
1148- click : ( ) => this . restartSessionInStandardMode ( ) ,
1150+ click : ( ) => this . restartSessionWithDurability ( false ) ,
1151+ } ,
1152+ ] ,
1153+ } ) ;
1154+ } else if ( isDurable === false ) {
1155+ advancedSubmenu . push ( {
1156+ label : "Session Durability" ,
1157+ submenu : [
1158+ {
1159+ label : "Restart Session in Durable Mode" ,
1160+ click : ( ) => this . restartSessionWithDurability ( true ) ,
11491161 } ,
11501162 ] ,
11511163 } ) ;
0 commit comments