Skip to content

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.

feat(ios): choose the team widget's bots and open each one on tap

leepokai34af5a5bbd04
diff --git a/apps/ios/Kit/Package.swift b/apps/ios/Kit/Package.swift
index 2ec356dc..2cffddf6 100644
--- a/apps/ios/Kit/Package.swift
+++ b/apps/ios/Kit/Package.swift
@@ -3,7 +3,7 @@ import PackageDescription
let package = Package(
name: "CodyncKit",
- platforms: [.iOS(.v17)],
+ platforms: [.iOS(.v18)],
products: [
.library(name: "CodyncKit", targets: ["CodyncKit"]),
.library(name: "CodyncUI", targets: ["CodyncUI"]),
diff --git a/apps/ios/Kit/Sources/CodyncKit/Design/WidgetCards.swift b/apps/ios/Kit/Sources/CodyncKit/Design/WidgetCards.swift
index eeaae7b2..88ad6bec 100644
--- a/apps/ios/Kit/Sources/CodyncKit/Design/WidgetCards.swift
+++ b/apps/ios/Kit/Sources/CodyncKit/Design/WidgetCards.swift
@@ -1,3 +1,4 @@
+import AppIntents
import SwiftUI
/// Shared by the widget extension and its in-app gallery so previews use the
@@ -267,16 +268,29 @@ public extension Bot {
}
}
-/// 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.
+/// Four bots in a 2×2 grid, each in its mood with a dot for its state. Spots picked in the
+/// widget's settings keep their bot; the rest fill with the bots that need you first, and
+/// empty spots hold a faded sleeping character.
public struct BotsTeamCard: View {
- let bots: [Bot]
+ let slots: [Bot?]
+ let links: [String: URL]
+
+ /// `links` (bot id → its conversation) makes each spot open its own bot.
+ public init(bots: [Bot], picks: [String?] = [], links: [String: URL] = [:]) {
+ slots = Self.slots(bots: bots, picks: picks)
+ self.links = links
+ }
- public init(bots: [Bot]) {
- self.bots = Array(bots.filter { !$0.hidden }.sorted {
+ /// The bots in their four spots: picks first (a deleted pick falls back to automatic).
+ public static func slots(bots: [Bot], picks: [String?]) -> [Bot?] {
+ let byId = Dictionary(bots.map { ($0.id, $0) }, uniquingKeysWith: { a, _ in a })
+ let picked = (0..<4).map { i in i < picks.count ? picks[i].flatMap { byId[$0] } : nil }
+ let taken = Set(picked.compactMap { $0?.id })
+ var queue = bots.filter { !$0.hidden && !taken.contains($0.id) }.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))
+ }[...]
+ return picked.map { $0 ?? queue.popFirst() }
}
public var body: some View {
@@ -287,26 +301,14 @@ public struct BotsTeamCard: View {
}
@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)
- }
+ if let bot = slots[index] {
+ // A small widget has one tap target unless it uses buttons: each spot is a
+ // button that opens its bot's conversation.
+ if let url = links[bot.id] {
+ Button(intent: OpenURLIntent(url)) { botTile(bot) }.buttonStyle(.plain)
+ } else {
+ botTile(bot)
}
- .accessibilityElement(children: .ignore)
- .accessibilityLabel("\(bot.name), \(bot.widgetState.label)")
} else {
CharacterAvatar(shape: "blob", color: "gray", size: 26)
.opacity(0.18)
@@ -315,6 +317,27 @@ public struct BotsTeamCard: View {
.accessibilityHidden(true)
}
}
+
+ private func botTile(_ bot: Bot) -> some View {
+ 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)")
+ }
}
public extension Bot {
diff --git a/apps/ios/Kit/Tests/CodyncKitTests/ActivityPresentationTests.swift b/apps/ios/Kit/Tests/CodyncKitTests/ActivityPresentationTests.swift
index faa168ac..6b7d460f 100644
--- a/apps/ios/Kit/Tests/CodyncKitTests/ActivityPresentationTests.swift
+++ b/apps/ios/Kit/Tests/CodyncKitTests/ActivityPresentationTests.swift
@@ -28,3 +28,12 @@ import Testing
#expect(BotActivityPresentation(status: "working", activity: "").caption == "Working")
#expect(BotActivityPresentation(status: "idle", activity: "Old step").caption == "Done")
}
+
+@Test func teamWidgetKeepsPicksAndFillsTheRestByUrgency() {
+ let bots = Bot.widgetPreview // review: needs you, build: working, docs: idle
+ #expect(BotsTeamCard.slots(bots: bots, picks: []).map { $0?.id } == ["preview-review", "preview-build", "preview-docs", nil])
+ let picked = BotsTeamCard.slots(bots: bots, picks: [nil, "preview-docs", nil, nil]).map { $0?.id }
+ #expect(picked == ["preview-review", "preview-docs", "preview-build", nil])
+ // A deleted pick falls back to automatic.
+ #expect(BotsTeamCard.slots(bots: bots, picks: ["gone"]).first??.id == "preview-review")
+}
diff --git a/apps/ios/Views/WidgetGalleryView.swift b/apps/ios/Views/WidgetGalleryView.swift
index b753e793..81ec8ebf 100644
--- a/apps/ios/Views/WidgetGalleryView.swift
+++ b/apps/ios/Views/WidgetGalleryView.swift
@@ -171,7 +171,7 @@ struct WidgetGalleryView: View {
VStack(alignment: .leading, spacing: 6) {
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."
+ : kind == "team" ? "Four bots as characters with a dot for each one at work. Touch and hold the widget, then Edit Widget to choose who sits in each spot; empty spots show the bots that need you first."
: "See who needs you and who's still working. Large shows up to six bots.")
.font(.caption).foregroundStyle(Palette.secondary)
}
diff --git a/apps/ios/Widgets/CodyncWidgets.swift b/apps/ios/Widgets/CodyncWidgets.swift
index 0797decb..080e2458 100644
--- a/apps/ios/Widgets/CodyncWidgets.swift
+++ b/apps/ios/Widgets/CodyncWidgets.swift
@@ -106,14 +106,14 @@ struct BotsWidgetView: View {
}
-/// Up to four bots as characters in a 2×2 grid.
+/// Up to four bots as characters in a 2×2 grid; Edit Widget picks the bot in each spot.
struct BotsTeamWidget: Widget {
var body: some WidgetConfiguration {
- StaticConfiguration(kind: "CodyncTeam", provider: BotsTimeline()) { entry in
+ AppIntentConfiguration(kind: "CodyncTeam", intent: TeamIntent.self, provider: TeamTimeline()) { entry in
Group {
- if entry.paired {
- BotsTeamCard(bots: entry.bots)
- .widgetURL(entry.lead.flatMap { entry.links[$0.id] })
+ if entry.bots.paired {
+ // Each spot opens its own bot; the gaps between them open the app.
+ BotsTeamCard(bots: entry.bots.bots, picks: entry.picks, links: entry.bots.links)
} else {
EmptyWidget(text: "Open Codync to pair with your computer.")
}
@@ -121,11 +121,68 @@ struct BotsTeamWidget: Widget {
.containerBackground(Palette.surface, for: .widget)
}
.configurationDisplayName("Team")
- .description("Four bots at a glance; the ones that need you come first.")
+ .description("Four bots at a glance. Edit the widget to choose who sits in each spot.")
.supportedFamilies([.systemSmall])
}
}
+/// A bot of the selected account, keyed `<computerId>/<botId>` like the widget snapshot.
+struct BotEntity: AppEntity {
+ static let typeDisplayRepresentation: TypeDisplayRepresentation = "Bot"
+ static let defaultQuery = BotEntityQuery()
+
+ let id: String
+ let name: String
+ var displayRepresentation: DisplayRepresentation { DisplayRepresentation(title: "\(name)") }
+}
+
+struct BotEntityQuery: EntityQuery {
+ private var all: [BotEntity] {
+ BotsEntry.current.bots.filter { !$0.hidden }.map { BotEntity(id: $0.id, name: $0.name) }
+ .sorted { $0.name.localizedStandardCompare($1.name) == .orderedAscending }
+ }
+
+ func entities(for identifiers: [String]) async throws -> [BotEntity] {
+ let all = all
+ return identifiers.compactMap { id in all.first { $0.id == id } }
+ }
+
+ func suggestedEntities() async throws -> [BotEntity] { all }
+}
+
+struct TeamIntent: WidgetConfigurationIntent {
+ static let title: LocalizedStringResource = "Team"
+ static let description = IntentDescription("Choose a bot for each spot; empty spots show the bots that need you.")
+
+ @Parameter(title: "Top left") var first: BotEntity?
+ @Parameter(title: "Top right") var second: BotEntity?
+ @Parameter(title: "Bottom left") var third: BotEntity?
+ @Parameter(title: "Bottom right") var fourth: BotEntity?
+
+ var picks: [String?] { [first?.id, second?.id, third?.id, fourth?.id] }
+}
+
+struct TeamEntry: TimelineEntry {
+ let date: Date
+ let bots: BotsEntry
+ let picks: [String?]
+}
+
+struct TeamTimeline: AppIntentTimelineProvider {
+ func placeholder(in context: Context) -> TeamEntry {
+ TeamEntry(date: .now, bots: BotsEntry(date: .now, bots: Bot.widgetPreview, paired: true), picks: [])
+ }
+
+ func snapshot(for configuration: TeamIntent, in context: Context) async -> TeamEntry {
+ context.isPreview ? placeholder(in: context) : TeamEntry(date: .now, bots: .current, picks: configuration.picks)
+ }
+
+ /// The app writes the roster and reloads this widget when a bot's state changes.
+ func timeline(for configuration: TeamIntent, in context: Context) async -> Timeline<TeamEntry> {
+ Timeline(entries: [TeamEntry(date: .now, bots: .current, picks: configuration.picks)], policy: .never)
+ }
+}
+
extension BotsEntry {
/// Needs you first, then working, then most recent.
var lead: Bot? {
@@ -508,28 +565,25 @@ struct BotLiveActivity: Widget {
// 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(context.attributes.name).font(.system(size: 14, weight: .semibold)).foregroundStyle(Palette.text)
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, state: state, size: 20)
} compactTrailing: {
- BotActivityIndicator(state: state).environment(\.colorScheme, .dark)
+ BotActivityIndicator(state: state)
} minimal: {
BotActivityIndicator(state: state)
- .environment(\.colorScheme, .dark)
.accessibilityLabel("\(context.attributes.name), \(state.title)")
}
.keylineTint(state.tint)
diff --git a/apps/ios/Widgets/WidgetPreviews.swift b/apps/ios/Widgets/WidgetPreviews.swift
index 004ab472..bf3a6a5a 100644
--- a/apps/ios/Widgets/WidgetPreviews.swift
+++ b/apps/ios/Widgets/WidgetPreviews.swift
@@ -40,8 +40,9 @@ import ActivityKit
#Preview(as: .systemSmall) {
BotsTeamWidget()
} timeline: {
- BotsEntry(date: .now, bots: Bot.widgetPreview, paired: true)
- BotsEntry(date: .now, bots: [], paired: false)
+ TeamEntry(date: .now, bots: BotsEntry(date: .now, bots: Bot.widgetPreview, paired: true), picks: [])
+ TeamEntry(date: .now, bots: BotsEntry(date: .now, bots: Bot.widgetPreview, paired: true), picks: [nil, "preview-docs"])
+ TeamEntry(date: .now, bots: BotsEntry(date: .now, bots: [], paired: false), picks: [])
}
#Preview(as: .accessoryRectangular) {
diff --git a/docs/design/mobile-widgets.md b/docs/design/mobile-widgets.md
index dfa01a6f..14cb5dba 100644
--- a/docs/design/mobile-widgets.md
+++ b/docs/design/mobile-widgets.md
@@ -27,7 +27,7 @@
| --- | --- | --- | --- |
| Provider usage | provider、最接近上限的用量、細刻度條、重置時間 | 同一 provider 的兩個用量視窗與重置時間 | 主要用量摘要、最多四個用量視窗 |
| Bots | 待回應/工作中的數量與角色圖示 | 狀態摘要與最多三個 bot,待回應優先;每列右側是上色的狀態(Needs you 琥珀、Failed 紅、Working 主色、Ready 灰) | 數量摘要與最多六個 bot |
-| Team | 2×2 角色格:最多四個 bot(待回應優先),頭像顯示當下 mood、工作中的角落有狀態點;空位是淡化的角色;點擊開最需要你的 bot | — | — |
+| Team | 2×2 角色格:最多四個 bot;「編輯 Widget」可為四個位置各選一個 bot(`TeamIntent`,選項來自目前帳號的 bot),沒選的位置自動補上待回應優先的 bot,被刪掉的 bot 退回自動,頭像顯示當下 mood、工作中的角落有狀態點;空位是淡化的角色;點擊開最需要你的 bot | — | — |
Widget 與 Live Activity 的頭像用 `CharacterAvatar(… still: true)`:畫出 mood(工作中、待回應的漣漪)但不動畫,因為 WidgetKit 只渲染一幀。Control Center 另有一個「Bots」控制項(`LeadBotControl`):顯示最需要你的 bot 與狀態,點擊開啟它;App 在 bot 狀態改變時重新載入 Bots、Team 與這個控制項。