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.

Sync in-progress work from the main tree

leepokai0533d7a6c7fb
diff --git a/AGENTS.md b/AGENTS.md
new file mode 100644
index 00000000..badd1d16
--- /dev/null
+++ b/AGENTS.md
@@ -0,0 +1,36 @@
+# Repository Guidelines
+
+## Project Structure & Module Organization
+
+- `host/`: Rust daemon, ACP integration, SQLite storage, HTTP/SSE API, and terminal UI; unit tests live alongside modules in `src/`.
+- `kit/`: shared Swift package. `CodyncKit` contains models, clients, and design primitives; `CodyncUI` contains shared screens and stores. Tests and fixtures live in `kit/Tests/CodyncKitTests/`.
+- `apps/`: iOS, macOS, and Linux clients, plus `screen` and `screen-linux` helpers. Apple assets live in each target’s `Resources/`; widgets live in `apps/ios/Widgets/`.
+- `relay/`: Cloudflare push worker and `test/`; `web/`: website git submodule; `packaging/`: distribution templates; `docs/`: architecture and naming guidance.
+
+## Build, Test, and Development Commands
+
+Run from the repository root unless a command changes directories:
+
+- `xcodegen generate`: regenerate `Codync.xcodeproj` after editing `project.yml`; never edit `project.pbxproj` directly.
+- `xcodebuild build -project Codync.xcodeproj -scheme macOS -configuration Debug`: build the Mac app. Use Xcode’s `iOS` scheme to run on a simulator or device.
+- `cd host && cargo build`: build the host; `cargo run -- serve` starts it in the foreground.
+- `cd host && cargo fmt --check && cargo clippy --all-targets -- -D warnings && cargo test`: run host CI checks.
+- `cd kit && swift test`: run shared Swift tests.
+- `cd apps/linux && cargo test`: test Linux code; requires GTK 4 and libadwaita development packages.
+- `cd relay && npm ci && npm test && npm run typecheck`: install dependencies and validate the relay.
+
+## Coding Style & Naming Conventions
+
+Use four-space indentation for Swift and Rust. Follow Swift 6 strict concurrency, SwiftUI, and structured `async/await`; avoid unchecked sendability. Rust uses edition 2024, rustfmt, and Clippy; avoid `unwrap()` outside tests.
+
+Name Swift files after their main `UpperCamelCase` type; use `snake_case.rs` and `kebab-case.ts`. Follow role suffixes such as `View`, `Row`, and `Store`. See `docs/structure.md` and `CLAUDE.md` for architectural conventions.
+
+- No built-in system UI controls (`Menu`/`Picker`, `.switch` toggles, system lists, stock sheets and alerts): build our own from `CodyncKit` design primitives (e.g. `ToggleStyle.codync`). Anything with a background fill gets no border line.
+
+## Testing Guidelines
+
+Use Swift Testing (`@Test`, `#expect`), Rust unit tests, and the relay’s Node assertion tests. Name tests after observable behavior. Add regression coverage for changed logic; no numeric coverage threshold is configured.
+
+## Commit & Pull Request Guidelines
+
+History mixes descriptive subjects with scoped Conventional Commits, such as `feat(macos): ...`. Keep subjects concise and changes focused. PRs should explain behavior changes, link relevant issues, list validation performed, and include screenshots for UI changes. Update affected documentation in the same change.
diff --git a/CLAUDE.md b/CLAUDE.md
index 0320d0d0..66fd713a 100644
--- a/CLAUDE.md
+++ b/CLAUDE.md
@@ -17,6 +17,7 @@ Bot-based remote for coding agents: persistent named bots on your computer, mess
- Clients: iOS app, native Mac window (menu bar app), native Linux app (`apps/linux/`, GTK 4 + libadwaita in Rust), terminal UI (`codync-host tui`, `host/src/tui/`, ratatui; layout and state vocabulary modeled on herdr). All talk to the host API; no web UI.
- Shared Swift (`kit/`): `CodyncKit` (models, client, theme, avatars) + `CodyncUI` (`BotStore` + chat screens) used by iOS and macOS. Platform specifics go through `BotStore` hooks or `Platform.swift`.
- UI principle: buttons an icon can express are icon-only (with tooltip / accessibility label); text only where an icon would be ambiguous (approval choices).
+- No built-in system UI controls (`Menu`/`Picker`, `.switch` toggles, system lists, stock sheets and alerts): build our own from `CodyncKit` design primitives (e.g. `ToggleStyle.codync`). Anything with a background fill gets no border line.
- `host/` — **codync-host** (Rust, macOS + Linux). Detects installed harnesses (`backends.rs`: login-shell PATH + known dirs) and the ACP registry (`registry.rs`, cached in `~/.codync/registry.json`, binaries under `~/.codync/agents`). Drives agents over **ACP** (JSON-RPC on stdio, hand-rolled in `acp.rs`, updates kept as `serde_json::Value` so new adapter variants never break parsing). One actor per bot (`bot.rs`) owns the agent process + session and maps `session/update` onto transcript entries.
- **Thread ≠ session**: a bot is one endless transcript (SQLite `entries`, ordered by `seq`); the ACP session underneath is resumed with `session/load` or replaced by *New session*.
- Bot collaboration: built-in `team` MCP (`team.rs`) lists visible bots and asks one for a reply through its actor queue. Requests are separate turns, cycle-checked and cancellable; native subagents stay with the harness. See [docs/bot-collaboration.md](docs/bot-collaboration.md).
diff --git a/Codync.xcodeproj/project.pbxproj b/Codync.xcodeproj/project.pbxproj
index ffc4f35f..ef2ca9cf 100644
--- a/Codync.xcodeproj/project.pbxproj
+++ b/Codync.xcodeproj/project.pbxproj
@@ -31,6 +31,7 @@
A12D125989D2EA1AC5308218 /* WidgetGalleryView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0E8563C243AB130DFA063CAD /* WidgetGalleryView.swift */; };
AA601649E43A5AF73DCF5B5E /* WebRTC in Frameworks */ = {isa = PBXBuildFile; productRef = 2D9748E611692583AFC5A152 /* WebRTC */; };
ACCB28F3DB9C89108B7911E3 /* Input.swift in Sources */ = {isa = PBXBuildFile; fileRef = 842DA106CA15E3810C3C9461 /* Input.swift */; };
+ AD4428FB4374EC7B1B89F1FD /* ActivityGalleryView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1B6C42CD9B7CED28A1EE536C /* ActivityGalleryView.swift */; };
AFC0CD8BD1FA61F810C96057 /* com.pokai.Codync.screen.plist in CopyFiles */ = {isa = PBXBuildFile; fileRef = 895BB6C2EB8986266EB4159A /* com.pokai.Codync.screen.plist */; };
B55C0D49B47C628C367BD92A /* AXTree.swift in Sources */ = {isa = PBXBuildFile; fileRef = 97876A72710A37EB86A082C1 /* AXTree.swift */; };
B75DD137E6F645F797B60B09 /* PairingView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 739EC95223CC8F8717C33736 /* PairingView.swift */; };
@@ -108,6 +109,7 @@
00F135A0B168269BD6C2A199 /* CodyncWidgets.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CodyncWidgets.swift; sourceTree = "<group>"; };
0E8563C243AB130DFA063CAD /* WidgetGalleryView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WidgetGalleryView.swift; sourceTree = "<group>"; };
19D41F16A62FEF37BE0AD1FC /* ClerkConfig.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist; path = ClerkConfig.plist; sourceTree = "<group>"; };
+ 1B6C42CD9B7CED28A1EE536C /* ActivityGalleryView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ActivityGalleryView.swift; sourceTree = "<group>"; };
1E47C60032C326157E0386B8 /* SwiftUI.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SwiftUI.framework; path = System/Library/Frameworks/SwiftUI.framework; sourceTree = SDKROOT; };
1F16B11B2920E9D05621AFE7 /* ViewingBadge.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewingBadge.swift; sourceTree = "<group>"; };
22F1B304BD18E48C91FC73E3 /* Widgets.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = Widgets.entitlements; sourceTree = "<group>"; };
@@ -194,6 +196,7 @@
isa = PBXGroup;
children = (
AFE4E0839DCD380109300DF1 /* AccountSwitcherView.swift */,
+ 1B6C42CD9B7CED28A1EE536C /* ActivityGalleryView.swift */,
C5E57711E223A292872322C5 /* BotListView.swift */,
739EC95223CC8F8717C33736 /* PairingView.swift */,
E1B79D48C1D6F90D53751B3F /* RootView.swift */,
@@ -602,6 +605,7 @@
files = (
FF6CF0FBF496B5B50F09E063 /* AccountSession.swift in Sources */,
28DE92C4209739829F6AD1A1 /* AccountSwitcherView.swift in Sources */,
+ AD4428FB4374EC7B1B89F1FD /* ActivityGalleryView.swift in Sources */,
CC9F6FB8055C38D5D625F738 /* BotListView.swift in Sources */,
2F0A1C29DBBD1D700C10BE46 /* CodyncApp.swift in Sources */,
B75DD137E6F645F797B60B09 /* PairingView.swift in Sources */,
diff --git a/apps/ios/App/CodyncApp.swift b/apps/ios/App/CodyncApp.swift
index 32bb6b12..6aaf955f 100644
--- a/apps/ios/App/CodyncApp.swift
+++ b/apps/ios/App/CodyncApp.swift
@@ -66,6 +66,7 @@ struct CodyncApp: App {
model.pair(p)
}
if ProcessInfo.processInfo.environment["CODYNC_OPEN_USAGE"] != nil { tab = .usage }
+ await LiveActivities.shared.previewIfRequested()
if ProcessInfo.processInfo.environment["CODYNC_OPEN_SCREEN"] != nil {
try? await Task.sleep(for: .seconds(2))
model.screenRequest = ScreenRequest()
diff --git a/apps/ios/App/Push.swift b/apps/ios/App/Push.swift
index 74bcbdcc..2ce05ec9 100644
--- a/apps/ios/App/Push.swift
+++ b/apps/ios/App/Push.swift
@@ -89,6 +89,32 @@ final class LiveActivities {
private var requests: [UUID: Task<Void, Never>] = [:]
+ #if DEBUG
+ /// Simulator-only visual verification. No host, relay, or APNs request.
+ func previewIfRequested() async {
+ #if targetEnvironment(simulator)
+ guard let status = ProcessInfo.processInfo.environment["CODYNC_ACTIVITY_PREVIEW"] else { return }
+ for activity in Activity<BotActivityAttributes>.activities where activity.attributes.botId.hasPrefix("codync-design-preview-") {
+ await activity.end(nil, dismissalPolicy: .immediate)
+ }
+ guard status != "stop", var bot = Bot.widgetPreview.first else { return }
+ try? await Task.sleep(for: .milliseconds(500))
+ for index in 0..<(status == "multiple" ? 2 : 1) {
+ bot.id = "codync-design-preview-\(index)"
+ bot.name = index == 0 ? "Reviewer" : "Builder"
+ let state = BotActivityAttributes.ContentState(
+ status: status == "multiple" ? (index == 0 ? "needsInput" : "working") : status == "stale" ? "working" : status,
+ activity: status == "needsInput" || status == "multiple" ? "Review the proposed changes." : "Running the test suite.",
+ startedAt: .now - 154)
+ do {
+ _ = try Activity.request(attributes: BotActivityAttributes(bot: bot, link: URL(string: "codync://computers")),
+ content: .init(state: state, staleDate: status == "stale" ? .now - 1 : .now + 900), pushType: nil)
+ } catch { log.error("Simulator activity preview: \(error.localizedDescription)") }
+ }
+ #endif
+ }
+ #endif
+
func endAll() {
requests.values.forEach { $0.cancel() }
requests.removeAll()
@@ -105,6 +131,7 @@ final class LiveActivities {
}
func start(for bot: Bot, model: BotStore) {
+ guard UserDefaults.standard.object(forKey: "liveActivitiesEnabled") as? Bool ?? true else { return }
guard ActivityAuthorizationInfo().areActivitiesEnabled, Self.find(bot.id) == nil, let client = model.client else { return }
let attributes = BotActivityAttributes(bot: bot, link: model.storage.botURL(bot.id))
let id = UUID()
@@ -120,7 +147,7 @@ final class LiveActivities {
let state = BotActivityAttributes.ContentState(status: "working", activity: "Starting…", startedAt: .now)
do {
try Task.checkCancellation()
- let activity = try Activity.request(attributes: attributes, content: .init(state: state, staleDate: nil), pushType: .token)
+ let activity = try Activity.request(attributes: attributes, content: .init(state: state, staleDate: .now + 15 * 60), pushType: .token)
for await token in activity.pushTokenUpdates {
guard !Task.isCancelled else { break }
guard let ticket = try? await relayTicket(token: token, kind: "liveactivity") else { continue }
@@ -150,7 +177,7 @@ final class LiveActivities {
if end {
await activity.end(.init(state: state, staleDate: nil), dismissalPolicy: .after(.now + 60))
} else {
- await activity.update(.init(state: state, staleDate: nil))
+ await activity.update(.init(state: state, staleDate: .now + 15 * 60))
}
}
}
diff --git a/apps/ios/Views/AccountSwitcherView.swift b/apps/ios/Views/AccountSwitcherView.swift
index a91ff452..c4aeab37 100644
--- a/apps/ios/Views/AccountSwitcherView.swift
+++ b/apps/ios/Views/AccountSwitcherView.swift
@@ -104,7 +104,10 @@ struct AccountSwitcherView: View {
.labelStyle(.iconOnly)
}
if account.isBusy {
- ToolbarItem(placement: .topBarTrailing) { ProgressView() }
+ ToolbarItem(placement: .topBarTrailing) {
+ ThinkingOrb(state: .connecting, size: 20)
+ .accessibilityHidden(false).accessibilityLabel("Signing in")
+ }
}
}
}
diff --git a/apps/ios/Views/ActivityGalleryView.swift b/apps/ios/Views/ActivityGalleryView.swift
new file mode 100644
index 00000000..b0691ef8
--- /dev/null
+++ b/apps/ios/Views/ActivityGalleryView.swift
@@ -0,0 +1,128 @@
+import ActivityKit
+import CodyncKit
+import SwiftUI
+
+struct ActivityGalleryView: View {
+ @Environment(\.scenePhase) private var scenePhase
+ @AppStorage("liveActivitiesEnabled") private var enabled = true
+ @State private var allowed = ActivityAuthorizationInfo().areActivitiesEnabled
+ @State private var form = BotActivityPreview.Form.lockScreen
+ @State private var phase = BotActivityPresentation.Phase.working
+ @State private var start = Date.now - 154
+
+ private var state: BotActivityPresentation {
+ let status: String = switch phase {
+ case .working, .stale: "working"
+ case .needsInput: "needsInput"
+ case .completed: "idle"
+ case .failed: "error"
+ case .waiting: "unknown"
+ }
+ return .init(status: status, activity: phase == .needsInput ? "Review the proposed changes." : "Running the test suite.",
+ startedAt: start, isStale: phase == .stale)
+ }
+
+ var body: some View {
+ ScrollView {
+ VStack(alignment: .leading, spacing: 24) {
+ VStack(alignment: .leading, spacing: 10) {
+ Toggle("Show Live Activities", isOn: $enabled)
+ .font(.subheadline.weight(.medium))
+ Text("Starts when you send a task from this iPhone. Follow its progress, then open the conversation when your bot needs you.")
+ .font(.footnote).foregroundStyle(Palette.secondary)
+ if !allowed {
+ Text("Live Activities are turned off in iOS Settings.")
+ .font(.footnote).foregroundStyle(Palette.secondary)
+ Link("Open iOS Settings", destination: URL(string: UIApplication.openSettingsURLString)!)
+ .font(.footnote.weight(.medium))
+ }
+ }
+ .padding(16).background(Palette.surface, in: RoundedRectangle(cornerRadius: 20))
+
+ VStack(alignment: .leading, spacing: 14) {
+ HStack {
+ Text("Preview").font(.subheadline.weight(.medium))
+ Spacer()
+ Text("Sample task").font(.caption).foregroundStyle(Palette.secondary)
+ }
+ Picker("Presentation", selection: $form) {
+ ForEach(BotActivityPreview.Form.allCases, id: \.self) { Text($0.rawValue).tag($0) }
+ }.pickerStyle(.menu)
+ Picker("Task state", selection: $phase) {
+ Text("Working").tag(BotActivityPresentation.Phase.working)
+ Text("Needs you").tag(BotActivityPresentation.Phase.needsInput)
+ Text("Done").tag(BotActivityPresentation.Phase.completed)
+ Text("Error").tag(BotActivityPresentation.Phase.failed)
+ Text("Update delayed").tag(BotActivityPresentation.Phase.stale)
+ }.pickerStyle(.menu)
+ if let bot = Bot.widgetPreview.first {
+ BotActivityPreview(bot: bot, state: state, form: form)
+ .frame(maxWidth: .infinity, minHeight: 90)
+ .padding(12)
+ .background(Palette.bubbleAgent, in: RoundedRectangle(cornerRadius: 28))
+ }
+ }
+ VStack(alignment: .leading, spacing: 14) {
+ explanation("Lock Screen", "A task card with the bot, current step and elapsed time. Tap it to return to the conversation.")
+ explanation("Compact", "The bot and timer appear beside the camera. The timer becomes a status icon when the task needs attention or ends.")
+ explanation("Minimal", "A small status icon when iOS displays multiple Live Activities.")
+ explanation("Expanded", "Touch and hold the Dynamic Island for the current step and a shortcut to the conversation.")
+ }
+ Text("iOS chooses the presentation based on your device and other active tasks. These previews don't start a Live Activity. Approvals are handled inside Codync.")
+ .font(.footnote).foregroundStyle(Palette.secondary)
+ }
+ .padding(18).frame(maxWidth: 560).frame(maxWidth: .infinity)
+ }
+ .background(Palette.background)
+ .navigationTitle("Live Activity")
+ .navigationBarTitleDisplayMode(.inline)
+ .tint(Palette.accent)
+ .onChange(of: enabled) { _, value in if !value { LiveActivities.shared.endAll() } }
+ .onChange(of: scenePhase) { _, value in
+ if value == .active { allowed = ActivityAuthorizationInfo().areActivitiesEnabled }
+ }
+ }
+
+ private func explanation(_ title: String, _ detail: String) -> some View {
+ VStack(alignment: .leading, spacing: 4) {
+ Text(title).font(.subheadline.weight(.medium)).accessibilityAddTraits(.isHeader)
+ Text(detail).font(.footnote).foregroundStyle(Palette.secondary)
+ }
+ }
+}
+
+struct LockWidgetGalleryView: View {
+ @State private var kind = "bots"
+
+ var body: some View {
+ ScrollView {
+ VStack(alignment: .leading, spacing: 22) {
+ Picker("Widget", selection: $kind) {
+ Text("Bots").tag("bots")
+ Text("Usage limits").tag("usage")
+ }.pickerStyle(.menu)
+ Text("Sample data").font(.caption).foregroundStyle(Palette.secondary)
+ ForEach(AccessoryWidgetCard.Family.allCases, id: \.self) { family in
+ VStack(alignment: .leading, spacing: 10) {
+ Text(family.rawValue).font(.subheadline.weight(.medium))
+ AccessoryWidgetCard(kind: kind == "bots" ? .bots : .usage, family: family,
+ bots: Bot.widgetPreview, usage: .widgetPreview)
+ .frame(width: family == .circular ? 64 : family == .rectangular ? 160 : nil,
+ height: family == .inline ? 24 : 64)
+ .padding(16).foregroundStyle(.white)
+ .background(.black, in: RoundedRectangle(cornerRadius: 20))
+ .environment(\.colorScheme, .dark)
+ }
+ }
+ Text("Touch and hold your Lock Screen → Customize → Lock Screen. Tap the widget area and choose Codync. Inline widgets go in the date row above the clock.")
+ .font(.footnote).foregroundStyle(Palette.secondary)
+ Text("Choose Bots for task status or Usage limits for the highest reported limit. iOS applies your Lock Screen's color and style.")
+ .font(.footnote).foregroundStyle(Palette.secondary)
+ }
+ .padding(18).frame(maxWidth: 560).frame(maxWidth: .infinity)
+ }
+ .background(Palette.background)
+ .navigationTitle("Lock Screen widgets")
+ .navigationBarTitleDisplayMode(.inline)
+ }
+}
diff --git a/apps/ios/Views/SettingsView.swift b/apps/ios/Views/SettingsView.swift
index 0e89b41b..88379cab 100644
--- a/apps/ios/Views/SettingsView.swift
+++ b/apps/ios/Views/SettingsView.swift
@@ -67,6 +67,9 @@ struct SettingsView: View {
} label: {
Label("Widgets", systemImage: "square.grid.2x2")
}
+ NavigationLink { ActivityGalleryView() } label: {
+ Label("Live Activity & Dynamic Island", systemImage: "waveform")
+ }
notificationsRow
}
diff --git a/apps/ios/Views/UsageView.swift b/apps/ios/Views/UsageView.swift
index fe54cd25..3a41c112 100644
--- a/apps/ios/Views/UsageView.swift
+++ b/apps/ios/Views/UsageView.swift
@@ -54,7 +54,7 @@ private struct ProviderCard: View {
var body: some View {
VStack(alignment: .leading, spacing: 12) {
HStack(spacing: 10) {
- AgentIcon(registry: provider.registry, size: 22)
+ CharacterAvatar(shape: provider.mascotShape, tint: provider.widgetTint, size: 22)
.frame(width: 34, height: 34)
.background(provider.tint.opacity(0.12), in: RoundedRectangle(cornerRadius: 10, style: .continuous))
Text(provider.name).font(.subheadline.weight(.semibold)).foregroundStyle(Palette.text)
diff --git a/apps/ios/Views/WidgetGalleryView.swift b/apps/ios/Views/WidgetGalleryView.swift
index ee06eb43..84bdc8d1 100644
--- a/apps/ios/Views/WidgetGalleryView.swift
+++ b/apps/ios/Views/WidgetGalleryView.swift
@@ -10,6 +10,7 @@ struct WidgetGalleryView: View {
@Environment(\.dynamicTypeSize) private var typeSize
@State private var kind = "usage"
@State private var providerID = "claude"
+ @State private var size = "medium"
@State private var hasWidget: Bool?
@State private var widgetCheckFailed = false
@@ -25,7 +26,7 @@ struct WidgetGalleryView: View {
VStack(alignment: .leading, spacing: 4) {
Text("Codync, at a glance.")
.font(.title3.weight(.semibold)).tracking(-0.4)
- Text("Your bots and usage, right on your Home Screen.")
+ Text("Your bots and usage, on every surface.")
.font(.footnote).foregroundStyle(Palette.secondary)
}
}
@@ -70,24 +71,33 @@ struct WidgetGalleryView: View {
providerPicker.pickerStyle(.segmented)
}
}
+ Picker("Size", selection: $size) {
+ Text("Small").tag("small")
+ Text("Medium").tag("medium")
+ Text("Large").tag("large")
+ }
+ .pickerStyle(.menu)
VStack(spacing: 18) {
- preview(wide: true)
- .frame(height: 158)
- ViewThatFits(in: .horizontal) {
- HStack(alignment: .center, spacing: 18) {
- preview(wide: false).frame(width: 158, height: 158)
- previewDescription.frame(minWidth: 100)
- }
- VStack(alignment: .leading, spacing: 12) {
- preview(wide: false).frame(width: 158, height: 158)
- previewDescription
- }
- }
+ preview(wide: size != "small")
+ .frame(width: size == "small" ? 158 : nil, height: size == "large" ? 338 : 158)
+ previewDescription
}
.padding(14)
.background(Palette.bubbleAgent, in: RoundedRectangle(cornerRadius: 26))
}
+ VStack(alignment: .leading, spacing: 12) {
+ sectionLabel("More ways to stay up to date")
+ NavigationLink { LockWidgetGalleryView() } label: {
+ Label("Lock Screen widgets", systemImage: "lock.rectangle")
+ }
+ NavigationLink { ActivityGalleryView() } label: {
+ Label("Live Activity & Dynamic Island", systemImage: "waveform")
+ }
+ }
+ .font(.subheadline)
+ .frame(maxWidth: .infinity, alignment: .leading)
+
guide(number: "01", title: "Add the widget", icon: "plus.square.on.square",
detail: "Touch and hold your Home Screen. Tap Edit, then Add Widget. Search for Codync and choose Bots or Provider usage.")
guide(number: "02", title: "Make it yours", icon: "slider.horizontal.3",
@@ -124,8 +134,8 @@ struct WidgetGalleryView: View {
private var previewDescription: some View {
VStack(alignment: .leading, spacing: 6) {
- Text("Small & medium").font(.subheadline.weight(.medium))
- Text(kind == "usage" ? "Small shows the tightest limit. Medium shows both windows." : "See who needs you and who's still working.")
+ Text("\(size.capitalized) widget").font(.subheadline.weight(.medium))
+ Text(kind == "usage" ? "Small shows the tightest limit. Medium shows two windows. Large adds a summary and up to four limits." : "See who needs you and who's still working. Large shows up to six bots.")
.font(.caption).foregroundStyle(Palette.secondary)
}
.frame(maxWidth: .infinity, alignment: .leading)
@@ -134,15 +144,15 @@ struct WidgetGalleryView: View {
@ViewBuilder private func preview(wide: Bool) -> some View {
Group {
if kind == "usage", let provider {
- ProviderWidgetCard(provider: provider, layout: wide ? .medium : .small)
+ ProviderWidgetCard(provider: provider, layout: size == "large" ? .large : wide ? .medium : .small)
} else {
- BotsWidgetCard(bots: Bot.widgetPreview, wide: wide)
+ BotsWidgetCard(bots: Bot.widgetPreview, wide: wide, large: size == "large")
}
}
.padding(14)
.background(Palette.surface, in: RoundedRectangle(cornerRadius: 22))
.accessibilityElement(children: .contain)
- .accessibilityLabel(wide ? "Medium widget preview" : "Small widget preview")
+ .accessibilityLabel("\(size.capitalized) widget preview")
}
private func sectionLabel(_ title: String) -> some View {
diff --git a/apps/ios/Widgets/CodyncWidgets.swift b/apps/ios/Widgets/CodyncWidgets.swift
index 7e585b49..2a99a573 100644
--- a/apps/ios/Widgets/CodyncWidgets.swift
+++ b/apps/ios/Widgets/CodyncWidgets.swift
@@ -48,8 +48,8 @@ struct BotsWidget: Widget {
.containerBackground(Palette.surface, for: .widget)
}
.configurationDisplayName("Bots")
- .description("Which bots need you, which are working, and what they said last.")
- .supportedFamilies([.systemSmall, .systemMedium, .accessoryCircular, .accessoryRectangular, .accessoryInline])
+ .description("Bots that need you, running tasks, and their current activity.")
+ .supportedFamilies([.systemSmall, .systemMedium, .systemLarge, .accessoryCircular, .accessoryRectangular, .accessoryInline])
}
}
@@ -64,16 +64,6 @@ struct BotsWidgetView: View {
return rank($0) != rank($1) ? rank($0) < rank($1) : $0.lastAt > $1.lastAt
}
}
- private var needing: Int { ordered.filter(\.needsInput).count }
- private var working: Int { ordered.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 (ordered.count, ordered.count == 1 ? "bot, all quiet" : "bots, all quiet", false)
- }
-
var body: some View {
if !entry.paired {
switch family {
@@ -91,21 +81,13 @@ struct BotsWidgetView: View {
} else {
switch family {
case .accessoryInline:
- Text(needing > 0 ? "\(needing) bot\(needing == 1 ? "" : "s") need\(needing == 1 ? "s" : "") you" : working > 0 ? "\(working) working" : ordered.isEmpty ? "No bots yet" : "Bots all quiet")
+ AccessoryWidgetCard(kind: .bots, family: .inline, bots: entry.bots).widgetAccentable()
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()
+ AccessoryWidgetCard(kind: .bots, family: .circular, bots: entry.bots).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)
+ AccessoryWidgetCard(kind: .bots, family: .rectangular, bots: entry.bots).widgetAccentable()
+ case .systemLarge:
+ BotsWidgetCard(bots: entry.bots, wide: true, large: true, links: entry.links)
case .systemMedium:
BotsWidgetCard(bots: entry.bots, wide: true, links: entry.links)
default:
@@ -115,11 +97,6 @@ struct BotsWidgetView: View {
}
}
- 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 EmptyWidget: View {
@@ -216,22 +193,11 @@ struct UsageWidgetView: View {
if let top = tightest {
switch family {
case .accessoryInline:
- Text("\(top.provider) \(percent(top.window)) · \(top.window.label)")
+ AccessoryWidgetCard(kind: .usage, family: .inline, usage: entry.usage).widgetAccentable()
case .accessoryCircular:
- Gauge(value: min(top.window.percent, 100), in: 0...100) {
- Text(top.provider.prefix(2))
- } currentValueLabel: {
- Text("\(Int(top.window.percent.rounded()))")
- }
- .gaugeStyle(.accessoryCircularCapacity)
+ AccessoryWidgetCard(kind: .usage, family: .circular, usage: entry.usage).widgetAccentable()
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)
- }
- .frame(maxWidth: .infinity, alignment: .leading)
+ AccessoryWidgetCard(kind: .usage, family: .rectangular, usage: entry.usage).widgetAccentable()
case .systemMedium:
HStack(alignment: .top, spacing: 18) {
hero(top).frame(width: 118, alignment: .leading)
@@ -341,7 +307,7 @@ struct ProviderUsageWidget: Widget {
}
.configurationDisplayName("Provider usage")
.description("Session and weekly limits in a compact, easy-to-read card.")
- .supportedFamilies([.systemSmall, .systemMedium])
+ .supportedFamilies([.systemSmall, .systemMedium, .systemLarge])
}
}
@@ -354,7 +320,7 @@ struct ProviderUsageView: View {
var body: some View {
Group {
if let provider, !provider.windows.isEmpty {
- ProviderWidgetCard(provider: provider, layout: family == .systemSmall ? .small : .medium, date: entry.date)
+ ProviderWidgetCard(provider: provider, layout: family == .systemSmall ? .small : family == .systemLarge ? .large : .medium, date: entry.date)
} else {
EmptyWidget(text: "Open Codync to connect a computer and check \(entry.provider.rawValue.capitalized) usage.")
}
@@ -369,78 +335,55 @@ struct ProviderUsageView: View {
struct BotLiveActivity: Widget {
var body: some WidgetConfiguration {
ActivityConfiguration(for: BotActivityAttributes.self) { context in
- LockScreenView(context: context)
- .activityBackgroundTint(Palette.background)
+ BotActivityCard(name: context.attributes.name, shape: context.attributes.avatarShape,
+ color: context.attributes.avatarColor, state: presentation(context))
+ .activityBackgroundTint(Palette.surface)
.widgetURL(context.attributes.link ?? URL(string: "codync://computers"))
} dynamicIsland: { context in
- let s = context.state
+ let state = presentation(context)
return DynamicIsland {
DynamicIslandExpandedRegion(.leading) {
- CharacterAvatar(shape: context.attributes.avatarShape, color: context.attributes.avatarColor, size: 36,
- mood: s.status == "needsInput" ? .needsInput : .working)
- }
- DynamicIslandExpandedRegion(.center) {
- VStack(alignment: .leading, spacing: 2) {
- Text(context.attributes.name).font(.headline)
- Text(statusText(s)).font(.caption).foregroundStyle(s.status == "needsInput" ? Palette.warning : .secondary).lineLimit(2)
+ HStack(spacing: 8) {
+ avatar(context, size: 26)
+ Text(context.attributes.name).font(.system(size: 14, weight: .semibold))
+ .foregroundStyle(.white).lineLimit(1)
}
- .frame(maxWidth: .infinity, alignment: .leading)
}
DynamicIslandExpandedRegion(.trailing) {
- if let started = s.startedAt, s.status == "working" {
- Text(started, style: .timer).font(.caption.monospacedDigit()).frame(width: 52)
+ BotActivityIndicator(state: state).environment(\.colorScheme, .dark)
+ }
+ DynamicIslandExpandedRegion(.bottom) {
+ VStack(alignment: .leading, spacing: 10) {
+ BotActivityDetail(state: state)
+ if let link = context.attributes.link {
+ Link(destination: link) {
+ Label(state.phase == .needsInput ? "Respond in Codync" : "Open conversation", systemImage: "arrow.up.right")
+ .font(.system(size: 12, weight: .medium))
+ }
+ .tint(.white)
+ }
}
+ .environment(\.colorScheme, .dark)
}
} compactLeading: {
- CharacterAvatar(shape: context.attributes.avatarShape, color: context.attributes.avatarColor, size: 20)
+ avatar(context, size: 20)
} compactTrailing: {
- if s.status == "needsInput" {
- Image(systemName: "hand.raised.fill").foregroundStyle(Palette.warning)
- } 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.text)
- }
+ BotActivityIndicator(state: state).environment(\.colorScheme, .dark)
} minimal: {
- CharacterAvatar(shape: context.attributes.avatarShape, color: context.attributes.avatarColor, size: 20)
+ BotActivityIndicator(state: state, minimal: true)
+ .environment(\.colorScheme, .dark)
+ .accessibilityLabel("\(context.attributes.name), \(state.title)")
}
.widgetURL(context.attributes.link ?? URL(string: "codync://computers"))
}
}
-}
-private func statusText(_ s: BotActivityAttributes.ContentState) -> String {
- switch s.status {
- case "needsInput": s.activity.isEmpty ? "Needs your approval" : s.activity
- case "working": s.activity.isEmpty ? "Working…" : s.activity
- case "error": "Stopped with an error"
- default: "Done"
+ private func presentation(_ context: ActivityViewContext<BotActivityAttributes>) -> BotActivityPresentation {
+ .init(status: context.state.status, activity: context.state.activity,
+ startedAt: context.state.startedAt, isStale: context.isStale)
}
-}
-private struct LockScreenView: View {
- let context: ActivityViewContext<BotActivityAttributes>
-
- var body: some View {
- let s = context.state
- HStack(spacing: 12) {
- CharacterAvatar(shape: context.attributes.avatarShape, color: context.attributes.avatarColor, size: 44,
- mood: s.status == "needsInput" ? .needsInput : s.status == "working" ? .working : .idle)
- VStack(alignment: .leading, spacing: 3) {
- Text(context.attributes.name).font(.headline).foregroundStyle(Palette.text)
- Text(statusText(s))
- .font(.subheadline)
- .foregroundStyle(s.status == "needsInput" ? Palette.warning : Palette.secondary)
- .lineLimit(2)
- }
- Spacer()
- if s.status == "working", let started = s.startedAt {
- Text(started, style: .timer)
- .font(.title3.monospacedDigit())
- .foregroundStyle(Palette.accent)
- .frame(width: 70, alignment: .trailing)
- }
- }
- .padding(16)
+ private func avatar(_ context: ActivityViewContext<BotActivityAttributes>, size: CGFloat) -> some View {
+ CharacterAvatar(shape: context.attributes.avatarShape, color: context.attributes.avatarColor, size: size)
}
}
diff --git a/apps/ios/Widgets/WidgetPreviews.swift b/apps/ios/Widgets/WidgetPreviews.swift
index f53cdadf..6fe84ac2 100644
--- a/apps/ios/Widgets/WidgetPreviews.swift
+++ b/apps/ios/Widgets/WidgetPreviews.swift
@@ -2,6 +2,7 @@
import CodyncKit
import SwiftUI
import WidgetKit
+import ActivityKit
// Native WidgetKit previews exercise the actual configurations, including their
// system margins and accessory families. All data here is explicitly synthetic.
@@ -56,4 +57,58 @@ import WidgetKit
UsageEntry(date: .now, usage: .widgetPreview)
UsageEntry(date: .now, usage: Usage())
}
+
+#Preview(as: .systemLarge) {
+ ProviderUsageWidget()
+} timeline: {
+ ProviderUsageEntry(date: .now, usage: .widgetPreview, provider: .claude)
+ ProviderUsageEntry(date: .now, usage: .widgetPreview, provider: .codex)
+}
+
+#Preview(as: .systemLarge) {
+ BotsWidget()
+} timeline: {
+ BotsEntry(date: .now, bots: Bot.widgetPreview, paired: true)
+ BotsEntry(date: .now, bots: [], paired: true)
+}
+
+private extension BotActivityAttributes {
+ static var preview: Self { .init(bot: Bot.widgetPreview[0], link: URL(string: "codync://computers")) }
+}
+
+#Preview("Activity · Lock Screen", as: .content, using: BotActivityAttributes.preview) {
+ BotLiveActivity()
+} contentStates: {
+ BotActivityAttributes.ContentState(status: "working", activity: "Running the test suite.", startedAt: .now - 154)
+ BotActivityAttributes.ContentState(status: "needsInput", activity: "Review the proposed changes.", startedAt: .now - 154)
+ BotActivityAttributes.ContentState(status: "idle", activity: "", startedAt: nil)
+ BotActivityAttributes.ContentState(status: "error", activity: "", startedAt: nil)
+}
+
+#Preview("Island · Compact", as: .dynamicIsland(.compact), using: BotActivityAttributes.preview) {
+ BotLiveActivity()
+} contentStates: {
+ BotActivityAttributes.ContentState(status: "working", activity: "Running tests.", startedAt: .now - 154)
+ BotActivityAttributes.ContentState(status: "needsInput", activity: "Review changes.", startedAt: nil)
+ BotActivityAttributes.ContentState(status: "error", activity: "", startedAt: nil)
+ BotActivityAttributes.ContentState(status: "idle", activity: "", startedAt: nil)
+}
+
+#Preview("Island · Minimal", as: .dynamicIsland(.minimal), using: BotActivityAttributes.preview) {
+ BotLiveActivity()
+} contentStates: {
+ BotActivityAttributes.ContentState(status: "working", activity: "Running tests.", startedAt: .now - 154)
+ BotActivityAttributes.ContentState(status: "needsInput", activity: "Review changes.", startedAt: nil)
+ BotActivityAttributes.ContentState(status: "error", activity: "", startedAt: nil)
+ BotActivityAttributes.ContentState(status: "idle", activity: "", startedAt: nil)
+}
+
+#Preview("Island · Expanded", as: .dynamicIsland(.expanded), using: BotActivityAttributes.preview) {
+ BotLiveActivity()
+} contentStates: {
+ BotActivityAttributes.ContentState(status: "working", activity: "Running the test suite.", startedAt: .now - 154)
+ BotActivityAttributes.ContentState(status: "needsInput", activity: "Review the proposed changes.", startedAt: nil)
+ BotActivityAttributes.ContentState(status: "error", activity: "", startedAt: nil)
+ BotActivityAttributes.ContentState(status: "idle", activity: "", startedAt: nil)
+}
#endif
diff --git a/apps/macos/App/CodyncMacApp.swift b/apps/macos/App/CodyncMacApp.swift
index e4aa5866..0817e0a6 100644
--- a/apps/macos/App/CodyncMacApp.swift
+++ b/apps/macos/App/CodyncMacApp.swift
@@ -233,7 +233,6 @@ private extension View {
self.padding(padding)
.frame(maxWidth: .infinity, alignment: .leading)
.background(Palette.surface, in: RoundedRectangle(cornerRadius: 14, style: .continuous))
- .overlay(RoundedRectangle(cornerRadius: 14, style: .continuous).strokeBorder(Palette.border, lineWidth: 0.5))
}
}
@@ -247,10 +246,9 @@ private struct RemoteScreenSection: View {
VStack(alignment: .leading, spacing: 10) {
HStack(spacing: 10) {
Image(systemName: "display")
- .font(.system(size: 13, weight: .semibold))
- .foregroundStyle(screen.enabled ? Palette.onAccent : Palette.text)
+ .font(.system(size: 17, weight: .regular))
+ .foregroundStyle(screen.enabled ? Palette.text : Palette.secondary)
.frame(width: 30, height: 30)
- .background(screen.enabled ? Palette.accentFill : Palette.bubbleUser, in: Circle())
.accessibilityHidden(true)
VStack(alignment: .leading, spacing: 1) {
Text("Remote screen").font(.callout.weight(.medium)).foregroundStyle(Palette.text)
@@ -336,7 +334,7 @@ private struct UsageBlock: View {
var body: some View {
VStack(alignment: .leading, spacing: 7) {
HStack(spacing: 6) {
- AgentIcon(registry: provider.registry, size: 15)
+ CharacterAvatar(shape: provider.mascotShape, tint: provider.widgetTint, size: 15)
Text(provider.name).font(.caption.weight(.semibold)).foregroundStyle(Palette.text)
Spacer()
Text("updated \(RelativeTime.short(Date(milliseconds: provider.updatedAt)))")
diff --git a/docs/mobile-widgets-design.md b/docs/mobile-widgets-design.md
index c3e5b438..d8a6657e 100644
--- a/docs/mobile-widgets-design.md
+++ b/docs/mobile-widgets-design.md
@@ -1,6 +1,6 @@
# Mobile onboarding 與 Widgets 設計
-更新:2026-09-25。此工作範圍是 iOS 介面與 WidgetKit;Cloudflare 後端由 Claude Code 另行實作。
+更新:2026-09-26。此工作範圍是 iOS 介面、WidgetKit 與 ActivityKit;Cloudflare 後端由 Claude Code 另行實作。
## 參考方向
@@ -23,16 +23,19 @@
## Widget 與 App 內預覽
-| 類型 | Small | Medium |
-| --- | --- | --- |
-| Provider usage | provider、最接近上限的用量、細刻度條、重置時間 | 同一 provider 的兩個用量視窗與重置時間 |
-| Bots | 待回應/工作中的數量與角色圖示 | 狀態摘要與最多三個 bot,待回應優先 |
+| 類型 | Small | Medium | Large |
+| --- | --- | --- | --- |
+| Provider usage | provider、最接近上限的用量、細刻度條、重置時間 | 同一 provider 的兩個用量視窗與重置時間 | 主要用量摘要、最多四個用量視窗 |
+| Bots | 待回應/工作中的數量與角色圖示 | 狀態摘要與最多三個 bot,待回應優先 | 數量摘要與最多六個 bot |
+
+既有 Usage limits 保留 Small/Medium 的跨 provider 用量摘要。Bots 與 Usage limits 另支援 Lock Screen 的圓形、矩形與行內形式;行內放在時鐘上方日期列。
- Provider usage 可在系統「編輯 Widget」選擇 Claude 或 Codex。
- Claude 使用既有暖色;Codex 使用藍色;90% 以上顯示警示色。
- 採平面深淺色表面、小型圖示、11–13 pt 標籤;大字只用於主要數值。
- App 的 Usage 卡片同步縮小字級、圖示、內距,並使用同一款刻度條。
-- Widgets 頁可從 Settings 或 Usage 的「Widgets & setup」進入,提供類型/provider 切換、小/中預覽與設定教學。
+- Widgets 頁可從 Settings 或 Usage 的「Widgets & setup」進入,提供類型/provider/大小切換、三種主畫面尺寸預覽與設定教學。
+- 「Lock Screen widgets」頁可切換 Bots/Usage limits,預覽圓形、矩形與行內形式。正式 widget 與預覽共用 `AccessoryWidgetCard`。
- 設定清單讀取實際電腦配對狀態與 `WidgetCenter` 的已安裝配置;不以點過教學當作完成。
- 查詢失敗時顯示錯誤與「Check again」,不會永久停在載入狀態。
- 預覽明確標示 Sample data。已安裝的 widget 不用範例資料掩蓋未配對或尚無用量的狀態。
@@ -41,6 +44,32 @@
`kit/Sources/CodyncKit/Design/WidgetCards.swift` 是共用繪製元件;`apps/ios/Views/WidgetGalleryView.swift` 與 `apps/ios/Widgets/CodyncWidgets.swift` 共用它,減少預覽與實際 widget 的差異。
+## Live Activity 與 Dynamic Island
+
+Settings 與 Widgets 頁都能進入「Live Activity & Dynamic Island」。這裡提供 Live Activities 開關、系統授權狀態,以及形式/任務狀態預覽。預覽明確標示 Sample task,不會啟動實際任務或 Live Activity。
+
+| 形式 | 資訊與互動 |
+| --- | --- |
+| Lock Screen/橫幅 | bot 名稱、狀態、目前工作、執行時間;點擊回到對話 |
+| Compact | 左側 bot、右側計時;需要回應/完成/錯誤時改為狀態圖示 |
+| Minimal | 在更小空間顯示狀態圖示,VoiceOver 包含 bot 名稱 |
+| Expanded | bot、狀態、工作摘要、回到對話的連結;需要回應時顯示 Respond in Codync |
+
+實際形式由 iOS 根據裝置、活動數量與互動決定;App 內的形式選單只控制設計預覽。[Apple Live Activities 設計指南](https://developer.apple.com/design/human-interface-guidelines/live-activities)
+
+所有形式共用 `BotActivityPresentation` 的狀態判斷:
+
+- Working:顯示目前工作,有開始時間才顯示計時。
+- Needs you:顯示待回應提示;審批與文字回應在 App 處理。
+- Done:完成勾號與查看結果提示。
+- Stopped:錯誤圖示,不會誤顯示成完成。
+- Update delayed:ActivityKit 回報 stale 時顯示延遲提示,不繼續顯示即時計時。
+- 未知狀態:保守顯示 Waiting for update,不宣稱任務完成。
+
+既有生命週期繼續由手機送出任務時啟動、App 接收事件時更新、完成時結束。App 本地更新設定 15 分鐘 stale date;沒有更新不代表工作失敗。遠端推播沿用現有 relay/host 合約,這輪未變更後端。關閉 Live Activities 會結束目前活動並阻止之後自動啟動。
+
+Dynamic Island 固定黑底,文字採淺色;Lock Screen 卡片配合系統外觀。`ActivityCards.swift` 共用主要內容,正式 Dynamic Island 由系統 region 排版,App 裡顯示示意容器。[Apple DynamicIsland API](https://developer.apple.com/documentation/widgetkit/dynamicisland)
+
## 資料與互動
- Widgets 跟隨 App 目前選取的帳號,讀取該帳號的 App Group 快取;不合併不同帳號的 bots 或用量。
@@ -58,15 +87,20 @@
已完成:
- iOS Simulator build,含 widget extension 與原生 WidgetKit 預覽巨集,沒有編譯警告。
-- Swift package 10 個測試,包含跨帳號隔離與跨電腦 widget 快取清除/保留的回歸測試。
+- Swift package 14 個測試,包含跨帳號隔離、跨電腦 widget 快取清除/保留,以及 Live Activity 錯誤/未知/stale/計時狀態的回歸測試。
- 首次 onboarding 隱藏帳號入口;完成後,即使沒有電腦仍保留帳號入口。
- App 內 Widgets 頁、Claude/Codex 預覽切換、淺色/深色與無障礙大字體佈局檢查。
- 共用卡片的離線圖片輸出:Claude、Codex、接近上限、Bots 工作/待回應、空清單;每種包含小/中尺寸及淺色/深色。
- 本機 HTTP/SSE 測試 host 到 App Group 的整合檢查:初次 bot/用量同步、狀態不變時改名及活動更新、刪除 bot、切換到離線電腦後清除上一台資料。
- 系統 Add Widget 搜尋能找到 Codync。測試配對不會保留在模擬器。
+- 大型 widget 用四個限制視窗及六個 bot 測試實際共用元件的排版;三種鎖定畫面配件也產生了深淺色檢查圖。
+- Live Activity 五種狀態 × Lock Screen/compact/minimal/expanded 共用內容已輸出檢查;四種原生 ActivityKit 預覽均可編譯。
+- 模擬器實際啟動不連 relay/APNs 的本機範例 Activity,確認系統 Dynamic Island compact 與 Lock Screen 卡片的 Needs you 呈現。Lock Screen 同時出現 iOS 的首次 Allow 提示,未操作該權限提示。
驗證限制:系統 widget 搜尋結果沒有提供可點擊的 accessibility 元素,座標點擊與捲動仍回報 `noWindowsAvailable`,鍵盤導覽也未能開啟結果。因此尚未在系統 Home/Lock Screen 上實際加入 widget、編輯 provider 或量測背景刷新排程;原生預覽可編譯與共用卡片圖片檢查不等同這些整合驗證。
+Live Activity 的 compact/Lock Screen 已觀察到系統實際呈現;minimal/expanded 的系統切換及 APNs 背景更新未完成端到端操作驗證。兩個同時活動的範例在此次模擬器中仍顯示 compact,不能據此宣稱 minimal 已驗證。
+
重現方式:
```sh
@@ -74,6 +108,32 @@ swift test --package-path kit
python3 tools/render-widgets.py
```
-圖片輸出在 `build/widget-previews/widgets-light.png` 與 `widgets-dark.png`。腳本使用 macOS 的 SwiftUI ImageRenderer,直接繪製產品共用元件;產物不含使用者資料。實際 WidgetKit 預覽在 `apps/ios/Widgets/WidgetPreviews.swift`,可於 Xcode canvas 切換 timeline 的 provider/空狀態。
+圖片輸出在 `build/widget-previews/`:`widgets-{light,dark}.png`、`large-widgets-{light,dark}.png`、`activities-{light,dark}.png`、`halftone-icons-{light,dark}.png`。腳本使用 macOS 的 SwiftUI ImageRenderer,直接繪製產品共用元件;產物不含使用者資料。實際 WidgetKit/ActivityKit 預覽在 `apps/ios/Widgets/WidgetPreviews.swift`,可於 Xcode canvas 切換 timeline/content states。
+
+DEBUG simulator build 也可用 `SIMCTL_CHILD_CODYNC_ACTIVITY_PREVIEW=needsInput xcrun simctl launch --terminate-running-process booted com.pokai.Codync.ios` 啟動系統範例。值可為 `working`、`needsInput`、`idle`、`error`、`stale` 或 `multiple`;以 `stop` 結束範例。此入口只存在於 DEBUG simulator,不連 host/relay/APNs,清理僅針對 `codync-design-preview-` 的活動。
帳號/雲端架構與 SSH computer 路線分別見 [帳號與裝置計畫](cloudflare-account-device-plan.md) 與 [Bot/computer/SSH 計畫](bot-computer-ssh-plan.md)。
+
+
+## Halftone 與 Thinking Orbs(2026-09-26)
+
+Bot 與 provider 的角色頭像統一使用 `CharacterAvatar` 點陣;小於 24 pt 也不再改用實心剪影。15 pt 用 7 × 7、20–26 pt 用 9 × 9、28 pt 以上用 13 × 13 網格,保留鏤空眼睛並提高小尺寸墨色。iOS 與 macOS 用量卡的 provider 頭像採相同元件。
+
+狀態圖示以 [Jakub Antalik 的 thinking-orbs](https://github.com/Jakubantalik/thinking-orbs) 為來源,這次原生移植四種實際使用的造型:
+
+| 造型 | 使用位置 |
+| --- | --- |
+| Working/orbits | Bot 工作列、聊天工作提示、工具執行、一般安裝進度、Live Activity 工作狀態 |
+| Searching/globe | 搜尋工具執行中 |
+| Listening/wave | Bot 待回應列、聊天待回應、Live Activity/Dynamic Island Needs you |
+| Connecting/web | 電腦連線提示、帳號登入、agent 登入狀態查詢、fetch 工具、Activity 等待更新 |
+
+角色頭像識別「哪一個 bot」;orb 表達「現在做什麼」。完成、錯誤、更新延遲繼續保留明確的勾號/錯誤/時鐘符號,導航及操作按鈕保留語意圖示。所有 orb 均附於可讀狀態文字或具備外層 accessibility label。
+
+實作採上游 0.3.1、commit `de85557ca220332586d070d8788c0e1d6e877a0d` 的幾何與 20/64 pt 預設值。小於 40 pt 使用精簡密度;其餘使用大尺寸密度。繪製端改用可套色的透明墨色,適配卡片、深淺色及 Dynamic Island。SwiftUI Canvas 不需要 WebView 或 JavaScript runtime。
+
+App 內動畫最多 30 fps;離開畫面、App 非 active 或啟用 Reduce Motion 時顯示靜態幀。Widget、Live Activity 與 Dynamic Island 明確傳入 `animated: false`,不依賴持續動畫計時。狀態仍隨既有資料更新。
+
+上游 MIT 授權全文隨 `CodyncKit` resource bundle 發佈,位於 `kit/Sources/CodyncKit/Resources/ThirdPartyNotices/thinking-orbs-LICENSE.txt`。`ThinkingOrbGeometryTests` 使用上游獨立 golden vectors 的取樣,驗證四種造型 × 兩尺寸 × 四時間點的 dot/line 數量、位置、半徑、墨色及深度順序。其餘五種上游造型暫未移植;有對應產品狀態時再加入。
+
+本次驗證:14 個 Swift package 測試全數通過(含 32 組上游幾何參考案例);iOS Simulator App/Widget extension build 成功、無編譯警告;確認兩個產物都包含第三方授權。已檢查深淺色 icon 圖版及 Live Activity 共用元件圖版。此驗證不擴大前述原生系統互動/APNs 的完成範圍。
diff --git a/kit/Package.swift b/kit/Package.swift
index 0c9802dc..a098389d 100644
--- a/kit/Package.swift
+++ b/kit/Package.swift
@@ -16,7 +16,7 @@ let package = Package(
.package(url: "https://github.com/migueldeicaza/SwiftTerm.git", exact: "1.18.0"),
],
targets: [
- .target(name: "CodyncKit"),
+ .target(name: "CodyncKit", resources: [.copy("Resources/ThirdPartyNotices")]),
.target(
name: "CodyncUI",
dependencies: [
diff --git a/kit/Sources/CodyncKit/Design/AccessoryWidgetCard.swift b/kit/Sources/CodyncKit/Design/AccessoryWidgetCard.swift
new file mode 100644
index 00000000..1dcb4e81
--- /dev/null
+++ b/kit/Sources/CodyncKit/Design/AccessoryWidgetCard.swift
@@ -0,0 +1,78 @@
+import SwiftUI
+
+/// Monochrome Lock Screen widgets; the system supplies the background and tint.
+public struct AccessoryWidgetCard: View {
+ public enum Kind { case bots, usage }
+ public enum Family: String, CaseIterable { case circular = "Circle", rectangular = "Rectangle", inline = "Inline" }
+ let kind: Kind
+ let family: Family
+ let bots: [Bot]
+ let usage: Usage
+ let paired: Bool
+
+ public init(kind: Kind, family: Family, bots: [Bot] = [], usage: Usage = Usage(), paired: Bool = true) {
+ self.kind = kind; self.family = family; self.bots = bots.filter { !$0.hidden }
+ self.usage = usage; self.paired = paired
+ }
+
+ private var needs: Int { bots.filter(\.needsInput).count }
+ private var working: Int { bots.filter { $0.isWorking && !$0.needsInput }.count }
+ private var count: Int { needs > 0 ? needs : working > 0 ? working : bots.count }
+ private var botLabel: String { needs > 0 ? (needs == 1 ? "needs you" : "need you") : working > 0 ? "working" : (bots.count == 1 ? "bot" : "bots") }
+ private var top: (name: String, window: UsageWindow)? {
+ usage.providers.flatMap { p in p.windows.map { (name: p.name, window: $0) } }
+ .max { $0.window.percent < $1.window.percent }
+ }
+ private var headline: String {
+ guard paired else { return "Connect a computer" }
+ if kind == .bots { return bots.isEmpty ? "No bots yet" : "\(count) \(botLabel)" }
+ return top.map { "\($0.name) \(Int($0.window.percent.rounded()))%" } ?? "No usage yet"
+ }
+
+ public var body: some View {
+ Group {
+ switch family {
+ case .inline:
+ Label(headline, systemImage: kind == .bots ? "bubble.left.and.bubble.right" : "chart.bar")
+ .font(.caption).lineLimit(1)
+ case .circular:
+ if !paired {
+ Image(systemName: "desktopcomputer").accessibilityLabel(headline)
+ } else if kind == .usage, let top {
+ Gauge(value: min(100, max(0, top.window.percent)), in: 0...100) {
+ Text(top.name.prefix(2))
+ } currentValueLabel: {
+ Text("\(Int(top.window.percent.rounded()))").font(.system(size: 18, weight: .semibold))
+ }
+ .gaugeStyle(.accessoryCircularCapacity)
+ .accessibilityLabel(headline)
+ } else {
+ VStack(spacing: 0) {
+ Text(kind == .bots ? "\(count)" : "—").font(.system(size: 24, weight: .semibold, design: .rounded))
+ Text(kind == .bots ? (needs > 0 ? "need you" : working > 0 ? "working" : "bots") : "usage")
+ .font(.system(size: 9))
+ }
+ }
+ case .rectangular:
+ VStack(alignment: .leading, spacing: 2) {
+ Text(headline).font(.system(size: 12, weight: .semibold)).lineLimit(1)
+ if paired, kind == .bots {
+ ForEach(bots.sorted { rank($0) < rank($1) }.prefix(2)) { bot in
+ Text("\(bot.name) · \(bot.needsInput ? "Needs you" : bot.isWorking ? "Working" : "Ready")")
+ .font(.system(size: 10)).lineLimit(1)
+ }
+ } else if paired, let top {
+ Text(top.window.title).font(.system(size: 10)).lineLimit(1)
+ if let reset = top.window.resetsShort() {
+ Text(reset).font(.system(size: 9)).lineLimit(1)
+ }
+ }
+ }
+ .frame(maxWidth: .infinity, alignment: .leading)
+ }
+ }
+ .accessibilityElement(children: .combine)
+ }
+
+ private func rank(_ bot: Bot) -> Int { bot.needsInput ? 0 : bot.isWorking ? 1 : 2 }
+}
diff --git a/kit/Sources/CodyncKit/Design/ActivityCards.swift b/kit/Sources/CodyncKit/Design/ActivityCards.swift
new file mode 100644
index 00000000..13cbbc13
--- /dev/null
+++ b/kit/Sources/CodyncKit/Design/ActivityCards.swift
@@ -0,0 +1,172 @@
+import SwiftUI
+
+public extension BotActivityPresentation {
+ var orbState: ThinkingOrb.State? {
+ switch phase {
+ case .working: .working
+ case .needsInput: .listening
+ case .waiting: .connecting
+ case .completed, .failed, .stale: nil
+ }
+ }
+
+ var tint: Color {
+ switch phase {
+ case .needsInput: Color(light: 0x936000, dark: 0xECAF52)
+ case .failed: Palette.danger
+ case .completed: Palette.added
+ case .stale, .waiting: Palette.secondary
+ case .working: Palette.text
+ }
+ }
+}
+
+/// Shared by the Lock Screen Live Activity and the in-app gallery.
+public struct BotActivityCard: View {
+ let name: String
+ let shape: String
+ let color: String
+ let state: BotActivityPresentation
+
+ public init(bot: Bot, state: BotActivityPresentation) {
+ self.init(name: bot.name, shape: bot.avatarShape, color: bot.avatarColor, state: state)
+ }
+
+ public init(name: String, shape: String, color: String, state: BotActivityPresentation) {
+ self.name = name
+ self.shape = shape
+ self.color = color
+ self.state = state
+ }
+
+ public var body: some View {
+ VStack(alignment: .leading, spacing: 10) {
+ HStack(spacing: 10) {
+ CharacterAvatar(shape: shape, color: color, size: 32)
+ VStack(alignment: .leading, spacing: 2) {
+ Text(name).font(.system(size: 14, weight: .semibold)).foregroundStyle(Palette.text)
+ Text(state.title).font(.system(size: 11, weight: .medium)).foregroundStyle(state.tint)
+ }
+ .lineLimit(1)
+ Spacer(minLength: 8)
+ BotActivityIndicator(state: state)
+ }
+ Text(state.detail).font(.system(size: 12)).foregroundStyle(Palette.secondary)
+ .lineLimit(2).fixedSize(horizontal: false, vertical: true)
+ }
+ .padding(16)
+ .accessibilityElement(children: .combine)
+ }
+}
+
+/// Compact trailing / minimal: errors and delayed updates never look complete.
+public struct BotActivityIndicator: View {
+ let state: BotActivityPresentation
+ let minimal: Bool
+
+ public init(state: BotActivityPresentation, minimal: Bool = false) {
+ self.state = state
+ self.minimal = minimal
+ }
+
+ public var body: some View {
+ Group {
+ if !minimal, state.showsTimer, let started = state.startedAt {
+ Text(started, style: .timer).monospacedDigit()
+ .font(.system(size: 12, weight: .medium))
+ .multilineTextAlignment(.trailing).frame(width: 46)
+ .minimumScaleFactor(0.7)
+ } else if let orb = state.orbState {
+ ThinkingOrb(state: orb, size: minimal ? 22 : 20, color: state.tint, animated: false)
+ .accessibilityHidden(false).accessibilityLabel(state.title)
+ } else {
+ Image(systemName: state.symbol).font(.system(size: 13, weight: .semibold))
+ .accessibilityLabel(state.title)
+ }
+ }
+ .foregroundStyle(state.tint)
+ }
+}
+
+/// The content below the camera in the expanded Dynamic Island.
+public struct BotActivityDetail: View {
+ let state: BotActivityPresentation
+ public init(state: BotActivityPresentation) { self.state = state }
+
+ public var body: some View {
+ VStack(alignment: .leading, spacing: 5) {
+ Label {
+ Text(state.title)
+ } icon: {
+ if let orb = state.orbState {
+ ThinkingOrb(state: orb, size: 16, color: state.tint, animated: false)
+ } else {
+ Image(systemName: state.symbol)
+ }
+ }
+ .font(.system(size: 11, weight: .semibold)).foregroundStyle(state.tint)
+ Text(state.detail).font(.system(size: 12)).foregroundStyle(Palette.secondary)
+ .lineLimit(2)
+ }
+ .frame(maxWidth: .infinity, alignment: .leading)
+ .accessibilityElement(children: .combine)
+ }
+}
+
+/// Illustrations for the gallery/exporter, using the same activity content views.
+/// The real Dynamic Island's regions and camera cutout are laid out by iOS.
+public struct BotActivityPreview: View {
+ public enum Form: String, CaseIterable {
+ case lockScreen = "Lock Screen", compact = "Compact", minimal = "Minimal", expanded = "Expanded"
+ }
+ let bot: Bot
+ let state: BotActivityPresentation
+ let form: Form
+
+ public init(bot: Bot, state: BotActivityPresentation, form: Form) {
+ self.bot = bot; self.state = state; self.form = form
+ }
+
+ public var body: some View {
+ Group {
+ if form == .lockScreen {
+ BotActivityCard(bot: bot, state: state)
+ .background(Palette.surface, in: RoundedRectangle(cornerRadius: 22))
+ } else {
+ island.environment(\.colorScheme, .dark)
+ }
+ }
+ .accessibilityElement(children: .contain)
+ .accessibilityLabel("\(form.rawValue) preview")
+ }
+
+ @ViewBuilder private var island: some View {
+ switch form {
+ case .compact:
+ HStack {
+ CharacterAvatar(bot: bot, size: 20, animated: false)
+ Spacer(minLength: 70)
+ BotActivityIndicator(state: state)
+ }
+ .padding(.horizontal, 12).frame(width: 210, height: 38)
+ .background(.black, in: Capsule())
+ case .minimal:
+ BotActivityIndicator(state: state, minimal: true)
+ .frame(width: 38, height: 38).background(.black, in: Circle())
+ case .expanded:
+ VStack(alignment: .leading, spacing: 12) {
+ HStack(spacing: 8) {
+ CharacterAvatar(bot: bot, size: 26, animated: false)
+ Text(bot.name).font(.system(size: 14, weight: .semibold)).foregroundStyle(.white).lineLimit(1)
+ Spacer()
+ BotActivityIndicator(state: state)
+ }
+ BotActivityDetail(state: state)
+ Text(state.phase == .needsInput ? "Respond in Codync ↗" : "Open conversation ↗")
+ .font(.system(size: 12, weight: .medium)).foregroundStyle(.white)
+ }
+ .padding(18).background(.black, in: RoundedRectangle(cornerRadius: 28))
+ case .lockScreen: EmptyView()
+ }
+ }
+}
diff --git a/kit/Sources/CodyncKit/Design/CharacterAvatar.swift b/kit/Sources/CodyncKit/Design/CharacterAvatar.swift
index 7803e7b5..2538c1b1 100644
--- a/kit/Sources/CodyncKit/Design/CharacterAvatar.swift
+++ b/kit/Sources/CodyncKit/Design/CharacterAvatar.swift
@@ -39,12 +39,13 @@ public struct CharacterAvatar: View {
}
}
-/// 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]
+/// Keep the halftone at every size. Small icons use fewer, larger dots so the
+/// gaps and hollow eyes survive rasterization in widgets and the Dynamic Island.
+private struct Grid {
+ let cells: Int
+ init(size: CGFloat) { cells = size < 18 ? 7 : size < 28 ? 9 : 13 }
+ var eyeColumns: [Int] { cells == 7 ? [2, 4] : cells == 9 ? [3, 6] : [4, 8] }
+ var eyeRows: [Int] { cells == 13 ? [4, 5, 6] : cells == 9 ? [3, 4] : [2, 3] }
}
private struct DottedBody: View {
@@ -55,28 +56,18 @@ private struct DottedBody: View {
@Environment(\.accessibilityReduceMotion) private var reduceMotion
var body: some View {
- let step = size / CGFloat(Grid.cells)
- let dots = Self.grid(shape: shape, size: size, step: step)
+ let grid = Grid(size: size)
+ let step = size / CGFloat(grid.cells)
+ let dots = Self.grid(shape: shape, size: size, step: step, cells: grid.cells)
let still = mood == .idle || reduceMotion
TimelineView(.animation(paused: still)) { timeline in
let 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 }
+ let eyeRows = blinking ? Array(grid.eyeRows.suffix(1)) : 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 / 2
let yaw = mood == .working ? t * 1.4 : -0.7
let lx = sin(yaw) * 0.8, ly = 0.55, lz = cos(yaw) * 0.5 + 0.6 // never fully behind
@@ -93,7 +84,8 @@ private struct DottedBody: View {
}
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.2 + 0.4 * min(1, shade / 0.7))))
+ let ink = grid.cells < 13 ? 0.4 + 0.4 * shade : 0.2 + 0.4 * min(1, shade / 0.7)
+ ctx.fill(dot, with: .color(Palette.text.opacity(ink)))
if shade > 0.6 {
ctx.fill(dot, with: .color(color.opacity((shade - 0.6) / 0.4)))
}
@@ -109,11 +101,11 @@ private struct DottedBody: View {
}
/// Square-grid dot centers that fall inside the silhouette.
- static func grid(shape: String, size: CGFloat, step: CGFloat) -> [Dot] {
+ static func grid(shape: String, size: CGFloat, step: CGFloat, cells: Int) -> [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 {
+ for row in 0..<cells {
+ for col in 0..<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)) }
}
diff --git a/kit/Sources/CodyncKit/Design/SwitchStyle.swift b/kit/Sources/CodyncKit/Design/SwitchStyle.swift
new file mode 100644
index 00000000..3c562899
--- /dev/null
+++ b/kit/Sources/CodyncKit/Design/SwitchStyle.swift
@@ -0,0 +1,32 @@
+import SwiftUI
+
+/// Codync's own on/off switch: label on the left, a flat capsule track on the right.
+public struct CodyncSwitch: ToggleStyle {
+ @Environment(\.accessibilityReduceMotion) private var reduceMotion
+
+ public init() {}
+
+ public func makeBody(configuration: Configuration) -> some View {
+ Button {
+ withAnimation(Motion.reduced(Motion.hover, reduceMotion)) { configuration.isOn.toggle() }
+ } label: {
+ HStack(spacing: 12) {
+ configuration.label
+ Spacer(minLength: 0)
+ Capsule()
+ .fill(configuration.isOn ? Palette.switchOn : Palette.bubbleUser)
+ .frame(width: 34, height: 20)
+ .overlay(alignment: configuration.isOn ? .trailing : .leading) {
+ Circle().fill(.white).padding(2)
+ }
+ }
+ .contentShape(Rectangle())
+ }
+ .buttonStyle(.plain)
+ .accessibilityRepresentation { Toggle(isOn: configuration.$isOn) { configuration.label } }
+ }
+}
+
+public extension ToggleStyle where Self == CodyncSwitch {
+ static var codync: CodyncSwitch { CodyncSwitch() }
+}
diff --git a/kit/Sources/CodyncKit/Design/ThinkingOrb.swift b/kit/Sources/CodyncKit/Design/ThinkingOrb.swift
index bb76e448..2a04b207 100644
--- a/kit/Sources/CodyncKit/Design/ThinkingOrb.swift
+++ b/kit/Sources/CodyncKit/Design/ThinkingOrb.swift
@@ -1,48 +1,66 @@
import SwiftUI
-/// The app's busy indicator: a small dotted sphere turning in place, after
-/// thinking-orbs' "working" orb. Depth is carried by dot size and opacity.
+/// Native thinking-orbs states, using its tuned dot geometry and depth shading.
+/// Supply an adjacent status label; this decorative view is hidden from VoiceOver.
public struct ThinkingOrb: View {
+ public enum State: String, CaseIterable, Sendable {
+ case working, searching, listening, connecting
+ }
+
+ let state: State
let size: CGFloat
let color: Color
+ let animated: Bool
@Environment(\.accessibilityReduceMotion) private var reduceMotion
+ @Environment(\.scenePhase) private var scenePhase
+ @SwiftUI.State private var visible = false
+ @SwiftUI.State private var epoch = Date.now
- public init(size: CGFloat = 16, color: Color = Palette.text) {
+ public init(state: State = .working, size: CGFloat = 16, color: Color = Palette.text, animated: Bool = true) {
+ self.state = state
self.size = size
self.color = color
+ self.animated = animated
}
public var body: some View {
- let lattice = Self.lattice(size < 20 ? 60 : 140)
- TimelineView(.animation(paused: reduceMotion)) { timeline in
- let t = reduceMotion ? 0.6 : timeline.date.timeIntervalSinceReferenceDate.truncatingRemainder(dividingBy: 3600)
- Canvas { ctx, canvas in
- let c = canvas.width / 2, r = c * 0.84
- let (sy, cy) = (sin(t * 0.9), cos(t * 0.9))
- let (st, ct) = (sin(0.35), cos(0.35))
- let dots = lattice.map { p -> (CGFloat, CGFloat, Double) in
- let x1 = p.x * cy + p.z * sy, z1 = -p.x * sy + p.z * cy
- let y1 = p.y * ct - z1 * st, z2 = p.y * st + z1 * ct
- return (c + x1 * r, c - y1 * r, z2)
- }.sorted { $0.2 < $1.2 }
- for (x, y, z) in dots {
- let depth = (z + 1) / 2
- let d = canvas.width * (0.035 + 0.075 * depth)
- ctx.fill(Path(ellipseIn: CGRect(x: x - d / 2, y: y - d / 2, width: d, height: d)),
- with: .color(color.opacity(0.12 + 0.88 * depth)))
+ let running = animated && !reduceMotion && visible && scenePhase == .active
+ Group {
+ if running {
+ TimelineView(.animation(minimumInterval: 1.0 / 30)) { timeline in
+ drawing(time: 0.6 + timeline.date.timeIntervalSince(epoch)
+ * ThinkingOrbGeometry.speed(state: state, size: size))
}
+ } else {
+ drawing(time: 0.6)
}
}
.frame(width: size, height: size)
.accessibilityHidden(true)
+ .onAppear { epoch = .now; visible = true }
+ .onDisappear { visible = false }
+ .onChange(of: running) { _, isRunning in if isRunning { epoch = .now } }
}
- /// Evenly spread directions on a unit sphere (Fibonacci lattice).
- private static func lattice(_ n: Int) -> [(x: Double, y: Double, z: Double)] {
- let golden = Double.pi * (3 - 5.0.squareRoot())
- return (0..<n).map { i in
- let y = 1 - 2 * (Double(i) + 0.5) / Double(n), rad = (1 - y * y).squareRoot(), a = Double(i) * golden
- return (rad * cos(a), y, rad * sin(a))
+ private func drawing(time: Double) -> some View {
+ let frame = ThinkingOrbGeometry.frame(state: state, size: size, time: time)
+ return Canvas { context, _ in
+ // Tintable ink: preserves depth and blends with cards, wallpaper and
+ // accessory rendering instead of baking a paper/background color in.
+ for line in frame.lines {
+ var path = Path()
+ path.move(to: CGPoint(x: line.x1, y: line.y1))
+ path.addLine(to: CGPoint(x: line.x2, y: line.y2))
+ context.stroke(path, with: .color(color.opacity(ink(line.white, line.alpha))), lineWidth: line.width)
+ }
+ for dot in frame.dots {
+ let rect = CGRect(x: dot.x - dot.radius, y: dot.y - dot.radius, width: dot.radius * 2, height: dot.radius * 2)
+ context.fill(Path(ellipseIn: rect), with: .color(color.opacity(ink(dot.white, dot.alpha))))
+ }
}
}
+
+ private func ink(_ white: Double, _ alpha: Double) -> Double {
+ (1 - min(1, max(0, white))) * alpha
+ }
}
diff --git a/kit/Sources/CodyncKit/Design/ThinkingOrbGeometry.swift b/kit/Sources/CodyncKit/Design/ThinkingOrbGeometry.swift
new file mode 100644
index 00000000..290b1eb3
--- /dev/null
+++ b/kit/Sources/CodyncKit/Design/ThinkingOrbGeometry.swift
@@ -0,0 +1,181 @@
+import Foundation
+
+// Native port of thinking-orbs 0.3.1, commit de85557 (MIT, Jakub Antalik).
+// Source: src/engine/{core,orbits,lattice,web}.ts and resolved 20/64 pt presets.
+// See Resources/ThirdPartyNotices/thinking-orbs-LICENSE.txt.
+// Keep geometry independent of SwiftUI so upstream golden vectors can verify it.
+enum ThinkingOrbGeometry {
+ struct Dot {
+ var x, y, z, radius, white: Double
+ var alpha: Double = 1
+ }
+ struct Line {
+ var x1, y1, x2, y2, white, alpha, width: Double
+ }
+ struct Frame {
+ var dots: [Dot] = []
+ var lines: [Line] = []
+ }
+ typealias Point = SIMD3<Double>
+
+ static func speed(state: ThinkingOrb.State, size: Double) -> Double {
+ let small = size < 40
+ switch state {
+ case .working: return small ? 3.9 : 1.885
+ case .searching: return small ? 2.665 : 2.015
+ case .listening: return small ? 3.998 : 4.388
+ case .connecting: return small ? 6.63 : 3.315
+ }
+ }
+
+ /// `time` is the engine time, already multiplied by the preset speed.
+ static func frame(state: ThinkingOrb.State, size: Double, time: Double) -> Frame {
+ guard size.isFinite, size > 0, time.isFinite else { return Frame() }
+ var frame: Frame
+ switch state {
+ case .working: frame = orbits(size, time)
+ case .searching: frame = lattice(size, time, listening: false)
+ case .listening: frame = lattice(size, time, listening: true)
+ case .connecting: frame = web(size, time)
+ }
+ frame.dots = frame.dots.filter { $0.alpha >= 0.02 }.map {
+ var dot = $0; dot.radius = max(0.3, dot.radius); return dot
+ }.sorted { $0.z < $1.z }
+ frame.lines = frame.lines.filter { $0.alpha >= 0.02 }
+ return frame
+ }
+
+ private static func projector(_ yaw: Double, _ tilt: Double, _ size: Double, _ scale: Double) -> (Point) -> Point {
+ let sy = sin(yaw), cy = cos(yaw), st = sin(tilt), ct = cos(tilt)
+ return { p in
+ let x = p.x * cy + p.z * sy, z = -p.x * sy + p.z * cy
+ return Point(size / 2 + x * scale, size / 2 - (p.y * ct - z * st) * scale, p.y * st + z * ct)
+ }
+ }
+ private static func hash(_ a: Double, _ b: Double) -> Double {
+ let h = sin(a * 12.9898 + b * 78.233) * 43758.5453
+ return h - floor(h)
+ }
+ private static func noise(_ x: Double, _ y: Double) -> Double {
+ let xi = floor(x), yi = floor(y)
+ let dx = x - xi, dy = y - yi
+ let fx = dx * dx * (3 - 2 * dx), fy = dy * dy * (3 - 2 * dy)
+ let a = hash(xi, yi), b = hash(xi + 1, yi), c = hash(xi, yi + 1), d = hash(xi + 1, yi + 1)
+ return a + (b - a) * fx + (c - a) * fy + (a - b - c + d) * fx * fy
+ }
+ private static func length(_ p: Point) -> Double { sqrt(p.x * p.x + p.y * p.y + p.z * p.z) }
+
+ private static func orbits(_ size: Double, _ t: Double) -> Frame {
+ let small = size < 40, radius = size / 2 * 0.82
+ let project = projector(t * 0.12, 0.3, size, 1)
+ let rs = pow(size / 300, 0.6), multiplier = small ? 2.4 : 1
+ let orbitCount = small ? 3 : 12, ghostCount = small ? 10 : 40
+ var frame = Frame()
+ for orb in 0..<orbitCount {
+ let h1 = hash(Double(orb), 1.7), h2 = hash(Double(orb), 5.2), h3 = hash(Double(orb), 8.9)
+ let ro = radius * (0.45 + 0.52 * h1), theta = h1 * 2 * .pi, phi = acos(2 * h2 - 1)
+ let normal = Point(sin(phi) * cos(theta), cos(phi), sin(phi) * sin(theta))
+ var u = Point(-normal.y, normal.x, 0)
+ u /= max(1e-6, length(u))
+ let v = Point(-normal.z * u.y, normal.z * u.x, normal.x * u.y - normal.y * u.x)
+ let speed = (0.25 + 0.55 * h3) * (h3 > 0.5 ? 1.0 : -1.0)
+ for k in 0..<ghostCount {
+ let angle = Double(k) / Double(ghostCount) * 2 * .pi
+ let p = project((u * cos(angle) + v * sin(angle)) * ro)
+ let depth = (p.z / ro + 1) / 2
+ frame.dots.append(Dot(x: p.x, y: p.y, z: p.z, radius: 0.9 * multiplier * rs,
+ white: 0.72, alpha: 0.5 * (0.4 + 0.6 * depth)))
+ }
+ for m in 0..<3 {
+ let angle = t * speed + Double(m) / 3 * 2 * .pi + h2 * 6
+ let p = project((u * cos(angle) + v * sin(angle)) * ro)
+ let depth = (p.z / ro + 1) / 2
+ frame.dots.append(Dot(x: p.x, y: p.y, z: p.z,
+ radius: (1.2 + 1.6 * depth) * multiplier * rs, white: 0.3 - 0.22 * depth))
+ }
+ }
+ return frame
+ }
+
+ private static func lattice(_ size: Double, _ t: Double, listening: Bool) -> Frame {
+ let small = size < 40, rs = pow(size / 300, 0.6)
+ let rings = listening ? (small ? 5 : 9) : (small ? 6 : 11)
+ let density = listening ? (small ? 13 : 23) : (small ? 14 : 29)
+ let multiplier = listening ? (small ? 1.6 : 1) : (small ? 1.75 : 1.15)
+ let radius = size / 2 * (listening ? 0.874 : 0.82)
+ let tilt = listening ? 0.38 : 0.4 + 0.06 * sin(t * 0.35)
+ let project = projector(t * (listening ? 0.18 : 0.5), tilt, size, listening ? 1 : radius)
+ let scan = t * (0.5 + 1.2 * (small ? 4.335 : 4.08))
+ var frame = Frame()
+ for ri in 0...rings {
+ let lat = -.pi / 2 + Double(ri) / Double(rings) * .pi
+ let cosLat = cos(lat), sinLat = sin(lat)
+ let wave = 0.62 * sin(t * 2.1 - Double(ri) * 0.52) + 0.38 * sin(t * 1.27 + Double(ri) * 0.83)
+ let rr = listening ? radius * (0.88 + 0.105 * wave) : 1
+ let lonCount = max(1, Int((abs(cosLat) * Double(density)).rounded()))
+ for j in 0..<lonCount {
+ let lon = Double(j) / Double(lonCount) * 2 * .pi
+ let p = project(Point(cosLat * cos(lon), sinLat, cosLat * sin(lon)) * rr)
+ let depth = (p.z / (listening ? radius : 1) + 1) / 2
+ if listening {
+ let crest = max(0, wave)
+ frame.dots.append(Dot(x: p.x, y: p.y, z: p.z,
+ radius: (0.6 + 1.7 * depth) * multiplier * (1 + 0.4 * crest) * rs,
+ white: 0.66 - 0.56 * depth - 0.1 * crest))
+ } else {
+ let angle = lon + t * 0.5 - scan
+ let delta = atan2(sin(angle), cos(angle))
+ let boost = exp(-(delta * delta) / 0.18) * max(0, p.z)
+ frame.dots.append(Dot(x: p.x, y: p.y, z: p.z,
+ radius: ((0.6 + 1.7 * depth) * multiplier + boost) * rs,
+ white: 0.62 - 0.54 * depth, alpha: 0.45 + 0.55 * min(1, boost)))
+ }
+ }
+ }
+ return frame
+ }
+
+ private static func web(_ size: Double, _ t: Double) -> Frame {
+ let small = size < 40, rs = pow(size / 300, 0.6)
+ let count = small ? 8 : 41, signals = small ? 1 : 7
+ let multiplier = small ? 1.52 : 0.95, threshold = 0.72
+ let project = projector(t * 0.12, 0.32, size, size / 2 * 0.8)
+ let golden = Double.pi * (3 - sqrt(5))
+ let nodes: [Point] = (0..<count).map { index in
+ let i = Double(index), y = 1 - 2 * (i + 0.5) / Double(count)
+ let r = sqrt(1 - y * y), a = i * golden
+ var p = Point(r * cos(a), y, r * sin(a))
+ p.x += 0.3 * (noise(i * 0.31 + 9, t * 0.24) - 0.5) * 2
+ p.y += 0.3 * (noise(i * 0.53 + 27, t * 0.21) - 0.5) * 2
+ p.z += 0.3 * (noise(i * 0.77 + 55, t * 0.27) - 0.5) * 2
+ return p / length(p)
+ }
+ var frame = Frame()
+ for i in 0..<count {
+ for j in (i + 1)..<count {
+ let distance = length(nodes[i] - nodes[j])
+ guard distance < threshold else { continue }
+ let a = project(nodes[i]), b = project(nodes[j]), depth = ((a.z + b.z) / 2 + 1) / 2
+ frame.lines.append(Line(x1: a.x, y1: a.y, x2: b.x, y2: b.y, white: 0.42,
+ alpha: (1 - distance / threshold) * (0.3 + 0.55 * depth), width: max(0.6, 0.8 * rs)))
+ }
+ let p = project(nodes[i]), depth = (p.z + 1) / 2
+ let pulse = 1 + 0.25 * sin(t * 1.4 + Double(i) * 2.7)
+ frame.dots.append(Dot(x: p.x, y: p.y, z: p.z,
+ radius: (1.4 + 1.8 * depth) * multiplier * pulse * rs, white: 0.55 - 0.45 * depth))
+ }
+ for s in 0..<signals {
+ let segment = floor(t * 0.55 + Double(s) * 7.31)
+ let a = Int(floor(hash(segment, Double(s) * 3.1 + 1.7) * Double(count)))
+ let b = Int(floor(hash(segment, Double(s) * 5.7 + 4.2) * Double(count)))
+ guard a != b else { continue }
+ let tick = t * 0.55 + Double(s) * 7.31, fraction = tick - floor(tick)
+ let node = nodes[a] + (nodes[b] - nodes[a]) * fraction
+ let p = project(node / max(1e-6, length(node))), depth = (p.z + 1) / 2
+ frame.dots.append(Dot(x: p.x, y: p.y, z: p.z,
+ radius: (1.4 * 1.5 + 1.8 * depth) * multiplier * rs,
+ white: 0.05, alpha: 0.5 + 0.5 * depth))
+ }
+ return frame
+ }
+}
diff --git a/kit/Sources/CodyncKit/Design/WidgetCards.swift b/kit/Sources/CodyncKit/Design/WidgetCards.swift
index c883219b..3c583ce7 100644
--- a/kit/Sources/CodyncKit/Design/WidgetCards.swift
+++ b/kit/Sources/CodyncKit/Design/WidgetCards.swift
@@ -3,7 +3,7 @@ import SwiftUI
/// Shared by the widget extension and its in-app gallery so previews use the
/// same typography, spacing and progress rendering as the installed widget.
public struct ProviderWidgetCard: View {
- public enum Layout { case small, medium }
+ public enum Layout { case small, medium, large }
let provider: UsageProvider
let layout: Layout
let date: Date
@@ -23,7 +23,7 @@ public struct ProviderWidgetCard: View {
.foregroundStyle(Palette.text)
.lineLimit(1)
Spacer(minLength: 0)
- if layout == .medium {
+ if layout != .small {
Text("Usage")
.font(.system(size: 10, weight: .medium))
.foregroundStyle(Palette.secondary)
@@ -47,7 +47,17 @@ public struct ProviderWidgetCard: View {
.font(.system(size: 9)).foregroundStyle(Palette.secondary)
.lineLimit(1)
} else {
- ForEach(provider.windows.prefix(2)) { window in
+ if layout == .large, let top = provider.tightest {
+ HStack(alignment: .firstTextBaseline, spacing: 8) {
+ Text("\(Int(top.percent.rounded()))%")
+ .font(.system(size: 36, weight: .semibold, design: .rounded)).monospacedDigit()
+ .foregroundStyle(top.percent >= 90 ? Palette.danger : Palette.text)
+ Text("\(top.title) · highest usage").font(.system(size: 11)).foregroundStyle(Palette.secondary)
+ .lineLimit(2)
+ }
+ .padding(.vertical, 4)
+ }
+ ForEach(provider.windows.prefix(layout == .large ? 4 : 2)) { window in
VStack(alignment: .leading, spacing: 3) {
HStack(alignment: .firstTextBaseline) {
Text(window.title)
@@ -66,6 +76,7 @@ public struct ProviderWidgetCard: View {
.lineLimit(1).frame(maxWidth: .infinity, alignment: .trailing)
}
}
+ .padding(.bottom, layout == .large ? 2 : 0)
}
}
}
@@ -76,7 +87,7 @@ public struct ProviderWidgetCard: View {
}
private var accessibleUsage: String {
- let windows = layout == .small ? provider.tightest.map { [$0] } ?? [] : Array(provider.windows.prefix(2))
+ let windows = layout == .small ? provider.tightest.map { [$0] } ?? [] : Array(provider.windows.prefix(layout == .large ? 4 : 2))
return windows.map { window in
"\(window.title), \(Int(window.percent.rounded())) percent" +
(window.resetsShort(now: date).map { ", \($0)" } ?? "")
@@ -135,11 +146,13 @@ public extension Usage {
public struct BotsWidgetCard: View {
let bots: [Bot]
let wide: Bool
+ let large: Bool
let links: [String: URL]
- public init(bots: [Bot], wide: Bool, links: [String: URL] = [:]) {
+ public init(bots: [Bot], wide: Bool, large: Bool = false, links: [String: URL] = [:]) {
self.bots = bots.filter { !$0.hidden }
self.wide = wide
+ self.large = large
self.links = links
}
@@ -163,22 +176,21 @@ public struct BotsWidgetCard: View {
Image(systemName: "bubble.left.and.bubble.right")
.font(.system(size: 12)).foregroundStyle(Palette.secondary)
}
- if wide {
+ if large {
+ HStack {
+ summary
+ Spacer()
+ Text("\(bots.count) total · \(working) working")
+ .font(.system(size: 11)).foregroundStyle(Palette.secondary)
+ }
+ Divider()
+ botRows(limit: 6)
+ Spacer(minLength: 0)
+ } else if wide {
HStack(alignment: .center, spacing: 16) {
summary.frame(width: 76, alignment: .leading)
Rectangle().fill(Palette.border).frame(width: 1)
- VStack(alignment: .leading, spacing: 8) {
- ForEach(ordered.prefix(3)) { bot in
- if let link = links[bot.id] {
- Link(destination: link) { row(bot) }
- } else { row(bot) }
- }
- if bots.isEmpty {
- Text("Create your first bot in Codync.")
- .font(.system(size: 12)).foregroundStyle(Palette.secondary)
- }
- }
- .frame(maxWidth: .infinity, alignment: .leading)
+ botRows(limit: 3)
}
} else {
Spacer(minLength: 0)
@@ -198,6 +210,21 @@ public struct BotsWidgetCard: View {
.frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .topLeading)
}
+ private func botRows(limit: Int) -> some View {
+ VStack(alignment: .leading, spacing: 8) {
+ ForEach(ordered.prefix(limit)) { bot in
+ if let link = links[bot.id] {
+ Link(destination: link) { row(bot) }
+ } else { row(bot) }
+ }
+ if bots.isEmpty {
+ Text("Create your first bot in Codync.")
+ .font(.system(size: 12)).foregroundStyle(Palette.secondary)
+ }
+ }
+ .frame(maxWidth: .infinity, alignment: .leading)
+ }
+
private var summary: some View {
VStack(alignment: .leading, spacing: 1) {
Text("\(count)").font(.system(size: 36, weight: .semibold, design: .rounded))
diff --git a/kit/Sources/CodyncKit/Models/BotActivityPresentation.swift b/kit/Sources/CodyncKit/Models/BotActivityPresentation.swift
new file mode 100644
index 00000000..9a11e450
--- /dev/null
+++ b/kit/Sources/CodyncKit/Models/BotActivityPresentation.swift
@@ -0,0 +1,59 @@
+import Foundation
+
+/// Presentation only; the ActivityKit payload and host push contract stay unchanged.
+public struct BotActivityPresentation: Hashable, Sendable {
+ public enum Phase: String, CaseIterable, Sendable {
+ case working, needsInput, completed, failed, stale, waiting
+ }
+
+ public let phase: Phase
+ public let activity: String
+ public let startedAt: Date?
+
+ public init(status: String, activity: String, startedAt: Date?, isStale: Bool = false) {
+ let phase: Phase = switch status {
+ case "working": .working
+ case "needsInput": .needsInput
+ case "idle", "completed": .completed
+ case "error": .failed
+ default: .waiting
+ }
+ self.phase = isStale && (phase == .working || phase == .needsInput) ? .stale : phase
+ self.activity = activity
+ self.startedAt = startedAt
+ }
+
+ public var title: String {
+ switch phase {
+ case .working: "Working"
+ case .needsInput: "Needs you"
+ case .completed: "Done"
+ case .failed: "Stopped"
+ case .stale: "Update delayed"
+ case .waiting: "Waiting for update"
+ }
+ }
+
+ public var detail: String {
+ switch phase {
+ case .stale: "Open Codync to check the latest status."
+ case .waiting: "Open Codync to check this task."
+ case .completed: "Your bot has finished. Open the conversation for the result."
+ case .failed: "The task stopped with an error. Open the conversation for details."
+ case .needsInput: activity.isEmpty ? "Open the conversation to respond." : activity
+ case .working: activity.isEmpty ? "Your bot is working on the computer." : activity
+ }
+ }
+
+ public var symbol: String {
+ switch phase {
+ case .working: "ellipsis"
+ case .needsInput: "hand.raised.fill"
+ case .completed: "checkmark"
+ case .failed: "exclamationmark.triangle.fill"
+ case .stale, .waiting: "clock.badge.questionmark"
+ }
+ }
+
+ public var showsTimer: Bool { phase == .working && startedAt != nil }
+}
diff --git a/kit/Sources/CodyncKit/Resources/ThirdPartyNotices/thinking-orbs-LICENSE.txt b/kit/Sources/CodyncKit/Resources/ThirdPartyNotices/thinking-orbs-LICENSE.txt
new file mode 100644
index 00000000..0e9405a2
--- /dev/null
+++ b/kit/Sources/CodyncKit/Resources/ThirdPartyNotices/thinking-orbs-LICENSE.txt
@@ -0,0 +1,21 @@
+MIT License
+
+Copyright (c) 2026 Jakub Antalik
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
diff --git a/kit/Sources/CodyncUI/Bots/BotEditorView.swift b/kit/Sources/CodyncUI/Bots/BotEditorView.swift
index de15b5c7..95e8790c 100644
--- a/kit/Sources/CodyncUI/Bots/BotEditorView.swift
+++ b/kit/Sources/CodyncUI/Bots/BotEditorView.swift
@@ -190,8 +190,7 @@ struct BotSettingsForm: View {
Text("Get notified when this bot finishes or needs you").font(InterfaceMetrics.secondary).foregroundStyle(Palette.secondary)
}
}
- .toggleStyle(.switch)
- .tint(Palette.switchOn)
+ .toggleStyle(.codync)
if model.screen != nil {
Toggle(isOn: Binding(get: { draft.computer ?? false }, set: { draft.computer = $0 })) {
VStack(alignment: .leading, spacing: 3) {
@@ -202,8 +201,7 @@ struct BotSettingsForm: View {
.font(InterfaceMetrics.secondary).foregroundStyle(Palette.secondary)
}
}
- .toggleStyle(.switch)
- .tint(Palette.switchOn)
+ .toggleStyle(.codync)
}
}
.padding(.horizontal, InterfaceMetrics.value(mac: 12, mobile: 18))
@@ -328,8 +326,7 @@ private struct PluginToggles: View {
}
}
}
- .toggleStyle(.switch)
- .tint(Palette.switchOn)
+ .toggleStyle(.codync)
}
}
.padding(InterfaceMetrics.value(mac: 12, mobile: 18))
@@ -339,20 +336,15 @@ private struct PluginToggles: View {
}
}
-/// A value shown in an outlined pill with a chevron; tapping opens the choices.
+/// A value shown in a pill with a chevron; tapping opens our own list of choices.
private struct PillMenu: View {
let title: String
@Binding var selection: String
let options: [(id: String, label: String)]
+ @State private var open = false
var body: some View {
- Menu {
- Picker(title, selection: $selection) {
- ForEach(options, id: \.id) { Text($0.label).tag($0.id) }
- }
- .pickerStyle(.inline)
- .labelsHidden()
- } label: {
+ Button { open.toggle() } label: {
HStack(spacing: 6) {
Text(title).lineLimit(1)
Image(systemName: "chevron.down").font(.caption2.weight(.semibold)).foregroundStyle(Palette.secondary)
@@ -360,28 +352,67 @@ private struct PillMenu: View {
.foregroundStyle(Palette.text)
.pill()
}
- .menuIndicator(.hidden)
.buttonStyle(.plain)
.fixedSize()
+ .popover(isPresented: $open, arrowEdge: .bottom) {
+ VStack(alignment: .leading, spacing: 2) {
+ ForEach(options, id: \.id) { option in
+ ChoiceRow(label: option.label, selected: option.id == selection) {
+ selection = option.id
+ open = false
+ }
+ }
+ }
+ .padding(6)
+ .frame(minWidth: 200)
+ .fixedSize()
+ .presentationCompactAdaptation(.popover)
+ .presentationBackground(Palette.bubbleAgent)
+ }
+ }
+}
+
+private struct ChoiceRow: View {
+ let label: String
+ let selected: Bool
+ let action: () -> Void
+ @State private var hovering = false
+
+ var body: some View {
+ Button(action: action) {
+ HStack(spacing: 10) {
+ Text(label).foregroundStyle(Palette.text).lineLimit(1)
+ Spacer(minLength: 16)
+ Image(systemName: "checkmark")
+ .font(.caption.weight(.semibold))
+ .foregroundStyle(Palette.text)
+ .opacity(selected ? 1 : 0)
+ }
+ .padding(.horizontal, 10)
+ .padding(.vertical, InterfaceMetrics.value(mac: 6, mobile: 10))
+ .background(hovering ? Palette.text.opacity(0.06) : .clear, in: RoundedRectangle(cornerRadius: 8, style: .continuous))
+ .contentShape(Rectangle())
+ }
+ .buttonStyle(.plain)
+ .onHover { h in withAnimation(Motion.hover) { hovering = h } }
+ .accessibilityAddTraits(selected ? .isSelected : [])
}
}
extension View {
- /// The outlined value pill used in the options card.
+ /// The value pill used in the options card.
func pill() -> some View {
padding(.horizontal, InterfaceMetrics.value(mac: 9, mobile: 12))
.padding(.vertical, InterfaceMetrics.value(mac: 5, mobile: 7))
.background(Palette.background, in: RoundedRectangle(cornerRadius: 10, style: .continuous))
- .overlay(RoundedRectangle(cornerRadius: 10, style: .continuous).stroke(Palette.border))
}
- /// A bordered, rounded input box.
+ /// A rounded input box.
func fieldBox() -> some View {
textFieldStyle(.plain)
.padding(.horizontal, InterfaceMetrics.value(mac: 10, mobile: 14))
.padding(.vertical, InterfaceMetrics.value(mac: 8, mobile: 11))
.background(Palette.background, in: RoundedRectangle(cornerRadius: 12, style: .continuous))
- .overlay(RoundedRectangle(cornerRadius: 12, style: .continuous).stroke(Palette.border))
}
}
@@ -496,6 +527,8 @@ struct FolderPicker: View {
ProgressView()
}
}
+ .scrollContentBackground(.hidden)
+ .background(Palette.background)
.searchable(text: $filter)
.navigationTitle(listing.map { ($0.path as NSString).lastPathComponent } ?? "Folders")
.inlineNavigationTitle()
diff --git a/kit/Sources/CodyncUI/Bots/BotRow.swift b/kit/Sources/CodyncUI/Bots/BotRow.swift
index b0e8f3d5..1c9d1271 100644
--- a/kit/Sources/CodyncUI/Bots/BotRow.swift
+++ b/kit/Sources/CodyncUI/Bots/BotRow.swift
@@ -74,7 +74,11 @@ public struct BotRow: View {
/// Live activity while working, otherwise the last message (Grok Bot row behavior).
@ViewBuilder private var preview: some View {
if bot.needsInput {
- Label(bot.activity.isEmpty ? "Needs your approval" : bot.activity, systemImage: "hand.raised.fill")
+ Label {
+ Text(bot.activity.isEmpty ? "Needs your approval" : bot.activity)
+ } icon: {
+ ThinkingOrb(state: .listening, size: 16, color: Palette.warning)
+ }
.font(InterfaceMetrics.secondary)
.foregroundStyle(Palette.warning)
.lineLimit(1)
@@ -110,7 +114,11 @@ public struct ConnectionBanner: View {
case .online, .unpaired:
EmptyView()
case .connecting:
- Label("Connecting to \(model.hostName)…", systemImage: "antenna.radiowaves.left.and.right")
+ Label {
+ Text("Connecting to \(model.hostName)…")
+ } icon: {
+ ThinkingOrb(state: .connecting, size: 18, color: Palette.secondary)
+ }
.font(.footnote)
.foregroundStyle(Palette.secondary)
case let .offline(reason):
diff --git a/kit/Sources/CodyncUI/Marketplace/MarketplaceView.swift b/kit/Sources/CodyncUI/Marketplace/MarketplaceView.swift
index 50316728..c83ba058 100644
--- a/kit/Sources/CodyncUI/Marketplace/MarketplaceView.swift
+++ b/kit/Sources/CodyncUI/Marketplace/MarketplaceView.swift
@@ -502,7 +502,7 @@ private struct AgentSheet: View {
HStack(spacing: 0) {
SetupStepRow(number: curated ? 2 : 1, title: "Sign in", detail: statusText, done: signedIn == true, action: nil)
if checking {
- ThinkingOrb(size: 16, color: Palette.secondary)
+ ThinkingOrb(state: .connecting, size: 16, color: Palette.secondary)
} else {
Button("Check again", systemImage: "arrow.clockwise") { Task { await check() } }
.labelStyle(.iconOnly)
diff --git a/kit/Sources/CodyncUI/Thread/ChatRows.swift b/kit/Sources/CodyncUI/Thread/ChatRows.swift
index 9dfd3b25..a2e550c2 100644
--- a/kit/Sources/CodyncUI/Thread/ChatRows.swift
+++ b/kit/Sources/CodyncUI/Thread/ChatRows.swift
@@ -128,7 +128,7 @@ struct WorkingIndicator: View {
HStack(alignment: .center, spacing: 10) {
Button(action: openTrace) {
HStack(spacing: 8) {
- ThinkingOrb(size: 16, color: bot.needsInput ? Palette.warning : Palette.secondary)
+ ThinkingOrb(state: bot.needsInput ? .listening : .working, size: 16, color: bot.needsInput ? Palette.warning : Palette.secondary)
Text(bot.activity.isEmpty ? "Working…" : bot.activity)
.font(.subheadline)
.foregroundStyle(bot.needsInput ? Palette.warning : Palette.secondary)
diff --git a/kit/Sources/CodyncUI/Thread/TraceView.swift b/kit/Sources/CodyncUI/Thread/TraceView.swift
index 7770abc2..3e3c65c8 100644
--- a/kit/Sources/CodyncUI/Thread/TraceView.swift
+++ b/kit/Sources/CodyncUI/Thread/TraceView.swift
@@ -59,7 +59,9 @@ private struct TraceRow: View {
DisclosureGroup {
Text(d.text ?? "").font(.footnote).foregroundStyle(Palette.secondary).textSelection(.enabled)
} label: {
- Label("Thinking", systemImage: "brain").font(.subheadline).foregroundStyle(Palette.secondary)
+ Label { Text("Thinking") } icon: {
+ ThinkingOrb(size: 16, color: Palette.secondary, animated: false)
+ }.font(.subheadline).foregroundStyle(Palette.secondary)
}
case "tool":
ToolRow(data: d)
@@ -128,7 +130,7 @@ struct ToolRow: View {
switch data.status {
case "completed": Image(systemName: "checkmark").foregroundStyle(Palette.accent)
case "failed": Image(systemName: "xmark").foregroundStyle(Palette.danger)
- default: ThinkingOrb(size: 12, color: Palette.secondary)
+ default: ThinkingOrb(state: data.toolKind == "search" ? .searching : data.toolKind == "fetch" ? .connecting : .working, size: 16, color: Palette.secondary)
}
}
.font(.caption)
diff --git a/kit/Tests/CodyncKitTests/ActivityPresentationTests.swift b/kit/Tests/CodyncKitTests/ActivityPresentationTests.swift
new file mode 100644
index 00000000..278f3e26
--- /dev/null
+++ b/kit/Tests/CodyncKitTests/ActivityPresentationTests.swift
@@ -0,0 +1,34 @@
+import Foundation
+import Testing
+@testable import CodyncKit
+
+@Test func activityErrorAndUnknownStatusNeverLookCompleted() {
+ let error = BotActivityPresentation(status: "error", activity: "", startedAt: .now)
+ #expect(error.phase == .failed)
+ #expect(error.symbol != "checkmark")
+ #expect(!error.showsTimer)
+ let unknown = BotActivityPresentation(status: "new-host-status", activity: "", startedAt: .now)
+ #expect(unknown.phase == .waiting)
+ #expect(unknown.symbol != "checkmark")
+}
+
+@Test func staleActivityStopsPresentingLiveProgress() {
+ for status in ["working", "needsInput"] {
+ let stale = BotActivityPresentation(status: status, activity: "Old step", startedAt: .now, isStale: true)
+ #expect(stale.phase == .stale)
+ #expect(!stale.showsTimer)
+ #expect(!stale.detail.contains("Old step"))
+ }
+ let done = BotActivityPresentation(status: "idle", activity: "Old step", startedAt: .now, isStale: true)
+ #expect(done.phase == .completed)
+ #expect(!done.showsTimer)
+ #expect(done.symbol == "checkmark")
+}
+
+@Test func activityTimerOnlyRunsDuringWork() {
+ #expect(BotActivityPresentation(status: "working", activity: "", startedAt: .now).showsTimer)
+ #expect(!BotActivityPresentation(status: "working", activity: "", startedAt: nil).showsTimer)
+ let input = BotActivityPresentation(status: "needsInput", activity: "Choose a branch", startedAt: .now)
+ #expect(input.detail == "Choose a branch")
+ #expect(!input.showsTimer)
+}
diff --git a/kit/Tests/CodyncKitTests/Fixtures/thinking-orbs-golden.json b/kit/Tests/CodyncKitTests/Fixtures/thinking-orbs-golden.json
new file mode 100644
index 00000000..dfa1758b
--- /dev/null
+++ b/kit/Tests/CodyncKitTests/Fixtures/thinking-orbs-golden.json
@@ -0,0 +1,1962 @@
+{
+ "source": "Jakubantalik/thinking-orbs de85557ca220332586d070d8788c0e1d6e877a0d/spec/orbs-golden.json (MIT; bundled license in CodyncKit Resources)",
+ "tolerance": 0.0001,
+ "cases": [
+ {
+ "key": "working-64-0.6",
+ "state": "working",
+ "size": 64,
+ "t": 0.6,
+ "dotCount": 516,
+ "lineCount": 0,
+ "dots": [
+ {
+ "index": 0,
+ "values": [
+ 32.34438,
+ 30.683937,
+ -24.13443,
+ 0.356187,
+ 0.72,
+ 0.200238
+ ]
+ },
+ {
+ "index": 172,
+ "values": [
+ 40.253686,
+ 49.524356,
+ -6.044044,
+ 0.356187,
+ 0.72,
+ 0.305322
+ ]
+ },
+ {
+ "index": 344,
+ "values": [
+ 45.55453,
+ 24.455599,
+ 6.439183,
+ 0.912907,
+ 0.147829,
+ 1
+ ]
+ },
+ {
+ "index": 515,
+ "values": [
+ 31.65562,
+ 33.316063,
+ 24.13443,
+ 0.356187,
+ 0.72,
+ 0.499762
+ ]
+ }
+ ],
+ "lines": []
+ },
+ {
+ "key": "working-64-1.7",
+ "state": "working",
+ "size": 64,
+ "t": 1.7,
+ "dotCount": 516,
+ "lineCount": 0,
+ "dots": [
+ {
+ "index": 0,
+ "values": [
+ 32.914704,
+ 31.715425,
+ -24.153751,
+ 0.356187,
+ 0.72,
+ 0.200118
+ ]
+ },
+ {
+ "index": 172,
+ "values": [
+ 38.446903,
+ 40.436581,
+ -6.023194,
+ 0.356187,
+ 0.72,
+ 0.275988
+ ]
+ },
+ {
+ "index": 344,
+ "values": [
+ 46.929945,
+ 27.427076,
+ 6.18801,
+ 0.356187,
+ 0.72,
+ 0.405263
+ ]
+ },
+ {
+ "index": 515,
+ "values": [
+ 31.085296,
+ 32.284575,
+ 24.153751,
+ 0.356187,
+ 0.72,
+ 0.499882
+ ]
+ }
+ ],
+ "lines": []
+ },
+ {
+ "key": "working-64-3.3",
+ "state": "working",
+ "size": 64,
+ "t": 3.3,
+ "dotCount": 516,
+ "lineCount": 0,
+ "dots": [
+ {
+ "index": 0,
+ "values": [
+ 32.181607,
+ 32.572354,
+ -24.16528,
+ 0.356187,
+ 0.72,
+ 0.200046
+ ]
+ },
+ {
+ "index": 172,
+ "values": [
+ 30.407455,
+ 12.539821,
+ -5.524681,
+ 0.356187,
+ 0.72,
+ 0.309161
+ ]
+ },
+ {
+ "index": 344,
+ "values": [
+ 47.093024,
+ 36.670402,
+ 5.700378,
+ 0.356187,
+ 0.72,
+ 0.400908
+ ]
+ },
+ {
+ "index": 515,
+ "values": [
+ 31.818393,
+ 31.427646,
+ 24.16528,
+ 0.356187,
+ 0.72,
+ 0.499954
+ ]
+ }
+ ],
+ "lines": []
+ },
+ {
+ "key": "working-64-5.1",
+ "state": "working",
+ "size": 64,
+ "t": 5.1,
+ "dotCount": 516,
+ "lineCount": 0,
+ "dots": [
+ {
+ "index": 0,
+ "values": [
+ 30.997376,
+ 33.248813,
+ -24.11963,
+ 0.356187,
+ 0.72,
+ 0.20033
+ ]
+ },
+ {
+ "index": 172,
+ "values": [
+ 46.654388,
+ 15.857363,
+ -5.773295,
+ 0.356187,
+ 0.72,
+ 0.311603
+ ]
+ },
+ {
+ "index": 344,
+ "values": [
+ 26.061969,
+ 14.959722,
+ 5.881549,
+ 0.356187,
+ 0.72,
+ 0.396483
+ ]
+ },
+ {
+ "index": 515,
+ "values": [
+ 33.002624,
+ 30.751187,
+ 24.11963,
+ 0.356187,
+ 0.72,
+ 0.49967
+ ]
+ }
+ ],
+ "lines": []
+ },
+ {
+ "key": "working-20-0.6",
+ "state": "working",
+ "size": 20,
+ "t": 0.6,
+ "dotCount": 39,
+ "lineCount": 0,
+ "dots": [
+ {
+ "index": 0,
+ "values": [
+ 11.235898,
+ 9.940794,
+ -7.451958,
+ 0.425401,
+ 0.72,
+ 0.202026
+ ]
+ },
+ {
+ "index": 13,
+ "values": [
+ 11.842255,
+ 11.567718,
+ -2.949718,
+ 0.425401,
+ 0.72,
+ 0.234015
+ ]
+ },
+ {
+ "index": 26,
+ "values": [
+ 8.157745,
+ 8.432282,
+ 2.949718,
+ 0.425401,
+ 0.72,
+ 0.465985
+ ]
+ },
+ {
+ "index": 38,
+ "values": [
+ 9.230714,
+ 10.206142,
+ 7.51188,
+ 1.321364,
+ 0.080613,
+ 1
+ ]
+ }
+ ],
+ "lines": []
+ },
+ {
+ "key": "working-20-1.7",
+ "state": "working",
+ "size": 20,
+ "t": 1.7,
+ "dotCount": 39,
+ "lineCount": 0,
+ "dots": [
+ {
+ "index": 0,
+ "values": [
+ 10.285845,
+ 9.91107,
+ -7.548047,
+ 0.425401,
+ 0.72,
+ 0.200118
+ ]
+ },
+ {
+ "index": 13,
+ "values": [
+ 3.157842,
+ 8.095235,
+ -2.572815,
+ 0.425401,
+ 0.72,
+ 0.298911
+ ]
+ },
+ {
+ "index": 26,
+ "values": [
+ 6.040948,
+ 4.010472,
+ 2.71011,
+ 0.425401,
+ 0.72,
+ 0.402972
+ ]
+ },
+ {
+ "index": 38,
+ "values": [
+ 9.714155,
+ 10.08893,
+ 7.548047,
+ 0.425401,
+ 0.72,
+ 0.499882
+ ]
+ }
+ ],
+ "lines": []
+ },
+ {
+ "key": "working-20-3.3",
+ "state": "working",
+ "size": 20,
+ "t": 3.3,
+ "dotCount": 39,
+ "lineCount": 0,
+ "dots": [
+ {
+ "index": 0,
+ "values": [
+ 9.799297,
+ 10.124795,
+ -7.550283,
+ 0.567387,
+ 0.299946,
+ 1
+ ]
+ },
+ {
+ "index": 13,
+ "values": [
+ 14.02176,
+ 15.781704,
+ -3.048046,
+ 0.795149,
+ 0.23369,
+ 1
+ ]
+ },
+ {
+ "index": 26,
+ "values": [
+ 3.387236,
+ 8.538116,
+ 3.346173,
+ 0.425401,
+ 0.72,
+ 0.416445
+ ]
+ },
+ {
+ "index": 38,
+ "values": [
+ 11.100429,
+ 10.065749,
+ 7.473109,
+ 0.425401,
+ 0.72,
+ 0.498394
+ ]
+ }
+ ],
+ "lines": []
+ },
+ {
+ "key": "working-20-5.1",
+ "state": "working",
+ "size": 20,
+ "t": 5.1,
+ "dotCount": 39,
+ "lineCount": 0,
+ "dots": [
+ {
+ "index": 0,
+ "values": [
+ 12.013185,
+ 10.689198,
+ -7.248084,
+ 0.425401,
+ 0.72,
+ 0.206074
+ ]
+ },
+ {
+ "index": 13,
+ "values": [
+ 7.776857,
+ 7.937206,
+ -2.314085,
+ 0.425401,
+ 0.72,
+ 0.259008
+ ]
+ },
+ {
+ "index": 26,
+ "values": [
+ 11.79197,
+ 11.336131,
+ 3.091289,
+ 1.251757,
+ 0.100862,
+ 1
+ ]
+ },
+ {
+ "index": 38,
+ "values": [
+ 7.986815,
+ 9.310802,
+ 7.248084,
+ 0.425401,
+ 0.72,
+ 0.493926
+ ]
+ }
+ ],
+ "lines": []
+ },
+ {
+ "key": "searching-64-0.6",
+ "state": "searching",
+ "size": 64,
+ "t": 0.6,
+ "dotCount": 204,
+ "lineCount": 0,
+ "dots": [
+ {
+ "index": 0,
+ "values": [
+ 33.490622,
+ 32.435651,
+ -0.998247,
+ 0.3,
+ 0.619527,
+ 0.45
+ ]
+ },
+ {
+ "index": 68,
+ "values": [
+ 56.812873,
+ 32.343922,
+ -0.325031,
+ 0.534194,
+ 0.437758,
+ 0.45
+ ]
+ },
+ {
+ "index": 136,
+ "values": [
+ 50.758478,
+ 47.903252,
+ 0.348748,
+ 0.794851,
+ 0.255838,
+ 0.45
+ ]
+ },
+ {
+ "index": 203,
+ "values": [
+ 30.509378,
+ 31.564349,
+ 0.998247,
+ 1.047571,
+ 0.080473,
+ 0.452023
+ ]
+ }
+ ],
+ "lines": []
+ },
+ {
+ "key": "searching-64-1.7",
+ "state": "searching",
+ "size": 64,
+ "t": 1.7,
+ "dotCount": 204,
+ "lineCount": 0,
+ "dots": [
+ {
+ "index": 0,
+ "values": [
+ 31.900072,
+ 31.862813,
+ -0.999979,
+ 0.3,
+ 0.619994,
+ 0.45
+ ]
+ },
+ {
+ "index": 68,
+ "values": [
+ 17.843177,
+ 52.41622,
+ -0.321796,
+ 0.535445,
+ 0.436885,
+ 0.45
+ ]
+ },
+ {
+ "index": 136,
+ "values": [
+ 7.252051,
+ 31.923194,
+ 0.332388,
+ 0.788522,
+ 0.260255,
+ 0.45
+ ]
+ },
+ {
+ "index": 203,
+ "values": [
+ 32.099928,
+ 32.137187,
+ 0.999979,
+ 1.226772,
+ 0.080006,
+ 0.700132
+ ]
+ }
+ ],
+ "lines": []
+ },
+ {
+ "key": "searching-64-3.3",
+ "state": "searching",
+ "size": 64,
+ "t": 3.3,
+ "dotCount": 204,
+ "lineCount": 0,
+ "dots": [
+ {
+ "index": 0,
+ "values": [
+ 30.111484,
+ 31.337894,
+ -0.997088,
+ 0.3,
+ 0.619214,
+ 0.45
+ ]
+ },
+ {
+ "index": 68,
+ "values": [
+ 50.509209,
+ 15.586491,
+ -0.333419,
+ 0.530949,
+ 0.440023,
+ 0.45
+ ]
+ },
+ {
+ "index": 136,
+ "values": [
+ 13.490791,
+ 48.413509,
+ 0.333419,
+ 0.818672,
+ 0.259977,
+ 0.491346
+ ]
+ },
+ {
+ "index": 203,
+ "values": [
+ 33.888516,
+ 32.662106,
+ 0.997088,
+ 1.174524,
+ 0.080786,
+ 0.629076
+ ]
+ }
+ ],
+ "lines": []
+ },
+ {
+ "key": "searching-64-5.1",
+ "state": "searching",
+ "size": 64,
+ "t": 5.1,
+ "dotCount": 204,
+ "lineCount": 0,
+ "dots": [
+ {
+ "index": 0,
+ "values": [
+ 31.700222,
+ 31.207725,
+ -0.999479,
+ 0.3,
+ 0.619859,
+ 0.45
+ ]
+ },
+ {
+ "index": 68,
+ "values": [
+ 12.173255,
+ 47.228769,
+ -0.303738,
+ 0.542431,
+ 0.432009,
+ 0.45
+ ]
+ },
+ {
+ "index": 136,
+ "values": [
+ 23.395815,
+ 55.317886,
+ 0.320625,
+ 0.783971,
+ 0.263431,
+ 0.45
+ ]
+ },
+ {
+ "index": 203,
+ "values": [
+ 32.299778,
+ 32.792275,
+ 0.999479,
+ 1.046592,
+ 0.080141,
+ 0.45
+ ]
+ }
+ ],
+ "lines": []
+ },
+ {
+ "key": "searching-20-0.6",
+ "state": "searching",
+ "size": 20,
+ "t": 0.6,
+ "dotCount": 54,
+ "lineCount": 0,
+ "dots": [
+ {
+ "index": 0,
+ "values": [
+ 11.574668,
+ 10.979949,
+ -0.974085,
+ 0.3,
+ 0.613003,
+ 0.45
+ ]
+ },
+ {
+ "index": 18,
+ "values": [
+ 3.075376,
+ 13.124789,
+ -0.376379,
+ 0.389486,
+ 0.451622,
+ 0.45
+ ]
+ },
+ {
+ "index": 36,
+ "values": [
+ 16.924624,
+ 6.875211,
+ 0.376379,
+ 0.610011,
+ 0.248378,
+ 0.45
+ ]
+ },
+ {
+ "index": 53,
+ "values": [
+ 8.425332,
+ 9.020051,
+ 0.974085,
+ 0.785661,
+ 0.086997,
+ 0.451532
+ ]
+ }
+ ],
+ "lines": []
+ },
+ {
+ "key": "searching-20-1.7",
+ "state": "searching",
+ "size": 20,
+ "t": 1.7,
+ "dotCount": 54,
+ "lineCount": 0,
+ "dots": [
+ {
+ "index": 0,
+ "values": [
+ 11.391322,
+ 10.794572,
+ -0.980725,
+ 0.3,
+ 0.614796,
+ 0.45
+ ]
+ },
+ {
+ "index": 18,
+ "values": [
+ 17.548859,
+ 8.654496,
+ -0.35438,
+ 0.395931,
+ 0.445683,
+ 0.45
+ ]
+ },
+ {
+ "index": 36,
+ "values": [
+ 5.31319,
+ 15.962189,
+ 0.380326,
+ 0.622622,
+ 0.247312,
+ 0.48199
+ ]
+ },
+ {
+ "index": 53,
+ "values": [
+ 8.608678,
+ 9.205428,
+ 0.980725,
+ 0.976657,
+ 0.085204,
+ 0.979487
+ ]
+ }
+ ],
+ "lines": []
+ },
+ {
+ "key": "searching-20-3.3",
+ "state": "searching",
+ "size": 20,
+ "t": 3.3,
+ "dotCount": 54,
+ "lineCount": 0,
+ "dots": [
+ {
+ "index": 0,
+ "values": [
+ 9.43813,
+ 10.572769,
+ -0.995201,
+ 0.3,
+ 0.618704,
+ 0.45
+ ]
+ },
+ {
+ "index": 18,
+ "values": [
+ 17.079146,
+ 13.436209,
+ -0.281234,
+ 0.417359,
+ 0.425933,
+ 0.45
+ ]
+ },
+ {
+ "index": 36,
+ "values": [
+ 14.026166,
+ 16.253242,
+ 0.421164,
+ 0.623131,
+ 0.236286,
+ 0.45
+ ]
+ },
+ {
+ "index": 53,
+ "values": [
+ 10.56187,
+ 9.427231,
+ 0.995201,
+ 0.7913,
+ 0.081296,
+ 0.450004
+ ]
+ }
+ ],
+ "lines": []
+ },
+ {
+ "key": "searching-20-5.1",
+ "state": "searching",
+ "size": 20,
+ "t": 5.1,
+ "dotCount": 54,
+ "lineCount": 0,
+ "dots": [
+ {
+ "index": 0,
+ "values": [
+ 10.48248,
+ 10.539644,
+ -0.996096,
+ 0.3,
+ 0.618946,
+ 0.45
+ ]
+ },
+ {
+ "index": 18,
+ "values": [
+ 2.915001,
+ 13.462705,
+ -0.274118,
+ 0.419444,
+ 0.424012,
+ 0.45
+ ]
+ },
+ {
+ "index": 36,
+ "values": [
+ 6.03966,
+ 16.285936,
+ 0.423203,
+ 0.623728,
+ 0.235735,
+ 0.45
+ ]
+ },
+ {
+ "index": 53,
+ "values": [
+ 9.51752,
+ 9.460356,
+ 0.996096,
+ 0.79156,
+ 0.081054,
+ 0.45
+ ]
+ }
+ ],
+ "lines": []
+ },
+ {
+ "key": "listening-64-0.6",
+ "state": "listening",
+ "size": 64,
+ "t": 0.6,
+ "dotCount": 134,
+ "lineCount": 0,
+ "dots": [
+ {
+ "index": 0,
+ "values": [
+ 29.764214,
+ 35.472327,
+ -23.59208,
+ 0.3,
+ 0.616191,
+ 1
+ ]
+ },
+ {
+ "index": 44,
+ "values": [
+ 11.697203,
+ 41.546238,
+ -8.384974,
+ 0.473002,
+ 0.463946,
+ 1
+ ]
+ },
+ {
+ "index": 89,
+ "values": [
+ 40.561925,
+ 9.682025,
+ 7.914476,
+ 0.720838,
+ 0.281414,
+ 1
+ ]
+ },
+ {
+ "index": 133,
+ "values": [
+ 34.080924,
+ 28.768185,
+ 21.957968,
+ 0.837966,
+ 0.160169,
+ 1
+ ]
+ }
+ ],
+ "lines": []
+ },
+ {
+ "key": "listening-64-1.7",
+ "state": "listening",
+ "size": 64,
+ "t": 1.7,
+ "dotCount": 134,
+ "lineCount": 0,
+ "dots": [
+ {
+ "index": 0,
+ "values": [
+ 29.452889,
+ 26.820117,
+ -24.96421,
+ 0.311263,
+ 0.5955,
+ 1
+ ]
+ },
+ {
+ "index": 44,
+ "values": [
+ 32.134226,
+ 7.691381,
+ -8.004805,
+ 0.541403,
+ 0.426727,
+ 1
+ ]
+ },
+ {
+ "index": 89,
+ "values": [
+ 9.197794,
+ 40.140539,
+ 8.385809,
+ 0.767637,
+ 0.261618,
+ 1
+ ]
+ },
+ {
+ "index": 133,
+ "values": [
+ 31.814541,
+ 28.243704,
+ 25.975582,
+ 1.08362,
+ 0.064285,
+ 1
+ ]
+ }
+ ],
+ "lines": []
+ },
+ {
+ "key": "listening-64-3.3",
+ "state": "listening",
+ "size": 64,
+ "t": 3.3,
+ "dotCount": 134,
+ "lineCount": 0,
+ "dots": [
+ {
+ "index": 0,
+ "values": [
+ 32.701365,
+ 35.38221,
+ -23.349024,
+ 0.3,
+ 0.613757,
+ 1
+ ]
+ },
+ {
+ "index": 44,
+ "values": [
+ 15.775356,
+ 16.269652,
+ -7.350356,
+ 0.485446,
+ 0.453588,
+ 1
+ ]
+ },
+ {
+ "index": 89,
+ "values": [
+ 48.115061,
+ 47.624103,
+ 7.30071,
+ 0.661669,
+ 0.306909,
+ 1
+ ]
+ },
+ {
+ "index": 133,
+ "values": [
+ 31.293866,
+ 28.594791,
+ 23.507798,
+ 0.856608,
+ 0.144653,
+ 1
+ ]
+ }
+ ],
+ "lines": []
+ },
+ {
+ "key": "listening-64-5.1",
+ "state": "listening",
+ "size": 64,
+ "t": 5.1,
+ "dotCount": 134,
+ "lineCount": 0,
+ "dots": [
+ {
+ "index": 0,
+ "values": [
+ 32.542605,
+ 35.665835,
+ -25.329402,
+ 0.305393,
+ 0.599967,
+ 1
+ ]
+ },
+ {
+ "index": 44,
+ "values": [
+ 48.172621,
+ 49.474268,
+ -8.379859,
+ 0.513627,
+ 0.442458,
+ 1
+ ]
+ },
+ {
+ "index": 89,
+ "values": [
+ 31.602892,
+ 55.972973,
+ 7.890793,
+ 0.726111,
+ 0.279565,
+ 1
+ ]
+ },
+ {
+ "index": 133,
+ "values": [
+ 31.462245,
+ 28.366927,
+ 25.103028,
+ 0.966269,
+ 0.102856,
+ 1
+ ]
+ }
+ ],
+ "lines": []
+ },
+ {
+ "key": "listening-20-0.6",
+ "state": "listening",
+ "size": 20,
+ "t": 0.6,
+ "dotCount": 42,
+ "lineCount": 0,
+ "dots": [
+ {
+ "index": 0,
+ "values": [
+ 9.17525,
+ 9.487216,
+ -7.986373,
+ 0.3,
+ 0.597281,
+ 1
+ ]
+ },
+ {
+ "index": 14,
+ "values": [
+ 5.077638,
+ 16.526579,
+ -2.032111,
+ 0.520601,
+ 0.365305,
+ 1
+ ]
+ },
+ {
+ "index": 28,
+ "values": [
+ 5.913276,
+ 4.910099,
+ 2.510098,
+ 0.533837,
+ 0.299585,
+ 1
+ ]
+ },
+ {
+ "index": 41,
+ "values": [
+ 10.767284,
+ 10.477054,
+ 7.429901,
+ 0.684609,
+ 0.141971,
+ 1
+ ]
+ }
+ ],
+ "lines": []
+ },
+ {
+ "key": "listening-20-1.7",
+ "state": "listening",
+ "size": 20,
+ "t": 1.7,
+ "dotCount": 42,
+ "lineCount": 0,
+ "dots": [
+ {
+ "index": 0,
+ "values": [
+ 11.601351,
+ 9.551738,
+ -7.619978,
+ 0.3,
+ 0.612337,
+ 1
+ ]
+ },
+ {
+ "index": 14,
+ "values": [
+ 2.757326,
+ 11.64422,
+ -2.381082,
+ 0.402035,
+ 0.444501,
+ 1
+ ]
+ },
+ {
+ "index": 28,
+ "values": [
+ 2.873632,
+ 8.580006,
+ 2.991485,
+ 0.588509,
+ 0.265971,
+ 1
+ ]
+ },
+ {
+ "index": 41,
+ "values": [
+ 8.386569,
+ 10.451643,
+ 7.677457,
+ 0.742565,
+ 0.115848,
+ 1
+ ]
+ }
+ ],
+ "lines": []
+ },
+ {
+ "key": "listening-20-3.3",
+ "state": "listening",
+ "size": 20,
+ "t": 3.3,
+ "dotCount": 42,
+ "lineCount": 0,
+ "dots": [
+ {
+ "index": 0,
+ "values": [
+ 9.509812,
+ 9.524327,
+ -7.295235,
+ 0.3,
+ 0.613715,
+ 1
+ ]
+ },
+ {
+ "index": 14,
+ "values": [
+ 3.693175,
+ 6.744026,
+ -2.006911,
+ 0.395409,
+ 0.444295,
+ 1
+ ]
+ },
+ {
+ "index": 28,
+ "values": [
+ 10,
+ 3.061482,
+ 2.771332,
+ 0.541843,
+ 0.291216,
+ 1
+ ]
+ },
+ {
+ "index": 41,
+ "values": [
+ 10.493455,
+ 10.478844,
+ 7.343862,
+ 0.681972,
+ 0.144728,
+ 1
+ ]
+ }
+ ],
+ "lines": []
+ },
+ {
+ "key": "listening-20-5.1",
+ "state": "listening",
+ "size": 20,
+ "t": 5.1,
+ "dotCount": 42,
+ "lineCount": 0,
+ "dots": [
+ {
+ "index": 0,
+ "values": [
+ 10.966528,
+ 9.50422,
+ -7.812768,
+ 0.3,
+ 0.608858,
+ 1
+ ]
+ },
+ {
+ "index": 14,
+ "values": [
+ 9.380591,
+ 2.289278,
+ -1.92074,
+ 0.4465,
+ 0.411104,
+ 1
+ ]
+ },
+ {
+ "index": 28,
+ "values": [
+ 10,
+ 2.648391,
+ 2.936326,
+ 0.600563,
+ 0.261399,
+ 1
+ ]
+ },
+ {
+ "index": 41,
+ "values": [
+ 9.019775,
+ 10.502806,
+ 7.923484,
+ 0.793827,
+ 0.092541,
+ 1
+ ]
+ }
+ ],
+ "lines": []
+ },
+ {
+ "key": "connecting-64-0.6",
+ "state": "connecting",
+ "size": 64,
+ "t": 0.6,
+ "dotCount": 48,
+ "lineCount": 81,
+ "dots": [
+ {
+ "index": 0,
+ "values": [
+ 23.99695,
+ 34.67833,
+ -0.944099,
+ 0.662966,
+ 0.537422,
+ 1
+ ]
+ },
+ {
+ "index": 16,
+ "values": [
+ 54.136874,
+ 24.212196,
+ -0.39964,
+ 0.992696,
+ 0.05,
+ 0.65009
+ ]
+ },
+ {
+ "index": 32,
+ "values": [
+ 51.305723,
+ 16.118749,
+ 0.215499,
+ 0.835942,
+ 0.276513,
+ 1
+ ]
+ },
+ {
+ "index": 47,
+ "values": [
+ 31.723599,
+ 32.180593,
+ 0.999917,
+ 1.490098,
+ 0.100019,
+ 1
+ ]
+ }
+ ],
+ "lines": [
+ {
+ "index": 0,
+ "values": [
+ 40.743047,
+ 12.360858,
+ 25.929776,
+ 13.006921,
+ 0.42,
+ 0.137696,
+ 0.6
+ ]
+ },
+ {
+ "index": 27,
+ "values": [
+ 12.260417,
+ 26.559508,
+ 24.925432,
+ 33.877535,
+ 0.42,
+ 0.05012,
+ 0.6
+ ]
+ },
+ {
+ "index": 54,
+ "values": [
+ 57.537838,
+ 33.725419,
+ 52.952403,
+ 45.819293,
+ 0.42,
+ 0.154398,
+ 0.6
+ ]
+ },
+ {
+ "index": 80,
+ "values": [
+ 39.028085,
+ 52.274015,
+ 32.648032,
+ 57.308696,
+ 0.42,
+ 0.140952,
+ 0.6
+ ]
+ }
+ ]
+ },
+ {
+ "key": "connecting-64-1.7",
+ "state": "connecting",
+ "size": 64,
+ "t": 1.7,
+ "dotCount": 48,
+ "lineCount": 86,
+ "dots": [
+ {
+ "index": 0,
+ "values": [
+ 33.977576,
+ 25.363526,
+ -0.962719,
+ 0.673322,
+ 0.541612,
+ 1
+ ]
+ },
+ {
+ "index": 16,
+ "values": [
+ 54.406825,
+ 23.609336,
+ -0.355642,
+ 0.70395,
+ 0.40502,
+ 1
+ ]
+ },
+ {
+ "index": 32,
+ "values": [
+ 54.871772,
+ 29.238257,
+ 0.436059,
+ 1.265277,
+ 0.226887,
+ 1
+ ]
+ },
+ {
+ "index": 47,
+ "values": [
+ 34.57579,
+ 32.330693,
+ 0.994841,
+ 1.120417,
+ 0.101161,
+ 1
+ ]
+ }
+ ],
+ "lines": [
+ {
+ "index": 0,
+ "values": [
+ 41.267017,
+ 11.923016,
+ 26.092415,
+ 12.415575,
+ 0.42,
+ 0.120141,
+ 0.6
+ ]
+ },
+ {
+ "index": 28,
+ "values": [
+ 35.25754,
+ 14.462134,
+ 28.550654,
+ 19.115322,
+ 0.42,
+ 0.186108,
+ 0.6
+ ]
+ },
+ {
+ "index": 57,
+ "values": [
+ 57.369714,
+ 33.541811,
+ 52.788825,
+ 42.567254,
+ 0.42,
+ 0.158848,
+ 0.6
+ ]
+ },
+ {
+ "index": 85,
+ "values": [
+ 39.457164,
+ 52.151538,
+ 33.301502,
+ 57.385467,
+ 0.42,
+ 0.128203,
+ 0.6
+ ]
+ }
+ ]
+ },
+ {
+ "key": "connecting-64-3.3",
+ "state": "connecting",
+ "size": 64,
+ "t": 3.3,
+ "dotCount": 48,
+ "lineCount": 86,
+ "dots": [
+ {
+ "index": 0,
+ "values": [
+ 26.162983,
+ 28.19066,
+ -0.962221,
+ 0.447613,
+ 0.5415,
+ 1
+ ]
+ },
+ {
+ "index": 16,
+ "values": [
+ 31.727267,
+ 7.443101,
+ -0.282345,
+ 1.032386,
+ 0.05,
+ 0.679414
+ ]
+ },
+ {
+ "index": 32,
+ "values": [
+ 13.004209,
+ 19.113363,
+ 0.442726,
+ 1.086584,
+ 0.225387,
+ 1
+ ]
+ },
+ {
+ "index": 47,
+ "values": [
+ 38.613665,
+ 32.279418,
+ 0.965991,
+ 1.016425,
+ 0.107652,
+ 1
+ ]
+ }
+ ],
+ "lines": [
+ {
+ "index": 0,
+ "values": [
+ 41.679052,
+ 11.205657,
+ 26.160525,
+ 11.884511,
+ 0.42,
+ 0.098617,
+ 0.6
+ ]
+ },
+ {
+ "index": 28,
+ "values": [
+ 37.503097,
+ 12.773246,
+ 40.873414,
+ 17.998692,
+ 0.42,
+ 0.235299,
+ 0.6
+ ]
+ },
+ {
+ "index": 57,
+ "values": [
+ 26.162983,
+ 28.19066,
+ 37.079862,
+ 38.596745,
+ 0.42,
+ 0.056727,
+ 0.6
+ ]
+ },
+ {
+ "index": 85,
+ "values": [
+ 40.498202,
+ 51.503337,
+ 34.673558,
+ 57.391659,
+ 0.42,
+ 0.093848,
+ 0.6
+ ]
+ }
+ ]
+ },
+ {
+ "key": "connecting-64-5.1",
+ "state": "connecting",
+ "size": 64,
+ "t": 5.1,
+ "dotCount": 48,
+ "lineCount": 88,
+ "dots": [
+ {
+ "index": 0,
+ "values": [
+ 30.861697,
+ 26.637384,
+ -0.976802,
+ 0.797397,
+ 0.05,
+ 0.505799
+ ]
+ },
+ {
+ "index": 16,
+ "values": [
+ 40.261135,
+ 9.421444,
+ -0.343489,
+ 0.931146,
+ 0.402285,
+ 1
+ ]
+ },
+ {
+ "index": 32,
+ "values": [
+ 54.666369,
+ 37.976953,
+ 0.40193,
+ 1.078646,
+ 0.234566,
+ 1
+ ]
+ },
+ {
+ "index": 47,
+ "values": [
+ 29.745085,
+ 33.3863,
+ 0.99464,
+ 1.446935,
+ 0.101206,
+ 1
+ ]
+ }
+ ],
+ "lines": [
+ {
+ "index": 0,
+ "values": [
+ 41.46493,
+ 9.674869,
+ 29.393319,
+ 12.885234,
+ 0.42,
+ 0.125281,
+ 0.6
+ ]
+ },
+ {
+ "index": 29,
+ "values": [
+ 51.017281,
+ 27.389833,
+ 57.432865,
+ 30.237399,
+ 0.42,
+ 0.095825,
+ 0.6
+ ]
+ },
+ {
+ "index": 58,
+ "values": [
+ 24.06655,
+ 44.973604,
+ 32.007901,
+ 55.810065,
+ 0.42,
+ 0.03785,
+ 0.6
+ ]
+ },
+ {
+ "index": 87,
+ "values": [
+ 39.214768,
+ 51.262794,
+ 35.596519,
+ 57.243516,
+ 0.42,
+ 0.096684,
+ 0.6
+ ]
+ }
+ ]
+ },
+ {
+ "key": "connecting-20-0.6",
+ "state": "connecting",
+ "size": 20,
+ "t": 0.6,
+ "dotCount": 9,
+ "lineCount": 0,
+ "dots": [
+ {
+ "index": 0,
+ "values": [
+ 12.345722,
+ 12.323515,
+ -0.910862,
+ 0.652664,
+ 0.05,
+ 0.522284
+ ]
+ },
+ {
+ "index": 3,
+ "values": [
+ 16.216325,
+ 9.675124,
+ -0.628139,
+ 0.646447,
+ 0.466331,
+ 1
+ ]
+ },
+ {
+ "index": 6,
+ "values": [
+ 16.719838,
+ 11.196911,
+ 0.521584,
+ 0.925632,
+ 0.207644,
+ 1
+ ]
+ },
+ {
+ "index": 8,
+ "values": [
+ 5.573026,
+ 8.166562,
+ 0.800785,
+ 0.816565,
+ 0.144823,
+ 1
+ ]
+ }
+ ],
+ "lines": []
+ },
+ {
+ "key": "connecting-20-1.7",
+ "state": "connecting",
+ "size": 20,
+ "t": 1.7,
+ "dotCount": 9,
+ "lineCount": 0,
+ "dots": [
+ {
+ "index": 0,
+ "values": [
+ 9.463514,
+ 5.457987,
+ -0.820464,
+ 0.584018,
+ 0.509604,
+ 1
+ ]
+ },
+ {
+ "index": 3,
+ "values": [
+ 2.194715,
+ 11.595745,
+ -0.091098,
+ 0.759562,
+ 0.345497,
+ 1
+ ]
+ },
+ {
+ "index": 6,
+ "values": [
+ 16.686373,
+ 11.048203,
+ 0.533176,
+ 0.65117,
+ 0.205035,
+ 1
+ ]
+ },
+ {
+ "index": 8,
+ "values": [
+ 6.063945,
+ 7.72457,
+ 0.822818,
+ 0.697856,
+ 0.139866,
+ 1
+ ]
+ }
+ ],
+ "lines": []
+ },
+ {
+ "key": "connecting-20-3.3",
+ "state": "connecting",
+ "size": 20,
+ "t": 3.3,
+ "dotCount": 9,
+ "lineCount": 0,
+ "dots": [
+ {
+ "index": 0,
+ "values": [
+ 14.1764,
+ 11.554531,
+ -0.830485,
+ 0.387323,
+ 0.511859,
+ 1
+ ]
+ },
+ {
+ "index": 3,
+ "values": [
+ 15.693894,
+ 4.534095,
+ 0.163145,
+ 0.942025,
+ 0.05,
+ 0.790786
+ ]
+ },
+ {
+ "index": 6,
+ "values": [
+ 11.282813,
+ 16.663498,
+ 0.529625,
+ 1.02264,
+ 0.205834,
+ 1
+ ]
+ },
+ {
+ "index": 8,
+ "values": [
+ 6.778048,
+ 7.016922,
+ 0.835915,
+ 1.110366,
+ 0.136919,
+ 1
+ ]
+ }
+ ],
+ "lines": []
+ },
+ {
+ "key": "connecting-20-5.1",
+ "state": "connecting",
+ "size": 20,
+ "t": 5.1,
+ "dotCount": 9,
+ "lineCount": 0,
+ "dots": [
+ {
+ "index": 0,
+ "values": [
+ 13.041535,
+ 12.026498,
+ -0.889543,
+ 0.558377,
+ 0.525147,
+ 1
+ ]
+ },
+ {
+ "index": 3,
+ "values": [
+ 14.875144,
+ 3.712069,
+ 0.104201,
+ 0.851987,
+ 0.301555,
+ 1
+ ]
+ },
+ {
+ "index": 6,
+ "values": [
+ 12.666422,
+ 16.589578,
+ 0.458729,
+ 0.614063,
+ 0.221786,
+ 1
+ ]
+ },
+ {
+ "index": 8,
+ "values": [
+ 8.533603,
+ 7.16428,
+ 0.916927,
+ 0.84121,
+ 0.118691,
+ 1
+ ]
+ }
+ ],
+ "lines": []
+ }
+ ]
+}
diff --git a/kit/Tests/CodyncKitTests/ThinkingOrbGeometryTests.swift b/kit/Tests/CodyncKitTests/ThinkingOrbGeometryTests.swift
new file mode 100644
index 00000000..0af96229
--- /dev/null
+++ b/kit/Tests/CodyncKitTests/ThinkingOrbGeometryTests.swift
@@ -0,0 +1,38 @@
+import Foundation
+import Testing
+@testable import CodyncKit
+
+/// Independent upstream vectors catch porting errors in projection, density,
+/// preset scaling, sorting and deterministic noise at both tuned sizes.
+@Test func thinkingOrbsMatchUpstreamGoldenVectors() throws {
+ struct Sample: Decodable { let index: Int; let values: [Double] }
+ struct Case: Decodable {
+ let key, state: String
+ let size, t: Double
+ let dotCount, lineCount: Int
+ let dots, lines: [Sample]
+ }
+ struct Fixture: Decodable { let tolerance: Double; let cases: [Case] }
+ let url = try #require(Bundle.module.url(forResource: "thinking-orbs-golden", withExtension: "json", subdirectory: "Fixtures"))
+ let fixture = try JSONDecoder().decode(Fixture.self, from: Data(contentsOf: url))
+ for vector in fixture.cases {
+ let state = try #require(ThinkingOrb.State(rawValue: vector.state))
+ let frame = ThinkingOrbGeometry.frame(state: state, size: vector.size, time: vector.t)
+ #expect(frame.dots.count == vector.dotCount, "\(vector.key) dots")
+ #expect(frame.lines.count == vector.lineCount, "\(vector.key) lines")
+ for sample in vector.dots {
+ guard sample.index < frame.dots.count else { continue }
+ let d = frame.dots[sample.index]
+ for (actual, expected) in zip([d.x, d.y, d.z, d.radius, d.white, d.alpha], sample.values) {
+ #expect(abs(actual - expected) <= fixture.tolerance, "\(vector.key), dot \(sample.index): \(actual) != \(expected)")
+ }
+ }
+ for sample in vector.lines {
+ guard sample.index < frame.lines.count else { continue }
+ let l = frame.lines[sample.index]
+ for (actual, expected) in zip([l.x1, l.y1, l.x2, l.y2, l.white, l.alpha, l.width], sample.values) {
+ #expect(abs(actual - expected) <= fixture.tolerance, "\(vector.key), line \(sample.index)")
+ }
+ }
+ }
+}
diff --git a/tools/render-widgets.swift b/tools/render-widgets.swift
index 6eea66d0..9a58dd31 100644
--- a/tools/render-widgets.swift
+++ b/tools/render-widgets.swift
@@ -20,8 +20,95 @@ struct WidgetDesignExport {
let url = output.appendingPathComponent("widgets-\(name).png")
try png.write(to: url)
print(url.path)
+ try export(IconBoard().environment(\.colorScheme, scheme), to: output.appendingPathComponent("halftone-icons-\(name).png"))
+ try export(ActivityBoard().environment(\.colorScheme, scheme), to: output.appendingPathComponent("activities-\(name).png"))
+ try export(LargeWidgetBoard().environment(\.colorScheme, scheme), to: output.appendingPathComponent("large-widgets-\(name).png"))
}
}
+
+ @MainActor private static func export<V: View>(_ content: V, to url: URL) throws {
+ let renderer = ImageRenderer(content: content)
+ renderer.scale = 2
+ guard let image = renderer.cgImage,
+ let png = NSBitmapImageRep(cgImage: image).representation(using: .png, properties: [:]) else {
+ fatalError("Could not render \(url.lastPathComponent)")
+ }
+ try png.write(to: url)
+ print(url.path)
+ }
+}
+
+private struct ActivityBoard: View {
+ private let statuses = ["working", "needsInput", "idle", "error", "stale"]
+ var body: some View {
+ VStack(alignment: .leading, spacing: 24) {
+ Text("Codync · Live Activity & Dynamic Island").font(.title2.weight(.semibold))
+ Text("Lock Screen / compact + minimal / expanded · illustrative sample task")
+ .font(.caption).foregroundStyle(Palette.secondary)
+ if let bot = Bot.widgetPreview.first {
+ ForEach(statuses, id: \.self) { status in
+ let state = BotActivityPresentation(status: status == "stale" ? "working" : status,
+ activity: status == "needsInput" ? "Review the proposed changes." : "Running the test suite.",
+ startedAt: nil, isStale: status == "stale")
+ VStack(alignment: .leading, spacing: 8) {
+ Text(state.title).font(.headline)
+ HStack(spacing: 18) {
+ BotActivityPreview(bot: bot, state: state, form: .lockScreen).frame(width: 300)
+ VStack(spacing: 18) {
+ BotActivityPreview(bot: bot, state: state, form: .compact)
+ BotActivityPreview(bot: bot, state: state, form: .minimal)
+ }
+ BotActivityPreview(bot: bot, state: state, form: .expanded).frame(width: 300)
+ }
+ }
+ }
+ }
+ }
+ .padding(24).foregroundStyle(Palette.text).background(Palette.background)
+ }
+}
+
+private struct LargeWidgetBoard: View {
+ private var bots: [Bot] {
+ (0..<6).map { i in
+ var bot = Bot.widgetPreview[i % 3]
+ bot.id = "preview-\(i)"
+ bot.name += " \(i + 1)"
+ return bot
+ }
+ }
+ private var provider: UsageProvider {
+ var p = Usage.widgetPreview.providers[0]
+ var extra = p.windows[1]
+ extra.id = "model-limit"; extra.label = "Weekly · Opus"; extra.percent = 76
+ p.windows.append(extra)
+ extra.id = "model-limit-2"; extra.label = "Weekly · Sonnet"; extra.percent = 42
+ p.windows.append(extra)
+ return p
+ }
+ var body: some View {
+ VStack(alignment: .leading, spacing: 18) {
+ Text("Large & Lock Screen widgets · sample data").font(.title2.weight(.semibold))
+ HStack(spacing: 18) {
+ ProviderWidgetCard(provider: provider, layout: .large)
+ .padding(16).frame(width: 338, height: 338)
+ .background(Palette.surface, in: RoundedRectangle(cornerRadius: 24))
+ BotsWidgetCard(bots: bots, wide: true, large: true)
+ .padding(16).frame(width: 338, height: 338)
+ .background(Palette.surface, in: RoundedRectangle(cornerRadius: 24))
+ }
+ ForEach(AccessoryWidgetCard.Family.allCases, id: \.self) { family in
+ HStack(spacing: 32) {
+ Text(family.rawValue).font(.caption).frame(width: 90, alignment: .leading)
+ AccessoryWidgetCard(kind: .bots, family: family, bots: bots)
+ .frame(width: family == .circular ? 64 : 210, height: 64)
+ AccessoryWidgetCard(kind: .usage, family: family, usage: .widgetPreview)
+ .frame(width: family == .circular ? 64 : 210, height: 64)
+ }
+ }
+ }
+ .padding(24).foregroundStyle(Palette.text).background(Palette.background)
+ }
}
private struct WidgetBoard: View {
@@ -75,3 +162,34 @@ private struct WidgetBoard: View {
.background(Palette.surface, in: RoundedRectangle(cornerRadius: 22))
}
}
+
+private struct IconBoard: View {
+ private let sizes: [CGFloat] = [15, 20, 22, 26, 32, 64]
+ private let shapes = ["blob", "pebble", "squircle", "tablet", "wedge", "hex", "cloud", "teardrop"]
+ var body: some View {
+ VStack(alignment: .leading, spacing: 18) {
+ Text("Codync · Halftone icons").font(.title2.weight(.semibold))
+ Text("15 / 20 / 22 / 26 / 32 / 64 pt · static reference frames")
+ .font(.caption).foregroundStyle(Palette.secondary)
+ ForEach(shapes, id: \.self) { shape in
+ HStack(spacing: 24) {
+ Text(shape).font(.caption).frame(width: 90, alignment: .leading)
+ ForEach(sizes, id: \.self) { size in
+ CharacterAvatar(shape: shape, color: "gray", size: size).frame(width: 64, height: 64)
+ }
+ }
+ }
+ Divider()
+ ForEach(ThinkingOrb.State.allCases, id: \.self) { state in
+ HStack(spacing: 24) {
+ Text(state.rawValue).font(.caption).frame(width: 90, alignment: .leading)
+ ForEach(sizes, id: \.self) { size in
+ ThinkingOrb(state: state, size: size, animated: false).frame(width: 64, height: 64)
+ }
+ }
+ }
+ Text("Thinking Orbs · Jakub Antalik · MIT").font(.caption2).foregroundStyle(Palette.secondary)
+ }
+ .padding(24).foregroundStyle(Palette.text).background(Palette.background)
+ }
+}