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): simplify live activity and center the expanded island
leepokai165fee06668f
diff --git a/apps/ios/Views/ActivityGalleryView.swift b/apps/ios/Views/ActivityGalleryView.swiftindex 75f1513f..3f20b572 100644--- a/apps/ios/Views/ActivityGalleryView.swift+++ b/apps/ios/Views/ActivityGalleryView.swift@@ -12,7 +12,8 @@ struct ActivityGalleryView: View {@State private var allowed = ActivityAuthorizationInfo().areActivitiesEnabled@State private var form: BotActivityPreview.Form?@State private var phase = BotActivityPresentation.Phase.working- @State private var start = Date.now - 154++ private var island: Bool { !forms.contains(.lockScreen) }private var state: BotActivityPresentation {let status: String = switch phase {@@ -23,17 +24,19 @@ struct ActivityGalleryView: View {case .waiting: "unknown"}return .init(status: status, activity: phase == .needsInput ? "Review the proposed changes." : "Running the test suite.",- startedAt: start, isStale: phase == .stale)+ isStale: phase == .stale)}var body: some View {ScrollView {VStack(alignment: .leading, spacing: 24) {VStack(alignment: .leading, spacing: 10) {- Toggle("Show Live Activities", isOn: $enabled)+ Toggle(island ? "Show in Dynamic Island" : "Show Live Activities", isOn: $enabled).toggleStyle(.codync).font(.subheadline.weight(.medium))- Text("Starts when you send a task from this iPhone. Follow its progress, then open the conversation when your bot needs you.")+ Text(island+ ? "The Dynamic Island shows the same Live Activity as the Lock Screen, so this switch turns off both."+ : "Starts when you send a task from this iPhone. Follow its progress, then open the conversation when your bot needs you.").font(.footnote).foregroundStyle(Palette.secondary)if !allowed {Text("Live Activities are turned off in iOS Settings.")@@ -85,10 +88,10 @@ struct ActivityGalleryView: View {private func explanation(_ form: BotActivityPreview.Form) -> some View {let detail = switch form {- case .lockScreen: "A task card with the bot, current step and elapsed time. Tap it to return to the conversation."- case .compact: "The bot and timer appear beside the camera. The timer becomes a status icon when the task needs attention or ends."- case .minimal: "A small status icon when iOS displays multiple Live Activities."- case .expanded: "Touch and hold the Dynamic Island for the current step and a shortcut to the conversation."+ case .lockScreen: "The bot, its current step and a thinking orb. Tap it to return to the conversation."+ case .compact: "The bot and a thinking orb beside the camera. The orb becomes a check or warning when the task ends."+ case .minimal: "Just the orb when iOS displays multiple Live Activities."+ case .expanded: "Touch and hold the Dynamic Island for the current step. Tap to open the conversation."}return VStack(alignment: .leading, spacing: 4) {Text(form.rawValue).font(.subheadline.weight(.medium)).accessibilityAddTraits(.isHeader)diff --git a/apps/ios/Widgets/CodyncWidgets.swift b/apps/ios/Widgets/CodyncWidgets.swiftindex 44ae01ac..90552181 100644--- a/apps/ios/Widgets/CodyncWidgets.swift+++ b/apps/ios/Widgets/CodyncWidgets.swift@@ -364,26 +364,21 @@ struct BotLiveActivity: Widget {let state = presentation(context)return DynamicIsland {DynamicIslandExpandedRegion(.leading) {- HStack(spacing: 8) {- avatar(context, size: 26)- Text(context.attributes.name).font(.system(size: 14, weight: .semibold))- .foregroundStyle(.white).lineLimit(1)- }+ avatar(context, size: 26).frame(maxHeight: .infinity)}DynamicIslandExpandedRegion(.trailing) {- BotActivityIndicator(state: state).environment(\.colorScheme, .dark)+ BotActivityIndicator(state: state, size: 28).frame(maxHeight: .infinity)}- DynamicIslandExpandedRegion(.bottom) {- VStack(alignment: .leading, spacing: 10) {- BotActivityDetail(state: state)- if let link = context.attributes.link {- Link(destination: link) {- Label(state.phase == .needsInput ? "Respond in Codync" : "Open conversation", systemImage: "arrow.up.right")- .font(.system(size: 12, weight: .medium))- }- .tint(.white)- }+ // Centered under the camera, between the avatar and the orb, so nothing reaches+ // the island's 44 pt corners (HIG: concentric margins, wrap around the camera).+ DynamicIslandExpandedRegion(.center) {+ VStack(spacing: 2) {+ Text(context.attributes.name).font(.system(size: 14, weight: .semibold)).foregroundStyle(.white)+ Text(state.caption).font(.system(size: 12)).foregroundStyle(Palette.secondary)}+ .lineLimit(1)+ .multilineTextAlignment(.center)+ .frame(maxWidth: .infinity).environment(\.colorScheme, .dark)}} compactLeading: {@@ -391,7 +386,7 @@ struct BotLiveActivity: Widget {} compactTrailing: {BotActivityIndicator(state: state).environment(\.colorScheme, .dark)} minimal: {- BotActivityIndicator(state: state, minimal: true)+ BotActivityIndicator(state: state).environment(\.colorScheme, .dark).accessibilityLabel("\(context.attributes.name), \(state.title)")}@@ -400,8 +395,7 @@ struct BotLiveActivity: Widget {}private func presentation(_ context: ActivityViewContext<BotActivityAttributes>) -> BotActivityPresentation {- .init(status: context.state.status, activity: context.state.activity,- startedAt: context.state.startedAt, isStale: context.isStale)+ .init(status: context.state.status, activity: context.state.activity, isStale: context.isStale)}private func avatar(_ context: ActivityViewContext<BotActivityAttributes>, size: CGFloat) -> some View {diff --git a/docs/design/mobile-widgets.md b/docs/design/mobile-widgets.mdindex 1f6d611d..afa1143e 100644--- a/docs/design/mobile-widgets.md+++ b/docs/design/mobile-widgets.md@@ -51,21 +51,20 @@ State 分頁的 Live Activity 頁顯示鎖定畫面形式,Dynamic Island 頁| 形式 | 資訊與互動 || --- | --- |-| Lock Screen/橫幅 | bot 名稱、狀態、目前工作、執行時間;點擊回到對話 |-| Compact | 左側 bot、右側計時;需要回應/完成/錯誤時改為狀態圖示 |-| Minimal | 在更小空間顯示狀態圖示,VoiceOver 包含 bot 名稱 |-| Expanded | bot、狀態、工作摘要、回到對話的連結;需要回應時顯示 Respond in Codync |+| Lock Screen/橫幅 | bot 頭像與名稱、一行說明、右側 orb;點擊回到對話 |+| Compact | 左側 bot、右側 orb;完成/錯誤時改為勾號/警告符號 |+| Minimal | 只有 orb(或結束符號),VoiceOver 包含 bot 名稱 |+| Expanded | bot、一行說明、orb;整塊點擊回到對話,不另放連結文字 |實際形式由 iOS 根據裝置、活動數量與互動決定;App 內的形式選單只控制設計預覽。[Apple Live Activities 設計指南](https://developer.apple.com/design/human-interface-guidelines/live-activities)所有形式共用 `BotActivityPresentation` 的狀態判斷:-- Working:顯示目前工作,有開始時間才顯示計時。-- Needs you:顯示待回應提示;審批與文字回應在 App 處理。-- Done:完成勾號與查看結果提示。-- Failed:錯誤圖示,不會誤顯示成完成。-- Update delayed:ActivityKit 回報 stale 時顯示延遲提示,不繼續顯示即時計時。-- 未知狀態:保守顯示 Waiting for update,不宣稱任務完成。+- 狀態由 orb 表達,文字只有一行 `caption`:進行中是 bot 目前的步驟,沒有步驟或已結束時是狀態名稱。不顯示計時、固定說明句或連結文字。+- Working:working orb。+- Needs you:listening orb(琥珀色);審批與文字回應在 App 處理。+- Update delayed/未知狀態:connecting orb,不顯示舊步驟,不宣稱任務完成。+- Done/Failed:orb 是進行中的指示,結束後改為勾號/警告符號,錯誤不會誤顯示成完成。既有生命週期繼續由手機送出任務時啟動、App 接收事件時更新、完成時結束。App 本地更新設定 15 分鐘 stale date;沒有更新不代表工作失敗。遠端推播現在也設定 15 分鐘 stale date、保留錯誤結束狀態,並支援重新註冊活動票券;完整合約與通知設計見 [Notifications and Live Activities](push-and-live-activity.md)。關閉 Live Activities 會結束目前活動並阻止之後自動啟動。@@ -100,9 +99,9 @@ Bot 的角色頭像使用 `CharacterAvatar` 點陣;provider 圖示由 `Provide| Working/orbits | Bot 工作列、聊天工作提示、工具執行、一般安裝進度、Live Activity 工作狀態 || Searching/globe | 搜尋工具執行中 || Listening/wave | Bot 待回應列、聊天待回應、Live Activity/Dynamic Island Needs you |-| Connecting/web | 電腦連線提示、帳號登入、agent 登入狀態查詢、fetch 工具、Activity 等待更新 |+| Connecting/web | 電腦連線提示、帳號登入、agent 登入狀態查詢、fetch 工具、Activity 等待更新/更新延遲 |-角色頭像識別「哪一個 bot」;orb 表達「現在做什麼」。完成、錯誤、更新延遲繼續保留明確的勾號/錯誤/時鐘符號,導航及操作按鈕保留語意圖示。所有 orb 均附於可讀狀態文字或具備外層 accessibility label。+角色頭像識別「哪一個 bot」;orb 表達「現在做什麼」。完成、錯誤繼續保留明確的勾號/錯誤符號,導航及操作按鈕保留語意圖示。所有 orb 均附於可讀狀態文字或具備外層 accessibility label。實作採上游 0.3.1、commit `de85557ca220332586d070d8788c0e1d6e877a0d` 的幾何與 20/64 pt 預設值。小於 40 pt 使用精簡密度;其餘使用大尺寸密度。繪製端改用可套色的透明墨色,適配卡片、深淺色及 Dynamic Island。SwiftUI Canvas 不需要 WebView 或 JavaScript runtime。diff --git a/kit/Sources/CodyncKit/Design/ActivityCards.swift b/kit/Sources/CodyncKit/Design/ActivityCards.swiftindex 2c72d20b..170012b9 100644--- a/kit/Sources/CodyncKit/Design/ActivityCards.swift+++ b/kit/Sources/CodyncKit/Design/ActivityCards.swift@@ -5,8 +5,8 @@ public extension BotActivityPresentation {switch phase {case .working: .workingcase .needsInput: .listening- case .waiting: .connecting- case .completed, .failed, .stale: nil+ case .waiting, .stale: .connecting+ case .completed, .failed: nil}}@@ -40,85 +40,45 @@ public struct BotActivityCard: View {}public var body: some View {- VStack(alignment: .leading, spacing: 10) {- HStack(spacing: 10) {- CharacterAvatar(shape: shape, color: color, size: 32)- VStack(alignment: .leading, spacing: 2) {- Text(name).font(.system(size: 14, weight: .semibold)).foregroundStyle(Palette.text)- Text(state.title).font(.system(size: 11, weight: .medium)).foregroundStyle(state.tint)- }- .lineLimit(1)- Spacer(minLength: 8)- BotActivityIndicator(state: state)- }- Text(state.detail).font(.system(size: 12)).foregroundStyle(Palette.secondary)- .lineLimit(2).fixedSize(horizontal: false, vertical: true)- if state.phase == .working, let started = state.startedAt {- HStack(spacing: 6) {- Image(systemName: "clock")- Text(started, style: .timer).monospacedDigit()- Text("elapsed")- }- .font(.system(size: 10, weight: .medium))- .foregroundStyle(Palette.tertiary)+ HStack(spacing: 12) {+ CharacterAvatar(shape: shape, color: color, size: 32)+ VStack(alignment: .leading, spacing: 2) {+ Text(name).font(.system(size: 14, weight: .semibold)).foregroundStyle(Palette.text)+ Text(state.caption).font(.system(size: 12)).foregroundStyle(Palette.secondary)}+ .lineLimit(1)+ Spacer(minLength: 8)+ BotActivityIndicator(state: state, size: 28)}.padding(16).accessibilityElement(children: .combine)+ .accessibilityLabel("\(name), \(state.title). \(state.caption)")}}-/// Compact trailing / minimal: errors and delayed updates never look complete.+/// The state mark: a thinking orb while the task is live, a symbol once it has ended+/// (errors and delayed updates never look complete).public struct BotActivityIndicator: View {let state: BotActivityPresentation- let minimal: Bool+ let size: CGFloat- public init(state: BotActivityPresentation, minimal: Bool = false) {+ public init(state: BotActivityPresentation, size: CGFloat = 20) {self.state = state- self.minimal = minimal+ self.size = size}public var body: some View {Group {- if !minimal, state.showsTimer, let started = state.startedAt {- Text(started, style: .timer).monospacedDigit()- .font(.system(size: 12, weight: .medium))- .multilineTextAlignment(.trailing).frame(width: 46)- .minimumScaleFactor(0.7)- } else if let orb = state.orbState {- ThinkingOrb(state: orb, size: minimal ? 22 : 20, color: state.tint, animated: false)- .accessibilityHidden(false).accessibilityLabel(state.title)+ if let orb = state.orbState {+ ThinkingOrb(state: orb, size: size, color: state.tint, animated: false)} else {- Image(systemName: state.symbol).font(.system(size: 13, weight: .semibold))- .accessibilityLabel(state.title)+ Image(systemName: state.symbol).font(.system(size: size * 0.6, weight: .semibold))}}+ .frame(width: size, height: size).foregroundStyle(state.tint)- }-}--/// The content below the camera in the expanded Dynamic Island.-public struct BotActivityDetail: View {- let state: BotActivityPresentation- public init(state: BotActivityPresentation) { self.state = state }-- public var body: some View {- VStack(alignment: .leading, spacing: 5) {- Label {- Text(state.title)- } icon: {- if let orb = state.orbState {- ThinkingOrb(state: orb, size: 16, color: state.tint, animated: false)- } else {- Image(systemName: state.symbol)- }- }- .font(.system(size: 11, weight: .semibold)).foregroundStyle(state.tint)- Text(state.detail).font(.system(size: 12)).foregroundStyle(Palette.secondary)- .lineLimit(2)- }- .frame(maxWidth: .infinity, alignment: .leading)- .accessibilityElement(children: .combine)+ .accessibilityElement()+ .accessibilityLabel(state.title)}}@@ -160,19 +120,18 @@ public struct BotActivityPreview: View {.padding(.horizontal, 12).frame(width: 210, height: 38).background(.black, in: Capsule())case .minimal:- BotActivityIndicator(state: state, minimal: true)+ BotActivityIndicator(state: state).frame(width: 38, height: 38).background(.black, in: Circle())case .expanded:- VStack(alignment: .leading, spacing: 12) {- HStack(spacing: 8) {- CharacterAvatar(bot: bot, size: 26, animated: false)- Text(bot.name).font(.system(size: 14, weight: .semibold)).foregroundStyle(.white).lineLimit(1)- Spacer()- BotActivityIndicator(state: state)+ HStack(spacing: 10) {+ CharacterAvatar(bot: bot, size: 26, animated: false)+ VStack(spacing: 2) {+ Text(bot.name).font(.system(size: 14, weight: .semibold)).foregroundStyle(.white)+ Text(state.caption).font(.system(size: 12)).foregroundStyle(Palette.secondary)}- BotActivityDetail(state: state)- Text(state.phase == .needsInput ? "Respond in Codync ↗" : "Open conversation ↗")- .font(.system(size: 12, weight: .medium)).foregroundStyle(.white)+ .lineLimit(1)+ .frame(maxWidth: .infinity)+ BotActivityIndicator(state: state, size: 28)}.padding(18).background(.black, in: RoundedRectangle(cornerRadius: 28))case .lockScreen: EmptyView()diff --git a/kit/Sources/CodyncKit/Models/BotActivityPresentation.swift b/kit/Sources/CodyncKit/Models/BotActivityPresentation.swiftindex e8a11048..6ce4ffad 100644--- a/kit/Sources/CodyncKit/Models/BotActivityPresentation.swift+++ b/kit/Sources/CodyncKit/Models/BotActivityPresentation.swift@@ -8,9 +8,8 @@ public struct BotActivityPresentation: Hashable, Sendable {public let phase: Phasepublic let activity: String- public let startedAt: Date?- public init(status: String, activity: String, startedAt: Date?, isStale: Bool = false) {+ public init(status: String, activity: String, isStale: Bool = false) {let phase: Phase = switch status {case "working": .workingcase "needsInput": .needsInput@@ -20,7 +19,6 @@ public struct BotActivityPresentation: Hashable, Sendable {}self.phase = isStale && (phase == .working || phase == .needsInput) ? .stale : phaseself.activity = activity- self.startedAt = startedAt}public var title: String {@@ -34,26 +32,19 @@ public struct BotActivityPresentation: Hashable, Sendable {}}- public var detail: String {+ /// The one line of text beside the orb: the bot's current step while it's live, else the state.+ public var caption: String {switch phase {- case .stale: "Open Codync to check the latest status."- case .waiting: "Open Codync to check this task."- case .completed: "Your bot has finished. Open the conversation for the result."- case .failed: "The task stopped with an error. Open the conversation for details."- case .needsInput: activity.isEmpty ? "Open the conversation to respond." : activity- case .working: activity.isEmpty ? "Your bot is working on the computer." : activity+ case .working, .needsInput: activity.isEmpty ? title : activity+ case .completed, .failed, .stale, .waiting: title}}public var symbol: String {switch phase {- case .working: "ellipsis"- case .needsInput: "hand.raised.fill"case .completed: "checkmark"case .failed: "exclamationmark.triangle.fill"- case .stale, .waiting: "clock.badge.questionmark"+ case .working, .needsInput, .stale, .waiting: "ellipsis"}}-- public var showsTimer: Bool { phase == .working && startedAt != nil }}diff --git a/kit/Tests/CodyncKitTests/ActivityPresentationTests.swift b/kit/Tests/CodyncKitTests/ActivityPresentationTests.swiftindex 9b4a339e..faa168ac 100644--- a/kit/Tests/CodyncKitTests/ActivityPresentationTests.swift+++ b/kit/Tests/CodyncKitTests/ActivityPresentationTests.swift@@ -3,33 +3,28 @@ import Testing@testable import CodyncKit@Test func activityErrorAndUnknownStatusNeverLookCompleted() {- let error = BotActivityPresentation(status: "error", activity: "", startedAt: .now)+ let error = BotActivityPresentation(status: "error", activity: "")#expect(error.phase == .failed)#expect(error.title == "Failed")#expect(error.symbol != "checkmark")- #expect(!error.showsTimer)- let unknown = BotActivityPresentation(status: "new-host-status", activity: "", startedAt: .now)+ let unknown = BotActivityPresentation(status: "new-host-status", activity: "")#expect(unknown.phase == .waiting)#expect(unknown.symbol != "checkmark")}@Test func staleActivityStopsPresentingLiveProgress() {for status in ["working", "needsInput"] {- let stale = BotActivityPresentation(status: status, activity: "Old step", startedAt: .now, isStale: true)+ let stale = BotActivityPresentation(status: status, activity: "Old step", isStale: true)#expect(stale.phase == .stale)- #expect(!stale.showsTimer)- #expect(!stale.detail.contains("Old step"))+ #expect(!stale.caption.contains("Old step"))}- let done = BotActivityPresentation(status: "idle", activity: "Old step", startedAt: .now, isStale: true)+ let done = BotActivityPresentation(status: "idle", activity: "Old step", isStale: true)#expect(done.phase == .completed)- #expect(!done.showsTimer)#expect(done.symbol == "checkmark")}-@Test func activityTimerOnlyRunsDuringWork() {- #expect(BotActivityPresentation(status: "working", activity: "", startedAt: .now).showsTimer)- #expect(!BotActivityPresentation(status: "working", activity: "", startedAt: nil).showsTimer)- let input = BotActivityPresentation(status: "needsInput", activity: "Choose a branch", startedAt: .now)- #expect(input.detail == "Choose a branch")- #expect(!input.showsTimer)+@Test func activityCaptionIsTheStepWhileLive() {+ #expect(BotActivityPresentation(status: "needsInput", activity: "Choose a branch").caption == "Choose a branch")+ #expect(BotActivityPresentation(status: "working", activity: "").caption == "Working")+ #expect(BotActivityPresentation(status: "idle", activity: "Old step").caption == "Done")}