Skip to content
Closed
Show file tree
Hide file tree
Changes from 32 commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
e149ac1
Add iOS share diagnostics report
Jun 26, 2026
d919bc5
Merge remote-tracking branch 'origin/main' into issue-5515-ios-in-app…
Jun 26, 2026
db955e0
Address diagnostics review notes
Jun 27, 2026
8288ce6
Merge remote-tracking branch 'origin/main' into issue-5515-ios-in-app…
Jun 27, 2026
a3f2407
Merge remote-tracking branch 'origin/main' into issue-5515-ios-in-app…
Jun 27, 2026
b9ae83e
Address diagnostics review feedback
Jun 27, 2026
8b2ee98
Test offline auth diagnostics recording
Jun 27, 2026
5aeff06
Record offline auth diagnostics
Jun 27, 2026
7edcbc8
Test external sign-in diagnostics recording
Jun 27, 2026
15b7021
Address diagnostics follow-up review
Jun 27, 2026
8b41185
Harden shared diagnostics report privacy
Jun 27, 2026
d49c111
Fix iOS diagnostics localization helper compatibility
Jun 27, 2026
eacec5a
Guard iOS glass helpers for older toolchains
Jun 27, 2026
939c284
Fix iOS diff accessibility interpolation
Jun 27, 2026
5ea1546
Guard iOS chat scroll-edge compatibility
Jun 27, 2026
717ad46
Guard iOS chat composer glass APIs
Jun 27, 2026
35d13cd
Refresh Swift file length budget
Jun 27, 2026
24dc6d2
Isolate iOS composer picker label
Jun 27, 2026
1778738
Preserve iOS OSLog diagnostics status
Jun 27, 2026
68671f6
Fix iOS hardware key command isolation
Jun 27, 2026
9b63571
Guard terminal accessory glass configuration
Jun 27, 2026
5ebafce
Refresh Swift file length budget
Jun 27, 2026
300dc5f
Fix mobile terminal Swift isolation
Jun 27, 2026
099b7b3
Use Xcode 16 compatible deinit cleanup
Jun 27, 2026
7ace7da
Avoid isolated deinit in mobile shell
Jun 27, 2026
e04b859
Fix iOS shell UI Xcode 16 compatibility
Jun 27, 2026
f9f8a68
Merge origin/main into diagnostics PR
Jun 29, 2026
d353041
Merge remote-tracking branch 'origin/main' into issue-5515-ios-in-app…
austinywang Jun 29, 2026
5b1d051
Merge remote-tracking branch 'origin/main' into issue-5515-ios-in-app…
austinywang Jun 30, 2026
5f5992e
Merge origin/main into issue-5515-ios-in-app-share-diagnostics-copy-s…
austinywang Jul 2, 2026
16486d3
Merge remote-tracking branch 'origin/main' into issue-5515-ios-in-app…
austinywang Jul 2, 2026
7fe4c85
iOS diagnostics: clear report inputs on sign-out (shared-device privacy)
austinywang Jul 2, 2026
fddd8b0
Fix diagnostics sheet lifecycle and refresh file-length budget
austinywang Jul 2, 2026
c88327a
Omit process-wide structured log from account-scoped diagnostics report
austinywang Jul 2, 2026
754ede4
Gate structured diagnostic-log export to DEBUG in privileged feedback
austinywang Jul 2, 2026
2170c8c
Merge remote-tracking branch 'origin/main' into issue-5515-ios-in-app…
austinywang Jul 2, 2026
b5a9993
Merge remote-tracking branch 'origin/main' into issue-5515-ios-in-app…
austinywang Jul 2, 2026
d8d93a0
Reset diagnostics event log by ordered instance swap on sign-out
austinywang Jul 2, 2026
1bc17a3
Merge remote-tracking branch 'origin/main' into issue-5515-ios-in-app…
austinywang Jul 3, 2026
03ccb2c
Fix auth diagnostics policy helper
austinywang Jul 3, 2026
590724a
Address diagnostics autoreview policy findings
austinywang Jul 3, 2026
28b927c
Fix diagnostics lint guards
austinywang Jul 4, 2026
c511a0e
Scope diagnostics event log to shell store
austinywang Jul 4, 2026
5b09252
Merge remote-tracking branch 'origin/main' into issue-5515-ios-in-app…
austinywang Jul 4, 2026
89e665d
Import mobile support in diagnostics assembler
austinywang Jul 4, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions .github/swift-file-length-budget.tsv
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Reduce counts as files shrink. CI fails if tracked files exceed this budget.
34430 CLI/cmux.swift
17978 Sources/AppDelegate.swift
16487 Sources/ContentView.swift
16484 Sources/ContentView.swift
14232 Sources/TerminalController.swift
13071 Sources/Workspace.swift
12348 cmuxTests/AppDelegateShortcutRoutingTests.swift
Expand All @@ -12,7 +12,7 @@
9497 cmuxTests/CLINotifyProcessIntegrationRegressionTests.swift
8032 Sources/Panels/BrowserPanelView.swift
8016 CLI/cmux_open.swift
7783 Packages/iOS/CmuxMobileShell/Sources/CmuxMobileShell/MobileShellComposite.swift
7813 Packages/iOS/CmuxMobileShell/Sources/CmuxMobileShell/MobileShellComposite.swift
Comment thread
cubic-dev-ai[bot] marked this conversation as resolved.
Resolved
7404 cmuxTests/WorkspaceUnitTests.swift
7218 cmuxTests/WorkspaceRemoteConnectionTests.swift
6359 cmuxTests/SessionPersistenceTests.swift
Expand Down Expand Up @@ -62,13 +62,13 @@
1560 cmuxTests/TextBoxMentionCompletionTests.swift
1500 cmuxUITests/MultiWindowNotificationsUITests.swift
1499 cmuxTests/OmnibarAndToolsTests.swift
1447 Sources/FileExplorerStore.swift
1433 Sources/RemoteTmuxControlConnection.swift
1420 cmuxTests/AppDelegateIssue2907RoutingTests.swift
1384 cmuxTests/KeyboardShortcutSettingsFileStoreStartupTests.swift
1380 cmuxUITests/MenuKeyEquivalentRoutingUITests.swift
1363 Sources/CMUXInstalledExtensionSidebarHostView.swift
1360 Sources/Feed/FeedButtonStyleDebugWindowController.swift
1317 Sources/FileExplorerStore.swift
1295 Packages/macOS/CmuxTerminalCore/Sources/CmuxTerminalCore/Config/GhosttyConfig.swift
1295 cmuxTests/MobileHostAuthorizationTests.swift
1290 cmuxTests/TextBoxSubmitActionTests.swift
Expand Down Expand Up @@ -115,8 +115,8 @@
845 cmuxTests/SSHStartupSignalLifecycleTests.swift
841 Packages/iOS/CmuxMobileShell/Tests/CmuxMobileShellTests/TerminalOutputDeliveryQueueTests.swift
834 Sources/MainWindowFocusController.swift
830 Packages/iOS/CmuxMobileShellUI/Sources/CmuxMobileShellUI/TerminalComposerView.swift
830 Sources/TaskManagerTypes.swift
825 Packages/iOS/CmuxMobileShellUI/Sources/CmuxMobileShellUI/TerminalComposerView.swift
813 Sources/WorkspaceContentView.swift
810 Packages/macOS/CmuxSwiftRender/Tests/CmuxSwiftRenderTests/SwiftViewInterpreterTests.swift
803 Packages/iOS/CmuxMobilePairedMac/Sources/CmuxMobilePairedMac/MobilePairedMacStore.swift
Expand All @@ -132,10 +132,10 @@
756 Sources/Panels/AgentSessionWebRendererCoordinator.swift
754 Sources/TerminalController+ControlWorkspaceContext.swift
752 cmuxUITests/CloseWorkspaceCmdDUITests.swift
750 Packages/iOS/CmuxMobileShellUI/Sources/CmuxMobileShellUI/WorkspaceDetailView.swift
748 Packages/Shared/CmuxAuthRuntime/Sources/CmuxAuthRuntime/Coordinator/AuthCoordinator.swift
744 Packages/iOS/CmuxMobileShellUI/Sources/CmuxMobileShellUI/WorkspaceDetailView.swift
739 cmuxTests/CLICodexHookTimeoutRegressionTests.swift
738 Packages/macOS/CMUXProjectModel/Sources/CMUXProjectModel/XcodeProjectAdapter.swift
718 Packages/Shared/CmuxAuthRuntime/Sources/CmuxAuthRuntime/Coordinator/AuthCoordinator.swift
716 Sources/TaskManagerSnapshot.swift
715 Sources/AppleScriptSupport.swift
710 Sources/TerminalSSHSessionDetector.swift
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ internal import CMUXAuthCore
import Foundation
import OSLog

