diff --git a/Packages/iOS/CmuxMobileShell/Sources/CmuxMobileShell/MobileShellComposite.swift b/Packages/iOS/CmuxMobileShell/Sources/CmuxMobileShell/MobileShellComposite.swift index ff0361608f83..5f903cbdf90f 100644 --- a/Packages/iOS/CmuxMobileShell/Sources/CmuxMobileShell/MobileShellComposite.swift +++ b/Packages/iOS/CmuxMobileShell/Sources/CmuxMobileShell/MobileShellComposite.swift @@ -3381,9 +3381,9 @@ public final class MobileShellComposite: MobileTerminalOutputSinking { clearRemoteConnectionContext(preservingOtherMacWorkspaceState: preservingOtherMacWorkspaceState) } - /// Disconnect from and hide the currently paired Mac so the next session - /// starts from a fresh QR scan without deleting local or server state. - /// Backs the "Rescan QR" action. + /// Disconnect from and hide the currently paired Mac on this device without + /// deleting local or server pairing state. + /// Backs the "Forget This Computer" action. public func disconnectAndHideActiveMac() { let staleMacID = connectedMacDeviceID ?? activeTicket?.macDeviceID let staleMacInstanceTag = connectedMacInstanceTag diff --git a/Packages/iOS/CmuxMobileShellUI/Sources/CmuxMobileShellUI/DisconnectedWorkspaceShellView.swift b/Packages/iOS/CmuxMobileShellUI/Sources/CmuxMobileShellUI/DisconnectedWorkspaceShellView.swift index d9f20f11a38e..d99cd57d27af 100644 --- a/Packages/iOS/CmuxMobileShellUI/Sources/CmuxMobileShellUI/DisconnectedWorkspaceShellView.swift +++ b/Packages/iOS/CmuxMobileShellUI/Sources/CmuxMobileShellUI/DisconnectedWorkspaceShellView.swift @@ -65,14 +65,10 @@ struct DisconnectedWorkspaceShellView: View { .accessibilityIdentifier("MobileDisconnectedWorkspaceShell") .task { // Load (and, via the backup decorator, restore) saved Macs so a - // known/restored Mac shows up here for one-tap reconnect. Only - // auto-present the pairing sheet when there is nothing to pick, - // so a returning user is not buried under the add-device flow. + // known/restored Mac shows up here for one-tap reconnect. + // Same-account discovery is the primary path; manual pairing + // remains available from the explicit Add Computer controls. await store?.loadPairedMacs() - if shouldAutoPresentAddDeviceAfterLoadingSavedMacs { - showAddDevice() - return - } #if os(iOS) // Registry + presence enrich the rows (online dots, build // labels). The loop then keeps presence and last-seen fresh @@ -102,12 +98,11 @@ struct DisconnectedWorkspaceShellView: View { }) { // Reuse the same Settings sheet the workspace list opens from its // Settings button so the no-devices screen's chrome matches. There is no - // connected host or QR to rescan here, but the store is forwarded so + // connected computer to forget here, but the store is forwarded so // a user whose active Mac went offline can still switch to another // paired Mac; the sheet also surfaces the account + Sign Out. MobileSettingsView( connectedHostName: "", - rescanQR: nil, startPairingScanner: { settingsPairingScannerHandoff.requestScannerAfterDismiss( isSettingsPresented: $showingSettings @@ -138,12 +133,6 @@ struct DisconnectedWorkspaceShellView: View { store.map { MacComputerSnapshot.snapshots(from: $0) } ?? [] } - var shouldAutoPresentAddDeviceAfterLoadingSavedMacs: Bool { - guard let store else { return false } - return store.pairedMacLoadState == .loaded - && store.pairedMacs.isEmpty - } - @ViewBuilder private var content: some View { if !savedComputers.isEmpty { @@ -212,13 +201,13 @@ struct DisconnectedWorkspaceShellView: View { private var emptyState: some View { ContentUnavailableView { Label( - L10n.string("mobile.devices.emptyTitle", defaultValue: "No devices"), + L10n.string("mobile.devices.emptyTitle", defaultValue: "No Computers"), systemImage: "desktopcomputer.and.iphone" ) } description: { Text(L10n.string( "mobile.devices.emptyDescription", - defaultValue: "Add a computer to start syncing terminal workspaces." + defaultValue: "Sign in to cmux on your computer with this account and it appears here automatically." )) } actions: { Button(action: showAddDevice) { @@ -302,14 +291,17 @@ struct DisconnectedWorkspaceShellView: View { ContentUnavailableView { Label( savedMacs.isEmpty - ? L10n.string("mobile.devices.emptyTitle", defaultValue: "No devices") + ? L10n.string("mobile.devices.emptyTitle", defaultValue: "No Computers") : L10n.string("mobile.devices.savedTitle", defaultValue: "Your Computers"), systemImage: "desktopcomputer.and.iphone" ) } description: { Text( savedMacs.isEmpty - ? L10n.string("mobile.devices.emptyDescription", defaultValue: "Add a computer to start syncing terminal workspaces.") + ? L10n.string( + "mobile.devices.emptyDescription", + defaultValue: "Sign in to cmux on your computer with this account and it appears here automatically." + ) : L10n.string("mobile.devices.savedDescription", defaultValue: "Tap a saved computer to reconnect, or add another.") ) } actions: { diff --git a/Packages/iOS/CmuxMobileShellUI/Sources/CmuxMobileShellUI/MobileSettingsView.swift b/Packages/iOS/CmuxMobileShellUI/Sources/CmuxMobileShellUI/MobileSettingsView.swift index 7d31bdac8c26..0698e7a70ef6 100644 --- a/Packages/iOS/CmuxMobileShellUI/Sources/CmuxMobileShellUI/MobileSettingsView.swift +++ b/Packages/iOS/CmuxMobileShellUI/Sources/CmuxMobileShellUI/MobileSettingsView.swift @@ -21,7 +21,6 @@ struct MobileSettingsView: View { @Environment(ToastCenter.self) private var toasts @Environment(\.irohSettingsController) private var irohSettingsController let connectedHostName: String - let rescanQR: (() -> Void)? let startPairingScanner: (() -> Void)? let signOut: (() -> Void)? /// The shell store, used to drive the multi-Mac switcher. `nil` in previews, @@ -87,8 +86,8 @@ struct MobileSettingsView: View { } // Hidden entirely when there is nothing to show (no connected - // Mac, no store to switch with, no rescan), so the no-devices - // screen's reuse of this sheet does not render an empty header. + // Mac and no store to switch with), so the no-devices screen's + // reuse of this sheet does not render an empty header. if hasConnectionSection { Section(L10n.string("mobile.settings.connection", defaultValue: "Connection")) { if !connectedHostName.isEmpty { @@ -108,18 +107,6 @@ struct MobileSettingsView: View { } .accessibilityIdentifier("MobileSettingsSwitchMac") } - if let rescanQR { - Button { - rescanQR() - dismiss() - } label: { - Label( - L10n.string("mobile.workspaces.rescan", defaultValue: "Rescan QR"), - systemImage: "qrcode.viewfinder" - ) - } - .accessibilityIdentifier("MobileSettingsRescanQR") - } } Button { showingSetupHelp = true @@ -496,10 +483,10 @@ struct MobileSettingsView: View { } /// Whether the Connection section has any rows to show. When this sheet is - /// reused from the no-devices screen there is no connected Mac, no store to - /// switch with, and no rescan action, so the section is omitted entirely. + /// reused from the no-devices screen there is no connected Mac or store to + /// switch with, so the section is omitted entirely. private var hasConnectionSection: Bool { - !connectedHostName.isEmpty || store != nil || rescanQR != nil + !connectedHostName.isEmpty || store != nil } /// Drives the team Picker. Reads the EFFECTIVE current team (`resolvedTeamID`, diff --git a/Packages/iOS/CmuxMobileShellUI/Sources/CmuxMobileShellUI/WorkspaceListView.swift b/Packages/iOS/CmuxMobileShellUI/Sources/CmuxMobileShellUI/WorkspaceListView.swift index a7aa66e9fe58..3b00b0c70c86 100644 --- a/Packages/iOS/CmuxMobileShellUI/Sources/CmuxMobileShellUI/WorkspaceListView.swift +++ b/Packages/iOS/CmuxMobileShellUI/Sources/CmuxMobileShellUI/WorkspaceListView.swift @@ -58,10 +58,6 @@ struct WorkspaceListView: View { /// in previews, where pull-to-refresh is hidden. `@Sendable` to match /// SwiftUI's `refreshable(action:)` action type under Swift 6. var refresh: (@Sendable () async -> Void)? - /// Optional: when present, the toolbar shows a "settings" menu offering - /// "Rescan QR" (disconnect + re-pair) and "Sign out". When nil (e.g. - /// previews), the menu is hidden. - var rescanQR: (() -> Void)? var signOut: (() -> Void)? /// Manual reconnect for the offline status row. `nil` in previews. var reconnect: (() -> Void)? @@ -386,7 +382,6 @@ struct WorkspaceListView: View { }) { MobileSettingsView( connectedHostName: host, - rescanQR: rescanQR, startPairingScanner: { settingsPairingScannerHandoff.requestScannerAfterDismiss( isSettingsPresented: $showingSettings @@ -757,17 +752,6 @@ struct WorkspaceListView: View { ) } .accessibilityIdentifier("MobileWorkspaceTerminalShortcutsMenuItem") - if let rescanQR { - Button { - rescanQR() - } label: { - Label( - L10n.string("mobile.workspaces.rescan", defaultValue: "Rescan QR"), - systemImage: "qrcode.viewfinder" - ) - } - .accessibilityIdentifier("MobileWorkspaceRescanQRMenuItem") - } if let signOut { Button(role: .destructive) { signOut() diff --git a/Packages/iOS/CmuxMobileShellUI/Sources/CmuxMobileShellUI/WorkspaceShellView.swift b/Packages/iOS/CmuxMobileShellUI/Sources/CmuxMobileShellUI/WorkspaceShellView.swift index 937607abbc24..9429c2aa2a45 100644 --- a/Packages/iOS/CmuxMobileShellUI/Sources/CmuxMobileShellUI/WorkspaceShellView.swift +++ b/Packages/iOS/CmuxMobileShellUI/Sources/CmuxMobileShellUI/WorkspaceShellView.swift @@ -259,7 +259,6 @@ struct WorkspaceShellView: View { }) { MobileSettingsView( connectedHostName: store.connectedHostName, - rescanQR: { store.disconnectAndHideActiveMac() }, startPairingScanner: { settingsPairingScannerHandoff.requestScannerAfterDismiss( isSettingsPresented: $showingRootSettings @@ -508,7 +507,6 @@ struct WorkspaceShellView: View { }, cancelMacSwitch: cancelMacSwitchFromWorkspacePicker, refresh: refreshWorkspacesClosure, - rescanQR: { store.disconnectAndHideActiveMac() }, signOut: signOut, reconnect: reconnectClosure, showAddDevice: showAddDevice, diff --git a/Packages/iOS/CmuxMobileShellUI/Tests/CmuxMobileShellUITests/DisconnectedWorkspaceShellViewTests.swift b/Packages/iOS/CmuxMobileShellUI/Tests/CmuxMobileShellUITests/DisconnectedWorkspaceShellViewTests.swift deleted file mode 100644 index 3b62b73a7212..000000000000 --- a/Packages/iOS/CmuxMobileShellUI/Tests/CmuxMobileShellUITests/DisconnectedWorkspaceShellViewTests.swift +++ /dev/null @@ -1,38 +0,0 @@ -#if os(iOS) -@testable import CmuxMobileShell -import Testing -@testable import CmuxMobileShellUI - -@MainActor -@Suite -struct DisconnectedWorkspaceShellViewTests { - @Test func successfulEmptyLoadAutoPresentsAddDeviceWithoutHiddenSuppression() { - let store = MobileShellComposite() - store.pairedMacLoadState = .loaded - store.hasHiddenComputers = true - - let view = DisconnectedWorkspaceShellView( - hasKnownPairedMac: false, - showAddDevice: {}, - showPairingScanner: {}, - signOut: {}, - store: store - ) - - #expect(view.shouldAutoPresentAddDeviceAfterLoadingSavedMacs) - } - - @Test func incompleteEmptyLoadDoesNotAutoPresentAddDevice() { - let store = MobileShellComposite() - let view = DisconnectedWorkspaceShellView( - hasKnownPairedMac: false, - showAddDevice: {}, - showPairingScanner: {}, - signOut: {}, - store: store - ) - - #expect(!view.shouldAutoPresentAddDeviceAfterLoadingSavedMacs) - } -} -#endif diff --git a/Packages/macOS/CmuxSettingsUI/Sources/CmuxSettingsUI/Sections/MobileSection.swift b/Packages/macOS/CmuxSettingsUI/Sources/CmuxSettingsUI/Sections/MobileSection.swift index 1e9c3fbccab5..b48b15bf5fe9 100644 --- a/Packages/macOS/CmuxSettingsUI/Sources/CmuxSettingsUI/Sections/MobileSection.swift +++ b/Packages/macOS/CmuxSettingsUI/Sources/CmuxSettingsUI/Sections/MobileSection.swift @@ -115,7 +115,10 @@ public struct MobileSection: View { configurationReview: .action, searchAnchorID: "setting:mobile:pairDevice", String(localized: "settings.mobile.pairDevice", defaultValue: "Pair a Device"), - subtitle: String(localized: "settings.mobile.pairDevice.subtitle", defaultValue: "Show a QR code to pair your iPhone or iPad with this Mac.") + subtitle: String( + localized: "settings.mobile.pairDevice.subtitle", + defaultValue: "Devices signed in to the same account connect automatically. Show a QR code to pair manually." + ) ) { Button(String(localized: "settings.mobile.pairDevice.button", defaultValue: "Pair…")) { hostActions.openMobilePairingWindow() diff --git a/Resources/Localizable.xcstrings b/Resources/Localizable.xcstrings index 501935379891..bf468add8520 100644 --- a/Resources/Localizable.xcstrings +++ b/Resources/Localizable.xcstrings @@ -128001,13 +128001,13 @@ "en": { "stringUnit": { "state": "translated", - "value": "Scan this code with the cmux app on your iPhone to sync your terminal workspaces." + "value": "iPhones signed in to the same cmux account connect automatically. Scan this code with the cmux app if this Mac doesn't appear on its own." } }, "ja": { "stringUnit": { "state": "translated", - "value": "iPhone の cmux アプリでこのコードをスキャンして、ターミナルワークスペースを同期します。" + "value": "同じ cmux アカウントでサインインしている iPhone は自動的に接続されます。この Mac が自動的に表示されない場合は、cmux アプリでこのコードをスキャンしてください。" } } } @@ -166412,13 +166412,13 @@ "en": { "stringUnit": { "state": "translated", - "value": "Show a QR code to pair your iPhone or iPad with this Mac." + "value": "Devices signed in to the same account connect automatically. Show a QR code to pair manually." } }, "ja": { "stringUnit": { "state": "translated", - "value": "QR コードを表示して、iPhone または iPad をこの Mac とペアリングします。" + "value": "同じアカウントでサインインしているデバイスは自動的に接続されます。手動でペアリングするには QR コードを表示します。" } } } diff --git a/Sources/FeatureFlags.swift b/Sources/FeatureFlags.swift index 1b42890134ad..03c6a6077899 100644 --- a/Sources/FeatureFlags.swift +++ b/Sources/FeatureFlags.swift @@ -37,7 +37,7 @@ final class CmuxFeatureFlags { private static let proUpgradeUIDefault = false #endif - private static let mobileConnectButtonDefault = true + private static let mobileConnectButtonDefault = false #if DEBUG private static let cloudVMUIDefault = true @@ -90,10 +90,11 @@ final class CmuxFeatureFlags { ), // FLAG(key: mobile-connect-button-enabled-release, owner: lawrencecchen, - // reviewBy: 2026-10-01, defaultWhenUnavailable: true) + // reviewBy: 2026-10-01, defaultWhenUnavailable: false) // Shows the top-right iPhone button that opens the Mobile Connect - // (phone pairing) window. Default keeps it visible when flags are - // unavailable; the window it opens ships in every build. + // window. Hidden by default so QR pairing does not sit in primary + // window chrome; pairing remains available from Settings > Mobile + // and the command palette, and PostHog can re-enable the button. CmuxFeatureFlagDefinition( key: "mobile-connect-button-enabled-release", title: String(localized: "featureFlags.mobileConnect.title", defaultValue: "Mobile Connect button"), diff --git a/Sources/Mobile/Pairing/MobilePairingView.swift b/Sources/Mobile/Pairing/MobilePairingView.swift index 9078406fa669..c5bcf7006506 100644 --- a/Sources/Mobile/Pairing/MobilePairingView.swift +++ b/Sources/Mobile/Pairing/MobilePairingView.swift @@ -20,6 +20,9 @@ struct MobilePairingView: View { /// Defaults to the Iroh identity QR. The user may explicitly reveal the /// separately minted released-client Tailscale code when one is available. @State private var showsLegacyPairingCode = false + /// Reports the scroll content's unconstrained height so the AppKit window + /// can grow to reveal it while retaining scrolling on shorter displays. + private let onContentHeightChange: (CGFloat) -> Void /// The shared auth coordinator, observed so the view re-runs `refresh()` /// when sign-in completes or settles. Captured once; stable post-startup. @@ -30,6 +33,10 @@ struct MobilePairingView: View { /// Where a Mac user goes to get cmux for iPhone while the beta is invite-only. static let iphoneAppURL = URL(string: "https://github.com/manaflow-ai/cmux#founders-edition")! + init(onContentHeightChange: @escaping (CGFloat) -> Void = { _ in }) { + self.onContentHeightChange = onContentHeightChange + } + var body: some View { ScrollView { VStack(alignment: .leading, spacing: 18) { @@ -40,6 +47,21 @@ struct MobilePairingView: View { } .padding(24) .frame(maxWidth: .infinity, alignment: .leading) + .background { + GeometryReader { geometry in + Color.clear.preference( + key: MobilePairingContentHeightPreferenceKey.self, + value: MobilePairingContentMeasurement( + height: geometry.size.height, + state: model.state, + showsLegacyPairingCode: showsLegacyPairingCode + ) + ) + } + } + } + .onPreferenceChange(MobilePairingContentHeightPreferenceKey.self) { measurement in + onContentHeightChange(measurement.height) } .task { await model.refresh() } .onDisappear { model.stopObserving() } @@ -57,7 +79,10 @@ struct MobilePairingView: View { VStack(alignment: .leading, spacing: 2) { Text(String(localized: "mobile.pairing.window.heading", defaultValue: "Pair your iPhone")) .cmuxFont(.title2, weight: .semibold) - Text(String(localized: "mobile.pairing.window.subheading", defaultValue: "Scan this code with the cmux app on your iPhone to sync your terminal workspaces.")) + Text(String( + localized: "mobile.pairing.window.subheading", + defaultValue: "iPhones signed in to the same cmux account connect automatically. Scan this code with the cmux app if this Mac doesn't appear on its own." + )) .cmuxFont(.callout) .foregroundStyle(.secondary) .fixedSize(horizontal: false, vertical: true) @@ -443,3 +468,27 @@ struct MobilePairingView: View { } } + +private struct MobilePairingContentMeasurement: Equatable { + let height: CGFloat + let state: MobilePairingModel.State + let showsLegacyPairingCode: Bool +} + +private struct MobilePairingContentHeightPreferenceKey: PreferenceKey { + static let defaultValue = MobilePairingContentMeasurement( + height: 0, + state: .loading, + showsLegacyPairingCode: false + ) + + static func reduce( + value: inout MobilePairingContentMeasurement, + nextValue: () -> MobilePairingContentMeasurement + ) { + let next = nextValue() + if next.height >= value.height { + value = next + } + } +} diff --git a/Sources/Mobile/Pairing/MobilePairingWindowController.swift b/Sources/Mobile/Pairing/MobilePairingWindowController.swift index 2a9e5236604c..e56e29955e95 100644 --- a/Sources/Mobile/Pairing/MobilePairingWindowController.swift +++ b/Sources/Mobile/Pairing/MobilePairingWindowController.swift @@ -18,6 +18,10 @@ final class MobilePairingWindowController: ReleasingWindowController { /// window behind it; referenced from the Cmd+W regression test. static let windowIdentifier = "cmux.mobilePairingWindow" + private static let screenMargin: CGFloat = 40 + private var idealContentHeight: CGFloat? + private var isUserResizing = false + private override init() { super.init() } @@ -38,13 +42,16 @@ final class MobilePairingWindowController: ReleasingWindowController { if !window.isVisible { window.center() } + resizeWindowToIdealContentHeight(window) window.makeKeyAndOrderFront(nil) window.orderFrontRegardless() } override func makeWindow() -> NSWindow { let appearanceMode = UserDefaults.standard.string(forKey: AppearanceSettings.appearanceModeKey) - let root = MobilePairingView() + let root = MobilePairingView { [weak self] height in + self?.pairingContentHeightDidChange(height) + } .cmuxAppearanceColorScheme(appearanceMode) let hostingController = NSHostingController(rootView: root) @@ -60,8 +67,62 @@ final class MobilePairingWindowController: ReleasingWindowController { // dogfood. The minimum keeps the QR plus the manual block usable on // small screens. window.setContentSize(NSSize(width: 560, height: 800)) - window.contentMinSize = NSSize(width: 480, height: 600) + window.contentMinSize = NSSize(width: 480, height: 320) window.center() return window } + + override func managedWindowWillClose(_ window: NSWindow) { + idealContentHeight = nil + isUserResizing = false + } + + func windowWillStartLiveResize(_ notification: Notification) { + isUserResizing = true + } + + func windowDidEndLiveResize(_ notification: Notification) { + isUserResizing = false + } + + private func pairingContentHeightDidChange(_ height: CGFloat) { + guard height > 0 else { return } + idealContentHeight = ceil(height) + guard !isUserResizing, let window else { return } + resizeWindowToIdealContentHeight(window) + } + + /// Keeps the current width and top edge, growing downward until the screen + /// margin would be crossed, then shifts the window up just enough to fit. + private func resizeWindowToIdealContentHeight(_ window: NSWindow) { + guard !isUserResizing, + let idealContentHeight, + let screen = window.screen ?? NSScreen.main else { return } + + let visibleFrame = screen.visibleFrame.insetBy( + dx: 0, + dy: Self.screenMargin / 2 + ) + let contentChromeHeight = window.frame.height - window.contentLayoutRect.height + // setFrame(_:display:) does not enforce contentMinSize, so clamp here + // or a small in-flight measurement (e.g. the loading spinner) could + // shrink the window below the usable floor. + let minContentHeight = window.contentMinSize.height + let targetFrameHeight = min( + max(idealContentHeight, minContentHeight) + contentChromeHeight, + visibleFrame.height + ) + guard targetFrameHeight > 0 else { return } + + var targetFrame = window.frame + targetFrame.origin.y = targetFrame.maxY - targetFrameHeight + targetFrame.size.height = targetFrameHeight + if targetFrame.minY < visibleFrame.minY { + targetFrame.origin.y = visibleFrame.minY + } + if targetFrame.maxY > visibleFrame.maxY { + targetFrame.origin.y = visibleFrame.maxY - targetFrameHeight + } + window.setFrame(targetFrame, display: true) + } } diff --git a/ios/cmux/Resources/Localizable.xcstrings b/ios/cmux/Resources/Localizable.xcstrings index 1fad8dd31038..32540f7acb2f 100644 --- a/ios/cmux/Resources/Localizable.xcstrings +++ b/ios/cmux/Resources/Localizable.xcstrings @@ -2268,13 +2268,13 @@ "en": { "stringUnit": { "state": "translated", - "value": "Add a computer to start syncing terminal workspaces." + "value": "Sign in to cmux on your computer with this account and it appears here automatically." } }, "ja": { "stringUnit": { "state": "translated", - "value": "コンピュータを追加してターミナルワークスペースの同期を開始します。" + "value": "コンピュータの cmux にこのアカウントでサインインすると、ここに自動的に表示されます。" } } } @@ -2285,13 +2285,13 @@ "en": { "stringUnit": { "state": "translated", - "value": "No devices" + "value": "No Computers" } }, "ja": { "stringUnit": { "state": "translated", - "value": "デバイスがありません" + "value": "コンピュータがありません" } } }