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): give widgets and live activities state colors and moods
leepokai240cdb66c7a8
diff --git a/apps/ios/App/CodyncApp.swift b/apps/ios/App/CodyncApp.swiftindex 76e8aa8c..1c56f59e 100644--- a/apps/ios/App/CodyncApp.swift+++ b/apps/ios/App/CodyncApp.swift@@ -350,5 +350,7 @@ enum BotsWidgetFeed {shown = signaturescope = currentScopeWidgetCenter.shared.reloadTimelines(ofKind: "CodyncBots")+ WidgetCenter.shared.reloadTimelines(ofKind: "CodyncTeam")+ ControlCenter.shared.reloadControls(ofKind: "CodyncLeadBot")}}diff --git a/apps/ios/Kit/Sources/CodyncKit/Design/ActivityCards.swift b/apps/ios/Kit/Sources/CodyncKit/Design/ActivityCards.swiftindex 170012b9..64e5c196 100644--- a/apps/ios/Kit/Sources/CodyncKit/Design/ActivityCards.swift+++ b/apps/ios/Kit/Sources/CodyncKit/Design/ActivityCards.swift@@ -12,13 +12,112 @@ public extension BotActivityPresentation {var tint: Color {switch phase {- case .needsInput: Color(light: 0x936000, dark: 0xECAF52)+ case .needsInput: Palette.attentioncase .failed: Palette.dangercase .completed: Palette.addedcase .stale, .waiting: Palette.secondarycase .working: Palette.text}}++ /// The caption stays quiet while the bot works and takes the state's color otherwise.+ var captionTint: Color { phase == .working ? Palette.secondary : tint }++ var mood: CharacterAvatar.Mood {+ switch phase {+ case .working: .working+ case .needsInput: .needsInput+ case .completed, .failed, .stale, .waiting: .idle+ }+ }++ /// The elapsed time counts up on its own (no push) while the task is live.+ func elapsedStart(_ startedAt: Date?) -> Date? {+ phase == .working || phase == .needsInput ? startedAt : nil+ }+}++public extension AnyTransition {+ /// The bot's face on a phase change: the old one grows out, the new one grows in.+ static var activityFace: AnyTransition {+ .asymmetric(insertion: .scale(scale: 0.55).combined(with: .opacity),+ removal: .scale(scale: 1.15).combined(with: .opacity))+ }++ /// Rows a new phase brings (the Review button, the timer): rise and fade in.+ static var activityRow: AnyTransition {+ .asymmetric(insertion: .move(edge: .bottom).combined(with: .opacity), removal: .opacity)+ }+}++/// The bot's face in its phase's mood, swapped with a pop when the phase changes.+public struct ActivityAvatar: View {+ let shape: String+ let color: String+ let state: BotActivityPresentation+ let size: CGFloat++ public init(shape: String, color: String, state: BotActivityPresentation, size: CGFloat) {+ self.shape = shape; self.color = color; self.state = state; self.size = size+ }++ public var body: some View {+ ZStack {+ CharacterAvatar(shape: shape, color: color, size: size, mood: state.mood, still: true)+ .id(state.phase)+ .transition(.activityFace)+ }+ .frame(width: size, height: size)+ .animation(Motion.activityPhase, value: state.phase)+ }+}++/// The step (or state) in its color, then the running time.+public struct ActivityCaption: View {+ let state: BotActivityPresentation+ let startedAt: Date?++ public init(state: BotActivityPresentation, startedAt: Date?) {+ self.state = state; self.startedAt = startedAt+ }++ public var body: some View {+ HStack(spacing: 4) {+ Text(state.caption)+ .foregroundStyle(state.captionTint)+ .contentTransition(.interpolate)+ // The step truncates first; the time always stays whole.+ if let since = state.elapsedStart(startedAt) {+ Text("·").foregroundStyle(Palette.tertiary)+ Text(since, style: .timer).monospacedDigit().foregroundStyle(Palette.secondary)+ .fixedSize().layoutPriority(1)+ }+ }+ .font(.system(size: 12))+ .lineLimit(1)+ }+}++/// Opens the conversation on the request; approval itself stays on the permission card.+public struct ActivityReviewButton: View {+ let state: BotActivityPresentation+ let link: URL?++ public init(state: BotActivityPresentation, link: URL?) {+ self.state = state; self.link = link+ }++ public var body: some View {+ if let link { Link(destination: link) { label } } else { label }+ }++ private var label: some View {+ Label("Review", systemImage: "hand.raised.fill")+ .font(.system(size: 13, weight: .semibold))+ .foregroundStyle(Palette.onAccent)+ .frame(maxWidth: .infinity, minHeight: 34)+ .background(state.tint, in: Capsule())+ }}/// Shared by the Lock Screen Live Activity and the in-app gallery.@@ -27,30 +126,39 @@ public struct BotActivityCard: View {let shape: Stringlet color: Stringlet state: BotActivityPresentation+ let startedAt: Date?+ let link: URL?- public init(bot: Bot, state: BotActivityPresentation) {- self.init(name: bot.name, shape: bot.avatarShape, color: bot.avatarColor, state: state)+ public init(bot: Bot, state: BotActivityPresentation, startedAt: Date? = nil) {+ self.init(name: bot.name, shape: bot.avatarShape, color: bot.avatarColor, state: state, startedAt: startedAt)}- public init(name: String, shape: String, color: String, state: BotActivityPresentation) {+ public init(name: String, shape: String, color: String, state: BotActivityPresentation, startedAt: Date? = nil, link: URL? = nil) {self.name = nameself.shape = shapeself.color = colorself.state = state+ self.startedAt = startedAt+ self.link = link}public var body: some View {- 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)+ VStack(spacing: 12) {+ HStack(spacing: 12) {+ ActivityAvatar(shape: shape, color: color, state: state, size: 32)+ VStack(alignment: .leading, spacing: 2) {+ Text(name).font(.system(size: 14, weight: .semibold)).foregroundStyle(Palette.text).lineLimit(1)+ ActivityCaption(state: state, startedAt: startedAt)+ }+ Spacer(minLength: 8)+ BotActivityIndicator(state: state, size: 28)+ }+ if state.phase == .needsInput {+ ActivityReviewButton(state: state, link: link).transition(.activityRow)}- .lineLimit(1)- Spacer(minLength: 8)- BotActivityIndicator(state: state, size: 28)}.padding(16)+ .animation(Motion.activityPhase, value: state).accessibilityElement(children: .combine).accessibilityLabel("\(name), \(state.title). \(state.caption)")}@@ -73,15 +181,43 @@ public struct BotActivityIndicator: View {ThinkingOrb(state: orb, size: size, color: state.tint, animated: false)} else {Image(systemName: state.symbol).font(.system(size: size * 0.6, weight: .semibold))+ .transition(.activityFace)}}.frame(width: size, height: size).foregroundStyle(state.tint)+ .animation(Motion.activityPhase, value: state.phase).accessibilityElement().accessibilityLabel(state.title)}}+/// The expanded island's bottom row: Review while the bot needs you, else the running time.+public struct ActivityIslandFooter: View {+ let state: BotActivityPresentation+ let startedAt: Date?+ let link: URL?++ public init(state: BotActivityPresentation, startedAt: Date?, link: URL?) {+ self.state = state; self.startedAt = startedAt; self.link = link+ }++ public var body: some View {+ Group {+ if state.phase == .needsInput {+ ActivityReviewButton(state: state, link: link)+ } else if let since = state.elapsedStart(startedAt) {+ Label { Text(since, style: .timer).monospacedDigit() } icon: { Image(systemName: "timer") }+ .font(.system(size: 12))+ .foregroundStyle(Palette.secondary)+ .frame(maxWidth: .infinity)+ }+ }+ .transition(.activityRow)+ .animation(Motion.activityPhase, value: state)+ }+}+/// Illustrations for the gallery/exporter, using the same activity content views./// The real Dynamic Island's regions and camera cutout are laid out by iOS.public struct BotActivityPreview: View {@@ -91,15 +227,16 @@ public struct BotActivityPreview: View {let bot: Botlet state: BotActivityPresentationlet form: Form+ let startedAt: Date?- public init(bot: Bot, state: BotActivityPresentation, form: Form) {- self.bot = bot; self.state = state; self.form = form+ public init(bot: Bot, state: BotActivityPresentation, form: Form, startedAt: Date? = nil) {+ self.bot = bot; self.state = state; self.form = form; self.startedAt = startedAt}public var body: some View {Group {if form == .lockScreen {- BotActivityCard(bot: bot, state: state)+ BotActivityCard(bot: bot, state: state, startedAt: startedAt).background(Palette.surface, in: RoundedRectangle(cornerRadius: 22))} else {island.environment(\.colorScheme, .dark)@@ -113,7 +250,7 @@ public struct BotActivityPreview: View {switch form {case .compact:HStack {- CharacterAvatar(bot: bot, size: 20, animated: false)+ ActivityAvatar(shape: bot.avatarShape, color: bot.avatarColor, state: state, size: 20)Spacer(minLength: 70)BotActivityIndicator(state: state)}@@ -123,15 +260,18 @@ public struct BotActivityPreview: View {BotActivityIndicator(state: state).frame(width: 38, height: 38).background(.black, in: Circle())case .expanded:- 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)+ VStack(spacing: 12) {+ HStack(spacing: 10) {+ ActivityAvatar(shape: bot.avatarShape, color: bot.avatarColor, state: state, size: 26)+ VStack(spacing: 2) {+ Text(bot.name).font(.system(size: 14, weight: .semibold)).foregroundStyle(.white)+ Text(state.caption).font(.system(size: 12)).foregroundStyle(state.captionTint)+ }+ .lineLimit(1)+ .frame(maxWidth: .infinity)+ BotActivityIndicator(state: state, size: 28)}- .lineLimit(1)- .frame(maxWidth: .infinity)- BotActivityIndicator(state: state, size: 28)+ ActivityIslandFooter(state: state, startedAt: startedAt, link: nil)}.padding(18).background(.black, in: RoundedRectangle(cornerRadius: 28))case .lockScreen: EmptyView()diff --git a/apps/ios/Kit/Sources/CodyncKit/Design/CharacterAvatar.swift b/apps/ios/Kit/Sources/CodyncKit/Design/CharacterAvatar.swiftindex 373a7664..0f2ea38c 100644--- a/apps/ios/Kit/Sources/CodyncKit/Design/CharacterAvatar.swift+++ b/apps/ios/Kit/Sources/CodyncKit/Design/CharacterAvatar.swift@@ -11,16 +11,20 @@ public struct CharacterAvatar: View {let color: Colorlet size: CGFloatlet mood: Mood+ let still: Bool- public init(shape: String, color: String, size: CGFloat = 40, mood: Mood = .idle) {- self.init(shape: shape, tint: AvatarPalette.color(color), size: size, mood: mood)+ /// `still` draws the mood's face without animating it (widgets and Live Activities,+ /// which render one frame).+ public init(shape: String, color: String, size: CGFloat = 40, mood: Mood = .idle, still: Bool = false) {+ self.init(shape: shape, tint: AvatarPalette.color(color), size: size, mood: mood, still: still)}- public init(shape: String, tint: Color, size: CGFloat = 40, mood: Mood = .idle) {+ public init(shape: String, tint: Color, size: CGFloat = 40, mood: Mood = .idle, still: Bool = false) {self.shape = shapeself.color = tintself.size = sizeself.mood = mood+ self.still = still}public init(bot: Bot, size: CGFloat = 40, animated: Bool = true) {@@ -28,17 +32,26 @@ public struct CharacterAvatar: View {shape: bot.avatarShape,color: bot.avatarColor,size: size,- mood: !animated ? .idle : bot.needsInput ? .needsInput : bot.isWorking ? .working : .idle+ mood: animated ? bot.mood : .idle)}+ /// The bot's current mood, drawn as one frame.+ public init(bot: Bot, size: CGFloat = 40, still: Bool) {+ self.init(shape: bot.avatarShape, color: bot.avatarColor, size: size, mood: bot.mood, still: still)+ }+public var body: some View {- DottedBody(shape: shape, color: color, size: size, mood: mood)+ DottedBody(shape: shape, color: color, size: size, mood: mood, paused: still).frame(width: size, height: size).accessibilityHidden(true)}}+public extension Bot {+ var mood: CharacterAvatar.Mood { needsInput ? .needsInput : isWorking ? .working : .idle }+}+/// Keep the halftone at every size. Small icons use fewer, larger dots so the/// gaps and hollow eyes survive rasterization in widgets and the Dynamic Island.private struct Grid {@@ -53,13 +66,14 @@ private struct DottedBody: View {let color: Colorlet size: CGFloatlet mood: CharacterAvatar.Mood+ let paused: Bool@Environment(\.accessibilityReduceMotion) private var reduceMotionvar body: some View {let grid = Grid(size: size)let step = size / CGFloat(grid.cells)let dots = Self.grid(shape: shape, size: size, step: step, cells: grid.cells)- let still = mood == .idle || reduceMotion+ let still = mood == .idle || reduceMotion || pausedTimelineView(.animation(paused: still)) { timeline inlet t = still ? 0 : timeline.date.timeIntervalSinceReferenceDate.truncatingRemainder(dividingBy: 3600)// Glance: whole-cell steps left / center / right, like a small display.diff --git a/apps/ios/Kit/Sources/CodyncKit/Design/Motion.swift b/apps/ios/Kit/Sources/CodyncKit/Design/Motion.swiftindex 93550f3d..3cbc09a8 100644--- a/apps/ios/Kit/Sources/CodyncKit/Design/Motion.swift+++ b/apps/ios/Kit/Sources/CodyncKit/Design/Motion.swift@@ -20,6 +20,10 @@ public enum Motion {/// Tiles moving into place: `{type: "spring", stiffness: 1000, damping: 63}`.public static let tile = Animation.interpolatingSpring(mass: 1, stiffness: 1000, damping: 63)+ /// A Live Activity's phase change (working → needs you → done): a soft spring that+ /// finishes well inside the 2 s iOS gives activity updates.+ public static let activityPhase = Animation.spring(duration: 0.6, bounce: 0.3)+/// `--ui-press-scale`.public static let pressScale: CGFloat = 0.98diff --git a/apps/ios/Kit/Sources/CodyncKit/Design/Theme.swift b/apps/ios/Kit/Sources/CodyncKit/Design/Theme.swiftindex 3cfe813d..1a5a80ae 100644--- a/apps/ios/Kit/Sources/CodyncKit/Design/Theme.swift+++ b/apps/ios/Kit/Sources/CodyncKit/Design/Theme.swift@@ -44,6 +44,8 @@ public enum Palette {public static let accentDim = Color(light: 0xD9D9D9, dark: 0x333333)public static let danger = Color(light: 0xC23A2B, dark: 0xF0A7A7)public static let warning = Color(hex: 0xF0A030)+ /// A bot that needs you, in widgets and Live Activities: readable amber in both modes.+ public static let attention = Color(light: 0x936000, dark: 0xECAF52)public static let codeBackground = Color(light: 0xF4F4F4, dark: 0x111111)public static let added = Color(light: 0x2E7D32, dark: 0x8FD18B)public static let removed = Color(light: 0xC62828, dark: 0xF0A7A7)diff --git a/apps/ios/Kit/Sources/CodyncKit/Design/WidgetCards.swift b/apps/ios/Kit/Sources/CodyncKit/Design/WidgetCards.swiftindex 0a420ce6..eeaae7b2 100644--- a/apps/ios/Kit/Sources/CodyncKit/Design/WidgetCards.swift+++ b/apps/ios/Kit/Sources/CodyncKit/Design/WidgetCards.swift@@ -168,7 +168,6 @@ public struct BotsWidgetCard: View {private var working: Int { bots.filter { $0.isWorking && !$0.needsInput }.count }private var count: Int { needs > 0 ? needs : working > 0 ? working : bots.count }private var label: String { needs > 0 ? (needs == 1 ? "Needs you" : "Need you") : working > 0 ? "Working" : bots.isEmpty ? "No bots yet" : "All quiet" }- private var attention: Color { Color(light: 0x936000, dark: 0xECAF52) }public var body: some View {VStack(alignment: .leading, spacing: 10) {@@ -199,7 +198,7 @@ public struct BotsWidgetCard: View {summaryHStack(spacing: -4) {ForEach(ordered.prefix(3)) { bot in- CharacterAvatar(bot: bot, size: 23, animated: false)+ CharacterAvatar(bot: bot, size: 23, still: true)}Spacer(minLength: 0)if working > 0 && needs > 0 {@@ -230,26 +229,94 @@ public struct BotsWidgetCard: View {private var summary: some View {VStack(alignment: .leading, spacing: 1) {Text("\(count)").font(.system(size: 36, weight: .semibold, design: .rounded))- .monospacedDigit().foregroundStyle(needs > 0 ? attention : Palette.text)+ .monospacedDigit().foregroundStyle(needs > 0 ? Palette.attention : Palette.text)Text(label).font(.system(size: 12, weight: .medium)).foregroundStyle(Palette.secondary)}.accessibilityElement(children: .combine)}+ /// Name and step on the left, the state on the right in its color.private func row(_ bot: Bot) -> some View {- HStack(spacing: 7) {- CharacterAvatar(bot: bot, size: 24, animated: false)+ let state = bot.widgetState+ return HStack(spacing: 7) {+ CharacterAvatar(bot: bot, size: 24, still: true)VStack(alignment: .leading, spacing: 1) {Text(bot.name).font(.system(size: 11, weight: .semibold)).foregroundStyle(Palette.text)- Text(bot.needsInput ? "Needs you" : bot.isWorking ? (bot.activity.isEmpty ? "Working…" : bot.activity) : "Ready")- .font(.system(size: 10)).foregroundStyle(bot.needsInput ? attention : Palette.secondary)+ if bot.isWorking, !bot.activity.isEmpty {+ Text(bot.activity).font(.system(size: 10)).foregroundStyle(Palette.secondary)+ }}.lineLimit(1)+ Spacer(minLength: 4)+ Text(state.label)+ .font(.system(size: 10, weight: bot.needsInput ? .semibold : .regular))+ .foregroundStyle(state.tint)+ .lineLimit(1)}.accessibilityElement(children: .combine)}}+public extension Bot {+ /// The state word the widgets show and its color: only what needs you (or failed) stands out.+ var widgetState: (label: String, tint: Color) {+ if needsInput { return ("Needs you", Palette.attention) }+ if status == "error" { return ("Failed", Palette.danger) }+ if isWorking { return ("Working", Palette.text) }+ return ("Ready", Palette.secondary)+ }+}++/// Four bots in a 2×2 grid, each in its mood with a dot for its state; the bots that+/// need you come first, and empty spots hold a faded sleeping character.+public struct BotsTeamCard: View {+ let bots: [Bot]++ public init(bots: [Bot]) {+ self.bots = Array(bots.filter { !$0.hidden }.sorted {+ let rank: (Bot) -> Int = { $0.needsInput ? 0 : $0.isWorking ? 1 : 2 }+ return rank($0) == rank($1) ? $0.lastAt > $1.lastAt : rank($0) < rank($1)+ }.prefix(4))+ }++ public var body: some View {+ Grid(horizontalSpacing: 8, verticalSpacing: 8) {+ GridRow { tile(0); tile(1) }+ GridRow { tile(2); tile(3) }+ }+ }++ @ViewBuilder private func tile(_ index: Int) -> some View {+ if bots.indices.contains(index) {+ let bot = bots[index]+ VStack(spacing: 4) {+ CharacterAvatar(bot: bot, size: 30, still: true)+ Text(bot.name)+ .font(.system(size: 9, weight: .semibold))+ .foregroundStyle(Palette.text)+ .lineLimit(1)+ .minimumScaleFactor(0.7)+ }+ .padding(.horizontal, 4)+ .frame(maxWidth: .infinity, maxHeight: .infinity)+ .background(Palette.bubbleAgent, in: RoundedRectangle(cornerRadius: 16))+ .overlay(alignment: .topTrailing) {+ if bot.isWorking || bot.status == "error" {+ Circle().fill(bot.widgetState.tint).frame(width: 7, height: 7).padding(7)+ }+ }+ .accessibilityElement(children: .ignore)+ .accessibilityLabel("\(bot.name), \(bot.widgetState.label)")+ } else {+ CharacterAvatar(shape: "blob", color: "gray", size: 26)+ .opacity(0.18)+ .frame(maxWidth: .infinity, maxHeight: .infinity)+ .background(Palette.bubbleAgent.opacity(0.5), in: RoundedRectangle(cornerRadius: 16))+ .accessibilityHidden(true)+ }+ }+}+public extension Bot {static var widgetPreview: [Bot] {let json = """diff --git a/apps/ios/Views/ActivityGalleryView.swift b/apps/ios/Views/ActivityGalleryView.swiftindex 3f20b572..e54cc9d4 100644--- a/apps/ios/Views/ActivityGalleryView.swift+++ b/apps/ios/Views/ActivityGalleryView.swift@@ -12,6 +12,7 @@ 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 startedAt = Date.now - 154private var island: Bool { !forms.contains(.lockScreen) }@@ -63,7 +64,7 @@ struct ActivityGalleryView: View {(.failed, "Error"), (.stale, "Update delayed"),])if let bot = Bot.widgetPreview.first {- BotActivityPreview(bot: bot, state: state, form: form ?? forms[0])+ BotActivityPreview(bot: bot, state: state, form: form ?? forms[0], startedAt: startedAt).frame(maxWidth: .infinity, minHeight: 90).padding(12).background(Palette.bubbleAgent, in: RoundedRectangle(cornerRadius: 28))@@ -88,10 +89,10 @@ struct ActivityGalleryView: View {private func explanation(_ form: BotActivityPreview.Form) -> some View {let detail = switch form {- 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 .lockScreen: "The bot in its mood, its current step in the state's color, the running time and a thinking orb. When the bot needs you, Review opens the request."+ case .compact: "The bot and a thinking orb beside the camera, outlined in the state's color. 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."+ case .expanded: "Touch and hold the Dynamic Island for the current step and the running time, or Review when the bot needs you. 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/Views/WidgetGalleryView.swift b/apps/ios/Views/WidgetGalleryView.swiftindex 9578d075..b753e793 100644--- a/apps/ios/Views/WidgetGalleryView.swift+++ b/apps/ios/Views/WidgetGalleryView.swift@@ -102,10 +102,12 @@ struct WidgetGalleryView: View {SegmentedChoice(selection: $providerID, options: providers)}}- ChoicePicker(selection: $size, options: [("small", "Small"), ("medium", "Medium"), ("large", "Large")])+ if kind != "team" {+ ChoicePicker(selection: $size, options: [("small", "Small"), ("medium", "Medium"), ("large", "Large")])+ }VStack(spacing: 18) {preview(wide: size != "small")- .frame(width: size == "small" ? 158 : nil, height: size == "large" ? 338 : 158)+ .frame(width: size == "small" || kind == "team" ? 158 : nil, height: size == "large" && kind != "team" ? 338 : 158)previewDescription}.padding(14)@@ -163,12 +165,14 @@ struct WidgetGalleryView: View {private enum Page: Hashable { case lockScreen }- private static let kinds: [(id: String, label: String)] = [("usage", "Provider usage"), ("bots", "Bots")]+ private static let kinds: [(id: String, label: String)] = [("usage", "Provider usage"), ("bots", "Bots"), ("team", "Team")]private var previewDescription: some View {VStack(alignment: .leading, spacing: 6) {- Text("\(size.capitalized) widget").font(.subheadline.weight(.medium))- Text(kind == "usage" ? "Small shows the tightest limit. Medium shows two windows. Large adds a summary and up to four limits." : "See who needs you and who's still working. Large shows up to six bots.")+ Text(kind == "team" ? "Small widget" : "\(size.capitalized) widget").font(.subheadline.weight(.medium))+ Text(kind == "usage" ? "Small shows the tightest limit. Medium shows two windows. Large adds a summary and up to four limits."+ : kind == "team" ? "Four bots as characters; the ones that need you come first, with a dot for each one at work."+ : "See who needs you and who's still working. Large shows up to six bots.").font(.caption).foregroundStyle(Palette.secondary)}.frame(maxWidth: .infinity, alignment: .leading)@@ -178,6 +182,8 @@ struct WidgetGalleryView: View {Group {if kind == "usage", let provider {ProviderWidgetCard(provider: provider, layout: size == "large" ? .large : wide ? .medium : .small)+ } else if kind == "team" {+ BotsTeamCard(bots: Bot.widgetPreview)} else {BotsWidgetCard(bots: Bot.widgetPreview, wide: wide, large: size == "large")}diff --git a/apps/ios/Widgets/CodyncWidgets.swift b/apps/ios/Widgets/CodyncWidgets.swiftindex 462b7b60..0797decb 100644--- a/apps/ios/Widgets/CodyncWidgets.swift+++ b/apps/ios/Widgets/CodyncWidgets.swift@@ -8,6 +8,8 @@ import WidgetKitstruct CodyncWidgets: WidgetBundle {var body: some Widget {BotsWidget()+ BotsTeamWidget()+ LeadBotControl()UsageWidget()ProviderUsageWidget()ClaudeUsageWidget()@@ -69,13 +71,6 @@ struct BotsWidgetView: View {let entry: BotsEntry@Environment(\.widgetFamily) private var family- /// Needs you first, then working, then most recent.- private var ordered: [Bot] {- entry.bots.filter { !$0.hidden }.sorted {- let rank = { (b: Bot) in b.needsInput ? 0 : b.isWorking ? 1 : 2 }- return rank($0) != rank($1) ? rank($0) < rank($1) : $0.lastAt > $1.lastAt- }- }var body: some View {if !entry.paired {switch family {@@ -104,13 +99,84 @@ struct BotsWidgetView: View {BotsWidgetCard(bots: entry.bots, wide: true, links: entry.links)default:BotsWidgetCard(bots: entry.bots, wide: false)- .widgetURL(ordered.first.flatMap { entry.links[$0.id] })+ .widgetURL(entry.lead.flatMap { entry.links[$0.id] })}}}}+/// Up to four bots as characters in a 2×2 grid.+struct BotsTeamWidget: Widget {+ var body: some WidgetConfiguration {+ StaticConfiguration(kind: "CodyncTeam", provider: BotsTimeline()) { entry in+ Group {+ if entry.paired {+ BotsTeamCard(bots: entry.bots)+ .widgetURL(entry.lead.flatMap { entry.links[$0.id] })+ } else {+ EmptyWidget(text: "Open Codync to pair with your computer.")+ }+ }+ .containerBackground(Palette.surface, for: .widget)+ }+ .configurationDisplayName("Team")+ .description("Four bots at a glance; the ones that need you come first.")+ .supportedFamilies([.systemSmall])+ }+}++extension BotsEntry {+ /// Needs you first, then working, then most recent.+ var lead: Bot? {+ bots.filter { !$0.hidden }.min {+ let rank = { (b: Bot) in b.needsInput ? 0 : b.isWorking ? 1 : 2 }+ return rank($0) != rank($1) ? rank($0) < rank($1) : $0.lastAt > $1.lastAt+ }+ }+}++// MARK: - Control Center++/// A Control Center button: the bot that needs you most and its state; a tap opens it.+struct LeadBotControl: ControlWidget {+ var body: some ControlWidgetConfiguration {+ StaticControlConfiguration(kind: "CodyncLeadBot", provider: LeadBotProvider()) { lead in+ ControlWidgetButton(action: OpenURLIntent(lead.url)) {+ Label(lead.text, systemImage: lead.symbol)+ }+ }+ .displayName("Bots")+ .description("The bot that needs you most. Tap to open it.")+ }+}++struct LeadBot: Sendable {+ let text: String+ let symbol: String+ let url: URL++ static let home = URL(string: "codync://computers")!++ init(text: String, symbol: String, url: URL = LeadBot.home) {+ self.text = text; self.symbol = symbol; self.url = url+ }++ init(_ entry: BotsEntry) {+ guard entry.paired else { self.init(text: "Connect a computer", symbol: "desktopcomputer"); return }+ guard let bot = entry.lead, bot.isWorking else { self.init(text: "All quiet", symbol: "moon.zzz.fill"); return }+ self.init(text: "\(bot.name): \(bot.widgetState.label)",+ symbol: bot.needsInput ? "hand.raised.fill" : "ellipsis.bubble.fill",+ url: entry.links[bot.id] ?? LeadBot.home)+ }+}++struct LeadBotProvider: ControlValueProvider {+ var previewValue: LeadBot { LeadBot(text: "Reviewer: Needs you", symbol: "hand.raised.fill") }++ func currentValue() async throws -> LeadBot { LeadBot(.current) }+}+private struct EmptyWidget: View {let text: String@@ -425,14 +491,15 @@ struct BotLiveActivity: Widget {var body: some WidgetConfiguration {ActivityConfiguration(for: BotActivityAttributes.self) { context inBotActivityCard(name: context.attributes.name, shape: context.attributes.avatarShape,- color: context.attributes.avatarColor, state: presentation(context))+ color: context.attributes.avatarColor, state: presentation(context),+ startedAt: context.state.startedAt, link: context.attributes.link).activityBackgroundTint(Palette.surface).widgetURL(context.attributes.link ?? URL(string: "codync://computers"))} dynamicIsland: { context inlet state = presentation(context)return DynamicIsland {DynamicIslandExpandedRegion(.leading) {- avatar(context, size: 26).frame(maxHeight: .infinity)+ avatar(context, state: state, size: 26).frame(maxHeight: .infinity)}DynamicIslandExpandedRegion(.trailing) {BotActivityIndicator(state: state, size: 28).frame(maxHeight: .infinity)@@ -442,15 +509,22 @@ struct BotLiveActivity: Widget {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)+ Text(state.caption).font(.system(size: 12)).foregroundStyle(state.captionTint)+ .contentTransition(.interpolate)}.lineLimit(1).multilineTextAlignment(.center).frame(maxWidth: .infinity).environment(\.colorScheme, .dark)+ .animation(Motion.activityPhase, value: state)+ }+ DynamicIslandExpandedRegion(.bottom) {+ ActivityIslandFooter(state: state, startedAt: context.state.startedAt, link: context.attributes.link)+ .padding(.horizontal, 4)+ .environment(\.colorScheme, .dark)}} compactLeading: {- avatar(context, size: 20)+ avatar(context, state: state, size: 20)} compactTrailing: {BotActivityIndicator(state: state).environment(\.colorScheme, .dark)} minimal: {@@ -458,6 +532,7 @@ struct BotLiveActivity: Widget {.environment(\.colorScheme, .dark).accessibilityLabel("\(context.attributes.name), \(state.title)")}+ .keylineTint(state.tint).widgetURL(context.attributes.link ?? URL(string: "codync://computers"))}}@@ -466,7 +541,7 @@ struct BotLiveActivity: Widget {.init(status: context.state.status, activity: context.state.activity, isStale: context.isStale)}- private func avatar(_ context: ActivityViewContext<BotActivityAttributes>, size: CGFloat) -> some View {- CharacterAvatar(shape: context.attributes.avatarShape, color: context.attributes.avatarColor, size: size)+ private func avatar(_ context: ActivityViewContext<BotActivityAttributes>, state: BotActivityPresentation, size: CGFloat) -> some View {+ ActivityAvatar(shape: context.attributes.avatarShape, color: context.attributes.avatarColor, state: state, size: size)}}diff --git a/apps/ios/Widgets/WidgetPreviews.swift b/apps/ios/Widgets/WidgetPreviews.swiftindex c46fed3e..004ab472 100644--- a/apps/ios/Widgets/WidgetPreviews.swift+++ b/apps/ios/Widgets/WidgetPreviews.swift@@ -37,6 +37,13 @@ import ActivityKitBotsEntry(date: .now, bots: [], paired: false)}+#Preview(as: .systemSmall) {+ BotsTeamWidget()+} timeline: {+ BotsEntry(date: .now, bots: Bot.widgetPreview, paired: true)+ BotsEntry(date: .now, bots: [], paired: false)+}+#Preview(as: .accessoryRectangular) {BotsWidget()} timeline: {diff --git a/docs/design/mobile-widgets.md b/docs/design/mobile-widgets.mdindex 219d36f0..85d13bbb 100644--- a/docs/design/mobile-widgets.md+++ b/docs/design/mobile-widgets.md@@ -26,7 +26,10 @@| 類型 | Small | Medium | Large || --- | --- | --- | --- || Provider usage | provider、最接近上限的用量、細刻度條、重置時間 | 同一 provider 的兩個用量視窗與重置時間 | 主要用量摘要、最多四個用量視窗 |-| Bots | 待回應/工作中的數量與角色圖示 | 狀態摘要與最多三個 bot,待回應優先 | 數量摘要與最多六個 bot |+| Bots | 待回應/工作中的數量與角色圖示 | 狀態摘要與最多三個 bot,待回應優先;每列右側是上色的狀態(Needs you 琥珀、Failed 紅、Working 主色、Ready 灰) | 數量摘要與最多六個 bot |+| Team | 2×2 角色格:最多四個 bot(待回應優先),頭像顯示當下 mood、工作中的角落有狀態點;空位是淡化的角色;點擊開最需要你的 bot | — | — |++Widget 與 Live Activity 的頭像用 `CharacterAvatar(… still: true)`:畫出 mood(工作中、待回應的漣漪)但不動畫,因為 WidgetKit 只渲染一幀。Control Center 另有一個「Bots」控制項(`LeadBotControl`):顯示最需要你的 bot 與狀態,點擊開啟它;App 在 bot 狀態改變時重新載入 Bots、Team 與這個控制項。既有 Usage limits 保留 Small/Medium 的跨 provider 用量摘要。Bots 與 Usage limits 另支援 Lock Screen 的圓形、矩形與行內形式;行內放在時鐘上方日期列。@@ -51,10 +54,12 @@ State 分頁的 Live Activity 頁顯示鎖定畫面形式,Dynamic Island 頁| 形式 | 資訊與互動 || --- | --- |-| Lock Screen/橫幅 | bot 頭像與名稱、一行說明、右側 orb;點擊回到對話 |-| Compact | 左側 bot、右側 orb;完成/錯誤時改為勾號/警告符號 |+| Lock Screen/橫幅 | bot 頭像(mood)與名稱、上色的一行說明與經過時間、右側 orb;待回應時下方多一個 Review 按鈕開啟請求;點擊回到對話 |+| Compact | 左側 bot(mood)、右側 orb;完成/錯誤時改為勾號/警告符號;島的外框(keyline)帶狀態色 || Minimal | 只有 orb(或結束符號),VoiceOver 包含 bot 名稱 |-| Expanded | bot、一行說明、orb;整塊點擊回到對話,不另放連結文字 |+| Expanded | bot、上色的一行說明、orb;底部是經過時間,待回應時換成 Review;整塊點擊回到對話 |++狀態色:待回應琥珀(`Palette.attention`)、失敗紅、完成綠;工作中的說明維持灰色,只有需要注意的狀態跳出來。經過時間用 `Text(startedAt, style: .timer)` 由系統自己往上數,不需要推播(`startedAt` 已在 remote content state 裡)。狀態切換時頭像舊臉放大淡出、新臉縮放進場,文字用 `.contentTransition(.interpolate)`,Review/時間列由下往上進場,全部用 `Motion.activityPhase`(0.6 s spring,在 iOS 給 activity 更新的 2 s 內)。Review 只開啟對話,核准仍在 App 的 permission card。實際形式由 iOS 根據裝置、活動數量與互動決定;App 內的形式選單只控制設計預覽。[Apple Live Activities 設計指南](https://developer.apple.com/design/human-interface-guidelines/live-activities)diff --git a/docs/design/push-and-live-activity.md b/docs/design/push-and-live-activity.mdindex bee1467d..c8283c30 100644--- a/docs/design/push-and-live-activity.md+++ b/docs/design/push-and-live-activity.md@@ -17,7 +17,7 @@ The encrypted title is limited to 80 characters and the body to 400 characters.Notification actions open the scoped conversation. Permission approval still requires the normal in-app permission card. An account mismatch does not navigate into another account. Notifications are grouped by computer plus bot. Muted and hidden bots do not alert. The existing host-wide suppression while an iOS event connection is open remains in place; independent foreground suppression for multiple phones is not implemented.-Use Settings → Notifications to switch push notifications off for this iPhone (the app calls `unregisterDevice`, so every computer drops its alert ticket; Live Activities are unaffected), and to request access or open the iOS notification settings. Per-bot notification preferences remain in the bot editor. State → Live Activity controls automatic activity creation and shows system authorization. Turning it off ends this phone's activities. State → Dynamic Island shows the same switch: iOS renders one activity in both places and offers no island-only opt-out. The expanded island centers the bot name and current step under the camera, between the avatar and the orb (both vertically centered), so no text reaches the island's 44 pt corners.+Use Settings → Notifications to switch push notifications off for this iPhone (the app calls `unregisterDevice`, so every computer drops its alert ticket; Live Activities are unaffected), and to request access or open the iOS notification settings. Per-bot notification preferences remain in the bot editor. State → Live Activity controls automatic activity creation and shows system authorization. Turning it off ends this phone's activities. State → Dynamic Island shows the same switch: iOS renders one activity in both places and offers no island-only opt-out. The expanded island centers the bot name and current step under the camera, between the avatar and the orb (both vertically centered), so no text reaches the island's 44 pt corners. Its bottom row shows the elapsed time (from `startedAt`, counted by the system) or, when the bot needs you, a Review button that opens the conversation.## Responsibilities and privacy