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
Grok-style redesign: black-and-white app, grid-face bots, computers and widgets
leepokaiedb54ccd7670
diff --git a/Codync-iOS/App/CodyncApp.swift b/Codync-iOS/App/CodyncApp.swiftindex 6d6c83f0..c7833ea3 100644--- a/Codync-iOS/App/CodyncApp.swift+++ b/Codync-iOS/App/CodyncApp.swift@@ -20,6 +20,9 @@ struct CodyncApp: App {model.pair(p)} else if url.host() == "bot" {model.selection = url.lastPathComponent+ } else if url.host() == "computers" {+ model.selection = nil+ model.showProfile = true}}.onChange(of: scenePhase, initial: true) { _, phase in@@ -43,7 +46,10 @@ enum AppStore {static let shared: BotStore = {let store = BotStore(pairing: SharedStore.pairing, clientKind: "ios", persistsPairing: true)store.onPaired = { PushRegistrar.shared.syncDevice(with: $0) }- store.onBotUpdated = { LiveActivities.shared.update(bot: $0) }+ store.onBotUpdated = {+ LiveActivities.shared.update(bot: $0)+ BotsWidgetFeed.update(store.roster)+ }store.onSent = { LiveActivities.shared.start(for: $0, model: store) }store.onUsageChanged = { usage inSharedStore.usage = usage@@ -75,3 +81,18 @@ final class AppDelegate: NSObject, UIApplicationDelegate, UNUserNotificationCent[]}}++/// Keeps the Bots widget's snapshot current; asks WidgetKit to redraw only when+/// something the widget shows changes (who is working / needs you / unread).+@MainActor+enum BotsWidgetFeed {+ private static var shown = ""++ static func update(_ roster: [Bot]) {+ SharedStore.bots = roster+ let signature = roster.map { "\($0.id):\($0.status):\($0.unread)" }.joined(separator: ",")+ guard signature != shown else { return }+ shown = signature+ WidgetCenter.shared.reloadTimelines(ofKind: "CodyncBots")+ }+}diff --git a/Codync-iOS/Assets.xcassets/AppIcon.appiconset/image.png b/Codync-iOS/Assets.xcassets/AppIcon.appiconset/image.pngindex 4b501be7..bdcad6b1 100644Binary files a/Codync-iOS/Assets.xcassets/AppIcon.appiconset/image.png and b/Codync-iOS/Assets.xcassets/AppIcon.appiconset/image.png differdiff --git a/Codync-iOS/Views/BotListView.swift b/Codync-iOS/Views/BotListView.swiftindex 85b156e4..c6629186 100644--- a/Codync-iOS/Views/BotListView.swift+++ b/Codync-iOS/Views/BotListView.swift@@ -6,7 +6,6 @@ import SwiftUIstruct BotListView: View {@Environment(BotStore.self) private var model@State private var editing: EditorRequest?- @State private var showSettings = false@State private var confirmDelete: Bot?var body: some View {@@ -29,11 +28,14 @@ struct BotListView: View {}ForEach(roster) { bot in- NavigationLink(value: bot.id) {+ // A plain button instead of a NavigationLink: same push, no chevron.+ Button { model.selection = bot.id } label: {BotRow(bot: bot)}+ .buttonStyle(.plain).listRowBackground(Palette.background)- .listRowSeparatorTint(Palette.border)+ .listRowSeparator(.hidden)+ .listRowInsets(EdgeInsets(top: 0, leading: 16, bottom: 0, trailing: 16)).swipeActions(edge: .leading) {Button(bot.pinned ? "Unpin" : "Pin", systemImage: bot.pinned ? "pin.slash" : "pin") {model.setPinned(bot, !bot.pinned)@@ -57,11 +59,16 @@ struct BotListView: View {.scrollContentBackground(.hidden).background(Palette.background).navigationTitle(model.hostName)- .navigationBarTitleDisplayMode(.large)+ .navigationBarTitleDisplayMode(.inline).toolbar {ToolbarItem(placement: .topBarLeading) {- Button("Settings", systemImage: "gearshape") { showSettings = true }+ Button { model.showProfile = true } label: {+ ComputerBadge(name: model.pairing?.name ?? model.hostName, size: 36)+ }+ .accessibilityLabel("Profile and computers")}+ // Grok-style bare top bar: no visible title, just the two buttons.+ ToolbarItem(placement: .principal) { Color.clear.frame(width: 1, height: 1) }ToolbarItem(placement: .topBarTrailing) {Button("New bot", systemImage: "plus") {editing = EditorRequest(BotDraft())@@ -76,7 +83,7 @@ struct BotListView: View {.sheet(item: $editing) { request inNavigationStack { BotEditorView(draft: request.draft) }}- .sheet(isPresented: $showSettings) {+ .sheet(isPresented: Bindable(model).showProfile) {NavigationStack { SettingsView() }}.deleteBotConfirmation($confirmDelete)diff --git a/Codync-iOS/Views/PairingView.swift b/Codync-iOS/Views/PairingView.swiftindex 4f40f583..27e31c19 100644--- a/Codync-iOS/Views/PairingView.swift+++ b/Codync-iOS/Views/PairingView.swift@@ -5,6 +5,8 @@ import VisionKit/// First run: explain the model, then pair with a computer running codync-host.struct PairingView: View {+ /// Set when adding another computer from the profile sheet; shows a close button.+ var onDone: (() -> Void)?@Environment(BotStore.self) private var model@State private var scanning = false@State private var pasted = ""@@ -76,6 +78,17 @@ struct PairingView: View {.padding(24)}.background(Palette.background)+ .overlay(alignment: .topLeading) {+ if let onDone {+ Button("Close", systemImage: "xmark", action: onDone)+ .labelStyle(.iconOnly)+ .font(.body.weight(.semibold))+ .frame(width: 44, height: 44)+ .background(Palette.bubbleAgent, in: Circle())+ .foregroundStyle(Palette.text)+ .padding(16)+ }+ }.sheet(isPresented: $scanning) {QRScanner { code inscanning = false@@ -92,6 +105,7 @@ struct PairingView: View {}error = nilmodel.pair(p)+ onDone?()Task { _ = await PushRegistrar.shared.requestAuthorization() }}}diff --git a/Codync-iOS/Views/SettingsView.swift b/Codync-iOS/Views/SettingsView.swiftindex 5f15ab0f..e5b65315 100644--- a/Codync-iOS/Views/SettingsView.swift+++ b/Codync-iOS/Views/SettingsView.swift@@ -3,57 +3,50 @@ import CodyncUIimport SwiftUIimport UserNotifications+/// The profile sheet behind the top-left button: which computer you're talking+/// to (and switching between them), usage, notifications, hidden bots.struct SettingsView: View {@Environment(BotStore.self) private var model@Environment(\.dismiss) private var dismiss@State private var notificationsAllowed: Bool?- @State private var confirmUnpair = false+ @State private var addingComputer = false+ @State private var confirmForget: Pairing?var body: some View {Form {- Section("Computer") {- LabeledContent("Name", value: model.hostName)- LabeledContent("Status") {- switch model.connection {- case .online: Text("Connected").foregroundStyle(Palette.accent)- case .connecting: Text("Connecting…")- case .offline: Text("Offline").foregroundStyle(Palette.warning)- case .unpaired: Text("Not paired")- }- }- if let url = model.client?.baseURL.absoluteString {- LabeledContent("Address", value: url).font(.footnote.monospaced())+ Section {+ ForEach(model.computers, id: \.token) { computer in+ ComputerRow(computer: computer, active: computer.token == model.pairing?.token)+ .contentShape(Rectangle())+ .onTapGesture { if computer.token != model.pairing?.token { model.pair(computer) } }+ .swipeActions {+ Button("Remove", systemImage: "trash", role: .destructive) { confirmForget = computer }+ }+ .contextMenu {+ Button("Remove", systemImage: "trash", role: .destructive) { confirmForget = computer }+ }}- if let hello = model.hello {- LabeledContent("Host version", value: hello.version)- LabeledContent("System", value: hello.os)+ Button {+ addingComputer = true+ } label: {+ Label("Add a computer", systemImage: "plus")+ .foregroundStyle(Palette.text)}- }-- Section {- ForEach(model.usage.providers) { UsageCard(provider: $0) }- Button("Refresh", systemImage: "arrow.clockwise") { Task { await model.refreshUsage() } }- .labelStyle(.iconOnly)- .accessibilityLabel("Refresh usage")- } header: {- Text("Usage limits")} footer: {- Text("Read on your computer from Claude Code and Codex. Add the Codync widget to your Home or Lock Screen to keep an eye on them.")+ Text("Each computer has its own bots. Tap one to switch.")}- Section("Notifications") {- if notificationsAllowed == false {- Button("Allow in Settings") {- UIApplication.shared.open(URL(string: UIApplication.openNotificationSettingsURLString)!)- }- } else if notificationsAllowed == nil {- Button("Turn on notifications") {- Task { notificationsAllowed = await PushRegistrar.shared.requestAuthorization() }+ Section {+ NavigationLink {+ UsageDetail()+ } label: {+ LabeledContent("Usage") {+ if let top = model.usage.providers.flatMap(\.windows).map(\.percent).max() {+ Text("\(Int(top.rounded()))%").monospacedDigit()+ }}- } else {- Label("On — you'll hear when a bot needs you or finishes", systemImage: "bell.badge")- .font(.footnote)}+ notificationsRow}if !model.hiddenBots.isEmpty {@@ -70,30 +63,32 @@ struct SettingsView: View {}Section {- Button("Unpair this phone", role: .destructive) { confirmUnpair = true }- } footer: {- Text("Bots and conversations stay on your computer.")- }-- Section {- Link("Source code", destination: URL(string: "https://github.com/leepokai/Codync")!)+ if let hello = model.hello {+ LabeledContent("Host version", value: hello.version)+ }LabeledContent("App version", value: Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String ?? "")+ Link("Source code", destination: URL(string: "https://github.com/leepokai/Codync")!)+ .foregroundStyle(Palette.text)}}.scrollContentBackground(.hidden).background(Palette.background)- .navigationTitle("Settings").navigationBarTitleDisplayMode(.inline).toolbar {- ToolbarItem(placement: .confirmationAction) {- Button("Done", systemImage: "checkmark") { dismiss() }.labelStyle(.iconOnly)+ ToolbarItem(placement: .cancellationAction) {+ Button("Close", systemImage: "xmark") { dismiss() }.labelStyle(.iconOnly)}}- .confirmationDialog("Unpair from \(model.hostName)?", isPresented: $confirmUnpair, titleVisibility: .visible) {- Button("Unpair", role: .destructive) {- model.unpair()- dismiss()+ .sheet(isPresented: $addingComputer) {+ PairingView { addingComputer = false }+ }+ .confirmationDialog("Remove \(confirmForget?.name ?? "computer")?", isPresented: Binding(get: { confirmForget != nil }, set: { if !$0 { confirmForget = nil } }), titleVisibility: .visible) {+ Button("Remove", role: .destructive) {+ if let c = confirmForget { model.forget(c) }+ if model.pairing == nil { dismiss() }}+ } message: {+ Text("Its bots and conversations stay on that computer. You can pair again any time.")}.task {let status = await UNUserNotificationCenter.current().notificationSettings().authorizationStatus@@ -104,5 +99,74 @@ struct SettingsView: View {}}}++ @ViewBuilder private var notificationsRow: some View {+ if notificationsAllowed == true {+ LabeledContent("Notifications", value: "On")+ } else {+ Button {+ if notificationsAllowed == false {+ UIApplication.shared.open(URL(string: UIApplication.openNotificationSettingsURLString)!)+ } else {+ Task { notificationsAllowed = await PushRegistrar.shared.requestAuthorization() }+ }+ } label: {+ LabeledContent("Notifications", value: notificationsAllowed == false ? "Off in Settings" : "Turn on")+ .foregroundStyle(Palette.text)+ }+ }+ }+}++private struct ComputerRow: View {+ let computer: Pairing+ let active: Bool+ @Environment(BotStore.self) private var model++ var body: some View {+ HStack(spacing: 12) {+ ComputerBadge(name: computer.name, size: 40)+ VStack(alignment: .leading, spacing: 2) {+ Text(computer.name).font(.body.weight(.semibold)).foregroundStyle(Palette.text)+ Text(status).font(.subheadline).foregroundStyle(Palette.secondary).lineLimit(1)+ }+ Spacer()+ if active {+ Image(systemName: "checkmark").font(.body.weight(.semibold)).foregroundStyle(Palette.text)+ }+ }+ .padding(.vertical, 2)+ }++ private var status: String {+ guard active else { return "\(computer.urls.count) address\(computer.urls.count == 1 ? "" : "es")" }+ return switch model.connection {+ case .online: "Connected · \(model.bots.count) bot\(model.bots.count == 1 ? "" : "s")"+ case .connecting: "Connecting…"+ case .offline: "Offline"+ case .unpaired: "Not paired"+ }+ }}+private struct UsageDetail: View {+ @Environment(BotStore.self) private var model++ var body: some View {+ Form {+ Section {+ ForEach(model.usage.providers) { UsageCard(provider: $0) }+ if model.usage.providers.isEmpty {+ Text("No usage reported yet.").foregroundStyle(Palette.secondary)+ }+ } footer: {+ Text("Read on your computer from Claude Code and Codex. Add the Codync widget to your Home or Lock Screen to keep an eye on them.")+ }+ }+ .scrollContentBackground(.hidden)+ .background(Palette.background)+ .navigationTitle("Usage")+ .navigationBarTitleDisplayMode(.inline)+ .refreshable { await model.refreshUsage() }+ }+}diff --git a/Codync-macOS/Assets.xcassets/AppIcon.appiconset/image 1.png b/Codync-macOS/Assets.xcassets/AppIcon.appiconset/image 1.pngindex f07f8ae2..62bf8de0 100644Binary files a/Codync-macOS/Assets.xcassets/AppIcon.appiconset/image 1.png and b/Codync-macOS/Assets.xcassets/AppIcon.appiconset/image 1.png differdiff --git a/Codync-macOS/Assets.xcassets/AppIcon.appiconset/image 2.png b/Codync-macOS/Assets.xcassets/AppIcon.appiconset/image 2.pngindex f07f8ae2..62bf8de0 100644Binary files a/Codync-macOS/Assets.xcassets/AppIcon.appiconset/image 2.png and b/Codync-macOS/Assets.xcassets/AppIcon.appiconset/image 2.png differdiff --git a/Codync-macOS/Assets.xcassets/AppIcon.appiconset/image 3.png b/Codync-macOS/Assets.xcassets/AppIcon.appiconset/image 3.pngindex 53e527fa..e3d40905 100644Binary files a/Codync-macOS/Assets.xcassets/AppIcon.appiconset/image 3.png and b/Codync-macOS/Assets.xcassets/AppIcon.appiconset/image 3.png differdiff --git a/Codync-macOS/Assets.xcassets/AppIcon.appiconset/image 4.png b/Codync-macOS/Assets.xcassets/AppIcon.appiconset/image 4.pngindex 507aafc8..efa4858b 100644Binary files a/Codync-macOS/Assets.xcassets/AppIcon.appiconset/image 4.png and b/Codync-macOS/Assets.xcassets/AppIcon.appiconset/image 4.png differdiff --git a/Codync-macOS/Assets.xcassets/AppIcon.appiconset/image 5.png b/Codync-macOS/Assets.xcassets/AppIcon.appiconset/image 5.pngindex 4c71de79..c1add191 100644Binary files a/Codync-macOS/Assets.xcassets/AppIcon.appiconset/image 5.png and b/Codync-macOS/Assets.xcassets/AppIcon.appiconset/image 5.png differdiff --git a/Codync-macOS/Assets.xcassets/AppIcon.appiconset/image 6.png b/Codync-macOS/Assets.xcassets/AppIcon.appiconset/image 6.pngindex 33261ab1..d22b286d 100644Binary files a/Codync-macOS/Assets.xcassets/AppIcon.appiconset/image 6.png and b/Codync-macOS/Assets.xcassets/AppIcon.appiconset/image 6.png differdiff --git a/Codync-macOS/Assets.xcassets/AppIcon.appiconset/image 7.png b/Codync-macOS/Assets.xcassets/AppIcon.appiconset/image 7.pngindex 4c71de79..c1add191 100644Binary files a/Codync-macOS/Assets.xcassets/AppIcon.appiconset/image 7.png and b/Codync-macOS/Assets.xcassets/AppIcon.appiconset/image 7.png differdiff --git a/Codync-macOS/Assets.xcassets/AppIcon.appiconset/image 8.png b/Codync-macOS/Assets.xcassets/AppIcon.appiconset/image 8.pngindex 33261ab1..d22b286d 100644Binary files a/Codync-macOS/Assets.xcassets/AppIcon.appiconset/image 8.png and b/Codync-macOS/Assets.xcassets/AppIcon.appiconset/image 8.png differdiff --git a/Codync-macOS/Assets.xcassets/AppIcon.appiconset/image 9.png b/Codync-macOS/Assets.xcassets/AppIcon.appiconset/image 9.pngindex 7c716818..f0a1100a 100644Binary files a/Codync-macOS/Assets.xcassets/AppIcon.appiconset/image 9.png and b/Codync-macOS/Assets.xcassets/AppIcon.appiconset/image 9.png differdiff --git a/Codync-macOS/Assets.xcassets/AppIcon.appiconset/image.png b/Codync-macOS/Assets.xcassets/AppIcon.appiconset/image.pngindex c43552f6..4968ae14 100644Binary files a/Codync-macOS/Assets.xcassets/AppIcon.appiconset/image.png and b/Codync-macOS/Assets.xcassets/AppIcon.appiconset/image.png differdiff --git a/Codync-macOS/Assets.xcassets/MenuBarIcon.imageset/Contents.json b/Codync-macOS/Assets.xcassets/MenuBarIcon.imageset/Contents.jsonnew file mode 100644index 00000000..1d16ad4e--- /dev/null+++ b/Codync-macOS/Assets.xcassets/MenuBarIcon.imageset/Contents.json@@ -0,0 +1,8 @@+{+ "images" : [+ { "filename" : "[email protected]", "idiom" : "universal", "scale" : "1x" },+ { "filename" : "[email protected]", "idiom" : "universal", "scale" : "2x" }+ ],+ "info" : { "author" : "xcode", "version" : 1 },+ "properties" : { "template-rendering-intent" : "template" }+}diff --git a/Codync-macOS/Assets.xcassets/MenuBarIcon.imageset/[email protected] b/Codync-macOS/Assets.xcassets/MenuBarIcon.imageset/[email protected]new file mode 100644index 00000000..af50cc7bBinary files /dev/null and b/Codync-macOS/Assets.xcassets/MenuBarIcon.imageset/[email protected] differdiff --git a/Codync-macOS/Assets.xcassets/MenuBarIcon.imageset/[email protected] b/Codync-macOS/Assets.xcassets/MenuBarIcon.imageset/[email protected]new file mode 100644index 00000000..d62e2825Binary files /dev/null and b/Codync-macOS/Assets.xcassets/MenuBarIcon.imageset/[email protected] differdiff --git a/Codync-macOS/Assets.xcassets/MenuBarIconAlert.imageset/Contents.json b/Codync-macOS/Assets.xcassets/MenuBarIconAlert.imageset/Contents.jsonnew file mode 100644index 00000000..6b5e3083--- /dev/null+++ b/Codync-macOS/Assets.xcassets/MenuBarIconAlert.imageset/Contents.json@@ -0,0 +1,8 @@+{+ "images" : [+ { "filename" : "[email protected]", "idiom" : "universal", "scale" : "1x" },+ { "filename" : "[email protected]", "idiom" : "universal", "scale" : "2x" }+ ],+ "info" : { "author" : "xcode", "version" : 1 },+ "properties" : { "template-rendering-intent" : "template" }+}diff --git a/Codync-macOS/Assets.xcassets/MenuBarIconAlert.imageset/[email protected] b/Codync-macOS/Assets.xcassets/MenuBarIconAlert.imageset/[email protected]new file mode 100644index 00000000..985c934bBinary files /dev/null and b/Codync-macOS/Assets.xcassets/MenuBarIconAlert.imageset/[email protected] differdiff --git a/Codync-macOS/Assets.xcassets/MenuBarIconAlert.imageset/[email protected] b/Codync-macOS/Assets.xcassets/MenuBarIconAlert.imageset/[email protected]new file mode 100644index 00000000..6f013241Binary files /dev/null and b/Codync-macOS/Assets.xcassets/MenuBarIconAlert.imageset/[email protected] differdiff --git a/Codync-macOS/ChatWindow.swift b/Codync-macOS/ChatWindow.swiftindex 50be7bcf..187f5665 100644--- a/Codync-macOS/ChatWindow.swift+++ b/Codync-macOS/ChatWindow.swift@@ -29,10 +29,12 @@ private struct ChatSplitView: View {@Environment(BotStore.self) private var model@State private var editing: EditorRequest?@State private var confirmDelete: Bot?+ @State private var composing = false+ @State private var columns: NavigationSplitViewVisibility = .allvar body: some View {@Bindable var model = model- NavigationSplitView {+ NavigationSplitView(columnVisibility: $columns) {List(selection: $model.selection) {ConnectionBanner()if !model.usage.providers.isEmpty {@@ -56,13 +58,18 @@ private struct ChatSplitView: View {.navigationTitle(model.hostName).toolbar {ToolbarItem {- Button("New Bot", systemImage: "square.and.pencil") { editing = EditorRequest(BotDraft()) }+ Button("New Message", systemImage: "square.and.pencil") {+ model.selection = nil+ composing = true+ }.keyboardShortcut("n").disabled(model.connection != .online)}}} detail: {- if let id = model.selection, model.bots[id] != nil {+ if composing {+ NewChatView { composing = false }+ } else if let id = model.selection, model.bots[id] != nil {NavigationStack { ThreadView(botId: id) }.id(id)} else {@@ -72,12 +79,15 @@ private struct ChatSplitView: View {CharacterAvatar(shape: "squircle", color: "orange", size: 60)CharacterAvatar(shape: "teardrop", color: "violet", size: 60, mood: .working)}- Text("Your coding agents, as teammates.").font(.title2.bold())+ Text("Your coding agents, as teammates.").font(.title2.weight(.semibold))Text("Pick a bot, or create one for each kind of work and point it at a project.").foregroundStyle(Palette.secondary)- Button("New Bot") { editing = EditorRequest(BotDraft()) }- .buttonStyle(.borderedProminent)- .tint(Palette.accentFill)+ Button("New Bot") { composing = true }+ .buttonStyle(.plain)+ .font(.body.weight(.semibold))+ .padding(.horizontal, 18)+ .padding(.vertical, 9)+ .background(Palette.accentFill, in: Capsule()).foregroundStyle(Palette.onAccent)}.frame(maxWidth: .infinity, maxHeight: .infinity)@@ -89,5 +99,17 @@ private struct ChatSplitView: View {}.deleteBotConfirmation($confirmDelete).storeErrorAlert(model)+ .onChange(of: model.selection) { _, id in if id != nil { composing = false } }+ #if DEBUG+ .onAppear {+ // Screenshot/UI checks: CODYNC_DEBUG_OPEN=compose | <bot name>+ let target = ProcessInfo.processInfo.environment["CODYNC_DEBUG_OPEN"]+ if target == "compose" {+ composing = true+ } else if let target, let bot = model.roster.first(where: { $0.name == target }) {+ model.selection = bot.id+ }+ }+ #endif}}diff --git a/Codync-macOS/CodyncMacApp.swift b/Codync-macOS/CodyncMacApp.swiftindex 79393f44..4901f4f4 100644--- a/Codync-macOS/CodyncMacApp.swift+++ b/Codync-macOS/CodyncMacApp.swift@@ -13,7 +13,8 @@ struct CodyncMacApp: App {.environment(host).frame(width: 340)} label: {- Image(systemName: host.needsAttention ? "person.2.badge.gearshape.fill" : host.working > 0 ? "person.2.wave.2.fill" : "person.2.fill")+ // The Codync mark; a dot joins it when a bot needs you.+ Image(host.needsAttention ? "MenuBarIconAlert" : "MenuBarIcon").task { host.start() }}.menuBarExtraStyle(.window)diff --git a/Codync.xcodeproj/project.pbxproj b/Codync.xcodeproj/project.pbxprojindex d34b09a7..0eec676a 100644--- a/Codync.xcodeproj/project.pbxproj+++ b/Codync.xcodeproj/project.pbxproj@@ -19,8 +19,10 @@55D43F0D178B7A63BA4E81F3 /* CodyncWidgets.appex in Embed Foundation Extensions */ = {isa = PBXBuildFile; fileRef = 04030896973C4041E7FEB319 /* CodyncWidgets.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };61455BFB935FE1AAF67C4CD4 /* Push.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74E27E10BA8F07E552E99BE9 /* Push.swift */; };76E613DFEABF73915C5FE9DC /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = AF5474468D6EBF22CB2FA1E9 /* Assets.xcassets */; };+ 956D20C2D50A4D88F47AF700 /* PrivacyInfo.xcprivacy in Resources */ = {isa = PBXBuildFile; fileRef = 6C77446ADDBAA86236BC6F35 /* PrivacyInfo.xcprivacy */; };989285CFB52552A97D95366C /* PairingView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 528534881700FE0CF94A49BC /* PairingView.swift */; };9D644515BB782DC91B1B71C8 /* SettingsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = CD4B599F142017103B340A87 /* SettingsView.swift */; };+ A5BC3A614AB38A7A4E28B160 /* PrivacyInfo.xcprivacy in Resources */ = {isa = PBXBuildFile; fileRef = DB5C5DC7D03F6400ABA9A133 /* PrivacyInfo.xcprivacy */; };CED43A6F2ED71E48C95E9E38 /* HostController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01C28522569623733B9B096D /* HostController.swift */; };CEFE64EFFEA10B5ED60F2CE3 /* CodyncApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = A3FCD76B514C8ECF2211945A /* CodyncApp.swift */; };D667C45D828CAD079A2EDD77 /* CodyncKit in Frameworks */ = {isa = PBXBuildFile; productRef = 4364B5D2EE15CB00ACF26E5D /* CodyncKit */; };@@ -63,6 +65,7 @@371D72CCCB665E6442DED8C8 /* BotListView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BotListView.swift; sourceTree = "<group>"; };38FE26380B2072AE3FBD5CF5 /* CodyncWidgets.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = CodyncWidgets.entitlements; sourceTree = "<group>"; };528534881700FE0CF94A49BC /* PairingView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PairingView.swift; sourceTree = "<group>"; };+ 6C77446ADDBAA86236BC6F35 /* PrivacyInfo.xcprivacy */ = {isa = PBXFileReference; path = PrivacyInfo.xcprivacy; sourceTree = "<group>"; };6CCA896856A480F390EBA9AB /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist; path = Info.plist; sourceTree = "<group>"; };6EBEF05AFCCF44C92BDA91A3 /* RootView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RootView.swift; sourceTree = "<group>"; };6F8473D6F162F5D18EF9D2EC /* ChatWindow.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChatWindow.swift; sourceTree = "<group>"; };@@ -75,6 +78,7 @@AF5474468D6EBF22CB2FA1E9 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };B274A0195CB3B2409EA4C194 /* WidgetKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = WidgetKit.framework; path = System/Library/Frameworks/WidgetKit.framework; sourceTree = SDKROOT; };CD4B599F142017103B340A87 /* SettingsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsView.swift; sourceTree = "<group>"; };+ DB5C5DC7D03F6400ABA9A133 /* PrivacyInfo.xcprivacy */ = {isa = PBXFileReference; path = PrivacyInfo.xcprivacy; sourceTree = "<group>"; };E70F8B0E7E2E15AAA8A2A0A7 /* CodyncWidgets.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CodyncWidgets.swift; sourceTree = "<group>"; };/* End PBXFileReference section */@@ -135,6 +139,7 @@38FE26380B2072AE3FBD5CF5 /* CodyncWidgets.entitlements */,E70F8B0E7E2E15AAA8A2A0A7 /* CodyncWidgets.swift */,1753C1409D62F8F721BE833F /* Info.plist */,+ DB5C5DC7D03F6400ABA9A133 /* PrivacyInfo.xcprivacy */,);path = CodyncWidgets;sourceTree = "<group>";@@ -176,6 +181,7 @@AF5474468D6EBF22CB2FA1E9 /* Assets.xcassets */,A30032680EAD00ABD06D30BE /* Codync-iOS.entitlements */,6CCA896856A480F390EBA9AB /* Info.plist */,+ 6C77446ADDBAA86236BC6F35 /* PrivacyInfo.xcprivacy */,F474B3D70851CF6BC24ED9DE /* App */,EE65F2FAD6D95ABE28885E83 /* Views */,);@@ -233,6 +239,7 @@buildConfigurationList = 44E0D659F23143196DD57DE0 /* Build configuration list for PBXNativeTarget "CodyncWidgets" */;buildPhases = (EB674074085209A1C457557E /* Sources */,+ AD74120AC78F1A5E6D6E9CFF /* Resources */,F84176A6E29D7445556D4800 /* Frameworks */,);buildRules = (@@ -279,12 +286,15 @@LastUpgradeCheck = 1430;TargetAttributes = {306ED26C181D06BDE1E6EB55 = {+ DevelopmentTeam = 7FUM8A8H72;ProvisioningStyle = Automatic;};95A633B0E0FD05A1D35CA468 = {+ DevelopmentTeam = 7FUM8A8H72;ProvisioningStyle = Automatic;};E8A9607522E696738C5CA56E = {+ DevelopmentTeam = 7FUM8A8H72;ProvisioningStyle = Automatic;};};@@ -314,11 +324,20 @@/* End PBXProject section *//* Begin PBXResourcesBuildPhase section */+ AD74120AC78F1A5E6D6E9CFF /* Resources */ = {+ isa = PBXResourcesBuildPhase;+ buildActionMask = 2147483647;+ files = (+ A5BC3A614AB38A7A4E28B160 /* PrivacyInfo.xcprivacy in Resources */,+ );+ runOnlyForDeploymentPostprocessing = 0;+ };D4DD49FA9E802F4F2DF2B232 /* Resources */ = {isa = PBXResourcesBuildPhase;buildActionMask = 2147483647;files = (76E613DFEABF73915C5FE9DC /* Assets.xcassets in Resources */,+ 956D20C2D50A4D88F47AF700 /* PrivacyInfo.xcprivacy in Resources */,);runOnlyForDeploymentPostprocessing = 0;};@@ -436,6 +455,7 @@CURRENT_PROJECT_VERSION = 17;DEAD_CODE_STRIPPING = YES;DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";+ DEVELOPMENT_TEAM = 7FUM8A8H72;ENABLE_NS_ASSERTIONS = NO;ENABLE_STRICT_OBJC_MSGSEND = YES;ENABLE_USER_SCRIPT_SANDBOXING = NO;@@ -592,6 +612,7 @@CURRENT_PROJECT_VERSION = 17;DEAD_CODE_STRIPPING = YES;DEBUG_INFORMATION_FORMAT = dwarf;+ DEVELOPMENT_TEAM = 7FUM8A8H72;ENABLE_STRICT_OBJC_MSGSEND = YES;ENABLE_TESTABILITY = YES;ENABLE_USER_SCRIPT_SANDBOXING = NO;diff --git a/CodyncKit/Sources/CodyncKit/CharacterAvatar.swift b/CodyncKit/Sources/CodyncKit/CharacterAvatar.swiftindex 53421376..ea99201b 100644--- a/CodyncKit/Sources/CodyncKit/CharacterAvatar.swift+++ b/CodyncKit/Sources/CodyncKit/CharacterAvatar.swift@@ -1,7 +1,9 @@import SwiftUI-/// Grok-Bot-style character: a colored shape with slit eyes. The eyes drift-/// while the bot works; a badge shows when it needs you.+/// Grok-Bot-style character drawn like the app icon: an even grid of dots,+/// shaded as if the silhouette were a ball, with the eyes left hollow (two+/// missing pairs of dots). The eyes glance side to side while the bot works+/// and blink now and then; a badge shows when it needs you.public struct CharacterAvatar: View {public enum Mood: Sendable { case idle, working, needsInput }@@ -27,26 +29,20 @@ public struct CharacterAvatar: View {}public var body: some View {- ZStack {- // too few dots below ~24pt to read as a character — stay solid- if size < 24 {- CharacterShape(kind: shape).fill(color.gradient)- } else {- DottedBody(shape: shape, color: color, size: size, mood: mood)- }- Eyes(size: size, working: mood == .working)- .offset(y: -size * 0.03)- }- .frame(width: size, height: size)- .accessibilityHidden(true)+ DottedBody(shape: shape, color: color, size: size, mood: mood)+ .frame(width: size, height: size)+ .accessibilityHidden(true)}}-/// The body as a halftone of dots (after thinking-orbs): each dot is shaded as-/// if the silhouette were a sphere, so size and ink carry the depth. The body-/// is grey ink; the bot's color only lands on the brightest dots. Working-/// swings the light around the body; needing you sends a ripple out from the-/// center. Idle is a still frame lit from the upper left.+/// Grid geometry shared by the dotted body: 13 columns, the eyes are the dots+/// in columns 4 and 8 of rows 4-6 (shifted one column while glancing).+private enum Grid {+ static let cells = 13+ static let eyeColumns = [4, 8]+ static let eyeRows = [4, 5, 6]+}+private struct DottedBody: View {let shape: Stringlet color: Color@@ -55,17 +51,34 @@ private struct DottedBody: View {@Environment(\.accessibilityReduceMotion) private var reduceMotionvar body: some View {- let step = size / 16+ let step = size / CGFloat(Grid.cells)let dots = Self.grid(shape: shape, size: size, step: step)let still = mood == .idle || reduceMotionTimelineView(.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.+ let glance = mood == .working ? Int((sin(t * 2 * .pi / 3.2) * 1.4).rounded()) : 0+ let blinking = !still && (t / 4.7).truncatingRemainder(dividingBy: 1) < 0.035+ let eyeRows = blinking ? [Grid.eyeRows[2]] : Grid.eyeRows+ let eyeCols = Grid.eyeColumns.map { $0 + glance }Canvas { ctx, _ in+ // Below ~24pt the dots stop reading: a solid body with the same hollow eyes.+ if size < 24 {+ ctx.fill(CharacterShape(kind: shape).path(in: CGRect(x: 0, y: 0, width: size, height: size)), with: .color(color))+ ctx.blendMode = .clear+ for c in eyeCols {+ for r in eyeRows {+ ctx.fill(Path(CGRect(x: CGFloat(c) * step, y: CGFloat(r) * step, width: step, height: step)), with: .color(.black))+ }+ }+ return+ }let half = size / 2let yaw = mood == .working ? t * 1.4 : -0.7let lx = sin(yaw) * 0.8, ly = 0.55, lz = cos(yaw) * 0.5 + 0.6 // never fully behindlet ll = (lx * lx + ly * ly + lz * lz).squareRoot()- for p in dots {+ for d in dots where !(eyeCols.contains(d.col) && eyeRows.contains(d.row)) {+ let p = d.centerlet u = (p.x - half) / half, v = (half - p.y) / halflet z = max(0.2, 1 - u * u - v * v).squareRoot()let nl = (u * u + v * v + z * z).squareRoot()@@ -74,62 +87,34 @@ private struct DottedBody: View {let ripple = 0.5 + 0.5 * sin((u * u + v * v).squareRoot() * 9 - t * 5)shade *= 0.6 + 0.4 * ripple}- let r = step * 0.38 * (0.3 + 0.7 * shade)+ let r = step * 0.42 * (0.55 + 0.45 * shade)let dot = Path(ellipseIn: CGRect(x: p.x - r, y: p.y - r, width: r * 2, height: r * 2))- ctx.fill(dot, with: .color(Palette.text.opacity(0.12 + 0.33 * min(1, shade / 0.7))))- if shade > 0.7 {- ctx.fill(dot, with: .color(color.opacity((shade - 0.7) / 0.3)))+ ctx.fill(dot, with: .color(Palette.text.opacity(0.2 + 0.4 * min(1, shade / 0.7))))+ if shade > 0.6 {+ ctx.fill(dot, with: .color(color.opacity((shade - 0.6) / 0.4)))}}}}}- /// Hex-packed dot centers that fall inside the silhouette.- static func grid(shape: String, size: CGFloat, step: CGFloat) -> [CGPoint] {- let path = CharacterShape(kind: shape).path(in: CGRect(x: 0, y: 0, width: size, height: size))- let rowH = step * 0.866- var out: [CGPoint] = []- var row = 0- var y = rowH / 2- while y < size {- var x = row.isMultiple(of: 2) ? step / 2 : step- while x < size {- let p = CGPoint(x: x, y: y)- if path.contains(p) { out.append(p) }- x += step- }- y += rowH- row += 1- }- return out+ struct Dot {+ let row: Int+ let col: Int+ let center: CGPoint}-}--/// Two thin lit slits that blink now and then and drift slowly while working.-private struct Eyes: View {- let size: CGFloat- let working: Bool- @Environment(\.accessibilityReduceMotion) private var reduceMotion- var body: some View {- HStack(spacing: size * 0.2 - max(1.4, size * 0.038)) {- ForEach(0..<2, id: \.self) { _ in- Capsule()- .fill(Palette.text)- .frame(width: max(1.4, size * 0.038), height: size * 0.12)+ /// Square-grid dot centers that fall inside the silhouette.+ static func grid(shape: String, size: CGFloat, step: CGFloat) -> [Dot] {+ let path = CharacterShape(kind: shape).path(in: CGRect(x: 0, y: 0, width: size, height: size))+ var out: [Dot] = []+ for row in 0..<Grid.cells {+ for col in 0..<Grid.cells {+ let p = CGPoint(x: (CGFloat(col) + 0.5) * step, y: (CGFloat(row) + 0.5) * step)+ if path.contains(p) { out.append(Dot(row: row, col: col, center: p)) }}}- .keyframeAnimator(initialValue: 1.0, repeating: !reduceMotion) { view, open in- view.scaleEffect(y: open)- } keyframes: { _ in- LinearKeyframe(1.0, duration: 4.5)- LinearKeyframe(0.12, duration: 0.08)- LinearKeyframe(1.0, duration: 0.1)- }- .phaseAnimator(working && !reduceMotion ? [-1.0, 1.0] : [0.0]) { view, phase in- view.offset(x: phase * size * 0.04)- } animation: { _ in .easeInOut(duration: 1.6) }+ return out}}@@ -223,3 +208,26 @@ public struct AvatarWithStatus: View {}}}++/// A computer's round monogram: the profile button and the rows that switch computers.+public struct ComputerBadge: View {+ let name: String+ let size: CGFloat++ public init(name: String, size: CGFloat = 36) {+ self.name = name+ self.size = size+ }++ public var body: some View {+ Circle()+ .fill(LinearGradient(colors: [Color(hex: 0x5A5A5A), Color(hex: 0x2E2E2E)], startPoint: .top, endPoint: .bottom))+ .overlay(+ Text(name.first.map { String($0).uppercased() } ?? "?")+ .font(.system(size: size * 0.42, weight: .semibold, design: .rounded))+ .foregroundStyle(.white)+ )+ .frame(width: size, height: size)+ .accessibilityHidden(true)+ }+}diff --git a/CodyncKit/Sources/CodyncKit/SharedStore.swift b/CodyncKit/Sources/CodyncKit/SharedStore.swiftindex 1b0d379c..01fa2e5e 100644--- a/CodyncKit/Sources/CodyncKit/SharedStore.swift+++ b/CodyncKit/Sources/CodyncKit/SharedStore.swift@@ -13,6 +13,16 @@ public enum SharedStore {set { defaults.set(newValue.flatMap { try? JSONEncoder().encode($0) }, forKey: "pairing") }}+ /// Every computer this phone has paired with, most recently used first.+ /// `pairing` is the active one.+ public static var computers: [Pairing] {+ get {+ let saved = defaults.data(forKey: "computers").flatMap { try? JSONDecoder().decode([Pairing].self, from: $0) } ?? []+ return saved.isEmpty ? pairing.map { [$0] } ?? [] : saved+ }+ set { defaults.set(try? JSONEncoder().encode(newValue), forKey: "computers") }+ }+/// Last address that answered, tried first next time.public static var preferredURL: String? {get { defaults.string(forKey: "preferredURL") }@@ -24,6 +34,12 @@ public enum SharedStore {set { defaults.set(newValue.flatMap { try? JSONEncoder().encode($0) }, forKey: "usage") }}+ /// Roster snapshot for the Bots widget, written by the app as bots change.+ public static var bots: [Bot] {+ get { defaults.data(forKey: "bots").flatMap { try? JSONDecoder().decode([Bot].self, from: $0) } ?? [] }+ set { defaults.set(try? JSONEncoder().encode(newValue), forKey: "bots") }+ }+/// Pairing with the last working address moved to the front.public static var orderedPairing: Pairing? {guard var p = pairing else { return nil }diff --git a/CodyncKit/Sources/CodyncKit/Theme.swift b/CodyncKit/Sources/CodyncKit/Theme.swiftindex 0dbbe935..d95f9c47 100644--- a/CodyncKit/Sources/CodyncKit/Theme.swift+++ b/CodyncKit/Sources/CodyncKit/Theme.swift@@ -36,40 +36,30 @@ public extension Color {}}-/// Ink on paper: neutral graphite, and the text color doubles as the accent.-/// Color comes from the bots themselves; the chrome stays monochrome, with-/// amber kept for "needs you" and red for errors.+/// Black and white: a pure black (or white) ground, grey bubbles, and color that+/// comes only from the bots; amber marks "needs you" and red marks errors.public enum Palette {- public static let background = Color(light: 0xF7F7F5, dark: 0x0E0F0E)- public static let surface = Color(light: 0xFFFFFF, dark: 0x171817)- public static let bubbleAgent = Color(light: 0xEFEFEC, dark: 0x1E1F1E)- public static let border = Color(light: 0xE4E4E0, dark: 0x2A2B2A)- public static let text = Color(light: 0x161716, dark: 0xEDEDEA)- public static let secondary = Color(light: 0x5E5F5C, dark: 0xA3A4A0)- public static let tertiary = Color(light: 0x94958F, dark: 0x6C6D69)- /// Ink used for fills (user bubbles, primary buttons).- public static let accentFill = Color(light: 0x161716, dark: 0xEDEDEA)+ public static let background = Color(light: 0xFFFFFF, dark: 0x000000)+ public static let surface = Color(light: 0xF4F4F4, dark: 0x141414)+ public static let bubbleAgent = Color(light: 0xF0F0F0, dark: 0x1C1C1C)+ public static let bubbleUser = Color(light: 0xE2E2E2, dark: 0x3A3A3A)+ public static let border = Color(light: 0xE6E6E6, dark: 0x262626)+ public static let text = Color(light: 0x141414, dark: 0xF2F2F2)+ public static let secondary = Color(light: 0x6B6B6B, dark: 0x9A9A9A)+ public static let tertiary = Color(light: 0x9B9B9B, dark: 0x6E6E6E)+ /// Ink used for fills (primary buttons, the send button, unread badges).+ public static let accentFill = Color(light: 0x000000, dark: 0xFFFFFF)/// Ink readable as text and tint on the background.- public static let accent = Color(light: 0x161716, dark: 0xEDEDEA)- public static let onAccent = Color(light: 0xF7F7F5, dark: 0x0E0F0E)- public static let accentDim = Color(light: 0xDADAD6, dark: 0x3A3B39)+ public static let accent = Color(light: 0x000000, dark: 0xFFFFFF)+ public static let onAccent = Color(light: 0xFFFFFF, dark: 0x000000)+ 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)- public static let codeBackground = Color(light: 0xF1F1EE, dark: 0x141514)+ 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)}-public extension View {- /// Small tracked monospaced caps for metadata: times, states, section labels.- func metaStyle(_ color: Color = Palette.tertiary) -> some View {- font(.system(size: 10.5, weight: .medium, design: .monospaced))- .tracking(0.6)- .textCase(.uppercase)- .foregroundStyle(color)- }-}-public enum AvatarPalette {public struct Swatch: Identifiable, Hashable, Sendable {public let id: String@@ -112,6 +102,24 @@ public enum RelativeTime {}}+ /// Roster stamp: 3:45 AM · Yesterday · Wednesday · Sep 16+ public static func day(_ date: Date, now: Date = .now) -> String {+ let cal = Calendar.current+ if cal.isDate(date, inSameDayAs: now) { return date.formatted(date: .omitted, time: .shortened) }+ if cal.isDateInYesterday(date) { return String(localized: "Yesterday") }+ if now.timeIntervalSince(date) < 6 * 86_400 { return date.formatted(.dateTime.weekday(.wide)) }+ return date.formatted(.dateTime.month(.abbreviated).day())+ }++ /// Chat separator: Today 3:27 AM · Yesterday 5:20 PM · Sep 16 9:02 AM+ public static func separator(_ date: Date) -> String {+ let cal = Calendar.current+ let day = cal.isDateInToday(date) ? String(localized: "Today")+ : cal.isDateInYesterday(date) ? String(localized: "Yesterday")+ : date.formatted(.dateTime.month(.abbreviated).day())+ return day + " " + date.formatted(date: .omitted, time: .shortened)+ }+public static func until(_ date: Date, now: Date = .now) -> String {let s = max(0, date.timeIntervalSince(now))let h = Int(s / 3600), m = Int(s.truncatingRemainder(dividingBy: 3600) / 60)diff --git a/CodyncKit/Sources/CodyncUI/BotEditorView.swift b/CodyncKit/Sources/CodyncUI/BotEditorView.swiftindex bcd45014..a33e7af3 100644--- a/CodyncKit/Sources/CodyncUI/BotEditorView.swift+++ b/CodyncKit/Sources/CodyncUI/BotEditorView.swift@@ -8,7 +8,7 @@ public struct EditorRequest: Identifiable {public init(_ draft: BotDraft) { self.draft = draft }}-/// Create or edit a bot: who it is, which agent, which project, how much it may do alone.+/// Create or edit a bot in a sheet (iPhone): the settings form plus Cancel / Save.public struct BotEditorView: View {@Environment(BotStore.self) private var model@Environment(\.dismiss) private var dismiss@@ -17,105 +17,186 @@ public struct BotEditorView: View {public init(draft: BotDraft) { _draft = State(initialValue: draft) }@State private var saving = false@State private var error: String?- @State private var pickingFolder = falseprivate var isNew: Bool { draft.id == nil }public var body: some View {- Form {- Section {- VStack(spacing: 14) {- CharacterAvatar(shape: draft.avatarShape, color: draft.avatarColor, size: 84, mood: .working)- TextField("Name", text: $draft.name)- .font(.title3.weight(.semibold))- .multilineTextAlignment(.center)- AvatarPicker(shape: $draft.avatarShape, color: $draft.avatarColor)+ BotSettingsForm(draft: $draft, error: error)+ .navigationTitle(isNew ? "New bot" : "Settings")+ .inlineNavigationTitle()+ .toolbar {+ ToolbarItem(placement: .cancellationAction) {+ Button("Cancel", systemImage: "xmark") { dismiss() }.labelStyle(.iconOnly).help("Cancel")+ }+ ToolbarItem(placement: .confirmationAction) {+ if saving {+ ProgressView()+ } else {+ Button(isNew ? "Create" : "Save", systemImage: "checkmark") { save() }+ .labelStyle(.iconOnly)+ .help(isNew ? "Create" : "Save")+ .disabled(!draft.isValid)+ }}- .frame(maxWidth: .infinity)- .padding(.vertical, 6)}+ .onAppear { if isNew { model.fillDefaults(&draft) } }+ }- Section {- TextField("e.g. Reviews PRs. Never pushes without asking. Answers in Traditional Chinese.", text: $draft.description, axis: .vertical)- .lineLimit(3...8)- } header: {- Text("Standing instructions")- } footer: {- Text("Rules that always apply. Put task-specific requests in the chat instead.")+ private func save() {+ saving = true+ error = nil+ Task {+ do {+ let bot = try await model.save(draft.normalized)+ dismiss()+ if isNew { model.selection = bot.id }+ } catch {+ self.error = error.localizedDescription}+ saving = false+ }+ }+}- Section("Agent") {- Picker("Runs on", selection: $draft.backend) {- ForEach(model.hello?.backends ?? []) { b in- Text(b.available ? b.name : "\(b.name) (not installed)").tag(b.id)- }- Text("Custom command").tag("custom")+/// The desktop inspector next to a conversation: the same form, saved as you edit.+public struct BotSettingsPanel: View {+ let botId: String+ @Environment(BotStore.self) private var model+ @State private var draft: BotDraft?+ @State private var error: String?++ public init(botId: String) { self.botId = botId }++ public var body: some View {+ Group {+ if let binding = Binding($draft) {+ BotSettingsForm(draft: binding, error: error)+ } else {+ Color.clear+ }+ }+ .task(id: botId) {+ draft = model.bots[botId].map(BotDraft.init)+ }+ .task(id: draft) {+ // Autosave a moment after the last change.+ guard let draft, let bot = model.bots[botId], draft != BotDraft(bot), draft.isValid else { return }+ try? await Task.sleep(for: .milliseconds(600))+ guard !Task.isCancelled else { return }+ do {+ _ = try await model.save(draft.normalized)+ error = nil+ } catch {+ self.error = error.localizedDescription+ }+ }+ }+}++/// Grok Bot-style bot settings: a big avatar, labeled fields, and one card of options.+struct BotSettingsForm: View {+ @Binding var draft: BotDraft+ let error: String?+ @Environment(BotStore.self) private var model+ @State private var pickingFolder = false++ var body: some View {+ ScrollView {+ VStack(alignment: .leading, spacing: 18) {+ VStack(spacing: 16) {+ CharacterAvatar(shape: draft.avatarShape, color: draft.avatarColor, size: 96)+ .padding(18)+ .background(Palette.bubbleAgent, in: RoundedRectangle(cornerRadius: 24, style: .continuous))+ AvatarPicker(shape: $draft.avatarShape, color: $draft.avatarColor)}- if let b = model.hello?.backends.first(where: { $0.id == draft.backend }), !b.available {- Text(b.installHint).font(.footnote).foregroundStyle(Palette.warning)+ .frame(maxWidth: .infinity)++ Field("Name") {+ TextField("Name", text: $draft.name).fieldBox()}- if draft.backend == "custom" {- TextField("ACP command, e.g. my-agent --acp", text: Binding(get: { draft.command ?? "" }, set: { draft.command = $0.isEmpty ? nil : $0 }))- .font(.callout.monospaced())- .plainTextInput()- .autocorrectionDisabled()+ Field("Standing instructions") {+ TextField("e.g. Reviews PRs. Never pushes without asking.", text: $draft.description, axis: .vertical)+ .lineLimit(3...8)+ .fieldBox()+ Text("Rules that always apply. Put task-specific requests in the chat instead.")+ .font(.caption)+ .foregroundStyle(Palette.tertiary)}- TextField("Model (optional)", text: Binding(get: { draft.model ?? "" }, set: { draft.model = $0.isEmpty ? nil : $0 }))- .plainTextInput()- .autocorrectionDisabled()- }- Section {- Button {- pickingFolder = true- } label: {- LabeledContent("Project folder") {- Text(draft.cwd.isEmpty ? "Choose…" : (draft.cwd as NSString).lastPathComponent)- .foregroundStyle(draft.cwd.isEmpty ? Palette.accent : Palette.secondary)+ VStack(spacing: 0) {+ OptionRow("Agent") {+ Picker("Agent", selection: $draft.backend) {+ ForEach(model.hello?.backends ?? []) { b in+ Text(b.available ? b.name : "\(b.name) (not installed)").tag(b.id)+ }+ Text("Custom command").tag("custom")+ }+ .labelsHidden()+ .fixedSize()}- .foregroundStyle(Palette.text)- }- } footer: {- if !draft.cwd.isEmpty {- Text(draft.cwd).font(.caption.monospaced())+ if let b = model.hello?.backends.first(where: { $0.id == draft.backend }), !b.available {+ Text(b.installHint).font(.caption).foregroundStyle(Palette.warning)+ .frame(maxWidth: .infinity, alignment: .leading)+ .padding(.bottom, 10)+ }+ if draft.backend == "custom" {+ TextField("ACP command, e.g. my-agent --acp", text: Binding(get: { draft.command ?? "" }, set: { draft.command = $0.isEmpty ? nil : $0 }))+ .font(.callout.monospaced())+ .plainTextInput()+ .fieldBox()+ .padding(.bottom, 10)+ }+ Divider().overlay(Palette.border)+ OptionRow("Model") {+ TextField("Default", text: Binding(get: { draft.model ?? "" }, set: { draft.model = $0.isEmpty ? nil : $0 }))+ .plainTextInput()+ .multilineTextAlignment(.trailing)+ .textFieldStyle(.plain)+ .frame(maxWidth: 200)+ }+ Divider().overlay(Palette.border)+ OptionRow("Project folder") {+ Button(draft.cwd.isEmpty ? "Choose…" : (draft.cwd as NSString).lastPathComponent) { pickingFolder = true }+ .buttonStyle(.plain)+ .foregroundStyle(draft.cwd.isEmpty ? Palette.text : Palette.secondary)+ .help(draft.cwd)+ }+ Divider().overlay(Palette.border)+ OptionRow("Permissions") {+ Picker("Permissions", selection: $draft.permission) {+ Text("Ask me").tag("ask")+ Text("Approve automatically").tag("auto")+ }+ .labelsHidden()+ .fixedSize()+ }+ Divider().overlay(Palette.border)+ Toggle(isOn: Binding(get: { draft.notify ?? true }, set: { draft.notify = $0 })) {+ VStack(alignment: .leading, spacing: 2) {+ Text("Notifications").foregroundStyle(Palette.text)+ Text("When it finishes or needs you").font(.caption).foregroundStyle(Palette.secondary)+ }+ }+ .toggleStyle(.switch)+ .padding(.vertical, 12)}- }+ .padding(.horizontal, 16)+ .background(Palette.bubbleAgent, in: RoundedRectangle(cornerRadius: 16, style: .continuous))- Section {- Picker("Permissions", selection: $draft.permission) {- Text("Ask me").tag("ask")- Text("Approve automatically").tag("auto")- }- Toggle("Notifications", isOn: Binding(get: { draft.notify ?? true }, set: { draft.notify = $0 }))- } footer: {Text(draft.permission == "auto"- ? "Tool requests are approved once, automatically. Your agent's own settings (like Claude Code's permission rules) still apply."+ ? "Tool requests are approved automatically. Your agent's own settings (like Claude Code's permission rules) still apply.": "You'll get an approval card and a notification whenever the agent asks.")- }+ .font(.caption)+ .foregroundStyle(Palette.tertiary)- if let error {- Section { Text(error).foregroundStyle(Palette.danger) }- }- }- .scrollContentBackground(.hidden)- .background(Palette.background)- .navigationTitle(isNew ? "New bot" : "Edit bot")- .inlineNavigationTitle()- .toolbar {- ToolbarItem(placement: .cancellationAction) {- Button("Cancel", systemImage: "xmark") { dismiss() }.labelStyle(.iconOnly).help("Cancel")- }- ToolbarItem(placement: .confirmationAction) {- if saving {- ProgressView()- } else {- Button(isNew ? "Create" : "Save", systemImage: "checkmark") { save() }- .labelStyle(.iconOnly)- .help(isNew ? "Create" : "Save")- .disabled(draft.name.trimmingCharacters(in: .whitespaces).isEmpty || draft.cwd.isEmpty)+ if let error {+ Text(error).font(.footnote).foregroundStyle(Palette.danger)}}+ .padding(20)}+ .scrollDismissesKeyboard(.interactively)+ .background(Palette.background).sheet(isPresented: $pickingFolder) {NavigationStack {FolderPicker(path: draft.cwd.isEmpty ? model.hello?.home : draft.cwd) {@@ -128,29 +209,88 @@ public struct BotEditorView: View {}}}+ #if os(macOS)+ .frame(minWidth: 460, minHeight: 520)+ #endif}- .onAppear {- if isNew, draft.backend == "claude", model.hello?.backends.first(where: { $0.id == "claude" })?.available == false,- let first = model.hello?.backends.first(where: \.available) {- draft.backend = first.id- }+ }+}++private struct Field<Content: View>: View {+ let label: String+ @ViewBuilder let content: Content++ init(_ label: String, @ViewBuilder content: () -> Content) {+ self.label = label+ self.content = content()+ }++ var body: some View {+ VStack(alignment: .leading, spacing: 6) {+ Text(label).font(.subheadline).foregroundStyle(Palette.secondary).padding(.leading, 4)+ content}}+}- private func save() {- saving = true- error = nil- if draft.backend != "custom" { draft.command = nil }- Task {- do {- let bot = try await model.save(draft)- dismiss()- if isNew { model.selection = bot.id }- } catch {- self.error = error.localizedDescription- }- saving = false+private struct OptionRow<Content: View>: View {+ let label: String+ @ViewBuilder let content: Content++ init(_ label: String, @ViewBuilder content: () -> Content) {+ self.label = label+ self.content = content()+ }++ var body: some View {+ HStack {+ Text(label).foregroundStyle(Palette.text)+ Spacer(minLength: 12)+ content}+ .frame(minHeight: 46)+ }+}++extension View {+ /// A bordered, rounded input box.+ func fieldBox() -> some View {+ textFieldStyle(.plain)+ .padding(.horizontal, 14)+ .padding(.vertical, 11)+ .background(Palette.background, in: RoundedRectangle(cornerRadius: 12, style: .continuous))+ .overlay(RoundedRectangle(cornerRadius: 12, style: .continuous).stroke(Palette.border))+ }+}++extension BotDraft {+ var isValid: Bool { !name.trimmingCharacters(in: .whitespaces).isEmpty && !cwd.isEmpty }++ /// What the host should get: no stale command unless the agent is custom.+ var normalized: BotDraft {+ var d = self+ if d.backend != "custom" { d.command = nil }+ return d+ }+}++public extension BotStore {+ /// Picks an installed agent and the home folder for a new bot.+ func fillDefaults(_ draft: inout BotDraft) {+ if hello?.backends.first(where: { $0.id == draft.backend })?.available != true,+ let first = hello?.backends.first(where: \.available) {+ draft.backend = first.id+ }+ if draft.cwd.isEmpty, let home = hello?.home { draft.cwd = home }+ }++ /// Creates "New Bot" with sensible defaults and opens it (desktop compose flow).+ func createDefaultBot() async throws -> Bot {+ var draft = BotDraft(name: "New Bot")+ fillDefaults(&draft)+ let bot = try await save(draft)+ selection = bot.id+ return bot}}diff --git a/CodyncKit/Sources/CodyncUI/BotStore.swift b/CodyncKit/Sources/CodyncUI/BotStore.swiftindex 175c7eb2..6cd9cd56 100644--- a/CodyncKit/Sources/CodyncUI/BotStore.swift+++ b/CodyncKit/Sources/CodyncUI/BotStore.swift@@ -18,6 +18,8 @@ public final class BotStore {}public private(set) var pairing: Pairing?+ /// Computers this phone knows, most recently used first (the active one leads).+ public private(set) var computers: [Pairing] = []public private(set) var connection: Connection = .unpairedpublic private(set) var client: HostClient?public private(set) var hello: Hello?@@ -29,6 +31,8 @@ public final class BotStore {public var lastError: String?/// The open conversation (iOS navigation path / Mac sidebar selection).public var selection: String?+ /// The phone's profile sheet (computers, usage); `codync://computers` opens it.+ public var showProfile = false// Platform hooks (push registration, Live Activities, widgets).public var onPaired: (@MainActor (BotStore) -> Void)?@@ -52,6 +56,7 @@ public final class BotStore {self.pairing = pairingself.clientKind = clientKindself.persistsPairing = persistsPairing+ computers = persistsPairing ? SharedStore.computers : pairing.map { [$0] } ?? []loadCache()connection = pairing == nil ? .unpaired : .connecting}@@ -91,12 +96,23 @@ public final class BotStore {SharedStore.pairing = pSharedStore.preferredURL = nil}+ // Re-pairing the same computer (new token after a reset) replaces its old entry.+ computers = [p] + computers.filter { $0.token != p.token && $0.name != p.name }+ if persistsPairing { SharedStore.computers = computers }if changedHost { resetMirror() }connection = .connectingrestartStream()onPaired?(self)}+ /// Forgets a computer; forgetting the active one switches to the next, if any.+ public func forget(_ p: Pairing) {+ computers.removeAll { $0.token == p.token }+ if persistsPairing { SharedStore.computers = computers }+ guard p.token == pairing?.token else { return }+ if let next = computers.first { pair(next) } else { unpair() }+ }+public func unpair() {streamTask?.cancel()pairing = nildiff --git a/CodyncKit/Sources/CodyncUI/ChatRows.swift b/CodyncKit/Sources/CodyncUI/ChatRows.swiftindex f4289412..d785dc20 100644--- a/CodyncKit/Sources/CodyncUI/ChatRows.swift+++ b/CodyncKit/Sources/CodyncUI/ChatRows.swift@@ -12,18 +12,18 @@ struct UserBubble: View {VStack(alignment: .trailing, spacing: 4) {Text(entry.data.text ?? "").font(.body)- .foregroundStyle(Palette.onAccent)+ .foregroundStyle(Palette.text).textSelection(.enabled)- .padding(.horizontal, 13)- .padding(.vertical, 9)- .background(Palette.accentFill, in: RoundedRectangle(cornerRadius: 18, style: .continuous))+ .padding(.horizontal, 16)+ .padding(.vertical, 10)+ .background(Palette.bubbleUser, in: RoundedRectangle(cornerRadius: 22, style: .continuous)).contextMenu {Button("Copy", systemImage: "doc.on.doc") { Pasteboard.copy(entry.data.text) }}status}.frame(maxWidth: .infinity, alignment: .trailing)- .padding(.leading, 48)+ .padding(.leading, 56)}@ViewBuilder private var status: some View {@@ -49,30 +49,19 @@ struct UserBubble: View {struct AgentBubble: View {let entry: Entry- let bot: Bot?- let showAvatar: Boollet openTrace: () -> Voidvar body: some View {- // Replies sit on the page like text in a document; only your own messages get a bubble.- HStack(alignment: .top, spacing: 10) {- Group {- if showAvatar, let bot {- CharacterAvatar(bot: bot, size: 28, animated: false)- } else {- Color.clear- }+ MarkdownText(entry.data.text ?? "")+ .padding(.horizontal, 16)+ .padding(.vertical, 10)+ .background(Palette.bubbleAgent, in: RoundedRectangle(cornerRadius: 22, style: .continuous))+ .contextMenu {+ Button("Copy", systemImage: "doc.on.doc") { Pasteboard.copy(entry.data.text) }+ Button("Show what it did", systemImage: "list.bullet.rectangle", action: openTrace)}- .frame(width: 28, height: 28)- MarkdownText(entry.data.text ?? "")- .padding(.top, 4)- .contentShape(Rectangle())- .contextMenu {- Button("Copy", systemImage: "doc.on.doc") { Pasteboard.copy(entry.data.text) }- Button("Show what it did", systemImage: "list.bullet.rectangle", action: openTrace)- }- Spacer(minLength: 24)- }+ .frame(maxWidth: .infinity, alignment: .leading)+ .padding(.trailing, 40)}}@@ -106,8 +95,9 @@ struct NoticeRow: View {.background(Palette.danger.opacity(0.12), in: RoundedRectangle(cornerRadius: 12))default:Text(text)- .font(.caption)- .foregroundStyle(Palette.tertiary)+ .font(.footnote)+ .foregroundStyle(Palette.secondary)+ .multilineTextAlignment(.center).frame(maxWidth: .infinity)}}@@ -120,7 +110,6 @@ struct WorkingIndicator: View {var body: some View {HStack(alignment: .center, spacing: 10) {- CharacterAvatar(bot: bot, size: 28)Button(action: openTrace) {HStack(spacing: 8) {ThinkingOrb(size: 16, color: bot.needsInput ? Palette.warning : Palette.secondary)@@ -130,11 +119,14 @@ struct WorkingIndicator: View {.lineLimit(1)if let started = bot.startedAt {Text(Date(milliseconds: started), style: .timer)- .font(.system(size: 11, weight: .medium, design: .monospaced))+ .font(.footnote.monospacedDigit()).foregroundStyle(Palette.tertiary)}Image(systemName: "chevron.right").font(.caption2).foregroundStyle(Palette.tertiary)}+ .padding(.horizontal, 16)+ .padding(.vertical, 12)+ .background(Palette.bubbleAgent, in: RoundedRectangle(cornerRadius: 22, style: .continuous))}.buttonStyle(.plain)Spacer()diff --git a/CodyncKit/Sources/CodyncUI/NewChatView.swift b/CodyncKit/Sources/CodyncUI/NewChatView.swiftnew file mode 100644index 00000000..15a5ce73--- /dev/null+++ b/CodyncKit/Sources/CodyncUI/NewChatView.swift@@ -0,0 +1,167 @@+import CodyncKit+import SwiftUI++/// Desktop "new message" page (Grok Bot's compose): a To: field that searches+/// your bots or creates a new one, with ⌘1…⌘9 shortcuts, and the message box+/// underneath. Whatever you typed is sent to the bot you pick.+public struct NewChatView: View {+ let close: () -> Void+ @Environment(BotStore.self) private var model+ @State private var query = ""+ @State private var draft = ""+ @State private var creating = false+ @FocusState private var toFocused: Bool++ public init(close: @escaping () -> Void) { self.close = close }++ private var matches: [Bot] {+ let q = query.trimmingCharacters(in: .whitespaces)+ return model.roster.filter { q.isEmpty || $0.name.localizedCaseInsensitiveContains(q) }+ }++ public var body: some View {+ VStack(spacing: 0) {+ HStack(spacing: 8) {+ Text("To:").foregroundStyle(Palette.secondary)+ TextField("Search or create bots", text: $query)+ .textFieldStyle(.plain)+ .focused($toFocused)+ .onSubmit { if let first = matches.first { pick(first) } else { create() } }+ Button("Close", systemImage: "xmark", action: close)+ .labelStyle(.iconOnly)+ .buttonStyle(.plain)+ .foregroundStyle(Palette.secondary)+ .keyboardShortcut(.cancelAction)+ }+ .font(.title3)+ .padding(.horizontal, 22)+ .padding(.vertical, 16)+ Divider().overlay(Palette.border)++ ScrollView {+ VStack(spacing: 2) {+ PickRow(shortcut: 1, action: create) {+ Image(systemName: creating ? "hourglass" : "plus")+ .font(.system(size: 13, weight: .medium))+ .frame(width: 26, height: 26)+ .background(Palette.bubbleAgent, in: Circle())+ } label: {+ Text(query.isEmpty ? "Create new Bot" : "Create “\(query)”")+ }+ ForEach(Array(matches.enumerated()), id: \.element.id) { i, bot in+ PickRow(shortcut: i + 2 <= 9 ? i + 2 : nil, action: { pick(bot) }) {+ CharacterAvatar(bot: bot, size: 26, animated: false)+ } label: {+ Text(bot.name)+ }+ }+ }+ .padding(8)+ }+ .frame(maxHeight: 460)+ .fixedSize(horizontal: false, vertical: true)+ .background(Palette.surface, in: RoundedRectangle(cornerRadius: 18, style: .continuous))+ .overlay(RoundedRectangle(cornerRadius: 18, style: .continuous).stroke(Palette.border))+ .shadow(color: .black.opacity(0.08), radius: 16, y: 6)+ .frame(maxWidth: 620, alignment: .leading)+ .frame(maxWidth: .infinity, alignment: .leading)+ .padding(.horizontal, 22)+ .padding(.top, 10)++ Spacer(minLength: 0)++ HStack(alignment: .bottom, spacing: 8) {+ TextField("Message Bot", text: $draft, axis: .vertical)+ .lineLimit(1...6)+ .textFieldStyle(.plain)+ .padding(.vertical, 11)+ }+ .padding(.leading, 18)+ .padding(.trailing, 5)+ .padding(.vertical, 5)+ .glass(in: RoundedRectangle(cornerRadius: 23, style: .continuous))+ .padding(16)+ }+ .background(Palette.background)+ .onAppear { toFocused = true }+ }++ private func pick(_ bot: Bot) {+ let text = draft.trimmingCharacters(in: .whitespacesAndNewlines)+ model.selection = bot.id+ if !text.isEmpty { model.send(text, to: bot.id) }+ close()+ }++ private func create() {+ guard !creating else { return }+ creating = true+ Task {+ do {+ var bot = try await model.createDefaultBot()+ let name = query.trimmingCharacters(in: .whitespaces)+ if !name.isEmpty {+ var d = BotDraft(bot)+ d.name = name+ bot = try await model.save(d)+ }+ pick(bot)+ } catch {+ model.lastError = error.localizedDescription+ }+ creating = false+ }+ }+}++private struct PickRow<Icon: View, Label: View>: View {+ let shortcut: Int?+ let action: () -> Void+ @ViewBuilder let icon: Icon+ @ViewBuilder let label: Label+ @State private var hovering = false++ var body: some View {+ if let shortcut {+ row.keyboardShortcut(KeyEquivalent(Character("\(shortcut)")), modifiers: .command)+ } else {+ row+ }+ }++ private var row: some View {+ Button(action: action) {+ HStack(spacing: 12) {+ icon+ label.foregroundStyle(Palette.text).lineLimit(1)+ Spacer()+ if let shortcut {+ HStack(spacing: 3) {+ KeyCap("⌘")+ KeyCap("\(shortcut)")+ }+ }+ }+ .padding(.horizontal, 12)+ .padding(.vertical, 8)+ .background(hovering ? Palette.bubbleAgent : .clear, in: RoundedRectangle(cornerRadius: 12, style: .continuous))+ .contentShape(Rectangle())+ }+ .buttonStyle(.plain)+ .onHover { hovering = $0 }+ }+}++private struct KeyCap: View {+ let text: String+ init(_ text: String) { self.text = text }++ var body: some View {+ Text(text)+ .font(.caption.monospaced())+ .foregroundStyle(Palette.secondary)+ .frame(minWidth: 18, minHeight: 18)+ .background(Palette.background, in: RoundedRectangle(cornerRadius: 4))+ .overlay(RoundedRectangle(cornerRadius: 4).stroke(Palette.border))+ }+}diff --git a/CodyncKit/Sources/CodyncUI/PermissionCard.swift b/CodyncKit/Sources/CodyncUI/PermissionCard.swiftindex 90bc5580..d9db9421 100644--- a/CodyncKit/Sources/CodyncUI/PermissionCard.swift+++ b/CodyncKit/Sources/CodyncUI/PermissionCard.swift@@ -1,8 +1,8 @@import CodyncKitimport SwiftUI-/// Grok Bot's approval card: what the agent wants, where it runs, and-/// Allow once / Always allow / Deny straight from the chat.+/// Approval card in Grok Bot's choice-card style: what the agent wants, where+/// it runs, and the answers as a list of rows.struct PermissionCard: View {let entry: Entrylet hostName: String@@ -25,13 +25,14 @@ struct PermissionCard: View {var body: some View {VStack(alignment: .leading, spacing: 10) {HStack(spacing: 8) {- Image(systemName: "hand.raised.fill")- .foregroundStyle(pending ? Palette.warning : Palette.tertiary)- Text(headline).font(.subheadline.weight(.semibold)).foregroundStyle(Palette.text)+ Text(headline).font(.headline).foregroundStyle(Palette.text)+ if pending {+ Circle().fill(Palette.warning).frame(width: 7, height: 7)+ }}Text(d.title ?? "")- .font(.callout)- .foregroundStyle(Palette.text)+ .font(.subheadline.monospaced())+ .foregroundStyle(Palette.secondary).lineLimit(expanded ? nil : 3)Label("Runs on \(hostName)\(d.cwd.map { " · \(($0 as NSString).lastPathComponent)" } ?? "")", systemImage: "desktopcomputer").font(.caption)@@ -62,13 +63,9 @@ struct PermissionCard: View {.foregroundStyle(Palette.secondary)}}- .padding(14)- .background(Palette.surface, in: RoundedRectangle(cornerRadius: 16, style: .continuous))- .overlay(- RoundedRectangle(cornerRadius: 16, style: .continuous)- .stroke(pending ? Palette.warning.opacity(0.6) : Palette.border)- )- .padding(.leading, 36)+ .padding(16)+ .background(Palette.bubbleAgent, in: RoundedRectangle(cornerRadius: 22, style: .continuous))+ .padding(.trailing, 40)}private var hasDetail: Bool {@@ -93,20 +90,23 @@ struct PermissionCard: View {private var buttons: some View {let options = ordered- return VStack(spacing: 8) {- HStack(spacing: 8) {- ForEach(options.filter { $0.kind.hasPrefix("allow") }) { o in- Button(label(o)) { respond(o.optionId) }- .buttonStyle(CardButton(primary: o.kind == "allow_once"))- }- }- HStack(spacing: 8) {- ForEach(options.filter { !$0.kind.hasPrefix("allow") }) { o in- Button(label(o), role: .destructive) { respond(o.optionId) }- .buttonStyle(CardButton(primary: false))+ return VStack(spacing: 0) {+ ForEach(Array(options.enumerated()), id: \.element.id) { i, o in+ if i > 0 { Divider().overlay(Palette.border) }+ Button { respond(o.optionId) } label: {+ Text(label(o))+ .font(.body.weight(o.kind == "allow_once" ? .semibold : .regular))+ .foregroundStyle(o.kind.hasPrefix("allow") ? Palette.text : Palette.danger)+ .frame(maxWidth: .infinity, minHeight: 46, alignment: .leading)+ .padding(.horizontal, 14)+ .contentShape(Rectangle())}+ .buttonStyle(.plain)}}+ .background(Palette.background, in: RoundedRectangle(cornerRadius: 14, style: .continuous))+ .overlay(RoundedRectangle(cornerRadius: 14, style: .continuous).stroke(Palette.border))+ .padding(.top, 4)}private var outcome: String {@@ -126,19 +126,6 @@ struct PermissionCard: View {}}-struct CardButton: ButtonStyle {- let primary: Bool-- func makeBody(configuration: Configuration) -> some View {- configuration.label- .font(.subheadline.weight(.semibold))- .frame(maxWidth: .infinity, minHeight: 38)- .foregroundStyle(primary ? Palette.onAccent : configuration.role == .destructive ? Palette.danger : Palette.text)- .background(primary ? Palette.accentFill : Palette.bubbleAgent, in: RoundedRectangle(cornerRadius: 10, style: .continuous))- .opacity(configuration.isPressed ? 0.7 : 1)- }-}-struct CodeBox: View {let text: Stringdiff --git a/CodyncKit/Sources/CodyncUI/Platform.swift b/CodyncKit/Sources/CodyncUI/Platform.swiftindex 1ade92ca..e0e21d0a 100644--- a/CodyncKit/Sources/CodyncUI/Platform.swift+++ b/CodyncKit/Sources/CodyncUI/Platform.swift@@ -42,3 +42,14 @@ extension View {#endif}}++extension View {+ /// Liquid Glass where the OS has it (content scrolls visibly underneath), a material before that.+ @ViewBuilder func glass(in shape: some Shape) -> some View {+ if #available(iOS 26, macOS 26, *) {+ glassEffect(.regular, in: shape)+ } else {+ background(.ultraThinMaterial, in: shape)+ }+ }+}diff --git a/CodyncKit/Sources/CodyncUI/Roster.swift b/CodyncKit/Sources/CodyncUI/Roster.swiftindex 0433e374..f4ecd323 100644--- a/CodyncKit/Sources/CodyncUI/Roster.swift+++ b/CodyncKit/Sources/CodyncUI/Roster.swift@@ -8,27 +8,28 @@ public struct BotRow: View {public init(bot: Bot) { self.bot = bot }public var body: some View {- HStack(spacing: 12) {+ HStack(spacing: 14) {AvatarWithStatus(bot: bot, size: 46)- VStack(alignment: .leading, spacing: 3) {+ VStack(alignment: .leading, spacing: 4) {HStack(alignment: .firstTextBaseline) {if bot.pinned {Image(systemName: "pin.fill").font(.caption2).foregroundStyle(Palette.tertiary)}Text(bot.name)- .font(.body.weight(bot.unread > 0 ? .semibold : .medium))+ .font(.body.weight(.semibold)).foregroundStyle(Palette.text).lineLimit(1)Spacer(minLength: 8)- Text(RelativeTime.short(Date(milliseconds: bot.lastAt)))- .metaStyle(bot.unread > 0 ? Palette.text : Palette.tertiary)+ Text(RelativeTime.day(Date(milliseconds: bot.lastAt)))+ .font(.subheadline)+ .foregroundStyle(bot.unread > 0 ? Palette.text : Palette.tertiary)}HStack(alignment: .firstTextBaseline, spacing: 6) {previewSpacer(minLength: 4)if bot.unread > 0 {Text("\(bot.unread)")- .font(.system(size: 11, weight: .semibold, design: .monospaced))+ .font(.caption2.bold()).foregroundStyle(Palette.onAccent).padding(.horizontal, 6).frame(minWidth: 18, minHeight: 18)@@ -37,7 +38,8 @@ public struct BotRow: View {}}}- .padding(.vertical, 6)+ .padding(.vertical, 10)+ .contentShape(Rectangle()).accessibilityElement(children: .combine)}@@ -60,12 +62,12 @@ public struct BotRow: View {Text(bot.lastMessage ?? "Something went wrong").font(.subheadline).foregroundStyle(Palette.danger)- .lineLimit(2)+ .lineLimit(1)} else {Text(bot.lastMessage ?? "\(model.backendName(bot.backend)) · \(bot.folderName)").font(.subheadline).foregroundStyle(Palette.secondary)- .lineLimit(2)+ .lineLimit(1)}}}diff --git a/CodyncKit/Sources/CodyncUI/ThreadView.swift b/CodyncKit/Sources/CodyncUI/ThreadView.swiftindex 67050b71..ee32f61b 100644--- a/CodyncKit/Sources/CodyncUI/ThreadView.swift+++ b/CodyncKit/Sources/CodyncUI/ThreadView.swift@@ -14,6 +14,8 @@ public struct ThreadView: View {@State private var editing: EditorRequest?@State private var confirmNewSession = false@State private var confirmDelete: Bot?+ /// Desktop: the bot's settings as an inspector beside the chat.+ @State private var showSettings = false@FocusState private var composerFocused: Boolprivate var bot: Bot? { model.bots[botId] }@@ -63,7 +65,20 @@ public struct ThreadView: View {.toolbar {ToolbarItem(placement: .principal) { header }ToolbarItem(placement: .primaryAction) { menu }+ #if os(macOS)+ ToolbarItem(placement: .primaryAction) {+ Button("Settings", systemImage: "sidebar.right") { showSettings.toggle() }+ .help("Bot settings")+ }+ #endif+ }+ #if os(macOS)+ .inspector(isPresented: $showSettings) {+ BotSettingsPanel(botId: botId)+ .inspectorColumnWidth(min: 300, ideal: 360, max: 460)}+ .onAppear { if bot?.name == "New Bot", model.thread(botId).isEmpty { showSettings = true } }+ #endif.onAppear { model.markRead(botId) }.sheet(isPresented: $showTrace) {NavigationStack { TraceView(botId: botId) }@@ -86,18 +101,20 @@ public struct ThreadView: View {@ViewBuilder private func row(_ item: ChatItem) -> some View {switch item.kind {case let .separator(date):- Text(date.formatted(.relative(presentation: .named)) + " · " + date.formatted(date: .omitted, time: .shortened))- .metaStyle()+ Text(RelativeTime.separator(date))+ .font(.footnote)+ .foregroundStyle(Palette.tertiary).frame(maxWidth: .infinity)- .padding(.vertical, 16)+ .padding(.top, 18)+ .padding(.bottom, 6)case let .entry(e, groupStart):switch e.kind {case "user":UserBubble(entry: e, botWorking: bot?.isWorking == true)- .padding(.top, groupStart ? 12 : 3)+ .padding(.top, groupStart ? 12 : 4)case "agent":- AgentBubble(entry: e, bot: bot, showAvatar: groupStart) { showTrace = true }- .padding(.top, groupStart ? 12 : 3)+ AgentBubble(entry: e) { showTrace = true }+ .padding(.top, groupStart ? 12 : 4)case "permission":PermissionCard(entry: e, hostName: model.hostName) { option inmodel.respond(e, option: option)@@ -112,23 +129,25 @@ public struct ThreadView: View {// MARK: chromeprivate var header: some View {+ // A pill with the bot and its name; the avatar itself shows working / needs you.HStack(spacing: 8) {- if let bot { CharacterAvatar(bot: bot, size: 28) }- VStack(alignment: .leading, spacing: 0) {- Text(bot?.name ?? "").font(.subheadline.weight(.semibold)).foregroundStyle(Palette.text)- Group {- if let bot, bot.needsInput {- Text("Needs you").metaStyle(Palette.warning)- } else if let bot, bot.isWorking {- Text("Working").metaStyle(Palette.secondary)- } else if let bot {- Text("\(model.backendName(bot.backend)) · \(bot.folderName)").metaStyle()- }- }+ if let bot { CharacterAvatar(bot: bot, size: 26) }+ Text(bot?.name ?? "")+ .font(.body.weight(.semibold))+ .foregroundStyle(Palette.text).lineLimit(1)- }}- .onTapGesture { if let bot { editing = EditorRequest(BotDraft(bot)) } }+ .padding(.leading, 8)+ .padding(.trailing, 16)+ .padding(.vertical, 6)+ .glass(in: Capsule())+ .onTapGesture {+ #if os(macOS)+ showSettings.toggle()+ #else+ if let bot { editing = EditorRequest(BotDraft(bot)) }+ #endif+ }}private var menu: some View {@@ -150,23 +169,20 @@ public struct ThreadView: View {let working = bot?.isWorking == truelet canSend = !draft.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty && model.connection == .onlinereturn HStack(alignment: .bottom, spacing: 8) {- TextField(working ? "Message (queued until it's done)" : "Message \(bot?.name ?? "")", text: $draft, axis: .vertical)+ TextField(working ? "Queue a message for \(bot?.name ?? "it")" : "Ask \(bot?.name ?? "")", text: $draft, axis: .vertical).lineLimit(1...6).textFieldStyle(.plain).focused($composerFocused)- .padding(.horizontal, 14)- .padding(.vertical, 10)- .background(Palette.surface, in: RoundedRectangle(cornerRadius: 20, style: .continuous))- .overlay(RoundedRectangle(cornerRadius: 20, style: .continuous).stroke(Palette.border))+ .padding(.vertical, 11)if working && draft.isEmpty {Button {model.stop(botId)} label: {Image(systemName: "stop.fill")- .font(.system(size: 14, weight: .bold))- .frame(width: 38, height: 38)- .background(Palette.bubbleAgent, in: Circle())- .foregroundStyle(Palette.text)+ .font(.system(size: 13, weight: .bold))+ .frame(width: 36, height: 36)+ .background(Palette.accentFill, in: Circle())+ .foregroundStyle(Palette.onAccent)}.accessibilityLabel("Stop")} else {@@ -175,18 +191,22 @@ public struct ThreadView: View {draft = ""} label: {Image(systemName: "arrow.up")- .font(.system(size: 16, weight: .bold))- .frame(width: 38, height: 38)- .background(canSend ? Palette.accentFill : Palette.bubbleAgent, in: Circle())+ .font(.system(size: 15, weight: .bold))+ .frame(width: 36, height: 36)+ .background(canSend ? Palette.accentFill : Palette.accentDim, in: Circle()).foregroundStyle(canSend ? Palette.onAccent : Palette.tertiary)}.disabled(!canSend).accessibilityLabel("Send")}}+ .padding(.leading, 18)+ .padding(.trailing, 5)+ .padding(.vertical, 5)+ .glass(in: RoundedRectangle(cornerRadius: 23, style: .continuous)).padding(.horizontal, 12)- .padding(.vertical, 8)- .background(.bar)+ .padding(.top, 6)+ .padding(.bottom, 8)}}diff --git a/CodyncKit/Sources/CodyncUI/UsageViews.swift b/CodyncKit/Sources/CodyncUI/UsageViews.swiftindex 87d2dfaf..f3060636 100644--- a/CodyncKit/Sources/CodyncUI/UsageViews.swift+++ b/CodyncKit/Sources/CodyncUI/UsageViews.swift@@ -51,7 +51,7 @@ public struct UsageStrip: View {.frame(width: 22, height: 22).tint(Palette.usageTint(w.percent))VStack(alignment: .leading, spacing: 0) {- Text("\(p.name) \(w.label)").metaStyle()+ Text("\(p.name) \(w.label)").font(.caption2).foregroundStyle(Palette.tertiary)Text("\(Int(w.percent.rounded()))%").font(.caption.bold().monospacedDigit()).foregroundStyle(Palette.text)}}diff --git a/CodyncWidgets/CodyncWidgets.swift b/CodyncWidgets/CodyncWidgets.swiftindex 33589405..98cab1b3 100644--- a/CodyncWidgets/CodyncWidgets.swift+++ b/CodyncWidgets/CodyncWidgets.swift@@ -7,12 +7,179 @@ import WidgetKit@mainstruct CodyncWidgets: WidgetBundle {var body: some Widget {+ BotsWidget()UsageWidget()BotLiveActivity()}}-// MARK: - Usage widget+// MARK: - Bots at a glance++struct BotsEntry: TimelineEntry {+ let date: Date+ let bots: [Bot]+ let paired: Bool+}++struct BotsTimeline: TimelineProvider {+ func placeholder(in context: Context) -> BotsEntry { BotsEntry(date: .now, bots: Bot.samples, paired: true) }++ func getSnapshot(in context: Context, completion: @escaping (BotsEntry) -> Void) {+ let bots = SharedStore.bots+ completion(BotsEntry(date: .now, bots: bots.isEmpty && context.isPreview ? Bot.samples : bots, paired: true))+ }++ /// The app writes the roster and reloads this widget when a bot's state changes.+ func getTimeline(in context: Context, completion: @escaping (Timeline<BotsEntry>) -> Void) {+ let entry = BotsEntry(date: .now, bots: SharedStore.bots, paired: SharedStore.pairing != nil)+ completion(Timeline(entries: [entry], policy: .never))+ }+}++struct BotsWidget: Widget {+ var body: some WidgetConfiguration {+ StaticConfiguration(kind: "CodyncBots", provider: BotsTimeline()) { entry in+ BotsWidgetView(entry: entry)+ .containerBackground(Palette.background, for: .widget)+ }+ .configurationDisplayName("Bots")+ .description("Which bots need you, which are working, and what they said last.")+ .supportedFamilies([.systemSmall, .systemMedium, .accessoryCircular, .accessoryRectangular, .accessoryInline])+ }+}++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+ }+ }+ private var needing: Int { entry.bots.filter(\.needsInput).count }+ private var working: Int { entry.bots.filter { $0.isWorking && !$0.needsInput }.count }++ /// The one line that sums up the roster.+ private var headline: (count: Int, label: String, needs: Bool) {+ if needing > 0 { return (needing, needing == 1 ? "needs you" : "need you", true) }+ if working > 0 { return (working, "working", false) }+ return (entry.bots.count, entry.bots.count == 1 ? "bot, all quiet" : "bots, all quiet", false)+ }++ var body: some View {+ if !entry.paired {+ EmptyWidget(text: "Open Codync to pair with your computer.")+ } else {+ switch family {+ case .accessoryInline:+ Text(needing > 0 ? "\(needing) bot\(needing == 1 ? "" : "s") need\(needing == 1 ? "s" : "") you" : working > 0 ? "\(working) working" : "Bots all quiet")+ case .accessoryCircular:+ VStack(spacing: 0) {+ Text("\(headline.count)").font(.system(size: 24, weight: .semibold, design: .rounded))+ Text(needing > 0 ? "need" : working > 0 ? "busy" : "bots").font(.system(size: 10, weight: .medium))+ }+ .widgetAccentable()+ case .accessoryRectangular:+ VStack(alignment: .leading, spacing: 1) {+ Text("\(headline.count) \(headline.label)").font(.headline).widgetAccentable()+ ForEach(ordered.prefix(2)) { bot in+ Text("\(bot.name) · \(line(bot))").font(.caption2).lineLimit(1)+ }+ }+ .frame(maxWidth: .infinity, alignment: .leading)+ case .systemMedium:+ HStack(alignment: .top, spacing: 16) {+ summary.frame(width: 104, alignment: .leading)+ VStack(alignment: .leading, spacing: 10) {+ ForEach(ordered.prefix(3)) { bot in+ Link(destination: URL(string: "codync://bot/\(bot.id)")!) { BotLine(bot: bot, detail: line(bot)) }+ }+ Spacer(minLength: 0)+ }+ }+ default:+ VStack(alignment: .leading, spacing: 0) {+ HStack(spacing: -6) {+ ForEach(ordered.prefix(3)) { bot in+ CharacterAvatar(bot: bot, size: 30, animated: false)+ }+ }+ Spacer(minLength: 6)+ summary+ }+ .frame(maxWidth: .infinity, alignment: .leading)+ .widgetURL(ordered.first.map { URL(string: "codync://bot/\($0.id)")! })+ }+ }+ }++ private var summary: some View {+ VStack(alignment: .leading, spacing: 2) {+ Text("\(headline.count)")+ .font(.system(size: 40, weight: .semibold, design: .rounded))+ .foregroundStyle(headline.needs ? Palette.warning : Palette.text)+ .contentTransition(.numericText())+ Text(headline.label).font(.subheadline).foregroundStyle(Palette.secondary)+ if family == .systemSmall, let first = ordered.first, first.isWorking {+ Text(first.name).font(.caption).foregroundStyle(Palette.tertiary).lineLimit(1).padding(.top, 2)+ }+ }+ }++ private func line(_ bot: Bot) -> String {+ if bot.needsInput { return bot.activity.isEmpty ? "Needs your approval" : bot.activity }+ if bot.isWorking { return bot.activity.isEmpty ? "Working…" : bot.activity }+ return bot.lastMessage ?? "Idle"+ }+}++private struct BotLine: View {+ let bot: Bot+ let detail: String++ var body: some View {+ HStack(spacing: 10) {+ CharacterAvatar(bot: bot, size: 28, animated: false)+ VStack(alignment: .leading, spacing: 1) {+ Text(bot.name).font(.subheadline.weight(.semibold)).foregroundStyle(Palette.text).lineLimit(1)+ Text(detail)+ .font(.caption)+ .foregroundStyle(bot.needsInput ? Palette.warning : Palette.secondary)+ .lineLimit(1)+ }+ Spacer(minLength: 0)+ }+ }+}++private struct EmptyWidget: View {+ let text: String++ var body: some View {+ VStack(alignment: .leading, spacing: 8) {+ CharacterAvatar(shape: "blob", color: "gray", size: 30)+ Spacer(minLength: 0)+ Text(text).font(.caption).foregroundStyle(Palette.secondary)+ }+ .frame(maxWidth: .infinity, alignment: .leading)+ }+}++extension Bot {+ static let samples: [Bot] = {+ let json = """+ [{"id":"1","name":"Reviewer","avatarShape":"blob","avatarColor":"green","backend":"claude","cwd":"/","status":"needsInput","activity":"Run cargo test --all?","lastAt":3},+ {"id":"2","name":"Fixer","avatarShape":"squircle","avatarColor":"orange","backend":"codex","cwd":"/","status":"working","activity":"Editing store.rs","lastAt":2},+ {"id":"3","name":"Docs writer","avatarShape":"teardrop","avatarColor":"violet","backend":"claude","cwd":"/","status":"idle","lastMessage":"README updated.","lastAt":1}]+ """+ return (try? JSONDecoder().decode([Bot].self, from: Data(json.utf8))) ?? []+ }()+}++// MARK: - Usage limitsstruct UsageEntry: TimelineEntry {let date: Date@@ -32,9 +199,14 @@ struct UsageTimeline: AppIntentTimelineProvider {UsageEntry(date: .now, usage: SharedStore.usage ?? .sample)}+ /// Refreshes every 30 minutes, or right after the next limit resets if that's sooner.func timeline(for configuration: UsageIntent, in context: Context) async -> Timeline<UsageEntry> {- let usage = await Self.fetch() ?? SharedStore.usage ?? Usage()- return Timeline(entries: [UsageEntry(date: .now, usage: usage)], policy: .after(.now + 15 * 60))+ let fetched = await Self.fetch()+ let usage = fetched ?? SharedStore.usage ?? Usage()+ let nextReset = usage.providers.flatMap(\.windows).compactMap(\.resetDate).filter { $0 > .now }.min()+ var next = Date.now + (fetched == nil ? 5 * 60 : 30 * 60)+ if let nextReset, nextReset + 1 < next { next = max(nextReset + 1, .now + 5 * 60) }+ return Timeline(entries: [UsageEntry(date: .now, usage: usage)], policy: .after(next))}/// Asks the paired host directly (works over Tailscale), falling back to the app's cache.@@ -58,10 +230,12 @@ struct UsageWidget: Widget {}.configurationDisplayName("Usage limits").description("Claude and Codex subscription limits from your computer.")- .supportedFamilies([.systemSmall, .systemMedium, .accessoryCircular, .accessoryRectangular])+ .supportedFamilies([.systemSmall, .systemMedium, .accessoryCircular, .accessoryRectangular, .accessoryInline])}}+/// The tightest limit is the headline (after CodexBar); the rest are thin grey bars+/// that only take color near the limit.struct UsageWidgetView: View {let entry: UsageEntry@Environment(\.widgetFamily) private var family@@ -70,58 +244,90 @@ struct UsageWidgetView: View {entry.usage.providers.flatMap { p in p.windows.map { (p.name, $0) } }}+ private var tightest: (provider: String, window: UsageWindow)? { windows.max { $0.window.percent < $1.window.percent } }+ private var rest: [(provider: String, window: UsageWindow)] {+ windows.filter { $0.window.id != tightest?.window.id || $0.provider != tightest?.provider }+ }+var body: some View {- switch family {- case .accessoryCircular:- if let first = windows.first {- Gauge(value: min(first.window.percent, 100), in: 0...100) {- Text(first.provider.prefix(1))+ if let top = tightest {+ switch family {+ case .accessoryInline:+ Text("\(top.provider) \(percent(top.window)) · \(top.window.label)")+ case .accessoryCircular:+ Gauge(value: min(top.window.percent, 100), in: 0...100) {+ Text(top.provider.prefix(2))} currentValueLabel: {- Text("\(Int(first.window.percent.rounded()))")+ Text("\(Int(top.window.percent.rounded()))")}.gaugeStyle(.accessoryCircularCapacity)- } else {- Image(systemName: "gauge.with.dots.needle.0percent")- }- case .accessoryRectangular:- VStack(alignment: .leading, spacing: 2) {- ForEach(Array(windows.prefix(3).enumerated()), id: \.offset) { _, item in- HStack {- Text("\(item.provider) \(item.window.label)").lineLimit(1)- Spacer()- Text("\(Int(item.window.percent.rounded()))%").monospacedDigit()- }- .font(.caption2)- }- }- default:- VStack(alignment: .leading, spacing: 8) {- HStack(spacing: 6) {- CharacterAvatar(shape: "blob", color: "green", size: 16)- Text("Usage").font(.caption.bold()).foregroundStyle(Palette.text)+ case .accessoryRectangular:+ VStack(alignment: .leading, spacing: 1) {+ Text("\(top.provider) \(top.window.label) \(percent(top.window))").font(.headline).widgetAccentable()+ Text(rest.prefix(2).map { "\($0.window.label) \(percent($0.window))" }.joined(separator: " · "))+ .font(.caption2).lineLimit(1)+ resetLine(top.window).font(.caption2)}- if windows.isEmpty {- Text("Open Codync and pair with your computer.")- .font(.caption2)- .foregroundStyle(Palette.secondary)+ .frame(maxWidth: .infinity, alignment: .leading)+ case .systemMedium:+ HStack(alignment: .top, spacing: 18) {+ hero(top).frame(width: 118, alignment: .leading)+ VStack(alignment: .leading, spacing: 9) {+ ForEach(Array(rest.prefix(4).enumerated()), id: \.offset) { _, item in bar(item) }+ Spacer(minLength: 0)+ }}- ForEach(Array(windows.prefix(family == .systemSmall ? 3 : 4).enumerated()), id: \.offset) { _, item in- VStack(alignment: .leading, spacing: 3) {- HStack {- Text("\(item.provider) · \(item.window.label)").lineLimit(1)- Spacer(minLength: 2)- Text("\(Int(item.window.percent.rounded()))%").bold().monospacedDigit()- }- .font(.caption2)- .foregroundStyle(Palette.text)- UsageBar(percent: item.window.percent, height: 5)- if family == .systemMedium, let reset = item.window.resetDescription {- Text(reset).font(.system(size: 9)).foregroundStyle(Palette.tertiary)- }+ default:+ VStack(alignment: .leading, spacing: 0) {+ hero(top)+ Spacer(minLength: 6)+ VStack(alignment: .leading, spacing: 7) {+ ForEach(Array(rest.prefix(2).enumerated()), id: \.offset) { _, item in bar(item) }}}- Spacer(minLength: 0)+ .frame(maxWidth: .infinity, alignment: .leading)}+ } else if family == .accessoryInline || family == .accessoryCircular || family == .accessoryRectangular {+ Text("No usage yet")+ } else {+ EmptyWidget(text: SharedStore.pairing == nil ? "Open Codync to pair with your computer." : "No usage reported yet.")+ }+ }++ private func hero(_ item: (provider: String, window: UsageWindow)) -> some View {+ VStack(alignment: .leading, spacing: 2) {+ Text("\(item.provider) · \(item.window.label)").font(.caption).foregroundStyle(Palette.secondary).lineLimit(1)+ Text(percent(item.window))+ .font(.system(size: 40, weight: .semibold, design: .rounded))+ .monospacedDigit()+ .foregroundStyle(item.window.percent >= 90 ? Palette.danger : Palette.text)+ .minimumScaleFactor(0.7)+ resetLine(item.window).font(.caption2).foregroundStyle(Palette.tertiary).lineLimit(1)+ }+ }++ private func bar(_ item: (provider: String, window: UsageWindow)) -> some View {+ VStack(alignment: .leading, spacing: 4) {+ HStack {+ Text("\(item.provider) \(item.window.label)").lineLimit(1)+ Spacer(minLength: 4)+ Text(percent(item.window)).monospacedDigit()+ }+ .font(.caption2)+ .foregroundStyle(Palette.secondary)+ UsageBar(percent: item.window.percent, height: 4)+ }+ }++ private func percent(_ w: UsageWindow) -> String { "\(Int(w.percent.rounded()))%" }++ @ViewBuilder private func resetLine(_ w: UsageWindow) -> some View {+ if let date = w.resetDate, date > entry.date {+ Text("resets \(Text(date, style: .relative))")+ } else if let text = w.resetDescription {+ Text(text)+ } else {+ Text(" ")}}}@@ -161,7 +367,7 @@ struct BotLiveActivity: Widget {} else if s.status == "working", let started = s.startedAt {Text(started, style: .timer).font(.caption2.monospacedDigit()).frame(width: 40)} else {- Image(systemName: "checkmark").foregroundStyle(Palette.accentFill)+ Image(systemName: "checkmark").foregroundStyle(Palette.text)}} minimal: {CharacterAvatar(shape: context.attributes.avatarShape, color: context.attributes.avatarColor, size: 20)