Skip to content

Commit b2282c1

Browse files
klopez4212Terp
andcommitted
fix(mobile): keep saved Solo retries available outside discovery
Allow locked retries to return their saved agent to Flutter for authoritative ownership revalidation. Keep inventory membership required for new chats and cover both native button and submit gates across inventory refreshes. Co-authored-by: Terp <5856f6900e8e0a4e0ea1f4f8d2ee33e4753d2119bc122f94ecafc660b46c0511@buzz.block.builderlab.xyz> Signed-off-by: kenny lopez <[email protected]>
1 parent e66bfab commit b2282c1

2 files changed

Lines changed: 25 additions & 4 deletions

File tree

‎mobile/ios/NativeControlTests/MeAgentAccessibilityTests.swift‎

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ struct MeAgentAccessibilityTests {
66
@MainActor static func main() {
77
for locked in [false, true] {
88
for empty in [false, true] {
9+
var submitted: [String: String]?
910
let controller = NativeProfileTextEditorViewController(
1011
title: "New chat", initialValue: "Chat", placeholder: "Chat name",
1112
multiline: false, pageBackgroundColor: .systemGroupedBackground,
@@ -14,8 +15,8 @@ struct MeAgentAccessibilityTests {
1415
channelDescription: nil, originalName: nil, originalDescription: nil,
1516
canEditDetails: true, canEditCanvas: false, canvasContent: "",
1617
canvasLoaded: false,
17-
chatOptions: ["presentationId": "test", "assistantsLoading": empty, "fieldsLocked": locked, "assistants": empty ? [] : [["id": "agent", "name": "Agent"]]],
18-
onCancel: {}, onSet: { _ in }
18+
chatOptions: ["selectedAssistant": "agent", "presentationId": "test", "assistantsLoading": empty, "fieldsLocked": locked, "assistants": empty ? [] : [["id": "agent", "name": "Agent"]]],
19+
onCancel: {}, onSet: { submitted = $0 as? [String: String] }
1920
)
2021
controller.loadViewIfNeeded()
2122
precondition(controller.numberOfSections(in: controller.tableView) == 3)
@@ -31,6 +32,11 @@ struct MeAgentAccessibilityTests {
3132
precondition(cell.accessibilityTraits.contains(.notEnabled) == disabled)
3233
precondition(cell.accessibilityTraits.contains(.button) == !disabled)
3334
precondition((cell.selectionStyle == .none) == disabled)
35+
let canSubmit = locked || !empty
36+
precondition(controller.navigationItem.rightBarButtonItem?.isEnabled == canSubmit)
37+
// Invoke the action even when disabled to check its independent gate.
38+
_ = controller.perform(NSSelectorFromString("setTapped"))
39+
precondition(submitted?["assistant"] == (canSubmit ? "agent" : nil))
3440
if empty && !locked {
3541
controller.tableView.frame = CGRect(x: 0, y: 0, width: 390, height: 844)
3642
controller.tableView.reloadData()
@@ -47,6 +53,14 @@ struct MeAgentAccessibilityTests {
4753
precondition(!updated.accessibilityTraits.contains(.notEnabled))
4854
precondition(controller.tableView(controller.tableView, titleForFooterInSection: 2) == nil)
4955
}
56+
submitted = nil
57+
controller.updateChatAssistants([
58+
"presentationId": "test",
59+
"assistants": empty ? [] : [["id": "agent", "name": "Agent"]],
60+
])
61+
precondition(controller.navigationItem.rightBarButtonItem?.isEnabled == canSubmit)
62+
_ = controller.perform(NSSelectorFromString("setTapped"))
63+
precondition(submitted?["assistant"] == (canSubmit ? "agent" : nil))
5064
}
5165
}
5266
avatarTests()

‎mobile/ios/Runner/NativeProfileTextEditor.swift‎

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -449,13 +449,20 @@ private final class NativeProfileTextEditorViewController:
449449
updateNavigation()
450450
}
451451

452+
// A durable retry keeps its saved recipient even if discovery hides it.
453+
// Flutter revalidates ownership before any creation writes.
454+
private var canSubmitAssistant: Bool {
455+
guard let selectedAssistant else { return false }
456+
return fieldsLocked || assistants.contains { $0["id"] == selectedAssistant }
457+
}
458+
452459
private func updateNavigation() {
453460
navigationItem.rightBarButtonItem?.isEnabled = canEditDetails && hasUnsavedChanges
454461
&& (!isChannelEditor || !canonicalChannelName.isEmpty)
455462
&& (!isChatEditor || (
456463
!currentValue.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty
457464
&& currentValue.count <= 120
458-
&& (isProjectEditor || assistants.contains { $0["id"] == selectedAssistant })
465+
&& (isProjectEditor || canSubmitAssistant)
459466
))
460467
navigationController?.isModalInPresentation = hasUnsavedChanges
461468
placeholderLabel.isHidden = !textView.text.isEmpty
@@ -497,7 +504,7 @@ private final class NativeProfileTextEditorViewController:
497504
onSet(name)
498505
} else if isChatEditor {
499506
guard let selectedAssistant,
500-
assistants.contains(where: { $0["id"] == selectedAssistant }),
507+
canSubmitAssistant,
501508
!currentValue.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty,
502509
currentValue.count <= 120 else { return }
503510
onSet(["name": currentValue, "assistant": selectedAssistant, "project": selectedProject ?? ""])

0 commit comments

Comments
 (0)