@@ -430,6 +430,7 @@ private void launchOrStopInstance() {
430430 if ("LOCAL" .equalsIgnoreCase (t )) {
431431 info .terminalWidget .stopProcess ();
432432 context .instance .setState (InstanceState .STOPPED );
433+ TerminalWidget .shutdown (context .instance .getInstanceId ());
433434 }
434435 } else {
435436 api .health ().check ().thenAccept (status -> ScreenManager .getInstance ().execute (() -> {
@@ -492,6 +493,35 @@ private void showFixPopup(String title, String desc, String buttonText, Runnable
492493 }
493494
494495 private void proceedWithServerStart (TabContext context , ServerContextInfo info ) {
496+ String backendType = context .instance .getBackendConfig () != null ? context .instance .getBackendConfig ().type : "LOCAL" ;
497+ if ("LOCAL" .equalsIgnoreCase (backendType )) {
498+ if (info .terminalWidget != null ) {
499+ info .terminalWidget .shutdown ();
500+ TerminalWidget .shutdown (context .instance .getInstanceId ());
501+ context .mainContainer .removeWidget (info .terminalWidget );
502+ }
503+
504+ ExecutionProvider exec = new UnifiedExecutionProvider (InstanceApi .of (context .instance ).console ());
505+ info .terminalWidget = ServerTerminal .getOrCreate (context .instance , exec , 5 , 60 , width - 10 , height - 66 );
506+ info .terminalWidget .addOutputListener (context .instance .getMSMPManager ()::handleConsoleLine );
507+ info .terminalWidget .setForceDirectLaunch (true );
508+ info .terminalWidget .start ();
509+ context .instance .attachTerminalListener (info .terminalWidget );
510+
511+ for (int i = 0 ; i < context .views .size (); i ++) {
512+ ViewEntry entry = context .views .get (i );
513+ if (entry .hint ().equals ("Terminal" )) {
514+ context .views .set (i , new ViewEntry (info .terminalWidget , entry .icon (), entry .hint (), entry .toolbarWidgets ()));
515+ if (context .selectedViewIndex == i ) {
516+ context .mainContainer .addWidget (info .terminalWidget );
517+ }
518+ break ;
519+ }
520+ }
521+ context .instance .setState (InstanceState .STARTING );
522+ return ;
523+ }
524+
495525 InstanceApi api = InstanceApi .of (context .instance );
496526 context .instance .setState (InstanceState .STARTING );
497527 api .console ().startServer ().thenAccept (command -> ScreenManager .getInstance ().execute (() -> {
0 commit comments