Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,36 @@ extension MobileShellComposite {
supportedHostCapabilities.contains(Self.workspaceGroupCreateCapability)
&& discoversMacScopedWorkspaceMutations
}
/// Whether the Mac supports creating task-composer workspaces.
/// Whether the New Task composer entrypoint is available. A connected
/// Mac's capability snapshot is authoritative for that Mac: any connected
/// Mac advertising task creation shows the entrypoint, and a fleet of
/// connected Macs that all lack it (remote flag off, or older builds)
/// hides it. With zero connected Macs there is no snapshot to consult, so
/// the entrypoint stays visible and the composer warns that no Mac is
/// connected instead of the button silently disappearing while offline.
public var supportsTaskComposer: Bool {
supportedHostCapabilities.contains(Self.taskCreateCapability)
var sawConnectedMac = false
if connectionState == .connected {
if supportedHostCapabilities.contains(Self.taskCreateCapability) {
return true
}
sawConnectedMac = true
}
for (_, subscription) in secondaryMacSubscriptions {
if subscription.supportedHostCapabilities.contains(Self.taskCreateCapability) {
return true
}
sawConnectedMac = true
}
return !sawConnectedMac
}
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved

/// True while at least one Mac session is live: the foreground connection
/// or any control-role secondary. The task composer keys its "No Mac is
/// connected" warning off this so the warning clears the moment any Mac
/// comes up, not only the foreground one.
public var hasAnyConnectedMac: Bool {
connectionState == .connected || !secondaryMacSubscriptions.isEmpty
Comment thread
azooz2003-bit marked this conversation as resolved.
Resolved
}
/// Whether the Mac supports dogfood feedback submission.
public var supportsDogfoodFeedback: Bool { supportedHostCapabilities.contains(Self.dogfoodFeedbackCapability) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,46 @@ import Testing
#expect(authorization.first?.stackAccessToken == "test-stack-token")
}

@Test func taskComposerEntrypointStaysAvailableWithNoConnectedMac() {
let store = MobileShellComposite.preview()
// With no Mac connected there is no capability snapshot to consult, so
// the New Task entrypoint must stay visible; the composer itself warns
// that no Mac is connected. Hiding here made the button vanish whenever
// the phone was offline or between reconnects.
#expect(store.supportsTaskComposer)
}

@Test func taskComposerEntrypointFollowsConnectedMacCapability() async throws {
let capable = try await connectedStore(capabilities: [
"events.v1",
"terminal.render_grid.v1",
"terminal.replay.v1",
"workspace.task_create.v1",
])
#expect(capable.store.supportsTaskComposer)

// A connected Mac that does not advertise task creation (remote flag
// off or an older build) is authoritative: the entrypoint hides.
let incapable = try await connectedStore(capabilities: [
"events.v1",
"terminal.render_grid.v1",
"terminal.replay.v1",
])
#expect(!incapable.store.supportsTaskComposer)
}

@Test func hasAnyConnectedMacTracksForegroundSession() async throws {
let offline = MobileShellComposite.preview()
#expect(!offline.hasAnyConnectedMac)

let connected = try await connectedStore(capabilities: [
"events.v1",
"terminal.render_grid.v1",
"terminal.replay.v1",
])
#expect(connected.store.hasAnyConnectedMac)
}

@Test func macScopedMutationsSurviveTicketExpiryOnAccountAuthHosts() async throws {
let connected = try await connectedStore(
capabilities: [
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#if os(iOS)
import SwiftUI

/// Non-blocking notice shown while no Mac connection is live. The composer
/// stays usable for drafting; submission needs a connected Mac, so the banner
/// explains the missing connection instead of the entrypoint hiding itself.
struct TaskComposerConnectionWarningBanner: View {
let message: String

var body: some View {
HStack(alignment: .top, spacing: 10) {
Image(systemName: "wifi.exclamationmark")
.font(.subheadline.weight(.semibold))
.accessibilityHidden(true)

Text(message)
.font(.footnote.weight(.medium))
.fixedSize(horizontal: false, vertical: true)
}
.foregroundStyle(.orange)
.frame(maxWidth: .infinity, alignment: .leading)
.padding(12)
.background(Color.orange.opacity(0.12), in: RoundedRectangle(cornerRadius: 14, style: .continuous))
.accessibilityElement(children: .combine)
.accessibilityIdentifier("MobileTaskComposerConnectionWarning")
}
}
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ struct TaskComposerLayout: View {
let isModelLoading: Bool
let isSubmitting: Bool
let isSubmitEnabled: Bool
/// Rendered as a non-blocking orange banner when no Mac connection is
/// live; `nil` while at least one Mac is connected.
let connectionWarningText: String?
let failureTitle: String
let failureText: String?
let completedOperationRecovery: TaskComposerCompletedOperationRecovery?
Expand Down Expand Up @@ -116,6 +119,11 @@ struct TaskComposerLayout: View {

private var accessoryBar: some View {
VStack(spacing: 10) {
if let connectionWarningText {
TaskComposerConnectionWarningBanner(message: connectionWarningText)
.padding(.horizontal, 16)
}

if failureText != nil || completedOperationRecovery != nil {
TaskComposerFailureRecoveryContent(
isSubmitting: isSubmitting,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,7 @@ struct TaskComposerSheet: View {
&& !workspaceGroupSelectionNeedsInventory
&& !workspaceGroupSelectionRequiresResolution
&& blockingCompletedOperationRecovery == nil,
connectionWarningText: connectionWarningText,
failureTitle: failureTitleStyle.title,
failureText: failureText,
completedOperationRecovery: blockingCompletedOperationRecovery,
Expand Down Expand Up @@ -551,6 +552,18 @@ struct TaskComposerSheet: View {
availableMachines ?? store.displayPairedMacs
}

/// The "No Mac is connected" notice. The entrypoint no longer hides while
/// offline, so the composer itself must say why a task cannot start yet.
/// The accessibility harness injects deterministic machines without live
/// sessions, so injected machines suppress the warning.
private var connectionWarningText: String? {
guard availableMachines == nil, !store.hasAnyConnectedMac else { return nil }
return L10n.string(
"mobile.taskComposer.warning.noConnectedMac",
defaultValue: "No Mac is connected. Open cmux on a Mac to start this task."
)
}

private var workspaceGroups: [MobileWorkspaceGroupPreview] {
guard canSelectWorkspaceGroup else { return [] }
return availableWorkspaceGroups ?? store.workspaceGroups
Expand Down
17 changes: 17 additions & 0 deletions ios/cmux/Resources/Localizable.xcstrings
Original file line number Diff line number Diff line change
Expand Up @@ -13294,6 +13294,23 @@
}
}
},
"mobile.taskComposer.warning.noConnectedMac": {
"extractionState": "manual",
"localizations": {
"en": {
"stringUnit": {
"state": "translated",
"value": "No Mac is connected. Open cmux on a Mac to start this task."
}
},
"ja": {
"stringUnit": {
"state": "translated",
"value": "接続されているMacがありません。タスクを開始するには、Macでcmuxを開いてください。"
}
}
}
},
"mobile.taskComposer.workspace": {
"extractionState": "manual",
"localizations": {
Expand Down