diff --git a/Packages/iOS/CmuxMobileShell/Sources/CmuxMobileShell/MobileShellComposite.swift b/Packages/iOS/CmuxMobileShell/Sources/CmuxMobileShell/MobileShellComposite.swift index 330c9352a98e..4514491e519d 100644 --- a/Packages/iOS/CmuxMobileShell/Sources/CmuxMobileShell/MobileShellComposite.swift +++ b/Packages/iOS/CmuxMobileShell/Sources/CmuxMobileShell/MobileShellComposite.swift @@ -822,9 +822,27 @@ public final class MobileShellComposite: MobileTerminalOutputSinking { @ObservationIgnored var signInGeneration = 0 public var selectedWorkspaceID: MobileWorkspacePreview.ID? { didSet { + // A surface id is only meaningful inside the workspace it was + // picked in; crossing workspaces must not let a stale id from the + // previous workspace render into the next one. + if selectedWorkspaceID != oldValue { + selectedMacSurfaceID = nil + } syncSelectedTerminalForWorkspace() } } + /// The Mac-native surface (markdown panel, file preview, todo board) the + /// user explicitly chose from the picker, or `nil` when the terminal is + /// shown. Selection is explicit and independent of terminal selection: + /// choosing a surface leaves ``selectedTerminalID`` (and its composer + /// draft) untouched, and the UI layer clears this when a terminal is + /// chosen. Reset on workspace switch. + public var selectedMacSurfaceID: MobileSurfacePreview.ID? + + /// Shows the given Mac surface without disturbing the terminal selection. + public func selectMacSurface(_ surfaceID: MobileSurfacePreview.ID) { + selectedMacSurfaceID = surfaceID + } /// The terminal whose surface (and composer draft) is currently shown. /// /// Changing it swaps the composer draft: `willSet` captures the outgoing diff --git a/Packages/iOS/CmuxMobileShellUI/Sources/CmuxMobileShellUI/MacSurfaceGalleryPreviewView.swift b/Packages/iOS/CmuxMobileShellUI/Sources/CmuxMobileShellUI/MacSurfaceGalleryPreviewView.swift index a05ff991261e..7406a84fa8ce 100644 --- a/Packages/iOS/CmuxMobileShellUI/Sources/CmuxMobileShellUI/MacSurfaceGalleryPreviewView.swift +++ b/Packages/iOS/CmuxMobileShellUI/Sources/CmuxMobileShellUI/MacSurfaceGalleryPreviewView.swift @@ -86,6 +86,7 @@ public struct MacSurfaceGalleryPreviewView: View { createTerminal: {}, openBrowser: {}, selectBrowserStream: { _ in }, + selectSimulatorStream: { _ in }, openTextSheet: {}, copyDebugLogs: {}, sendFeedback: {} diff --git a/Packages/iOS/CmuxMobileShellUI/Sources/CmuxMobileShellUI/WorkspaceDetailView.swift b/Packages/iOS/CmuxMobileShellUI/Sources/CmuxMobileShellUI/WorkspaceDetailView.swift index 28c1b2ee890b..9379e2d73e30 100644 --- a/Packages/iOS/CmuxMobileShellUI/Sources/CmuxMobileShellUI/WorkspaceDetailView.swift +++ b/Packages/iOS/CmuxMobileShellUI/Sources/CmuxMobileShellUI/WorkspaceDetailView.swift @@ -518,7 +518,7 @@ struct WorkspaceDetailView: View { /// with a working keyboard. Hidden retained details keep their raw /// status: the guard only applies to the selected workspace on the /// foreground connection. - private var effectiveConnectionStatus: MobileMacConnectionStatus { + var effectiveConnectionStatus: MobileMacConnectionStatus { if store.selectedWorkspaceID == workspace.id, store.selectedWorkspaceUsesForegroundConnection { if store.connectionRecoveryFailed {