@@ -1211,18 +1211,33 @@ final class WindowTerminalPortal: NSObject {
12111211 return
12121212 }
12131213 guard let anchorView = entry. anchorView, let window else {
1214- // Only hide if the entry is not marked visibleInUI. When a workspace is
1215- // remounting, updateNSView sets visibleInUI=true before the deferred bind
1216- // provides an anchor — hiding here would race with that and cause a flash.
1217- if !entry. visibleInUI {
1214+ if entry. visibleInUI {
1215+ let shouldPreserveVisibleOnTransient = !hostedView. isHidden &&
1216+ scheduleTransientRecoveryRetryIfNeeded (
1217+ forHostedId: hostedId,
1218+ entry: & entry,
1219+ hostedView: hostedView,
1220+ reason: " missingAnchorOrWindow "
1221+ )
1222+ if shouldPreserveVisibleOnTransient {
12181223#if DEBUG
1219- if !hostedView. isHidden {
1220- dlog ( " portal.hidden hosted= \( portalDebugToken ( hostedView) ) value=1 reason=missingAnchorOrWindow " )
1221- }
1224+ dlog (
1225+ " portal.hidden.deferKeep hosted= \( portalDebugToken ( hostedView) ) " +
1226+ " reason=missingAnchorOrWindow frame= \( portalDebugFrame ( hostedView. frame) ) "
1227+ )
12221228#endif
1223- hostedView . isHidden = true
1224- resetTransientRecoveryRetryIfNeeded ( forHostedId : hostedId , entry : & entry )
1229+ return
1230+ }
12251231 } else {
1232+ resetTransientRecoveryRetryIfNeeded ( forHostedId: hostedId, entry: & entry)
1233+ }
1234+ #if DEBUG
1235+ if !hostedView. isHidden {
1236+ dlog ( " portal.hidden hosted= \( portalDebugToken ( hostedView) ) value=1 reason=missingAnchorOrWindow " )
1237+ }
1238+ #endif
1239+ hostedView. isHidden = true
1240+ if entry. visibleInUI {
12261241 _ = scheduleTransientRecoveryRetryIfNeeded (
12271242 forHostedId: hostedId,
12281243 entry: & entry,
0 commit comments