Skip to content

Commit 59bc671

Browse files
lawrencecchenclaude
andcommitted
iOS: registry-driven auto-attach (sign in → connected)
A signed-in phone whose team has one reachable Mac now connects on the cold-start path with no QR scan or manual host entry. The attach ticket is route-discovery only; the Mac authorizes the mint purely on matching Stack account, so a registry route + Stack token is sufficient (no prior pairing). - MobileAutoAttachTargetSelector: pure target picker (online-preferred, else single most-recently-seen with a reachable route; ambiguity → nil → manual). - MobileAttachRoutePriority: shared route-priority helper (single source of truth for reconnect, switch, device-tree tap, auto-attach). - MobileAutoAttachFlag: mobileAutoAttach flag, DEBUG on / Release off, override via cmux.mobile.autoAttach.enabled. - attemptAutoAttachIfEligible chains from the no-stored-mac reconnect branch; bounded, cancellable, one attempt per generation; reuses connectToRegistryInstance (Stack-authenticated mint + paired-mac persist) so the next launch takes the normal reconnect path. - Presence seam optional (MobileAutoAttachPresenceProviding); degrades to recency until presence (#5792) lands. Tests: pure selector (online>recency, no-candidate, ambiguity) + composite behavior (connects+persists, fall-through, one-attempt-per-generation, flag off, already-connected). swift test green for CmuxMobileShellModel and CmuxMobileShell; iOS simulator arm64 build succeeds. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 0b82dfe commit 59bc671

9 files changed

Lines changed: 1994 additions & 25 deletions

File tree

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
public import Foundation
2+
3+
/// An online/offline signal for registry-driven auto-attach target selection.
4+
///
5+
/// Optional seam: when no presence provider is wired (the presence service is
6+
/// not merged yet, #5792), auto-attach degrades to most-recently-seen selection,
7+
/// which is correct for the dominant single-Mac team. Once the presence client
8+
/// lands, an adapter conforming to this protocol lets auto-attach prefer the live
9+
/// Mac and treat multiple live Macs as ambiguous (fall through to manual pair)
10+
/// rather than guessing on recency.
11+
public protocol MobileAutoAttachPresenceProviding: Sendable {
12+
/// The device ids the presence service currently reports as online, scoped to
13+
/// the signed-in user's team. Best-effort: a `nil` snapshot means "no
14+
/// presence signal right now," so selection falls back to recency.
15+
func onlineDeviceIDs() async -> Set<String>?
16+
}

Packages/CmuxMobileShell/Sources/CmuxMobileShell/MobileShellComposite.swift

Lines changed: 443 additions & 23 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)