@@ -1002,12 +1002,24 @@ const trayToggleEvtHandler = async () => {
10021002 showSwitcherWindow ( ) ;
10031003 } else {
10041004 const window = getSwitcherWindow ( ) ;
1005-
1006- if ( window && window . isVisible ( ) ) {
1007- if ( isDebug ) {
1008- console . log ( 'is visible, to hide' ) ;
1005+
1006+ if ( window && window . isVisible ( ) && ! window . isMinimized ( ) ) {
1007+ if ( window . isFocused ( ) ) {
1008+ if ( isDebug ) {
1009+ console . log ( 'is visible and focused, to hide' ) ;
1010+ }
1011+ hideSwitcherWindow ( ) ;
1012+ } else {
1013+ // Visible but covered by another app — bring to front instead of hiding
1014+ if ( isDebug ) {
1015+ console . log ( 'is visible but unfocused, bringing to front' ) ;
1016+ }
1017+ if ( appMode === 'normal' ) {
1018+ app . focus ( { steal : true } ) ;
1019+ }
1020+ window . show ( ) ;
1021+ window . focus ( ) ;
10091022 }
1010- hideSwitcherWindow ( ) ;
10111023 } else if ( window ) {
10121024 if ( isDebug ) {
10131025 console . log ( 'is not visible, to show' ) ;
@@ -1327,10 +1339,22 @@ const trayToggleEvtHandler = async () => {
13271339 const window = getSwitcherWindow ( ) ;
13281340
13291341 if ( window && window . isVisible ( ) && ! window . isMinimized ( ) ) {
1330- if ( isDebug ) {
1331- console . log ( 'Switcher window visible, hiding it' ) ;
1342+ if ( window . isFocused ( ) ) {
1343+ if ( isDebug ) {
1344+ console . log ( 'Switcher window visible and focused, hiding it' ) ;
1345+ }
1346+ hideSwitcherWindow ( ) ;
1347+ } else {
1348+ // Visible but covered by another app — bring to top instead of hiding
1349+ if ( isDebug ) {
1350+ console . log ( 'Switcher window visible but unfocused, bringing to front' ) ;
1351+ }
1352+ if ( appMode === 'normal' ) {
1353+ app . focus ( { steal : true } ) ;
1354+ }
1355+ window . show ( ) ;
1356+ window . focus ( ) ;
13321357 }
1333- hideSwitcherWindow ( ) ;
13341358 } else if ( window ) {
13351359 if ( isDebug ) {
13361360 console . log ( 'Switcher window exists but hidden, showing it' ) ;
@@ -1626,9 +1650,19 @@ const trayToggleEvtHandler = async () => {
16261650 switcherWindow = createSwitcherWindow ( ) ;
16271651 }
16281652 const window = getSwitcherWindow ( ) ;
1629- if ( window && window . isVisible ( ) ) {
1630- // If already showing Terminal tab, hide; otherwise switch to Terminal
1631- window . webContents . send ( 'check-terminal-and-hide' ) ;
1653+ if ( window && window . isVisible ( ) && ! window . isMinimized ( ) ) {
1654+ if ( window . isFocused ( ) ) {
1655+ // If already showing Terminal tab, hide; otherwise switch to Terminal
1656+ window . webContents . send ( 'check-terminal-and-hide' ) ;
1657+ } else {
1658+ // Visible but covered — bring to front and switch to Terminal tab
1659+ if ( appMode === 'normal' ) {
1660+ app . focus ( { steal : true } ) ;
1661+ }
1662+ window . show ( ) ;
1663+ window . focus ( ) ;
1664+ window . webContents . send ( 'switch-to-terminal' ) ;
1665+ }
16321666 } else if ( window ) {
16331667 window . webContents . send ( 'switch-to-terminal' ) ;
16341668 showSwitcherWindow ( ) ;
0 commit comments