private let authLog = Logger(subsystem: "ai.manaflow.cmux", category: "auth")
nonisolated private let authLog = Logger(subsystem: "ai.manaflow.cmux", category: "auth")

extension AuthCoordinator {
// MARK: - Priming
Expand Down Expand Up @@ -213,6 +213,7 @@ extension AuthCoordinator {
authLog.info("Cached session validation superseded by a newer session transition; leaving state untouched")
return
}
recordAuthError(error)
// Drive the clear-vs-preserve decision from LIVE session validity, not
// the error code alone. The SDK throws the same `UserNotSignedInError`
// ("USER_NOT_SIGNED_IN") for two opposite situations: a genuine
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ internal import CMUXAuthCore
import Foundation
import OSLog

private let authLog = Logger(subsystem: "ai.manaflow.cmux", category: "auth")
nonisolated private let authLog = Logger(subsystem: "ai.manaflow.cmux", category: "auth")

extension AuthCoordinator {
// MARK: - Tokens
Expand Down Expand Up @@ -31,8 +31,12 @@ extension AuthCoordinator {
if let devToken = await devAuthAccessTokenFallback() {
return devToken
}
recordAuthError(AuthError.unauthorized)
clearAuthState(preservePendingCode: true)
throw AuthError.unauthorized
} catch {
recordAuthError(error)
throw error
}
}

Expand Down Expand Up @@ -97,9 +101,11 @@ extension AuthCoordinator {
public func currentTokens() async throws -> (accessToken: String, refreshToken: String) {
await awaitBootstrapped()
guard let access = await client.accessToken(), !access.isEmpty else {
recordAuthError(AuthError.unauthorized)
throw AuthError.unauthorized
}
guard let refresh = await client.refreshToken(), !refresh.isEmpty else {
recordAuthError(AuthError.unauthorized)
throw AuthError.unauthorized
}
return (access, refresh)
Expand All @@ -123,8 +129,12 @@ extension AuthCoordinator {
try await self.forceRefreshAccessTokenWithoutStateClear()
}
} catch AuthError.unauthorized {
recordAuthError(AuthError.unauthorized)
clearAuthState(preservePendingCode: true)
throw AuthError.unauthorized
} catch {
recordAuthError(error)
throw error
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import Foundation
public import Observation
import OSLog

private let authLog = Logger(subsystem: "ai.manaflow.cmux", category: "auth")
nonisolated private let authLog = Logger(subsystem: "ai.manaflow.cmux", category: "auth")

/// The shared, injected auth orchestrator for cmux.
///
Expand Down Expand Up @@ -39,6 +39,13 @@ public final class AuthCoordinator {
public private(set) var isLoading = false
/// Whether a cached session is being restored/validated at launch.
public private(set) var isRestoringSession = false
/// Most recent display-safe auth failure category for diagnostics reports.
///
/// Raw backend errors can contain opaque identifiers or token-adjacent
/// payloads, so diagnostics retain only ``AuthError`` case names or the
/// fallback category `AuthError.authFailure` when no display-safe mapping
/// exists.
public private(set) var lastAuthError: String?
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
/// The teams the signed-in user belongs to (refreshed on sign-in/restore).
public private(set) var availableTeams: [CMUXAuthTeam] = []
/// The user's selected team id. Writes persist through the injected
Expand Down Expand Up @@ -214,7 +221,7 @@ public final class AuthCoordinator {

/// Send a sign-in code to `email`, or run the debug `42` shortcut.
public func sendCode(to email: String) async throws {
try await requireOnline()
try await requireOnlineForAuth()
isLoading = true
defer { isLoading = false }

Expand All @@ -234,7 +241,7 @@ public final class AuthCoordinator {
}
pendingNonce = nonce
} catch {
throw AuthError(displaySafe: error) ?? error
throw recordAuthError(error)
}
}

Expand All @@ -246,7 +253,7 @@ public final class AuthCoordinator {
// Captured before the first await so a sign-out landing anywhere in
// this flow (connectivity probe, exchange, user fetch) wins.
let flow = try await beginSignInFlow()
try await requireOnline()
try await requireOnlineForAuth()
isLoading = true
defer { isLoading = false }

Expand All @@ -258,7 +265,7 @@ public final class AuthCoordinator {
}
try await completeSignIn(flow: flow)
} catch {
throw AuthError(displaySafe: error) ?? error
throw recordAuthError(error)
}
pendingNonce = nil
}
Expand All @@ -268,7 +275,7 @@ public final class AuthCoordinator {
// Captured before the first await so a sign-out landing anywhere in
// this flow (connectivity probe, exchange, user fetch) wins.
let flow = try await beginSignInFlow()
try await requireOnline()
try await requireOnlineForAuth()
if setLoading { isLoading = true }
defer { if setLoading { isLoading = false } }

Expand All @@ -279,7 +286,7 @@ public final class AuthCoordinator {
}
try await completeSignIn(flow: flow)
} catch {
throw AuthError(displaySafe: error) ?? error
throw recordAuthError(error)
}
}

Expand All @@ -297,7 +304,7 @@ public final class AuthCoordinator {
// Captured before the first await so a sign-out landing anywhere in
// this flow (connectivity probe, OAuth exchange, user fetch) wins.
let flow = try await beginSignInFlow()
try await requireOnline()
try await requireOnlineForAuth()
isLoading = true
defer { isLoading = false }
do {
Expand All @@ -313,7 +320,7 @@ public final class AuthCoordinator {
try await completeSignIn(flow: flow)
} catch {
log.log("auth.oauth provider=\(provider) failed: \(error)")
throw AuthError(displaySafe: error) ?? error
throw recordAuthError(error)
}
}

Expand Down Expand Up @@ -402,7 +409,7 @@ public final class AuthCoordinator {
do {
try await completeSignIn(flow: flow)
} catch {
throw AuthError(displaySafe: error) ?? error
throw recordAuthError(error)
}
}

Expand Down Expand Up @@ -527,11 +534,10 @@ public final class AuthCoordinator {
} catch {
// Best-effort by design; see the security tradeoff above.
// The full error goes to the unified log privately; the
// public redacted sink gets only the error TYPE, because
// a Stack error body can carry opaque identifiers the
// redaction regexes don't recognize.
// public redacted sink gets only a generic failure marker,
// because even error type names can expose provider details.
authLog.error("Sign-out session revocation failed: \(error.localizedDescription, privacy: .private)")
log.log("auth.signOut revocation failed: \(String(describing: type(of: error)))")
log.log("auth.signOut revocation failed")
}
}
group.addTask {
Expand All @@ -556,6 +562,7 @@ public final class AuthCoordinator {
currentUser = user
isAuthenticated = true
isRestoringSession = false
lastAuthError = nil
saveCachedUser(user)
sessionCache.setHasTokens(true)
await refreshTeams(generation: generation)
Expand Down Expand Up @@ -621,6 +628,21 @@ public final class AuthCoordinator {
isRestoringSession = false
}

@discardableResult
func recordAuthError(_ error: any Error) -> any Error {
let displaySafe = AuthError(displaySafe: error)
let reportable = displaySafe ?? error
lastAuthError = Self.diagnosticDescription(for: reportable)
return reportable
}

private static func diagnosticDescription(for error: any Error) -> String {
if let authError = error as? AuthError {
return "AuthError.\(authError.diagnosticName)"
}
return "AuthError.authFailure"
}

func clearPersistedAuthForUITest() async {
if launch.includesDevAuth { debugCredentials = nil }
await clearPersistedStackSession()
Expand All @@ -646,6 +668,14 @@ public final class AuthCoordinator {
}
}

func requireOnlineForAuth() async throws {
do {
try await requireOnline()
} catch {
throw recordAuthError(error)
}
}

/// Race `operation` against the phase deadline on the injected clock,
/// dispatching token-touching and side-effect phases to coordinator-owned
/// helpers so sign-out can still cancel late work after a timeout.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,3 +95,30 @@ public enum AuthError: Error, LocalizedError, Equatable, Sendable {
}
}
}

extension AuthError {
var diagnosticName: String {
switch self {
case .offline:
return "offline"
case .networkError:
return "networkError"
case .timedOut:
return "timedOut"
case .serverError:
return "serverError"
case .invalidCode:
return "invalidCode"
case .invalidCallback:
return "invalidCallback"
case .browserSignInFailed:
return "browserSignInFailed"
case .unauthorized:
return "unauthorized"
case .authFailure:
return "authFailure"
case .cancelled:
return "cancelled"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -117,11 +117,44 @@ import Testing
#expect(coordinator.isAuthenticated)
}

@Test func offlineFailsFast() async {
@Test func offlinePasswordSignInRecordsDiagnostic() async {
let (coordinator, _) = makeCoordinator(client: FakeAuthClient(), isOnline: { false })
await #expect(throws: AuthError.offline) {
try await coordinator.signInWithPassword(email: "a@b.com", password: "pw")
}
#expect(coordinator.lastAuthError == "AuthError.offline")
}

@Test func offlineSendCodeRecordsDiagnostic() async {
let (coordinator, _) = makeCoordinator(client: FakeAuthClient(), isOnline: { false })
await #expect(throws: AuthError.offline) {
try await coordinator.sendCode(to: "a@b.com")
}
#expect(coordinator.lastAuthError == "AuthError.offline")
}

@Test func offlineVerifyCodeRecordsDiagnostic() async throws {
let connectivity = ConnectivityProbe(isOnline: true)
let (coordinator, _) = makeCoordinator(
client: FakeAuthClient(),
isOnline: { await connectivity.isOnline() }
)
try await coordinator.sendCode(to: "a@b.com")

await connectivity.setOnline(false)

await #expect(throws: AuthError.offline) {
try await coordinator.verifyCode("123456")
}
#expect(coordinator.lastAuthError == "AuthError.offline")
}

@Test func offlineOAuthRecordsDiagnostic() async {
let (coordinator, _) = makeCoordinator(client: FakeAuthClient(), isOnline: { false })
await #expect(throws: AuthError.offline) {
try await coordinator.signInWithApple()
}
#expect(coordinator.lastAuthError == "AuthError.offline")
}

@Test func oauthAppleAndGoogleRouteToProviders() async throws {
Expand Down Expand Up @@ -460,5 +493,6 @@ import Testing
}
#expect(coordinator.isAuthenticated == false)
#expect(coordinator.isLoading == false)
#expect(coordinator.lastAuthError == "AuthError.unauthorized")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,23 @@ actor FakeAuthClient: AuthClient {
}
}

/// Mutable connectivity probe for auth tests that flip online state mid-flow.
actor ConnectivityProbe {
private var online: Bool

init(isOnline: Bool) {
self.online = isOnline
}

func setOnline(_ value: Bool) {
online = value
}

func isOnline() -> Bool {
online
}
}

/// A no-op presentation anchor for OAuth flows in tests.
final class FakeAnchor: NSObject, AuthPresentationAnchoring {
func presentationAnchor(for session: ASWebAuthenticationSession) -> ASPresentationAnchor {
Expand Down
Loading
Loading