Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 3 additions & 2 deletions .github/swift-file-length-budget.tsv
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
6156 Sources/TabManager.swift
6153 CLI/cmux_open.swift
6074 Sources/TextBoxInput.swift
5994 Packages/CmuxMobileShell/Sources/CmuxMobileShell/MobileShellComposite.swift
5925 cmuxTests/TerminalAndGhosttyTests.swift
5558 Packages/CmuxMobileShell/Sources/CmuxMobileShell/MobileShellComposite.swift
5526 cmuxTests/BrowserConfigTests.swift
4921 Sources/cmuxApp.swift
4467 Sources/Panels/FilePreviewPanel.swift
Expand Down Expand Up @@ -93,6 +93,7 @@
945 Sources/SessionIndexRegisteredAgents.swift
937 Sources/TextBoxMentionIndexStore.swift
934 Sources/App/ShortcutRoutingSupport.swift
932 Packages/CmuxMobileShell/Tests/CmuxMobileShellTests/MobileAutoAttachTests.swift
926 Sources/DockPanelView.swift
920 Sources/CommandPalette/CommandPaletteSettingsToggle.swift
918 cmuxTests/WorkspaceGroupTests.swift
Expand All @@ -107,6 +108,7 @@
845 cmuxTests/SSHStartupSignalLifecycleTests.swift
841 Sources/Panels/MarkdownWebRenderer.swift
830 Sources/TaskManagerTypes.swift
825 Packages/CmuxMobileShellUI/Sources/CmuxMobileShellUI/TerminalComposerView.swift
810 Packages/CmuxSwiftRender/Tests/CmuxSwiftRenderTests/SwiftViewInterpreterTests.swift
797 Sources/ClosedItemHistory.swift
779 cmuxUITests/BrowserOmnibarSuggestionsUITests.swift
Expand All @@ -120,7 +122,6 @@
752 cmuxUITests/CloseWorkspaceCmdDUITests.swift
749 Packages/CmuxTerminal/Sources/CmuxTerminal/Surface/TerminalSurface+Input.swift
746 Sources/App/MenuBarExtraController.swift
825 Packages/CmuxMobileShellUI/Sources/CmuxMobileShellUI/TerminalComposerView.swift
738 Packages/CMUXProjectModel/Sources/CMUXProjectModel/XcodeProjectAdapter.swift
736 Packages/CmuxAuthRuntime/Sources/CmuxAuthRuntime/Coordinator/AuthCoordinator.swift
726 Packages/CmuxMobileShellUI/Sources/CmuxMobileShellUI/WorkspaceDetailView.swift
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
public import Foundation

/// An online/offline signal for registry-driven auto-attach target selection.
///
/// Optional seam: when no presence provider is wired (the presence service is
/// not merged yet, #5792), auto-attach degrades to most-recently-seen selection,
/// which is correct for the dominant single-Mac team. Once the presence client
/// lands, an adapter conforming to this protocol lets auto-attach prefer the live
/// Mac and treat multiple live Macs as ambiguous (fall through to manual pair)
/// rather than guessing on recency.
public protocol MobileAutoAttachPresenceProviding: Sendable {
/// The device ids the presence service currently reports as online, scoped to
/// the signed-in user's team. Best-effort: a `nil` snapshot means "no
/// presence signal right now," so selection falls back to recency.
func onlineDeviceIDs() async -> Set<String>?
}

Large diffs are not rendered by default.

15 changes: 15 additions & 0 deletions Packages/CmuxMobileShell/Sources/CmuxMobileShell/PresenceMap.swift
Original file line number Diff line number Diff line change
Expand Up @@ -86,4 +86,19 @@ public struct PresenceMap: Equatable, Sendable {
lastSeenAt: Date(timeIntervalSince1970: lastSeenMs / 1000)
)
}

/// The device ids the live presence stream currently reports online (any
/// instance online), using the same rollup rule as ``deviceSummary``. This
/// is the auto-attach target selector's presence signal: it prefers a single
/// live Mac and treats 2+ live Macs as ambiguous instead of guessing on
/// recency. Empty when no presence data has streamed yet, which the caller
/// distinguishes from "data exists, nobody online" via ``isEmpty``.
public func onlineDeviceIDs() -> Set<String> {
var ids: Set<String> = []
for (deviceId, instances) in instancesByDevice
where instances.values.contains(where: { $0.online }) {
ids.insert(deviceId)
}
return ids
}
}
Loading
Loading