@@ -36,6 +36,7 @@ define(function (require, exports, module) {
3636 const NodeConnector = require ( "NodeConnector" ) ;
3737 const Mustache = require ( "thirdparty/mustache/mustache" ) ;
3838 const Dialogs = require ( "widgets/Dialogs" ) ;
39+ const DefaultDialogs = require ( "widgets/DefaultDialogs" ) ;
3940 const Strings = require ( "strings" ) ;
4041 const StringUtils = require ( "utils/StringUtils" ) ;
4142
@@ -605,23 +606,48 @@ define(function (require, exports, module) {
605606 }
606607 }
607608
608- if ( terminalInstances . length > 1 || activeProcesses . length > 0 ) {
609- const msgKey = activeProcesses . length > 0
610- ? Strings . TERMINAL_CLOSE_ALL_MSG_PROCESS
611- : Strings . TERMINAL_CLOSE_ALL_MSG ;
612- const message = StringUtils . format (
613- msgKey , terminalInstances . length , activeProcesses . length
614- ) ;
615- const dialog = Dialogs . showConfirmDialog (
616- Strings . TERMINAL_CLOSE_ALL_TITLE , message
617- ) ;
618- const buttonId = await dialog . getPromise ( ) ;
619- if ( buttonId !== Dialogs . DIALOG_BTN_OK ) {
620- return false ;
621- }
609+ let title , message , confirmText ;
610+ const count = terminalInstances . length ;
611+ const procCount = activeProcesses . length ;
612+
613+ if ( count === 1 && procCount > 0 ) {
614+ // Single terminal with an active process
615+ title = Strings . TERMINAL_CLOSE_SINGLE_TITLE ;
616+ message = Strings . TERMINAL_CLOSE_SINGLE_MSG ;
617+ confirmText = Strings . TERMINAL_CLOSE_SINGLE_BTN ;
618+ } else if ( count > 1 && procCount === 0 ) {
619+ // Multiple terminals, no active processes
620+ title = Strings . TERMINAL_CLOSE_ALL_TITLE ;
621+ message = Strings . TERMINAL_CLOSE_ALL_MSG ;
622+ confirmText = Strings . TERMINAL_CLOSE_ALL_BTN ;
623+ } else if ( count > 1 && procCount > 0 ) {
624+ // Multiple terminals, some with active processes
625+ title = Strings . TERMINAL_CLOSE_ALL_TITLE ;
626+ message = procCount === 1
627+ ? Strings . TERMINAL_CLOSE_ALL_MSG_PROCESS_ONE
628+ : StringUtils . format ( Strings . TERMINAL_CLOSE_ALL_MSG_PROCESS_MANY , procCount ) ;
629+ confirmText = Strings . TERMINAL_CLOSE_ALL_STOP_BTN ;
630+ } else {
631+ // Single idle terminal — no confirmation needed
632+ _disposeAll ( ) ;
633+ activeTerminalId = null ;
634+ _updateFlyout ( ) ;
635+ return true ;
636+ }
637+
638+ const buttons = [
639+ { className : Dialogs . DIALOG_BTN_CLASS_NORMAL , id : Dialogs . DIALOG_BTN_CANCEL , text : Strings . CANCEL } ,
640+ { className : Dialogs . DIALOG_BTN_CLASS_PRIMARY , id : Dialogs . DIALOG_BTN_OK , text : confirmText }
641+ ] ;
642+ const dialog = Dialogs . showModalDialog (
643+ DefaultDialogs . DIALOG_ID_INFO , title , message , buttons
644+ ) ;
645+ const buttonId = await dialog . getPromise ( ) ;
646+ if ( buttonId !== Dialogs . DIALOG_BTN_OK ) {
647+ return false ;
622648 }
623649
624- // User confirmed (or single idle terminal) — dispose everything
650+ // User confirmed — dispose everything
625651 _disposeAll ( ) ;
626652 activeTerminalId = null ;
627653 _updateFlyout ( ) ;
0 commit comments