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
feat(ios): show the bot's avatar on notification banners
leepokai98db4362abd4
diff --git a/apps/ios/NotificationService/NotificationService.swift b/apps/ios/NotificationService/NotificationService.swiftindex 2ad9d850..8b56ea60 100644--- a/apps/ios/NotificationService/NotificationService.swift+++ b/apps/ios/NotificationService/NotificationService.swift@@ -1,4 +1,6 @@import CodyncKit+import Intents+import SwiftUIimport UserNotificationsimport os@@ -7,8 +9,7 @@ import osfinal class NotificationService: UNNotificationServiceExtension {override func didReceive(_ request: UNNotificationRequest, withContentHandler contentHandler: @escaping (UNNotificationContent) -> Void) {let info = request.content.userInfo- guard let content = request.content.mutableCopy() as? UNMutableNotificationContent,- let sealed = info["sealed"] as? String,+ guard let sealed = info["sealed"] as? String,let computerId = info["computerId"] as? String,let ctx = info["ctx"] as? String,let alert = DeviceIdentity.openPush(sealed: sealed, computerId: computerId, contextID: ctx) else {@@ -17,9 +18,74 @@ final class NotificationService: UNNotificationServiceExtension {contentHandler(request.content)return}+ guard let content = request.content.mutableCopy() as? UNMutableNotificationContent else {+ contentHandler(request.content)+ return+ }content.title = alert.titlecontent.subtitle = alert.subtitle ?? ""content.body = alert.body- contentHandler(content)+ contentHandler(Self.fromBot(content, alert: alert, botId: info["botId"] as? String, computerId: computerId, ctx: ctx))+ }++ /// A communication notification shows the bot's face in place of the app icon; a group+ /// message shows the group's face with the speaking member's on it. Without the bot in this+ /// account's snapshot (or if the system refuses), the plain notification stays.+ private static func fromBot(_ content: UNMutableNotificationContent, alert: PushAlert, botId: String?, computerId: String, ctx: String) -> UNNotificationContent {+ let store = SharedStore.activeContext+ guard let botId, store.id == ctx else { return content }+ let bots = store.bots.filter { $0.computerId == computerId }.map(\.bot)+ guard let chat = bots.first(where: { $0.id == botId }) else { return content }+ let members = bots.filter { chat.members.contains($0.id) }+ let conversation = "\(computerId)/\(chat.id)"++ let intent: INSendMessageIntent+ if chat.isGroup, let speaker = bots.first(where: { $0.id == alert.from }) {+ // Two or more recipients make iOS lay it out as a group conversation.+ let me = INPerson(personHandle: INPersonHandle(value: "me", type: .unknown), nameComponents: nil,+ displayName: nil, image: nil, contactIdentifier: nil, customIdentifier: nil, isMe: true)+ let others = members.filter { $0.id != speaker.id }.map { person($0, computerId: computerId, image: nil) }+ intent = INSendMessageIntent(recipients: [me] + others, outgoingMessageType: .outgoingMessageText, content: content.body,+ speakableGroupName: INSpeakableString(spokenPhrase: chat.name), conversationIdentifier: conversation,+ serviceName: nil, sender: person(speaker, computerId: computerId, image: avatar(speaker, members: [])), attachments: nil)+ if let face = avatar(chat, members: members) { intent.setImage(face, forParameterNamed: \.speakableGroupName) }+ } else {+ intent = INSendMessageIntent(recipients: nil, outgoingMessageType: .outgoingMessageText, content: content.body,+ speakableGroupName: nil, conversationIdentifier: conversation,+ serviceName: nil, sender: person(chat, computerId: computerId, image: avatar(chat, members: members)), attachments: nil)+ }+ let interaction = INInteraction(intent: intent, response: nil)+ interaction.direction = .incoming+ interaction.donate(completion: nil)+ return (try? content.updating(from: intent)) ?? content+ }++ private static func person(_ bot: Bot, computerId: String, image: INImage?) -> INPerson {+ INPerson(personHandle: INPersonHandle(value: "\(computerId)/\(bot.id)", type: .unknown), nameComponents: nil,+ displayName: bot.name, image: image, contactIdentifier: nil, customIdentifier: bot.id)+ }++ /// The bot's avatar, dark like the app icon. SwiftUI draws on the main thread,+ /// and the extension may be called on another one.+ private static func avatar(_ bot: Bot, members: [Bot]) -> INImage? {+ let png = Thread.isMainThread+ ? MainActor.assumeIsolated { render(bot, members: members) }+ : DispatchQueue.main.sync { MainActor.assumeIsolated { render(bot, members: members) } }+ return png.map { INImage(imageData: $0) }+ }++ @MainActor private static func render(_ bot: Bot, members: [Bot]) -> Data? {+ let face = Group {+ if bot.isGroup { GroupAvatar(members: members, size: 88, animated: false) }+ else { CharacterAvatar(bot: bot, size: 88, animated: false) }+ }+ .padding(20)+ .background(Palette.background)+ .environment(\.colorScheme, .dark)+ let renderer = ImageRenderer(content: face)+ renderer.scale = 2+ var png: Data?+ UITraitCollection(userInterfaceStyle: .dark).performAsCurrent { png = renderer.uiImage?.pngData() }+ return png}}diff --git a/apps/ios/Resources/Info.plist b/apps/ios/Resources/Info.plistindex b95a9797..d612e3d5 100644--- a/apps/ios/Resources/Info.plist+++ b/apps/ios/Resources/Info.plist@@ -16,6 +16,10 @@</array></dict></array>+ <key>NSUserActivityTypes</key>+ <array>+ <string>INSendMessageIntent</string>+ </array><key>UIBackgroundModes</key><array><string>audio</string>diff --git a/apps/ios/Resources/iOS.entitlements b/apps/ios/Resources/iOS.entitlementsindex 17fa6661..80ae842f 100644--- a/apps/ios/Resources/iOS.entitlements+++ b/apps/ios/Resources/iOS.entitlements@@ -4,6 +4,8 @@<dict><key>aps-environment</key><string>development</string>+ <key>com.apple.developer.usernotifications.communication</key>+ <true/><key>com.apple.security.application-groups</key><array><string>group.com.pokai.Codync</string>diff --git a/docs/design/push-and-live-activity.md b/docs/design/push-and-live-activity.mdindex d418e74a..f37c01c5 100644--- a/docs/design/push-and-live-activity.md+++ b/docs/design/push-and-live-activity.md@@ -35,6 +35,7 @@ flowchart LR- `relay/` holds the APNs signing key, opens opaque tickets and selects the APNs environment/topic. It has no notification decryption key.- `cloud/` handles accounts and the encrypted connection. It is a separate service from the APNs Worker; no new Durable Object or D1 table is needed for this change.- The notification extension decrypts the title, optional subtitle and body using the account context's shared Keychain key. This is local work and does not require a network fetch. [Apple notification content modification](https://developer.apple.com/documentation/usernotifications/modifying-content-in-newly-delivered-notifications)+- The extension then turns the alert into a communication notification (`INSendMessageIntent`) so the banner shows the bot's avatar instead of the app icon. A group alert carries the speaking member (`from`, sealed with the text) and shows as a group conversation: the group's avatar and name, with the member as sender. The avatar is drawn locally from the widget snapshot in the App Group (shape and color only); a bot missing from the active account's snapshot keeps the plain banner. Needs the app's Communication Notifications entitlement and `NSUserActivityTypes: INSendMessageIntent`. [Apple communication notifications](https://developer.apple.com/documentation/usernotifications/implementing-communication-notifications)- ActivityKit renders both Lock Screen and Dynamic Island. A separate Dynamic Island Worker or event API is unnecessary. APNs updates use a dedicated activity token, not the normal notification token. [Apple ActivityKit push updates](https://developer.apple.com/documentation/ActivityKit/starting-and-updating-live-activities-with-activitykit-push-notifications)Remote activity content contains only `status`, empty `activity`, and `startedAt`. Foreground app updates may show the current step from the encrypted connection; a remote update clears that free text. The notification service extension is not an ActivityKit decryption stage. The UI therefore does not promise private task summaries in background Live Activities. Bot identity and its deep link are set locally when starting the activity.diff --git a/host/src/agent/bot.rs b/host/src/agent/bot.rsindex 14f65f0d..43a054cc 100644--- a/host/src/agent/bot.rs+++ b/host/src/agent/bot.rs@@ -1124,6 +1124,7 @@ impl Actor {push::notify(&self.hub,&self.cfg,+ None,&self.cfg.name,&body,if failed { AlertKind::Failed } else { AlertKind::Done },@@ -1305,7 +1306,14 @@ impl Actor {});// Tapping it opens where the card is: the group, for a room turn.let target = self.hub.store.bot(&self.lane.chat).ok().flatten().map_or_else(|| self.cfg.clone(), |r| r.config);- push::notify(&self.hub, &target, &format!("{} needs you", self.cfg.name), &title, AlertKind::NeedsInput);+ push::notify(+ &self.hub,+ &target,+ Some(&self.cfg.id),+ &format!("{} needs you", self.cfg.name),+ &title,+ AlertKind::NeedsInput,+ );}async fn answer_permission(&mut self, entry_id: &str, option_id: Option<String>) {diff --git a/host/src/chat/group.rs b/host/src/chat/group.rsindex 382890e4..5f883c79 100644--- a/host/src/chat/group.rs+++ b/host/src/chat/group.rs@@ -118,7 +118,7 @@ pub fn start(hub: &Arc<Hub>, group: &BotConfig, lane: Lane) {async fn run(hub: &Arc<Hub>, group_id: &str, lane: &Lane, epoch: u64) -> Result<()> {let mut replies = 0;- let mut last_reply: Option<(String, String)> = None;+ let mut last_reply: Option<(String, String, String)> = None;for round in 0..MAX_ROUNDS {let group = hub.store.bot(group_id)?.filter(|r| !r.deleted).ok_or_else(|| anyhow!("group deleted"))?.config;let members = members(hub, &group);@@ -143,17 +143,17 @@ async fn run(hub: &Arc<Hub>, group_id: &str, lane: &Lane, epoch: u64) -> Result<if let Ok(Ok(Ok(Some(text)))) = tokio::time::timeout(crate::chat::team::ASK_TIMEOUT, answer).await {spoke += 1;replies += 1;- last_reply = Some((member.name.clone(), text));+ last_reply = Some((member.id.clone(), member.name.clone(), text));}}if spoke == 0 {break;}}- if let Some((name, text)) = last_reply+ if let Some((from, name, text)) = last_reply&& let Some(group) = hub.store.bot(group_id)?.map(|r| r.config){- push::notify(hub, &group, &format!("{name} in {}", group.name), &text, AlertKind::Done);+ push::notify(hub, &group, Some(&from), &format!("{name} in {}", group.name), &text, AlertKind::Done);}Ok(())}diff --git a/host/src/remote/push.rs b/host/src/remote/push.rsindex ad2821aa..56229372 100644--- a/host/src/remote/push.rs+++ b/host/src/remote/push.rs@@ -88,7 +88,8 @@ fn purge_dead_tickets(hub: &Hub) {}}-pub fn notify(hub: &Hub, bot: &BotConfig, title: &str, body: &str, kind: AlertKind) {+/// `bot` is the chat the alert opens; `from` is the member bot speaking when that chat is a group.+pub fn notify(hub: &Hub, bot: &BotConfig, from: Option<&str>, title: &str, body: &str, kind: AlertKind) {purge_dead_tickets(hub);if bot.notify == Some(false) || bot.hidden || hub.ios_connected() {return;@@ -108,9 +109,12 @@ pub fn notify(hub: &Hub, bot: &BotConfig, title: &str, body: &str, kind: AlertKiAlertKind::NeedsInput => "Response needed",AlertKind::Failed => "Task failed",};- let secret = json!({"title": crate::agent::acp::truncate(title, 80), "subtitle": subtitle,- "body": crate::agent::acp::truncate(body, 400)})- .to_string();+ let mut secret = json!({"title": crate::agent::acp::truncate(title, 80), "subtitle": subtitle,+ "body": crate::agent::acp::truncate(body, 400)});+ if let Some(from) = from.filter(|f| *f != bot.id) {+ secret["from"] = from.into();+ }+ let secret = secret.to_string();let computer_id = hub.identity.computer_id();let mut notifications = Vec::new();for t in hub.store.push_tickets() {diff --git a/host/src/routines/runner.rs b/host/src/routines/runner.rsindex 3bb0c6a7..7eb48e39 100644--- a/host/src/routines/runner.rs+++ b/host/src/routines/runner.rs@@ -176,6 +176,7 @@ impl Routines {crate::remote::push::notify(hub,&bot.config,+ None,&bot.config.name,data["text"].as_str().unwrap_or_default(),crate::remote::push::AlertKind::Done,diff --git a/kit/Sources/CodyncKit/Models/PushAlert.swift b/kit/Sources/CodyncKit/Models/PushAlert.swiftindex 8c821cf4..bc9d7e23 100644--- a/kit/Sources/CodyncKit/Models/PushAlert.swift+++ b/kit/Sources/CodyncKit/Models/PushAlert.swift@@ -5,4 +5,6 @@ public struct PushAlert: Decodable, Sendable {public let title: Stringpublic let subtitle: String?public let body: String+ /// The member bot speaking, when the alert is for a group chat.+ public let from: String?}diff --git a/kit/Tests/CodyncKitTests/PushAlertTests.swift b/kit/Tests/CodyncKitTests/PushAlertTests.swiftindex 6f779f20..46e27afa 100644--- a/kit/Tests/CodyncKitTests/PushAlertTests.swift+++ b/kit/Tests/CodyncKitTests/PushAlertTests.swift@@ -8,4 +8,7 @@ import Testing#expect(current.body == "All tests passed.")let olderHost = try JSONDecoder().decode(PushAlert.self, from: Data(#"{"title":"Reviewer","body":"All tests passed."}"#.utf8))#expect(olderHost.subtitle == nil)+ #expect(olderHost.from == nil)+ let group = try JSONDecoder().decode(PushAlert.self, from: Data(#"{"title":"Bob in Team","body":"Done.","from":"b"}"#.utf8))+ #expect(group.from == "b")}