From d61d049bdbcbf710c2f2b2fab6d9409c4ffad2ff Mon Sep 17 00:00:00 2001 From: Theo Browne Date: Sat, 1 Aug 2026 02:45:09 -0700 Subject: [PATCH] feat(ios): simplify mobile prompt controls --- apps/swift-ios/App/NativeFeatureClient.swift | 33 +++--- .../Features/Chat/FeatureComposerView.swift | 105 +----------------- .../Features/Root/FeatureRootModel.swift | 6 +- .../Features/Shared/FeatureModels.swift | 19 ++++ .../Features/Workspace/DailyUXModels.swift | 28 ++++- .../Features/Workspace/NewThreadView.swift | 12 +- .../Workspace/ProviderModelPicker.swift | 31 ++++-- .../DailyUXModelPickerTests.swift | 27 +++++ .../FeatureTests/DailyUXNewTaskTests.swift | 13 ++- .../NativeRetryIdentityTests.swift | 16 ++- 10 files changed, 135 insertions(+), 155 deletions(-) diff --git a/apps/swift-ios/App/NativeFeatureClient.swift b/apps/swift-ios/App/NativeFeatureClient.swift index 7afc439c32..20f82c448d 100644 --- a/apps/swift-ios/App/NativeFeatureClient.swift +++ b/apps/swift-ios/App/NativeFeatureClient.swift @@ -469,8 +469,8 @@ final class NativeFeatureClient: FeatureClient, FeatureDeviceManaging { providerName: providerDisplayName(model.instanceId), modelID: model.model, modelOptions: mapOptionSelections(model.options), - runtimeMode: runtimeMode, - interactionMode: interactionMode + runtimeMode: runtimeMode.mobileNormalized, + interactionMode: interactionMode.mobileNormalized ) } @@ -673,11 +673,13 @@ final class NativeFeatureClient: FeatureClient, FeatureDeviceManaging { } let model = selection.map(coreModelSelection) let uploads = try makeUploadAttachments(attachments) + let runtimeMode = coreRuntimeMode(mapRuntimeMode(shellThread.runtimeMode)) + let interactionMode = InteractionMode.default let signature = TurnSubmissionSignature( text: text, model: model, - runtimeMode: shellThread.runtimeMode, - interactionMode: shellThread.interactionMode, + runtimeMode: runtimeMode, + interactionMode: interactionMode, attachments: attachments ) let pending: PendingTurnSubmission @@ -696,8 +698,8 @@ final class NativeFeatureClient: FeatureClient, FeatureDeviceManaging { _ = try await client.sendTurn( threadID: route.wireID, text: text, - runtimeMode: shellThread.runtimeMode, - interactionMode: shellThread.interactionMode, + runtimeMode: runtimeMode, + interactionMode: interactionMode, model: model, attachments: uploads, commandID: pending.identity.commandID, @@ -2912,28 +2914,21 @@ final class NativeFeatureClient: FeatureClient, FeatureDeviceManaging { private func mapRuntimeMode(_ mode: RuntimeMode) -> FeatureRuntimeMode { switch mode { - case .approvalRequired: .approvalRequired - case .autoAcceptEdits: .autoAcceptEdits - case .auto: .automatic + case .approvalRequired, .autoAcceptEdits, .auto: .automatic case .fullAccess: .fullAccess } } private func coreRuntimeMode(_ mode: FeatureRuntimeMode) -> RuntimeMode { - switch mode { - case .approvalRequired: .approvalRequired - case .autoAcceptEdits: .autoAcceptEdits - case .automatic: .auto - case .fullAccess: .fullAccess - } + mode.mobileNormalized == .fullAccess ? .fullAccess : .auto } - private func mapInteractionMode(_ mode: InteractionMode) -> FeatureInteractionMode { - mode == .plan ? .plan : .standard + private func mapInteractionMode(_: InteractionMode) -> FeatureInteractionMode { + .standard } - private func coreInteractionMode(_ mode: FeatureInteractionMode) -> InteractionMode { - mode == .plan ? .plan : .default + private func coreInteractionMode(_: FeatureInteractionMode) -> InteractionMode { + .default } private func mapProviders(_ shell: OrchestrationShellSnapshot) -> [FeatureProvider] { diff --git a/apps/swift-ios/Features/Chat/FeatureComposerView.swift b/apps/swift-ios/Features/Chat/FeatureComposerView.swift index 8186928d33..c944276624 100644 --- a/apps/swift-ios/Features/Chat/FeatureComposerView.swift +++ b/apps/swift-ios/Features/Chat/FeatureComposerView.swift @@ -13,8 +13,6 @@ struct FeatureComposerView: View { private let isSending: Bool private let isWorking: Bool private let focused: FocusState.Binding - private let runtimeMode: FeatureRuntimeMode? - private let interactionMode: FeatureInteractionMode? private let contextUsage: Double? private let forceExpanded: Bool private let pendingApprovals: [FeatureApproval] @@ -22,8 +20,6 @@ struct FeatureComposerView: View { private let isResolvingRequest: Bool private let onSend: () -> Void private let onStop: () -> Void - private let onRuntimeModeChange: ((FeatureRuntimeMode) -> Void)? - private let onInteractionModeChange: ((FeatureInteractionMode) -> Void)? private let onApprovalDecision: ((String, FeatureApprovalDecision) -> Void)? private let onUserInputSubmit: ((String, [String: FeatureInputAnswer]) -> Void)? @@ -38,12 +34,8 @@ struct FeatureComposerView: View { focused: FocusState.Binding, onSend: @escaping () -> Void, onStop: @escaping () -> Void, - runtimeMode: FeatureRuntimeMode? = nil, - interactionMode: FeatureInteractionMode? = nil, contextUsage: Double? = nil, forceExpanded: Bool = false, - onRuntimeModeChange: ((FeatureRuntimeMode) -> Void)? = nil, - onInteractionModeChange: ((FeatureInteractionMode) -> Void)? = nil, pendingApprovals: [FeatureApproval] = [], pendingUserInputs: [FeatureUserInput] = [], isResolvingRequest: Bool = false, @@ -60,12 +52,8 @@ struct FeatureComposerView: View { self.focused = focused self.onSend = onSend self.onStop = onStop - self.runtimeMode = runtimeMode - self.interactionMode = interactionMode self.contextUsage = contextUsage self.forceExpanded = forceExpanded - self.onRuntimeModeChange = onRuntimeModeChange - self.onInteractionModeChange = onInteractionModeChange self.pendingApprovals = pendingApprovals self.pendingUserInputs = pendingUserInputs self.isResolvingRequest = isResolvingRequest @@ -220,16 +208,9 @@ struct FeatureComposerView: View { style: .compact, threadSelection: threadSelection ) - .frame(maxWidth: 156, alignment: .leading) + .frame(maxWidth: 220, alignment: .leading) .layoutPriority(2) - if runtimeMode != nil || interactionMode != nil { - modePicker( - runtimeMode: runtimeMode, - interactionMode: interactionMode - ) - } - Spacer(minLength: 0) if let contextUsage { @@ -244,67 +225,6 @@ struct FeatureComposerView: View { .padding(.bottom, 8) } - private func modePicker( - runtimeMode: FeatureRuntimeMode?, - interactionMode: FeatureInteractionMode? - ) -> some View { - Menu { - if let interactionMode, let onInteractionModeChange { - Section("Interaction") { - ForEach(FeatureInteractionMode.allCases, id: \.self) { mode in - Button { - onInteractionModeChange(mode) - } label: { - if mode == interactionMode { - Label(interactionModeLabel(mode), systemImage: "checkmark") - } else { - Text(interactionModeLabel(mode)) - } - } - } - } - } - if let runtimeMode, let onRuntimeModeChange { - Section("Access") { - ForEach(FeatureRuntimeMode.allCases, id: \.self) { mode in - Button { - onRuntimeModeChange(mode) - } label: { - if mode == runtimeMode { - Label(runtimeModeLabel(mode), systemImage: "checkmark") - } else { - Text(runtimeModeLabel(mode)) - } - } - } - } - } - } label: { - ViewThatFits(in: .horizontal) { - HStack(spacing: 6) { - Image(systemName: interactionMode == .plan ? "list.bullet.clipboard" : "lock") - Text(modeControlLabel(runtimeMode: runtimeMode, interactionMode: interactionMode)) - .lineLimit(1) - Image(systemName: "chevron.down") - .font(.system(size: 8, weight: .bold)) - } - - Image(systemName: "lock") - .frame(width: 30) - } - .font(T3Typography.supportingStrong) - .foregroundStyle(T3Colors.textSecondary) - .frame(minHeight: 30) - .contentShape(Rectangle()) - } - .buttonStyle(.plain) - .frame(maxWidth: 116) - .accessibilityLabel("Interaction and access mode") - .accessibilityValue( - modeControlLabel(runtimeMode: runtimeMode, interactionMode: interactionMode) - ) - } - private var submitButton: some View { Button(action: performPrimaryAction) { Group { @@ -377,29 +297,6 @@ struct FeatureComposerView: View { } } - private func runtimeModeLabel(_ mode: FeatureRuntimeMode) -> String { - switch mode { - case .approvalRequired: "Supervised" - case .autoAcceptEdits: "Auto-accept edits" - case .automatic: "Auto" - case .fullAccess: "Full access" - } - } - - private func interactionModeLabel(_ mode: FeatureInteractionMode) -> String { - switch mode { - case .standard: "Build" - case .plan: "Plan" - } - } - - private func modeControlLabel( - runtimeMode: FeatureRuntimeMode?, - interactionMode: FeatureInteractionMode? - ) -> String { - if interactionMode == .plan { return "Plan" } - return runtimeMode.map(runtimeModeLabel) ?? "Mode" - } } enum FeatureComposerSubmissionEligibility { diff --git a/apps/swift-ios/Features/Root/FeatureRootModel.swift b/apps/swift-ios/Features/Root/FeatureRootModel.swift index 5b351d8e2e..d52c5f0f91 100644 --- a/apps/swift-ios/Features/Root/FeatureRootModel.swift +++ b/apps/swift-ios/Features/Root/FeatureRootModel.swift @@ -140,8 +140,8 @@ public final class FeatureRootModel { projectID: request.projectID, prompt: prompt, selection: request.selection, - runtimeMode: request.runtimeMode, - interactionMode: request.interactionMode, + runtimeMode: request.runtimeMode.mobileNormalized, + interactionMode: request.interactionMode.mobileNormalized, attachments: request.attachments.map(\.upload) ) guard currentEnvironmentIdentity == environment else { @@ -199,6 +199,7 @@ public final class FeatureRootModel { } public func setRuntimeMode(_ id: String, mode: FeatureRuntimeMode) async { + let mode = mode.mobileNormalized let environment = currentEnvironmentIdentity await perform { try await client.setRuntimeMode(id: id, mode: mode) @@ -208,6 +209,7 @@ public final class FeatureRootModel { } public func setInteractionMode(_ id: String, mode: FeatureInteractionMode) async { + let mode = mode.mobileNormalized let environment = currentEnvironmentIdentity await perform { try await client.setInteractionMode(id: id, mode: mode) diff --git a/apps/swift-ios/Features/Shared/FeatureModels.swift b/apps/swift-ios/Features/Shared/FeatureModels.swift index 3396a6900e..924c29e9f6 100644 --- a/apps/swift-ios/Features/Shared/FeatureModels.swift +++ b/apps/swift-ios/Features/Shared/FeatureModels.swift @@ -98,11 +98,30 @@ public enum FeatureRuntimeMode: String, CaseIterable, Sendable, Codable { case autoAcceptEdits case automatic case fullAccess + + /// Mobile intentionally exposes the two modes that remain useful without + /// carrying the desktop's older approval-policy matrix into the composer. + public static let allCases: [FeatureRuntimeMode] = [.automatic, .fullAccess] + + public var mobileNormalized: FeatureRuntimeMode { + switch self { + case .approvalRequired, .autoAcceptEdits, .automatic: + .automatic + case .fullAccess: + .fullAccess + } + } } public enum FeatureInteractionMode: String, CaseIterable, Sendable, Codable { case standard case plan + + /// Plan remains decodable for existing server state, but is no longer a + /// mobile prompt choice. + public static let allCases: [FeatureInteractionMode] = [.standard] + + public var mobileNormalized: FeatureInteractionMode { .standard } } public struct FeatureThread: Identifiable, Sendable, Equatable, Hashable, Codable { diff --git a/apps/swift-ios/Features/Workspace/DailyUXModels.swift b/apps/swift-ios/Features/Workspace/DailyUXModels.swift index 24db39bb9b..2b4b9b7318 100644 --- a/apps/swift-ios/Features/Workspace/DailyUXModels.swift +++ b/apps/swift-ios/Features/Workspace/DailyUXModels.swift @@ -45,8 +45,8 @@ public struct NewTaskRequest: Sendable, Equatable { self.projectID = projectID self.prompt = prompt self.selection = selection - self.runtimeMode = runtimeMode - self.interactionMode = interactionMode + self.runtimeMode = runtimeMode.mobileNormalized + self.interactionMode = interactionMode.mobileNormalized self.attachments = attachments } @@ -589,6 +589,30 @@ enum DailyUXModelOptions { return labels.isEmpty ? nil : labels.joined(separator: " · ") } + /// The compact composer gives reasoning its own non-compressible label so + /// a long model name cannot hide the setting users change most often. + static func reasoningSummary( + for model: FeatureModel, + selections: [FeatureModelOptionSelection] + ) -> String? { + guard let descriptor = model.options.first(where: { descriptor in + let searchable = "\(descriptor.id) \(descriptor.label)".lowercased() + return searchable.contains("reason") + || searchable.contains("effort") + || searchable.contains("thinking") + || searchable.contains("thought") + }), let value = value(for: descriptor, in: selections) else { + return nil + } + + switch value { + case let .string(choiceID): + return descriptor.choices.first(where: { $0.id == choiceID })?.label + case let .boolean(isEnabled): + return isEnabled ? descriptor.label : nil + } + } + static func supportsImages( selection: FeatureSelection?, providers: [FeatureProvider] diff --git a/apps/swift-ios/Features/Workspace/NewThreadView.swift b/apps/swift-ios/Features/Workspace/NewThreadView.swift index 6e5e161689..d39229728b 100644 --- a/apps/swift-ios/Features/Workspace/NewThreadView.swift +++ b/apps/swift-ios/Features/Workspace/NewThreadView.swift @@ -9,8 +9,6 @@ public struct NewThreadView: View { @State private var projectID = "" @State private var prompt = "" @State private var selection: FeatureSelection? - @State private var runtimeMode: FeatureRuntimeMode = .fullAccess - @State private var interactionMode: FeatureInteractionMode = .standard @State private var attachments: [FeatureDraftAttachment] = [] @State private var isSubmitting = false @State private var submissionFailed = false @@ -49,11 +47,7 @@ public struct NewThreadView: View { focused: $promptFocused, onSend: startTask, onStop: {}, - runtimeMode: runtimeMode, - interactionMode: interactionMode, - forceExpanded: true, - onRuntimeModeChange: { runtimeMode = $0 }, - onInteractionModeChange: { interactionMode = $0 } + forceExpanded: true ) } .onAppear { @@ -198,8 +192,8 @@ public struct NewThreadView: View { projectID: projectID, prompt: trimmedPrompt, selection: selection, - runtimeMode: runtimeMode, - interactionMode: interactionMode, + runtimeMode: .fullAccess, + interactionMode: .standard, attachments: attachments ) diff --git a/apps/swift-ios/Features/Workspace/ProviderModelPicker.swift b/apps/swift-ios/Features/Workspace/ProviderModelPicker.swift index 03e24b2072..56a6a9bc9b 100644 --- a/apps/swift-ios/Features/Workspace/ProviderModelPicker.swift +++ b/apps/swift-ios/Features/Workspace/ProviderModelPicker.swift @@ -53,12 +53,20 @@ public struct ProviderModelPicker: View { } .contentShape(Rectangle()) case .compact: - HStack(spacing: 6) { + HStack(spacing: 5) { selectionMark(size: 14) - Text(compactSelectionLabel) + Text(compactModelName) .lineLimit(1) + .truncationMode(.middle) + if let compactReasoningLabel { + Text("· \(compactReasoningLabel)") + .lineLimit(1) + .fixedSize(horizontal: true, vertical: false) + .layoutPriority(2) + } Image(systemName: "chevron.up.chevron.down") .font(.system(size: 8, weight: .bold)) + .fixedSize() } .font(T3Typography.supportingStrong) .foregroundStyle(T3Colors.textSecondary) @@ -102,18 +110,19 @@ public struct ProviderModelPicker: View { return "\(base) · \(summary)" } - private var compactSelectionLabel: String { + private var compactModelName: String { guard let selectedOption else { return selection == nil ? "Automatic" : "Choose model" } - guard let selection, - let summary = DailyUXModelOptions.summary( - for: selectedOption.model, - selections: selection.options - ) else { - return selectedOption.model.name - } - return "\(selectedOption.model.name) · \(summary)" + return selectedOption.model.name + } + + private var compactReasoningLabel: String? { + guard let selectedOption, let selection else { return nil } + return DailyUXModelOptions.reasoningSummary( + for: selectedOption.model, + selections: selection.options + ) } @ViewBuilder diff --git a/apps/swift-ios/Tests/FeatureTests/DailyUXModelPickerTests.swift b/apps/swift-ios/Tests/FeatureTests/DailyUXModelPickerTests.swift index 2f5cb0c607..fa512a9b1f 100644 --- a/apps/swift-ios/Tests/FeatureTests/DailyUXModelPickerTests.swift +++ b/apps/swift-ios/Tests/FeatureTests/DailyUXModelPickerTests.swift @@ -151,6 +151,33 @@ struct DailyUXModelPickerTests { #expect(summary == "High · Fast") } + @Test + func compactReasoningSummaryIgnoresOtherModelOptions() { + let model = FeatureModel( + id: "gpt-5", + name: "A model name long enough to truncate", + options: [ + .init( + id: "reasoningEffort", + label: "Reasoning", + kind: .select, + choices: [.init(id: "xhigh", label: "Extra high")] + ), + .init(id: "fast", label: "Fast mode", kind: .boolean), + ] + ) + + let summary = DailyUXModelOptions.reasoningSummary( + for: model, + selections: [ + .init(id: "reasoningEffort", value: .string("xhigh")), + .init(id: "fast", value: .boolean(true)), + ] + ) + + #expect(summary == "Extra high") + } + @Test func preferredSelectionFindsDefaultAcrossProvidersAndIncludesDefaults() { let providers = [ diff --git a/apps/swift-ios/Tests/FeatureTests/DailyUXNewTaskTests.swift b/apps/swift-ios/Tests/FeatureTests/DailyUXNewTaskTests.swift index 28aa27f342..4d2f53aa2d 100644 --- a/apps/swift-ios/Tests/FeatureTests/DailyUXNewTaskTests.swift +++ b/apps/swift-ios/Tests/FeatureTests/DailyUXNewTaskTests.swift @@ -6,7 +6,7 @@ import UIKit @Suite("Message-first task creation") struct DailyUXNewTaskTests { @Test - func requestKeepsPromptModesAndImageBytesTogether() { + func requestNormalizesLegacyModesAndKeepsImageBytes() { let image = FeatureDraftAttachment( data: Data([1, 2, 3]), filename: "Image 1.jpg", @@ -16,16 +16,23 @@ struct DailyUXNewTaskTests { projectID: "project", prompt: " Build it \n", selection: FeatureSelection(providerID: "codex", modelID: "gpt-5"), - runtimeMode: .fullAccess, + runtimeMode: .approvalRequired, interactionMode: .plan, attachments: [image] ) #expect(request.trimmedPrompt == "Build it") - #expect(request.interactionMode == .plan) + #expect(request.runtimeMode == .automatic) + #expect(request.interactionMode == .standard) #expect(request.attachments.first?.byteCount == 3) } + @Test + func mobileModeChoicesOnlyExposeSupportedValues() { + #expect(FeatureRuntimeMode.allCases == [.automatic, .fullAccess]) + #expect(FeatureInteractionMode.allCases == [.standard]) + } + @Test func passiveProjectsKeepTheirOwnModelCatalogAndDefault() throws { let passiveDefault = FeatureSelection( diff --git a/apps/swift-ios/Tests/FeatureTests/NativeRetryIdentityTests.swift b/apps/swift-ios/Tests/FeatureTests/NativeRetryIdentityTests.swift index e4dd2420b5..c0919e731a 100644 --- a/apps/swift-ios/Tests/FeatureTests/NativeRetryIdentityTests.swift +++ b/apps/swift-ios/Tests/FeatureTests/NativeRetryIdentityTests.swift @@ -36,7 +36,9 @@ final class NativeRetryIdentityTests: XCTestCase { suiteName: "t3-native-retry-\(UUID().uuidString)" )! let client = NativeFeatureClient(runtime: runtime, settingsStore: settings) - _ = try await client.initialSnapshot() + let initial = try await client.initialSnapshot() + XCTAssertEqual(initial.threads.first?.runtimeMode, .automatic) + XCTAssertEqual(initial.threads.first?.interactionMode, .standard) await connection.waitUntilConnected() for _ in 0..<2 { @@ -56,8 +58,8 @@ final class NativeRetryIdentityTests: XCTestCase { projectID: "project-1", prompt: "Create exactly one task", selection: FeatureSelection(providerID: "codex", modelID: "gpt-5.4"), - runtimeMode: .fullAccess, - interactionMode: .standard, + runtimeMode: .autoAcceptEdits, + interactionMode: .plan, attachments: [] ) XCTFail("The synthetic bootstrap should fail ambiguously.") @@ -68,6 +70,10 @@ final class NativeRetryIdentityTests: XCTestCase { XCTAssertEqual(commands.count, 4) assertStableIdentity(commands[0], commands[1], includesThreadID: false) assertStableIdentity(commands[2], commands[3], includesThreadID: true) + for command in commands { + XCTAssertEqual(command["runtimeMode"]?.stringValue, "auto") + XCTAssertEqual(command["interactionMode"]?.stringValue, "default") + } await client.disconnect() } @@ -167,8 +173,8 @@ private func retryShellSnapshot() -> OrchestrationShellSnapshot { projectId: "project-1", title: "Existing", modelSelection: model, - runtimeMode: .fullAccess, - interactionMode: .default, + runtimeMode: .approvalRequired, + interactionMode: .plan, branch: nil, worktreePath: nil, latestTurn: nil,