Skip to content
Closed
Show file tree
Hide file tree
Changes from 5 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
9 changes: 5 additions & 4 deletions .github/swift-file-length-budget.tsv
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,18 @@
6156 Sources/TabManager.swift
6153 CLI/cmux_open.swift
6074 Sources/TextBoxInput.swift
5987 Packages/CmuxMobileShell/Sources/CmuxMobileShell/MobileShellComposite.swift
5925 cmuxTests/TerminalAndGhosttyTests.swift
5526 cmuxTests/BrowserConfigTests.swift
5551 Packages/CmuxMobileShell/Sources/CmuxMobileShell/MobileShellComposite.swift
4920 Sources/cmuxApp.swift
4467 Sources/Panels/FilePreviewPanel.swift
4400 cmuxTests/BrowserPanelTests.swift
4227 Sources/BrowserWindowPortal.swift
3937 Sources/Feed/FeedPanelView.swift
3926 cmuxTests/TabManagerUnitTests.swift
3903 cmuxTests/WindowAndDragTests.swift
3699 cmuxTests/CLIGenericHookPersistenceTests.swift
3734 Packages/CmuxMobileTerminal/Sources/CmuxMobileTerminal/GhosttySurfaceView.swift
3699 cmuxTests/CLIGenericHookPersistenceTests.swift
3397 Sources/CmuxConfig.swift
3331 cmuxTests/TabManagerSessionSnapshotTests.swift
3055 Sources/Update/UpdateTitlebarAccessory.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 @@ -119,6 +120,7 @@
752 cmuxUITests/CloseWorkspaceCmdDUITests.swift
749 Packages/CmuxTerminal/Sources/CmuxTerminal/Surface/TerminalSurface+Input.swift
746 Sources/App/MenuBarExtraController.swift
744 Packages/CmuxMobileShellUI/Sources/CmuxMobileShellUI/TerminalComposerView.swift
738 Packages/CMUXProjectModel/Sources/CMUXProjectModel/XcodeProjectAdapter.swift
736 Packages/CmuxAuthRuntime/Sources/CmuxAuthRuntime/Coordinator/AuthCoordinator.swift
726 cmuxTests/CLICodexHookTimeoutRegressionTests.swift
Expand Down Expand Up @@ -176,6 +178,7 @@
562 cmuxTests/AgentExecutableResolverTests.swift
561 cmuxTests/GhosttyConfigPathResolverTests.swift
558 Packages/CmuxGit/Sources/CmuxGit/Parsing/GitMetadataService+Config.swift
557 Packages/CmuxMobileShellUI/Sources/CmuxMobileShellUI/WorkspaceDetailView.swift
554 Sources/Panels/BrowserAutomation.swift
551 Packages/CmuxSettingsUI/Sources/CmuxSettingsUI/Sections/BrowserSection.swift
547 Packages/CmuxSocketControl/Sources/CmuxSocketControl/SocketControlSettings.swift
Expand All @@ -199,7 +202,6 @@
520 cmuxTests/MainWindowVisibilityControllerTests.swift
519 Packages/CmuxSwiftRender/Tests/CmuxSwiftRenderTests/Corpus/stress-two-column-cockpit-sidebar.swift
519 Sources/CmuxConfigExecutor.swift
557 Packages/CmuxMobileShellUI/Sources/CmuxMobileShellUI/WorkspaceDetailView.swift
518 Packages/CmuxSwiftRender/Tests/CmuxSwiftRenderTests/Corpus/stress-git-review-queue-command-deck.swift
517 Sources/TerminalImageTransfer.swift
514 Packages/CmuxSwiftRender/Sources/CmuxSwiftRender/ExpressionEvaluator.swift
Expand All @@ -212,4 +214,3 @@
503 Sources/Settings/ConfigSource.swift
502 Packages/CmuxControlSocket/Tests/CmuxControlSocketTests/ControlCommandContextTestStubs.swift
502 Sources/CmuxEventPublishing.swift
744 Packages/CmuxMobileShellUI/Sources/CmuxMobileShellUI/TerminalComposerView.swift
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