Open source Grok Bot alternative, Bring your own agent and subscription: message Claude Code, Codex, Gemini CLI, Cursor, Copilot and 40+ AI agents as bots on your own computer, from iPhone, Mac, Windows, Linux or terminal. Agent-agnostic and free. Also a Muse and Dots alternative. Built in Rust.
Rust acpagent-client-protocolai-agentsai-assistantclaudeclaude-codecodexcoding-agentscursorgeminigemini-cligrok-bot-alternativeiosiphonelinuxmacosmcpopen-sourcerustself-hosted
test(ios): check notification routing at completion
Sean Ferguson1a0276e9d6aa
diff --git a/apps/tests/notification_response.py b/apps/tests/notification_response.pyindex 3cdf9a61..ae08579f 100644--- a/apps/tests/notification_response.py+++ b/apps/tests/notification_response.py@@ -17,6 +17,7 @@ HEADER = r"""#import <Foundation/Foundation.h>NS_ASSUME_NONNULL_BEGINvoid InvokeNotification(id delegate, NSDictionary<NSString *, NSString *> *info,+ NSString * _Nullable malformedField,void (^completion)(void));NS_ASSUME_NONNULL_END"""@@ -40,9 +41,12 @@ OBJC = r"""@endvoid InvokeNotification(id delegate, NSDictionary<NSString *, NSString *> *info,+ NSString *malformedField,void (^completion)(void)) {UNMutableNotificationContent *content = [UNMutableNotificationContent new];- content.userInfo = info;+ NSMutableDictionary *payload = [info mutableCopy];+ if (malformedField) { payload[malformedField] = @42; }+ content.userInfo = payload;FixtureNotification *notification = [FixtureNotification new];notification.request = [UNNotificationRequest requestWithIdentifier:@"fixture"content:content trigger:nil];@@ -59,7 +63,7 @@ SWIFT = r"""import Foundationimport UserNotifications-struct BotReference: Equatable {+struct BotReference: Equatable, Sendable {let accountId: String?let computerId: Stringlet botId: String@@ -80,55 +84,70 @@ struct BotReference: Equatable {@MainActor final class AppDelegate: NSObject, UNUserNotificationCenterDelegate {__METHOD__}+struct Completion: Equatable, Sendable {+ let main: Bool+ let routed: Bool+}actor CompletionRecord {- private var threads: [Bool] = []- func record(main: Bool) { threads.append(main) }- func snapshot() -> [Bool] { threads }+ private var completions: [Completion] = []+ func record(_ completion: Completion) { completions.append(completion) }+ func snapshot() -> [Completion] { completions }}@MainActor enum Runner {static var finished = falsestatic var failures = 0static func check() async {- let cases: [(String, [String: String], Bool)] = [- ("valid", ["ctx": "active", "computerId": "known", "botId": "bot"], true),- ("empty payload", [:], false),- ("missing account", ["computerId": "known", "botId": "bot"], false),- ("missing computer", ["ctx": "active", "botId": "bot"], false),- ("missing bot", ["ctx": "active", "computerId": "known"], false),- ("different account", ["ctx": "other", "computerId": "known", "botId": "bot"], false),- ("removed computer", ["ctx": "active", "computerId": "removed", "botId": "bot"], false),+ let valid = ["ctx": "active", "computerId": "known", "botId": "bot"]+ let cases: [(String, [String: String], String?, Bool)] = [+ ("valid", valid, nil, true),+ ("empty payload", [:], nil, false),+ ("missing account", ["computerId": "known", "botId": "bot"], nil, false),+ ("missing computer", ["ctx": "active", "botId": "bot"], nil, false),+ ("missing bot", ["ctx": "active", "computerId": "known"], nil, false),+ ("different account", ["ctx": "other", "computerId": "known", "botId": "bot"], nil, false),+ ("removed computer", ["ctx": "active", "computerId": "removed", "botId": "bot"], nil, false),+ ("wrong account type", valid, "ctx", false),+ ("wrong computer type", valid, "computerId", false),+ ("wrong bot type", valid, "botId", false),]for background in [false, true] {- for (name, info, opens) in cases {+ for (name, info, malformedField, opens) in cases {let app = AppStore.sharedapp.tab = .state- app.accounts.selection = nil+ let previous = BotReference(accountId: "account", computerId: "known", botId: "previous")+ app.accounts.selection = previous+ let expected = opens ? BotReference(accountId: "account", computerId: "known", botId: "bot") : previouslet delegate = AppDelegate()let record = CompletionRecord()let completion: @Sendable () -> Void = {let main = Thread.isMainThread- Task { await record.record(main: main) }+ // Inspect the route inside the callback, before UIKit could+ // archive it, rather than after other work has run.+ let routed = main && MainActor.assumeIsolated {+ let app = AppStore.shared+ return app.accounts.selection == expected && app.tab == (opens ? .bots : .state)+ }+ Task { await record.record(Completion(main: main, routed: routed)) }}if background {- let invocation = Task.detached { InvokeNotification(delegate, info, completion) }+ let invocation = Task.detached { InvokeNotification(delegate, info, malformedField, completion) }await invocation.value} else {- InvokeNotification(delegate, info, completion)+ InvokeNotification(delegate, info, malformedField, completion)}- var threads: [Bool] = []+ var completions: [Completion] = []for _ in 0..<200 {- threads = await record.snapshot()- if !threads.isEmpty { break }+ completions = await record.snapshot()+ if !completions.isEmpty { break }try? await Task.sleep(for: .milliseconds(10))}try? await Task.sleep(for: .milliseconds(20))- threads = await record.snapshot()- let expected = opens ? BotReference(accountId: "account", computerId: "known", botId: "bot") : nil+ completions = await record.snapshot()let routeCorrect = app.accounts.selection == expected && app.tab == (opens ? .bots : .state)- let passed = threads == [true] && routeCorrect+ let passed = completions == [Completion(main: true, routed: true)] && routeCorrectif !passed { failures += 1 }- print("\(passed ? "PASS" : "FAIL") \(background ? "background" : "main") entry, \(name): completions=\(threads.count), main=\(threads), routing=\(routeCorrect)")+ print("\(passed ? "PASS" : "FAIL") \(background ? "background" : "main") entry, \(name): completions=\(completions.count), main=\(completions.map(\.main)), routedBeforeCompletion=\(completions.map(\.routed)), routing=\(routeCorrect)")}}finished = true