From fffdc7275249ab393792235e31d95885e795a147 Mon Sep 17 00:00:00 2001 From: Leo Date: Tue, 22 Sep 2026 02:41:56 -0700 Subject: [PATCH] test: pin Computer Use onboarding production wiring --- Sources/AppDelegate.swift | 3 --- Sources/HostSettingsActions.swift | 15 +++++------ Sources/cmuxApp.swift | 7 ++++- cmuxTests/ComputerUseUXTests.swift | 26 ++++++++++++++++--- ...ostSettingsShortcutNotificationTests.swift | 3 ++- 5 files changed, 36 insertions(+), 18 deletions(-) diff --git a/Sources/AppDelegate.swift b/Sources/AppDelegate.swift index c167d19de4fe..b267345475b3 100644 --- a/Sources/AppDelegate.swift +++ b/Sources/AppDelegate.swift @@ -2558,9 +2558,6 @@ final class AppDelegate: NSObject, NSApplicationDelegate, UNUserNotificationCent ) self.newMachineSheetPresenter = newMachineSheetPresenter self.computerUseRuntimeService = computerUseRuntimeService - (settingsRuntime.hostActions as? HostSettingsActions)?.setRunComputerUseOnboardingAction { [weak self] startingPoint in - self?.computerUseUXCoordinator.presentOnboardingFromSettings(startingAt: startingPoint) - } let cloudUploader = CloudTelemetryUploader( auth: auth.coordinator, baseURL: CloudTelemetryUploader.telemetryBaseURL, client: .current() ) diff --git a/Sources/HostSettingsActions.swift b/Sources/HostSettingsActions.swift index ca740545a76b..5f1afc078478 100644 --- a/Sources/HostSettingsActions.swift +++ b/Sources/HostSettingsActions.swift @@ -21,8 +21,8 @@ final class HostSettingsActions: SettingsHostActions { let computersActions: ComputersSettingsActions private let configFileURL: URL private let computerUseRuntimeService: ComputerUseRuntimeService - private var runComputerUseOnboardingAction: - @MainActor (ComputerUseOnboardingWindowController.StartingPoint) -> Void = { _ in } + private let runComputerUseOnboardingAction: + @MainActor (ComputerUseOnboardingWindowController.StartingPoint) -> Void /// Serializes font-size config writes so rapid slider saves persist in order. private let fontConfigWriter = FontConfigWriter() @@ -56,11 +56,14 @@ final class HostSettingsActions: SettingsHostActions { init( configFileURL: URL, computerUseRuntimeService: ComputerUseRuntimeService, - computersActions: ComputersSettingsActions? = nil + computersActions: ComputersSettingsActions? = nil, + runComputerUseOnboardingAction: + @escaping @MainActor (ComputerUseOnboardingWindowController.StartingPoint) -> Void ) { self.computersActions = computersActions ?? ComputersSettingsActions() self.configFileURL = configFileURL self.computerUseRuntimeService = computerUseRuntimeService + self.runComputerUseOnboardingAction = runComputerUseOnboardingAction startObservingAppIconMode() } @@ -217,12 +220,6 @@ final class HostSettingsActions: SettingsHostActions { runComputerUseOnboardingAction(.screenRecording) } - func setRunComputerUseOnboardingAction( - _ action: @escaping @MainActor (ComputerUseOnboardingWindowController.StartingPoint) -> Void - ) { - runComputerUseOnboardingAction = action - } - func openConfigInExternalEditor() { // Honor the user's configured editor (`preferredEditorCommand`), // falling back to the OS default. Opening the config file directly diff --git a/Sources/cmuxApp.swift b/Sources/cmuxApp.swift index bb7d39a5cebd..a366efcce0c5 100644 --- a/Sources/cmuxApp.swift +++ b/Sources/cmuxApp.swift @@ -197,7 +197,12 @@ struct cmuxApp: App { hostActions: HostSettingsActions( configFileURL: configFileURL, computerUseRuntimeService: computerUseRuntimeService, - computersActions: devices.settingsActions + computersActions: devices.settingsActions, + runComputerUseOnboardingAction: { startingPoint in + AppDelegate.shared?.computerUseUXCoordinator.presentOnboardingFromSettings( + startingAt: startingPoint + ) + } ), shortcutDefaultResolver: Self.makeShortcutDefaultResolver() ) diff --git a/cmuxTests/ComputerUseUXTests.swift b/cmuxTests/ComputerUseUXTests.swift index 430f3cf504ff..7b584128e098 100644 --- a/cmuxTests/ComputerUseUXTests.swift +++ b/cmuxTests/ComputerUseUXTests.swift @@ -233,6 +233,24 @@ struct ComputerUseUXTests { directCaptureReady: true)) } + @Test @MainActor + func settingsHostActionsRoutePermissionRequestsToRequiredOnboardingAction() { + var presentations: [ComputerUseOnboardingWindowController.StartingPoint] = [] + let actions = HostSettingsActions( + configFileURL: FileManager.default.temporaryDirectory + .appendingPathComponent("cmux-settings-\(UUID().uuidString).json"), + computerUseRuntimeService: ComputerUseRuntimeService(), + runComputerUseOnboardingAction: { startingPoint in + presentations.append(startingPoint) + } + ) + + actions.requestComputerUseAccessibility() + actions.requestComputerUseScreenRecording() + + #expect(presentations == [.accessibility, .screenRecording]) + } + @Test(.timeLimit(.minutes(1))) @MainActor func grantedPermissionsResumeIncompleteSetupFromSettingsRefresh() async throws { let root = FileManager.default.temporaryDirectory @@ -284,11 +302,11 @@ struct ComputerUseUXTests { ] = [] let actions = HostSettingsActions( configFileURL: root.appendingPathComponent("cmux.json"), - computerUseRuntimeService: runtime + computerUseRuntimeService: runtime, + runComputerUseOnboardingAction: { startingPoint in + presentations.append(startingPoint) + } ) - actions.setRunComputerUseOnboardingAction { startingPoint in - presentations.append(startingPoint) - } await actions.refreshComputerUsePermissions() diff --git a/cmuxTests/HostSettingsShortcutNotificationTests.swift b/cmuxTests/HostSettingsShortcutNotificationTests.swift index b74b8626ad16..213fb281d4c0 100644 --- a/cmuxTests/HostSettingsShortcutNotificationTests.swift +++ b/cmuxTests/HostSettingsShortcutNotificationTests.swift @@ -66,7 +66,8 @@ struct HostSettingsShortcutNotificationTests { try updatedContents.write(to: settingsFileURL, atomically: true, encoding: .utf8) HostSettingsActions( configFileURL: settingsFileURL, - computerUseRuntimeService: ComputerUseRuntimeService() + computerUseRuntimeService: ComputerUseRuntimeService(), + runComputerUseOnboardingAction: { _ in } ).notifyShortcutSettingsDidChange() #expect(counter.value == expectedNotificationCount)