Skip to content

Open source Grok Bot alternative, Bring your own agent and subscription: message Claude Code, Codex, Gemini CLI, Cursor, Copilot and 40+ AI agents as bots on your own computer, from iPhone, Mac, Windows, Linux or terminal. Agent-agnostic and free. Also a Muse and Dots alternative. Built in Rust.

feat(ios): group bots by computer and redo the widget gallery

leepokaie20774ef33ac
diff --git a/Codync.xcodeproj/project.pbxproj b/Codync.xcodeproj/project.pbxproj
index 81246c0e..041cd0c9 100644
--- a/Codync.xcodeproj/project.pbxproj
+++ b/Codync.xcodeproj/project.pbxproj
@@ -38,6 +38,7 @@
AFC0CD8BD1FA61F810C96057 /* com.pokai.Codync.screen.plist in CopyFiles */ = {isa = PBXBuildFile; fileRef = 895BB6C2EB8986266EB4159A /* com.pokai.Codync.screen.plist */; };
B75DD137E6F645F797B60B09 /* PairingView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 739EC95223CC8F8717C33736 /* PairingView.swift */; };
B8B86B2B7F8D9EE8639A9E09 /* CodyncUI in Frameworks */ = {isa = PBXBuildFile; productRef = BEE30A9D5C73E5A151F34180 /* CodyncUI */; };
+ C4C13F3D07038489DD466E33 /* WidgetSetupDemo.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5BBB4ED17352B4F399428D2F /* WidgetSetupDemo.swift */; };
C937F66F810AA238B73E8363 /* PrivacyInfo.xcprivacy in Resources */ = {isa = PBXBuildFile; fileRef = 4EDD440CC0624F03363AC1BA /* PrivacyInfo.xcprivacy */; };
CC9F6FB8055C38D5D625F738 /* BotListView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C5E57711E223A292872322C5 /* BotListView.swift */; };
CEB634F257363FE66E0BBCF1 /* AccessRequestView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1233BBE848155CA9E177A7E2 /* AccessRequestView.swift */; };
@@ -139,6 +140,7 @@
55AABA9596547D7459B1CC5B /* Push.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Push.swift; sourceTree = "<group>"; };
57273C989336832CFF7B7ACD /* WelcomeView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WelcomeView.swift; sourceTree = "<group>"; };
57DFD81025893713D631B5D7 /* ComputersView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ComputersView.swift; sourceTree = "<group>"; };
+ 5BBB4ED17352B4F399428D2F /* WidgetSetupDemo.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WidgetSetupDemo.swift; sourceTree = "<group>"; };
60422D3CA8FEBCDC5AC465E0 /* iOS.app */ = {isa = PBXFileReference; includeInIndex = 0; lastKnownFileType = wrapper.application; path = iOS.app; sourceTree = BUILT_PRODUCTS_DIR; };
6D734BEE7CD3F84677B0218B /* Widgets.appex */ = {isa = PBXFileReference; includeInIndex = 0; lastKnownFileType = "wrapper.app-extension"; path = Widgets.appex; sourceTree = BUILT_PRODUCTS_DIR; };
739EC95223CC8F8717C33736 /* PairingView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PairingView.swift; sourceTree = "<group>"; };
@@ -247,6 +249,7 @@
47BCE8E2AFA6CA829DBC489A /* UsageView.swift */,
57273C989336832CFF7B7ACD /* WelcomeView.swift */,
0E8563C243AB130DFA063CAD /* WidgetGalleryView.swift */,
+ 5BBB4ED17352B4F399428D2F /* WidgetSetupDemo.swift */,
);
path = Views;
sourceTree = "<group>";
@@ -724,6 +727,7 @@
ED143C01BF7AD4953101D160 /* UsageView.swift in Sources */,
AD70E2D55507BF2A75743763 /* WelcomeView.swift in Sources */,
A12D125989D2EA1AC5308218 /* WidgetGalleryView.swift in Sources */,
+ C4C13F3D07038489DD466E33 /* WidgetSetupDemo.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
diff --git a/apps/ios/App/CodyncApp.swift b/apps/ios/App/CodyncApp.swift
index be7c0e02..d83aacc3 100644
--- a/apps/ios/App/CodyncApp.swift
+++ b/apps/ios/App/CodyncApp.swift
@@ -46,7 +46,7 @@ struct CodyncApp: App {
if let s = ProcessInfo.processInfo.environment["CODYNC_PAIR_URL"], let p = Pairing(string: s) {
_ = try? await app.pair(p)
}
- if ProcessInfo.processInfo.environment["CODYNC_OPEN_USAGE"] != nil { app.tab = .usage }
+ if ProcessInfo.processInfo.environment["CODYNC_OPEN_USAGE"] != nil { app.tab = .state; app.showUsage = true }
await LiveActivities.shared.previewIfRequested()
if ProcessInfo.processInfo.environment["CODYNC_OPEN_SCREEN"] != nil {
try? await Task.sleep(for: .seconds(2))
@@ -58,7 +58,7 @@ struct CodyncApp: App {
}
}
-enum AppTab: Hashable { case bots, usage }
+enum AppTab: Hashable { case bots, state }
/// One `AccountStore` per account context: switching accounts retires the old one so
/// in-flight work can't land on another user's screen or storage.
@@ -75,6 +75,8 @@ final class AppStore {
private(set) var generation = 0
var tab = AppTab.bots
var showComputers = false
+ /// The usage limits sheet over the State tab.
+ var showUsage = false
/// The computer whose marketplace is open.
var marketplace: ComputerID?
@@ -173,7 +175,9 @@ final class AppStore {
tab = .bots
marketplace = currentStore?.computer.id
case "usage":
- tab = .usage
+ accounts.selection = nil
+ tab = .state
+ showUsage = true
case "computers":
accounts.selection = nil
tab = .bots
diff --git a/apps/ios/Views/ActivityGalleryView.swift b/apps/ios/Views/ActivityGalleryView.swift
index 4fc90dcb..75f1513f 100644
--- a/apps/ios/Views/ActivityGalleryView.swift
+++ b/apps/ios/Views/ActivityGalleryView.swift
@@ -4,11 +4,13 @@ import CodyncUI
import SwiftUI
struct ActivityGalleryView: View {
+ /// The presentations shown: the State tab splits Lock Screen from the Dynamic Island.
+ var forms = BotActivityPreview.Form.allCases
@Environment(\.scenePhase) private var scenePhase
@Environment(\.openURL) private var openURL
@AppStorage("liveActivitiesEnabled") private var enabled = true
@State private var allowed = ActivityAuthorizationInfo().areActivitiesEnabled
- @State private var form = BotActivityPreview.Form.lockScreen
+ @State private var form: BotActivityPreview.Form?
@State private var phase = BotActivityPresentation.Phase.working
@State private var start = Date.now - 154
@@ -50,23 +52,22 @@ struct ActivityGalleryView: View {
Spacer()
Text("Sample task").font(.caption).foregroundStyle(Palette.secondary)
}
- ChoicePicker(selection: $form, options: BotActivityPreview.Form.allCases.map { ($0, $0.rawValue) })
+ if forms.count > 1 {
+ ChoicePicker(selection: Binding(get: { form ?? forms[0] }, set: { form = $0 }), options: forms.map { ($0, $0.rawValue) })
+ }
ChoicePicker(selection: $phase, options: [
(.working, "Working"), (.needsInput, "Needs you"), (.completed, "Done"),
(.failed, "Error"), (.stale, "Update delayed"),
])
if let bot = Bot.widgetPreview.first {
- BotActivityPreview(bot: bot, state: state, form: form)
+ BotActivityPreview(bot: bot, state: state, form: form ?? forms[0])
.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.")
+ ForEach(forms, id: \.self) { explanation($0) }
}
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)
@@ -74,7 +75,7 @@ struct ActivityGalleryView: View {
.padding(18).frame(maxWidth: 560).frame(maxWidth: .infinity)
}
.background(Palette.background)
- .page("Live Activity", pushed: true)
+
.tint(Palette.accent)
.onChange(of: enabled) { _, value in if !value { LiveActivities.shared.endAll() } }
.onChange(of: scenePhase) { _, value in
@@ -82,9 +83,15 @@ struct ActivityGalleryView: View {
}
}
- private func explanation(_ title: String, _ detail: String) -> some View {
- VStack(alignment: .leading, spacing: 4) {
- Text(title).font(.subheadline.weight(.medium)).accessibilityAddTraits(.isHeader)
+ private func explanation(_ form: BotActivityPreview.Form) -> some View {
+ let detail = switch form {
+ case .lockScreen: "A task card with the bot, current step and elapsed time. Tap it to return to the conversation."
+ case .compact: "The bot and timer appear beside the camera. The timer becomes a status icon when the task needs attention or ends."
+ case .minimal: "A small status icon when iOS displays multiple Live Activities."
+ case .expanded: "Touch and hold the Dynamic Island for the current step and a shortcut to the conversation."
+ }
+ return VStack(alignment: .leading, spacing: 4) {
+ Text(form.rawValue).font(.subheadline.weight(.medium)).accessibilityAddTraits(.isHeader)
Text(detail).font(.footnote).foregroundStyle(Palette.secondary)
}
}
diff --git a/apps/ios/Views/BotListView.swift b/apps/ios/Views/BotListView.swift
index 56433fcd..5028cdd3 100644
--- a/apps/ios/Views/BotListView.swift
+++ b/apps/ios/Views/BotListView.swift
@@ -6,11 +6,24 @@ import SwiftUI
struct BotListView: View {
@Environment(AppStore.self) private var app
@Environment(AccountStore.self) private var accounts
+ @State private var connectingComputer: CloudComputer?
@State private var editing: EditTarget?
@State private var editingGroup: GroupTarget?
- @State private var newMenu = false
@State private var pickingComputer = false
@State private var confirmDelete: RosterItem?
+ /// Computers left out of the list on this device, comma-separated IDs.
+ @AppStorage("hiddenComputers") private var hiddenComputers = ""
+
+ private var hidden: Set<ComputerID> { Set(hiddenComputers.split(separator: ",").map(String.init)) }
+
+ /// More than one computer: the list groups bots under their computer and the header filters.
+ private var grouped: Bool { accounts.computers.count > 1 }
+
+ /// The computers the list shows (all of them when the filter would leave none).
+ private var shownComputers: [Computer] {
+ let shown = accounts.computers.filter { !hidden.contains($0.id) }
+ return shown.isEmpty ? accounts.computers : shown
+ }
/// Computers that can take a new bot right now.
private var onlineStores: [BotStore] {
@@ -22,22 +35,76 @@ struct BotListView: View {
ScrollView {
LazyVStack(spacing: 0) {
// Keep actionable offline warnings; transient connecting state lives in the header.
- ForEach(accounts.computers) { computer in
- if let store = accounts.store(for: computer.id), store.connection != .online {
+ ForEach(shownComputers) { computer in
+ // Connecting draws nothing here (the header shows it), so it takes no space either.
+ if let store = accounts.store(for: computer.id), ![.online, .connecting, .unpaired].contains(store.connection) {
ConnectionBanner()
.environment(store)
.padding(.vertical, 4)
}
}
- if roster.isEmpty {
+ if !accountComputers.isEmpty {
+ VStack(alignment: .leading, spacing: 12) {
+ Text("Connect from your account")
+ .font(.title3.weight(.semibold))
+ .foregroundStyle(Palette.text)
+ Text("Connect once to see all the bots on your computer. No QR code needed.")
+ .font(.subheadline)
+ .foregroundStyle(Palette.secondary)
+ ForEach(accountComputers) { computer in
+ Button {
+ withAnimation(Motion.layout) {
+ if computer.access == "granted" {
+ app.showComputers = true
+ } else {
+ connectingComputer = computer
+ }
+ }
+ } label: {
+ HStack(spacing: 12) {
+ Image(systemName: "desktopcomputer")
+ .font(.title2)
+ VStack(alignment: .leading, spacing: 4) {
+ Text(computer.name).font(.headline)
+ Text(computer.isOnline ? "Online" : "Offline · Turn on your computer to connect")
+ .font(.subheadline)
+ .foregroundStyle(Palette.secondary)
+ }
+ Spacer()
+ Text(computer.access == "granted" ? "Manage" : "Connect")
+ .font(.subheadline.weight(.semibold))
+ }
+ .foregroundStyle(Palette.text)
+ .padding(16)
+ .frame(maxWidth: .infinity, alignment: .leading)
+ .background(Palette.surface, in: RoundedRectangle(cornerRadius: 16))
+ }
+ .buttonStyle(PressScale())
+ }
+ }
+ .padding(.vertical, 16)
+ }
+
+ if roster.isEmpty && accountComputers.isEmpty {
EmptyRoster(canCreate: !onlineStores.isEmpty, hasComputer: !accounts.computers.isEmpty,
create: newBot, showComputers: { app.showComputers = true })
}
- ForEach(roster) { item in
- if let store = accounts.store(for: item.ref.computerId) {
- row(item, store: store)
+ if grouped {
+ ForEach(shownComputers) { computer in
+ if let store = accounts.store(for: computer.id) {
+ ComputerSection(store: store)
+ ForEach(roster.filter { $0.ref.computerId == computer.id }) { item in
+ row(item, store: store, caption: false)
+ }
+ }
+ }
+ } else {
+ ForEach(roster) { item in
+ if let store = accounts.store(for: item.ref.computerId) {
+ row(item, store: store, caption: true)
+ }
}
}
}
@@ -52,32 +119,43 @@ struct BotListView: View {
AccountSwitcherButton()
}
ToolbarItem(placement: .principal) {
- // Keep the center empty when connected, while the system owns the bar's layout.
- ZStack {
- Color.clear.frame(width: 1, height: 1)
- ConnectingIndicator(isConnecting: accounts.computers.contains {
- accounts.store(for: $0.id)?.connection == .connecting
- })
+ if grouped {
+ VStack(spacing: 0) {
+ filterButton
+ ConnectingIndicator(isConnecting: shownComputers.contains {
+ accounts.store(for: $0.id)?.connection == .connecting
+ })
+ }
+ } else {
+ // Keep the center empty when connected, while the system owns the bar's layout.
+ ZStack {
+ Color.clear.frame(width: 1, height: 1)
+ ConnectingIndicator(isConnecting: accounts.computers.contains {
+ accounts.store(for: $0.id)?.connection == .connecting
+ })
+ }
}
}
ToolbarItem(placement: .topBarTrailing) {
Button("Computers", systemImage: "desktopcomputer") { app.showComputers = true }
}
ToolbarItem(placement: .topBarTrailing) {
- Button("New", systemImage: "plus") { newMenu = true }
- .disabled(onlineStores.isEmpty)
- .codyncMenu(isPresented: $newMenu) {
- [
- MenuItem("New bot", icon: "plus", action: newBot),
- MenuItem("New group chat", icon: "person.2", action: newGroup),
- ]
- }
+ // A native menu: the bar hosts toolbar buttons outside SwiftUI's layout,
+ // so an anchored Codync menu can't find where the button is.
+ Menu("New", systemImage: "plus") {
+ Button("New bot", systemImage: "plus", action: newBot)
+ Button("New group chat", systemImage: "person.2", action: newGroup)
+ }
+ .disabled(onlineStores.isEmpty)
}
}
.refreshable {
for computer in accounts.computers { accounts.store(for: computer.id)?.restartStream() }
await accounts.refreshCloud()
}
+ .codyncSheet(item: $connectingComputer) { computer in
+ AccessRequestView(computer: computer, pending: accounts.pendingAccess[computer.id] != nil)
+ }
.codyncSheet(item: $editing) { target in
if let store = accounts.store(for: target.computerId) {
BotEditorView(draft: target.draft)
@@ -120,16 +198,67 @@ struct BotListView: View {
}
}
- private func row(_ item: RosterItem, store: BotStore) -> some View {
+ private var accountComputers: [CloudComputer] {
+ accounts.cloudComputers.filter { computer in
+ !accounts.computers.contains { $0.id == computer.id }
+ }
+ }
+
+ /// "All computers ⌄" / "MacBook ⌄" / "2 computers ⌄".
+ private var filterButton: some View {
+ let shown = shownComputers
+ let title = shown.count == accounts.computers.count ? "All computers"
+ : shown.count == 1 ? (accounts.store(for: shown[0].id)?.hostName ?? shown[0].name)
+ : "\(shown.count) computers"
+ return Menu {
+ Button { setHidden([]) } label: {
+ Label("All computers", systemImage: shown.count == accounts.computers.count ? "checkmark" : "square.stack")
+ }
+ Divider()
+ ForEach(accounts.computers) { computer in
+ let isShown = shown.contains { $0.id == computer.id }
+ // A tap toggles one computer; the last one shown stays.
+ Button {
+ guard !isShown || shown.count > 1 else { return }
+ setHidden(isShown ? hidden.union([computer.id]) : hidden.subtracting([computer.id]))
+ } label: {
+ Label(accounts.store(for: computer.id)?.hostName ?? computer.name,
+ systemImage: isShown ? "checkmark" : "desktopcomputer")
+ }
+ }
+ } label: {
+ HStack(spacing: 6) {
+ Text(title)
+ .contentTransition(.opacity)
+ .lineLimit(1)
+ Image(systemName: "chevron.down").font(.caption2.weight(.bold)).foregroundStyle(Palette.tertiary)
+ }
+ .font(.subheadline.weight(.semibold))
+ .foregroundStyle(Palette.text)
+ .padding(.horizontal, 12)
+ .frame(height: 32)
+ .contentShape(Rectangle())
+ .animation(Motion.layout, value: title)
+ }
+ .accessibilityLabel("Show computers: \(title)")
+ }
+
+ private func setHidden(_ ids: Set<ComputerID>) {
+ withAnimation(Motion.layout) { hiddenComputers = ids.sorted().joined(separator: ",") }
+ }
+
+ private func row(_ item: RosterItem, store: BotStore, caption: Bool) -> some View {
let bot = item.bot
// A plain button instead of a NavigationLink: same push, no chevron.
return Button { accounts.selection = item.ref } label: {
VStack(alignment: .leading, spacing: 0) {
BotRow(bot: bot)
- ComputerCaption(store: store)
- .padding(.leading, 58)
- .padding(.bottom, 6)
- .offset(y: -6)
+ if caption {
+ ComputerCaption(store: store)
+ .padding(.leading, 58)
+ .padding(.bottom, 6)
+ .offset(y: -6)
+ }
}
.environment(store)
}
@@ -140,7 +269,7 @@ struct BotListView: View {
bot.isGroup
? MenuItem("Edit group", icon: "person.2") { editingGroup = GroupTarget(computerId: item.ref.computerId, group: bot) }
: MenuItem("Edit profile", icon: "pencil") { editing = EditTarget(computerId: item.ref.computerId, draft: BotDraft(bot)) },
- MenuItem("Mark as read", icon: "checkmark.message") { store.markRead(bot.id) },
+ MenuItem("Mark as read", icon: "checkmark.message") { store.markAllRead(bot.id) },
MenuItem("Hide from list", icon: "eye.slash") { store.setHidden(bot, true) },
MenuItem("Delete", icon: "trash", destructive: true, divider: true) { confirmDelete = item },
]
@@ -168,6 +297,33 @@ struct BotListView: View {
}
}
+/// A computer's heading above its bots: badge, name, and its connection, changing in place.
+private struct ComputerSection: View {
+ let store: BotStore
+
+ var body: some View {
+ HStack(spacing: 6) {
+ ComputerBadge(store.computer, size: 18)
+ Text(store.hostName)
+ .font(.footnote.weight(.semibold))
+ .foregroundStyle(Palette.secondary)
+ .lineLimit(1)
+ Text(store.statusText)
+ .font(.footnote)
+ .foregroundStyle(store.isOffline ? Palette.warning : Palette.tertiary)
+ .contentTransition(.opacity)
+ if store.connection == .online {
+ RouteIcon(route: store.hostRoute).font(.caption2).foregroundStyle(Palette.tertiary)
+ }
+ Spacer()
+ }
+ .padding(.top, 18)
+ .padding(.bottom, 4)
+ .accessibilityElement(children: .combine)
+ .accessibilityAddTraits(.isHeader)
+ }
+}
+
private struct GroupTarget: Identifiable {
let id = UUID()
let computerId: ComputerID
diff --git a/apps/ios/Views/RootView.swift b/apps/ios/Views/RootView.swift
index 6308b0ea..811aeb7b 100644
--- a/apps/ios/Views/RootView.swift
+++ b/apps/ios/Views/RootView.swift
@@ -55,9 +55,9 @@ struct RootView: View {
// Holds the pushes inside the sheet (Widgets, Live Activity); no bar shows.
NavigationStack { SettingsView() }
}
- .codyncSheet(isPresented: Binding(get: { app.marketplace != nil }, set: { if !$0 { app.marketplace = nil } })) {
- if let store = app.marketplace.flatMap(accounts.store(for:)) {
- MarketplaceView { app.marketplace = nil }
+ .codyncSheet(item: Binding(get: { app.marketplace.map(MarketplaceTarget.init) }, set: { app.marketplace = $0?.id })) { target in
+ if let store = accounts.store(for: target.id) {
+ MarketplaceView()
.environment(store)
}
}
@@ -71,8 +71,8 @@ struct RootView: View {
.navigationDestination(for: BotReference.self) { ref in ChatScreen(ref: ref) }
}
.tabLayer(app.tab == .bots)
- UsageTab()
- .tabLayer(app.tab == .usage)
+ StateTab()
+ .tabLayer(app.tab == .state)
}
.animation(Motion.reduced(Motion.fade, reduceMotion), value: app.tab)
.safeAreaInset(edge: .bottom, spacing: 0) {
@@ -81,7 +81,7 @@ struct RootView: View {
AccessBanners()
TabBar(selection: Bindable(app).tab, tabs: [
(id: AppTab.bots, title: "Bots", icon: "bubble.left.and.bubble.right.fill"),
- (id: AppTab.usage, title: "Usage", icon: "chart.bar.fill"),
+ (id: AppTab.state, title: "State", icon: "rectangle.stack.fill"),
])
.padding(.bottom, 4)
}
@@ -146,10 +146,51 @@ private struct ChatScreen: View {
}
}
+/// Where your bots show up outside the app: Widget, Live Activity and Dynamic Island,
+/// each designed and switched on here. Usage limits open from the header.
+private struct StateTab: View {
+ enum Surface: Hashable { case widget, liveActivity, island }
+
+ @Environment(AppStore.self) private var app
+ @Environment(\.accessibilityReduceMotion) private var reduceMotion
+ @State private var surface = Surface.widget
+
+ var body: some View {
+ VStack(spacing: 0) {
+ ScreenHeader {
+ EmptyView()
+ } title: {
+ Text("State").font(.body.weight(.semibold)).foregroundStyle(Palette.text)
+ } trailing: {
+ IconButton("Usage limits", systemImage: "chart.bar") { app.showUsage = true }
+ }
+ SegmentedChoice(selection: $surface, options: [
+ (.widget, "Widget"), (.liveActivity, "Live Activity"), (.island, "Dynamic Island"),
+ ])
+ .padding(.horizontal, 16)
+ .padding(.bottom, 8)
+ ZStack {
+ // Holds the gallery's pushes (Lock Screen widgets); no bar shows.
+ NavigationStack { WidgetGalleryView() }
+ .environment(\.stateSurfaceActive, app.tab == .state && surface == .widget)
+ .tabLayer(surface == .widget)
+ ActivityGalleryView(forms: [.lockScreen])
+ .tabLayer(surface == .liveActivity)
+ ActivityGalleryView(forms: [.compact, .minimal, .expanded])
+ .tabLayer(surface == .island)
+ }
+ .animation(Motion.reduced(Motion.fade, reduceMotion), value: surface)
+ }
+ .background(Palette.background)
+ .codyncSheet(isPresented: Bindable(app).showUsage) { UsageSheet() }
+ }
+}
+
/// Usage for one computer at a time: the last active one, which the Usage widget shows too.
-private struct UsageTab: View {
+private struct UsageSheet: View {
@Environment(AppStore.self) private var app
@Environment(AccountStore.self) private var accounts
+ @Environment(\.dismissModal) private var dismiss
/// Picked here; also becomes the computer the Usage widget shows.
@State private var picked: ComputerID?
@@ -157,7 +198,7 @@ private struct UsageTab: View {
let store = picked.flatMap(accounts.store(for:)) ?? app.currentStore
VStack(spacing: 0) {
ScreenHeader {
- EmptyView()
+ IconButton("Close", systemImage: "xmark") { dismiss() }
} title: {
Text("Usage").font(.body.weight(.semibold)).foregroundStyle(Palette.text)
} trailing: {
@@ -295,3 +336,8 @@ private struct AccessBanners: View {
.accessibilityElement(children: .contain)
}
}
+
+/// The marketplace sheet's item, so it keeps its computer while sliding away.
+private struct MarketplaceTarget: Identifiable {
+ let id: ComputerID
+}
diff --git a/apps/ios/Views/SettingsView.swift b/apps/ios/Views/SettingsView.swift
index 27eb5949..d402d71d 100644
--- a/apps/ios/Views/SettingsView.swift
+++ b/apps/ios/Views/SettingsView.swift
@@ -12,7 +12,6 @@ struct SettingsView: View {
@Environment(AccountStore.self) private var accounts
@Environment(\.dismissModal) private var dismissModal
@Environment(\.openURL) private var openURL
- @State private var page: Page?
@State private var notificationsAllowed: Bool?
@State private var addingComputer = false
@State private var confirmForget: Computer?
@@ -74,14 +73,6 @@ struct SettingsView: View {
}
CardSection {
- Button { page = .widgets } label: {
- LinkRow { Label("Widgets", systemImage: "square.grid.2x2") }
- }
- .buttonStyle(.plain)
- Button { page = .activity } label: {
- LinkRow { Label("Live Activity & Dynamic Island", systemImage: "waveform") }
- }
- .buttonStyle(.plain)
notificationsRow
}
@@ -133,12 +124,6 @@ struct SettingsView: View {
}
.refreshable { await accounts.refreshCloud() }
.page("Computers & settings", pushed: pushed)
- .navigationDestination(item: $page) { page in
- switch page {
- case .widgets: WidgetGalleryView(pushed: true)
- case .activity: ActivityGalleryView()
- }
- }
.task { await accounts.refreshCloud() }
.codyncSheet(isPresented: $addingComputer) {
PairingView(inModal: true)
@@ -170,7 +155,6 @@ struct SettingsView: View {
}
}
- private enum Page: Hashable { case widgets, activity }
private struct AccessTarget: Identifiable {
let computer: CloudComputer
diff --git a/apps/ios/Views/UsageView.swift b/apps/ios/Views/UsageView.swift
index 13d6840d..4e732f66 100644
--- a/apps/ios/Views/UsageView.swift
+++ b/apps/ios/Views/UsageView.swift
@@ -2,11 +2,10 @@ import CodyncKit
import CodyncUI
import SwiftUI
-/// The Usage tab: one card per provider, the tightest limit as a big bar, every limit listed below.
+/// Usage limits (opened from the State tab): one card per provider, the tightest limit as a big bar, every limit listed below.
struct UsageView: View {
@Environment(BotStore.self) private var model
@State private var collapsed: Set<String> = []
- @State private var widgetHelp = false
var body: some View {
ScrollView {
@@ -28,21 +27,11 @@ struct UsageView: View {
.frame(maxWidth: .infinity)
.padding(.top, 60)
}
- Button("Widgets & setup") { widgetHelp = true }
- .buttonStyle(.plain)
- .font(.subheadline.weight(.medium))
- .foregroundStyle(Palette.secondary)
- .padding(.top, 4)
}
.padding(16)
}
.background(Palette.background)
.refreshable { await model.refreshUsage() }
- .codyncSheet(isPresented: $widgetHelp) {
- // Holds the pushes inside the sheet (Lock Screen widgets, Live Activity); no bar shows.
- NavigationStack { WidgetGalleryView() }
- .environment(model)
- }
}
}
diff --git a/apps/ios/Views/WidgetGalleryView.swift b/apps/ios/Views/WidgetGalleryView.swift
index 54371c7f..fd036e5b 100644
--- a/apps/ios/Views/WidgetGalleryView.swift
+++ b/apps/ios/Views/WidgetGalleryView.swift
@@ -3,10 +3,8 @@ import CodyncUI
import SwiftUI
import WidgetKit
-/// The installed widgets and these previews share their rendering components.
+/// The State tab's Widget page. The installed widgets and these previews share their rendering components.
struct WidgetGalleryView: View {
- /// Pushed inside Computers & settings rather than opened as its own sheet.
- var pushed = false
@Environment(AccountStore.self) private var accounts
@Environment(\.accessibilityReduceMotion) private var reduceMotion
@State private var page: Page?
@@ -104,20 +102,13 @@ struct WidgetGalleryView: View {
Label("Lock Screen widgets", systemImage: "lock.rectangle").foregroundStyle(Palette.accent)
}
.buttonStyle(PressScale())
- Button { page = .activity } label: {
- Label("Live Activity & Dynamic Island", systemImage: "waveform").foregroundStyle(Palette.accent)
- }
- .buttonStyle(PressScale())
}
.font(.subheadline)
.frame(maxWidth: .infinity, alignment: .leading)
VStack(alignment: .leading, spacing: 12) {
sectionLabel("Add a widget")
- WidgetSetupAnimation()
- Text("Touch and hold the Home Screen · Edit · Add Widget · Codync")
- .font(.caption).foregroundStyle(Palette.secondary)
- .frame(maxWidth: .infinity, alignment: .center)
+ WidgetSetupDemo()
}
Text("Widgets show the latest report. Open Codync for live updates and approvals.")
.font(.caption2).foregroundStyle(Palette.tertiary)
@@ -127,18 +118,17 @@ struct WidgetGalleryView: View {
.frame(maxWidth: .infinity)
}
.background(Palette.background)
- .page("Widgets", pushed: pushed)
+ .hidesSystemNavigationBar()
.navigationDestination(item: $page) { page in
switch page {
case .lockScreen: LockWidgetGalleryView()
- case .activity: ActivityGalleryView()
}
}
.task { checkWidgets() }
.onChange(of: scenePhase) { _, phase in if phase == .active { checkWidgets() } }
}
- private enum Page: Hashable { case lockScreen, activity }
+ private enum Page: Hashable { case lockScreen }
private static let kinds: [(id: String, label: String)] = [("usage", "Provider usage"), ("bots", "Bots")]
private static let providers: [(id: String, label: String)] = [("claude", "Claude"), ("codex", "Codex")]
@@ -199,102 +189,3 @@ struct WidgetGalleryView: View {
}
}
}
-
-private struct WidgetSetupAnimation: View {
- private enum Stage: CaseIterable { case home, choose, placed }
- @Environment(\.accessibilityReduceMotion) private var reduceMotion
-
- var body: some View {
- Group {
- if reduceMotion {
- stageContent(.placed)
- } else {
- PhaseAnimator(Stage.allCases) { stage in
- stageContent(stage)
- } animation: { _ in .easeInOut(duration: 0.55) }
- }
- }
- }
-
- private func stageContent(_ stage: Stage) -> some View {
- ZStack {
- RoundedRectangle(cornerRadius: 24).fill(Palette.bubbleAgent)
- switch stage {
- case .home:
- VStack(spacing: 14) {
- Text("9:41").font(.system(size: 32, weight: .medium, design: .rounded)).foregroundStyle(Palette.text)
- HStack(spacing: 12) {
- appIcon("message.fill", "Messages", .green)
- appIcon("calendar", "Calendar", .red)
- appIcon("photo.fill", "Photos", .blue)
- appIcon("gearshape.fill", "Settings", .gray)
- }
- Label("Touch & hold", systemImage: "hand.tap.fill")
- .font(.caption.weight(.medium)).foregroundStyle(Palette.secondary)
- }
- .transition(.opacity.combined(with: .scale(scale: 0.96)))
- case .choose:
- VStack(spacing: 10) {
- HStack(spacing: 8) {
- Image(systemName: "magnifyingglass").foregroundStyle(Palette.tertiary)
- Text("Search widgets").foregroundStyle(Palette.secondary)
- Spacer()
- }
- .font(.caption).padding(10).background(Palette.surface, in: Capsule())
- HStack(spacing: 12) {
- CharacterAvatar(shape: "hex", color: "gray", size: 38)
- VStack(alignment: .leading, spacing: 2) {
- Text("Codync").font(.subheadline.weight(.semibold)).foregroundStyle(Palette.text)
- Text("Bots · Usage").font(.caption).foregroundStyle(Palette.secondary)
- }
- Spacer()
- Image(systemName: "plus.circle.fill").font(.title2).foregroundStyle(Palette.accent)
- }
- .padding(14).background(Palette.surface, in: RoundedRectangle(cornerRadius: 18))
- }
- .padding(20).transition(.opacity.combined(with: .move(edge: .trailing)))
- case .placed:
- HStack(spacing: 16) {
- VStack(alignment: .leading, spacing: 10) {
- Text("Codync").font(.caption.weight(.semibold)).foregroundStyle(Palette.text)
- HStack(spacing: 6) {
- CharacterAvatar(shape: "blob", color: "green", size: 24)
- VStack(alignment: .leading, spacing: 2) {
- Text("Reviewer").font(.system(size: 10, weight: .semibold))
- Text("Needs you").font(.system(size: 9)).foregroundStyle(Palette.warning)
- }
- Spacer(minLength: 0)
- }
- HStack(spacing: 6) {
- CharacterAvatar(shape: "hex", color: "orange", size: 24)
- VStack(alignment: .leading, spacing: 2) {
- Text("Builder").font(.system(size: 10, weight: .semibold))
- Text("Running tests").font(.system(size: 9)).foregroundStyle(Palette.secondary)
- }
- Spacer(minLength: 0)
- }
- }
- .padding(14).frame(width: 188, height: 142, alignment: .topLeading)
- .background(Palette.surface, in: RoundedRectangle(cornerRadius: 22))
- VStack(spacing: 10) {
- Image(systemName: "checkmark.circle.fill").font(.system(size: 32)).foregroundStyle(Palette.added)
- Text("Added").font(.caption.weight(.medium)).foregroundStyle(Palette.text)
- }
- .transition(.scale.combined(with: .opacity))
- }
- .transition(.opacity.combined(with: .scale(scale: 0.96)))
- }
- }
- .frame(height: 190)
- .padding(10)
- .accessibilityLabel("Widget setup preview, \(stage == .home ? "hold the Home Screen" : stage == .choose ? "choose Codync" : "widget added")")
- }
-
- private func appIcon(_ symbol: String, _ title: String, _ tint: Color) -> some View {
- VStack(spacing: 5) {
- Image(systemName: symbol).font(.system(size: 17, weight: .medium)).foregroundStyle(.white)
- .frame(width: 38, height: 38).background(tint, in: RoundedRectangle(cornerRadius: 11))
- Text(title).font(.system(size: 8)).foregroundStyle(Palette.secondary)
- }
- }
-}
diff --git a/apps/ios/Views/WidgetSetupDemo.swift b/apps/ios/Views/WidgetSetupDemo.swift
new file mode 100644
index 00000000..f8fb1d27
--- /dev/null
+++ b/apps/ios/Views/WidgetSetupDemo.swift
@@ -0,0 +1,435 @@
+import CodyncKit
+import CodyncUI
+import SwiftUI
+
+/// "Add a widget", acted out on a drawn iPhone: hold the Home Screen, Edit, Add Widget, find Codync,
+/// add it, Done. Every frame is a pure function of one clock, so it loops, pauses and scrubs.
+struct WidgetSetupDemo: View {
+ @Environment(\.accessibilityReduceMotion) private var reduceMotion
+ @Environment(\.stateSurfaceActive) private var active
+ @State private var playing = true
+ /// The clock reads `base` at `since`, then runs on while playing.
+ @State private var base: Double = 0
+ @State private var since = Date.now
+ @State private var scrubbing = false
+
+ static let duration: Double = 9.5
+
+ var body: some View {
+ let running = playing && !scrubbing && active
+ VStack(spacing: 14) {
+ TimelineView(.animation(paused: !running)) { context in
+ let t = time(at: context.date)
+ VStack(spacing: 14) {
+ DemoPhone(t: t)
+ .accessibilityElement(children: .ignore)
+ .accessibilityLabel("How to add the Codync widget")
+ .accessibilityValue(Self.step(at: t).text)
+ Text(Self.step(at: t).text)
+ .font(.footnote.weight(.medium))
+ .foregroundStyle(Palette.text)
+ .contentTransition(.opacity)
+ .animation(Motion.fade, value: Self.step(at: t).index)
+ .frame(maxWidth: .infinity)
+ .accessibilityHidden(true)
+ controls(t)
+ }
+ }
+ }
+ .onAppear { if reduceMotion { pause(at: 7.8) } }
+ // Hidden tabs keep their place: the clock stops with them and picks up where it was.
+ .onChange(of: active) { _, on in
+ if on {
+ since = .now
+ } else if playing, !scrubbing {
+ base = (base + Date.now.timeIntervalSince(since)).truncatingRemainder(dividingBy: Self.duration)
+ }
+ }
+ }
+
+ // MARK: clock
+
+ private func time(at date: Date) -> Double {
+ guard playing, !scrubbing, active else { return base }
+ return (base + date.timeIntervalSince(since)).truncatingRemainder(dividingBy: Self.duration)
+ }
+
+ private func pause(at t: Double) {
+ base = t
+ playing = false
+ }
+
+ private func controls(_ t: Double) -> some View {
+ HStack(spacing: 10) {
+ IconButton(playing ? "Pause" : "Play", systemImage: playing ? "pause.fill" : "play.fill") {
+ if playing {
+ pause(at: t)
+ } else {
+ base = t
+ since = .now
+ playing = true
+ }
+ }
+ GeometryReader { geo in
+ let x = geo.size.width * t / Self.duration
+ ZStack(alignment: .leading) {
+ Capsule().fill(Palette.accentDim).frame(height: 4)
+ Capsule().fill(Palette.accent).frame(width: x, height: 4)
+ Circle().fill(Palette.accent)
+ .frame(width: scrubbing ? 18 : 14, height: scrubbing ? 18 : 14)
+ .offset(x: x - (scrubbing ? 9 : 7))
+ .animation(Motion.press, value: scrubbing)
+ }
+ .frame(maxHeight: .infinity)
+ .contentShape(Rectangle())
+ .gesture(
+ DragGesture(minimumDistance: 0)
+ .onChanged { value in
+ scrubbing = true
+ base = min(max(value.location.x / geo.size.width, 0), 0.999) * Self.duration
+ }
+ .onEnded { _ in
+ since = .now
+ scrubbing = false
+ }
+ )
+ }
+ .frame(height: 32)
+ .accessibilityElement()
+ .accessibilityLabel("Step")
+ .accessibilityValue(Self.step(at: t).text)
+ .accessibilityAdjustableAction { direction in
+ let i = Self.step(at: t).index + (direction == .increment ? 1 : -1)
+ guard Self.steps.indices.contains(i) else { return }
+ pause(at: Self.steps[i].start + 0.05)
+ }
+ }
+ }
+
+ // MARK: script
+
+ struct Step {
+ let index: Int
+ let start: Double
+ let text: String
+ }
+
+ static let steps: [Step] = [
+ Step(index: 0, start: 0, text: "Touch and hold an empty spot on the Home Screen"),
+ Step(index: 1, start: 1.8, text: "Tap Edit, then Add Widget"),
+ Step(index: 2, start: 3.0, text: "Find Codync in the list"),
+ Step(index: 3, start: 4.5, text: "Tap Add Widget"),
+ Step(index: 4, start: 6.0, text: "Tap Done"),
+ ]
+
+ static func step(at t: Double) -> Step { steps.last { t >= $0.start } ?? steps[0] }
+}
+
+extension EnvironmentValues {
+ /// False while the State tab or its Widget page is hidden, so the demo stops drawing.
+ @Entry var stateSurfaceActive = true
+}
+
+// MARK: - The phone
+
+/// 0 before `a`, 1 after `b`, smooth in between.
+private func ramp(_ t: Double, _ a: Double, _ b: Double) -> Double {
+ let x = min(max((t - a) / (b - a), 0), 1)
+ return x * x * (3 - 2 * x)
+}
+
+/// Ease-out for things that arrive (sheets, pages).
+private func arrive(_ t: Double, _ a: Double, _ b: Double) -> Double {
+ let x = min(max((t - a) / (b - a), 0), 1)
+ return 1 - pow(1 - x, 3)
+}
+
+private struct DemoPhone: View {
+ let t: Double
+ @Environment(\.colorScheme) private var scheme
+
+ private static let size = CGSize(width: 184, height: 384)
+ private static let widgetHeight: CGFloat = 84
+
+ // Where the finger goes and when it taps (screen points).
+ private static let path: [(t: Double, p: CGPoint)] = [
+ (0.2, CGPoint(x: 150, y: 300)), (0.9, CGPoint(x: 128, y: 262)), (1.8, CGPoint(x: 128, y: 262)),
+ (2.2, CGPoint(x: 28, y: 40)), (2.45, CGPoint(x: 28, y: 40)), (2.8, CGPoint(x: 52, y: 66)),
+ (3.1, CGPoint(x: 52, y: 66)), (3.9, CGPoint(x: 92, y: 177)), (4.5, CGPoint(x: 92, y: 177)),
+ (5.1, CGPoint(x: 92, y: 334)), (6.2, CGPoint(x: 92, y: 334)), (6.8, CGPoint(x: 156, y: 40)),
+ (7.6, CGPoint(x: 156, y: 40)),
+ ]
+ private static let taps: [Double] = [2.35, 2.95, 4.3, 5.75, 7.2]
+
+ private var jiggle: Double { ramp(t, 1.45, 1.65) * (1 - ramp(t, 7.2, 7.35)) }
+ private var menu: Double { ramp(t, 2.4, 2.55) * (1 - ramp(t, 2.95, 3.1)) }
+ private var sheet: Double { arrive(t, 3.0, 3.5) * (1 - ramp(t, 5.8, 6.2)) }
+ private var detail: Double { arrive(t, 4.4, 4.85) }
+ private var placed: Double { arrive(t, 5.95, 6.4) }
+
+ var body: some View {
+ ZStack(alignment: .topLeading) {
+ wallpaper
+ homeScreen
+ editButtons
+ editMenu
+ gallery
+ finger
+ statusBar
+ }
+ .frame(width: Self.size.width, height: Self.size.height)
+ .clipShape(RoundedRectangle(cornerRadius: 30, style: .continuous))
+ .padding(5)
+ .background(Color.black, in: RoundedRectangle(cornerRadius: 35, style: .continuous))
+ .environment(\.colorScheme, .dark)
+ .frame(maxWidth: .infinity)
+ }
+
+ private var wallpaper: some View {
+ LinearGradient(colors: [Color(red: 0.16, green: 0.33, blue: 0.43), Color(red: 0.29, green: 0.53, blue: 0.47)],
+ startPoint: .top, endPoint: .bottom)
+ // The Home Screen dims behind the widget gallery.
+ .overlay(Color.black.opacity(0.35 * sheet))
+ }
+
+ private var statusBar: some View {
+ ZStack {
+ Capsule().fill(.black).frame(width: 54, height: 16)
+ HStack {
+ Text("9:41").font(.system(size: 9, weight: .semibold))
+ Spacer()
+ Image(systemName: "battery.75percent").font(.system(size: 9))
+ }
+ .foregroundStyle(.white)
+ .padding(.horizontal, 20)
+ }
+ .frame(width: Self.size.width, height: 30)
+ }
+
+ // MARK: home
+
+ private static let apps: [(String, Color)] = [
+ ("message.fill", .green), ("calendar", .red), ("photo.fill", .orange), ("camera.fill", .gray),
+ ("map.fill", .teal), ("clock.fill", .black), ("cloud.sun.fill", .blue), ("note.text", .yellow),
+ ("music.note", .pink), ("book.fill", .orange), ("heart.fill", .red), ("gearshape.fill", .gray),
+ ]
+ private static let dock: [(String, Color)] = [("phone.fill", .green), ("safari.fill", .blue), ("envelope.fill", .blue), ("music.note", .red)]
+
+ private var homeScreen: some View {
+ VStack(spacing: 0) {
+ BotsWidgetCard(bots: Bot.widgetPreview, wide: true)
+ .padding(12)
+ .frame(width: 164 / 0.62, height: Self.widgetHeight / 0.62)
+ .background(Color(white: 0.11), in: RoundedRectangle(cornerRadius: 22 / 0.62, style: .continuous))
+ .scaleEffect(0.62)
+ .frame(width: 164, height: Self.widgetHeight)
+ .scaleEffect(0.9 + 0.1 * placed, anchor: .top)
+ .rotationEffect(.degrees(jiggle * 1.2 * sin(t * 30 + 5)))
+ .opacity(placed)
+ // The icons below slide down as the widget takes its row.
+ .frame(height: (Self.widgetHeight + 14) * placed, alignment: .top)
+ LazyVGrid(columns: Array(repeating: GridItem(.fixed(34), spacing: 10), count: 4), spacing: 12) {
+ ForEach(Self.apps.indices, id: \.self) { i in
+ icon(Self.apps[i], index: i)
+ }
+ }
+ Spacer(minLength: 0)
+ HStack(spacing: 10) {
+ ForEach(Self.dock.indices, id: \.self) { i in icon(Self.dock[i], index: i + 20, label: false) }
+ }
+ .padding(9)
+ .background(.white.opacity(0.18), in: RoundedRectangle(cornerRadius: 22, style: .continuous))
+ .padding(.bottom, 8)
+ }
+ .padding(.top, 58)
+ .frame(width: Self.size.width, height: Self.size.height)
+ .scaleEffect(1 - 0.04 * sheet)
+ }
+
+ private func icon(_ app: (String, Color), index: Int, label: Bool = true) -> some View {
+ VStack(spacing: 3) {
+ Image(systemName: app.0)
+ .font(.system(size: 15, weight: .medium))
+ .foregroundStyle(.white)
+ .frame(width: 34, height: 34)
+ .background(app.1.gradient, in: RoundedRectangle(cornerRadius: 9, style: .continuous))
+ if label { Capsule().fill(.white.opacity(0.55)).frame(width: 20, height: 3) }
+ }
+ .rotationEffect(.degrees(jiggle * 2.4 * sin(t * 32 + Double(index) * 1.7)))
+ }
+
+ // MARK: edit mode
+
+ private var editButtons: some View {
+ HStack {
+ pill("Edit", highlighted: pressed(near: 2.35))
+ Spacer()
+ pill("Done", highlighted: pressed(near: 7.2))
+ }
+ .padding(.horizontal, 12)
+ .padding(.top, 30)
+ .frame(width: Self.size.width)
+ .opacity(jiggle)
+ }
+
+ private func pill(_ title: String, highlighted: Bool) -> some View {
+ Text(title)
+ .font(.system(size: 9, weight: .semibold))
+ .foregroundStyle(.white)
+ .padding(.horizontal, 9)
+ .frame(height: 20)
+ .background(.white.opacity(highlighted ? 0.45 : 0.25), in: Capsule())
+ }
+
+ private var editMenu: some View {
+ VStack(alignment: .leading, spacing: 0) {
+ menuRow("Add Widget", "plus.rectangle.on.rectangle", highlighted: pressed(near: 2.95))
+ Rectangle().fill(.white.opacity(0.12)).frame(height: 0.5)
+ menuRow("Customize", "paintbrush", highlighted: false)
+ }
+ .frame(width: 104)
+ .background(Color(white: 0.16), in: RoundedRectangle(cornerRadius: 12, style: .continuous))
+ .scaleEffect(0.6 + 0.4 * menu, anchor: .topLeading)
+ .opacity(menu)
+ .offset(x: 12, y: 54)
+ }
+
+ private func menuRow(_ title: String, _ symbol: String, highlighted: Bool) -> some View {
+ HStack(spacing: 6) {
+ Text(title).font(.system(size: 9, weight: .medium))
+ Spacer(minLength: 0)
+ Image(systemName: symbol).font(.system(size: 9))
+ }
+ .foregroundStyle(.white)
+ .padding(.horizontal, 10)
+ .frame(height: 24)
+ .background(.white.opacity(highlighted ? 0.12 : 0))
+ }
+
+ // MARK: widget gallery
+
+ private var gallery: some View {
+ ZStack(alignment: .topLeading) {
+ galleryList
+ .offset(x: -40 * detail)
+ .opacity(1 - detail)
+ galleryDetail
+ .offset(x: Self.size.width * (1 - detail))
+ }
+ .frame(width: Self.size.width, height: Self.size.height - 60, alignment: .top)
+ .background(Color(white: 0.12), in: UnevenRoundedRectangle(topLeadingRadius: 20, topTrailingRadius: 20, style: .continuous))
+ .clipShape(UnevenRoundedRectangle(topLeadingRadius: 20, topTrailingRadius: 20, style: .continuous))
+ .offset(y: 60 + (Self.size.height - 60) * (1 - sheet))
+ }
+
+ private var galleryList: some View {
+ VStack(spacing: 0) {
+ Capsule().fill(.white.opacity(0.3)).frame(width: 28, height: 3).padding(.vertical, 6)
+ HStack(spacing: 5) {
+ Image(systemName: "magnifyingglass")
+ Text("Search Widgets")
+ Spacer()
+ }
+ .font(.system(size: 9))
+ .foregroundStyle(.white.opacity(0.5))
+ .padding(.horizontal, 9)
+ .frame(height: 22)
+ .background(.white.opacity(0.1), in: Capsule())
+ .padding(.horizontal, 12)
+ .padding(.bottom, 10)
+ listRow("Batteries", Image(systemName: "battery.100percent"), tint: .green)
+ listRow("Calendar", Image(systemName: "calendar"), tint: .red)
+ listRow("Codync", nil, tint: .clear, highlighted: pressed(near: 4.3))
+ listRow("Fitness", Image(systemName: "figure.run"), tint: .orange)
+ listRow("Weather", Image(systemName: "cloud.sun.fill"), tint: .blue)
+ }
+ }
+
+ private func listRow(_ title: String, _ symbol: Image?, tint: Color, highlighted: Bool = false) -> some View {
+ HStack(spacing: 8) {
+ Group {
+ if let symbol {
+ symbol.font(.system(size: 10)).foregroundStyle(.white)
+ .frame(width: 20, height: 20)
+ .background(tint.gradient, in: RoundedRectangle(cornerRadius: 5, style: .continuous))
+ } else {
+ CharacterAvatar(shape: "hex", color: "gray", size: 20)
+ }
+ }
+ Text(title).font(.system(size: 10, weight: .medium)).foregroundStyle(.white)
+ Spacer()
+ Image(systemName: "chevron.right").font(.system(size: 7, weight: .semibold)).foregroundStyle(.white.opacity(0.35))
+ }
+ .padding(.horizontal, 12)
+ .frame(height: 28)
+ .background(.white.opacity(highlighted ? 0.1 : 0))
+ }
+
+ private var galleryDetail: some View {
+ VStack(spacing: 12) {
+ Capsule().fill(.white.opacity(0.3)).frame(width: 28, height: 3).padding(.top, 6)
+ HStack(spacing: 6) {
+ CharacterAvatar(shape: "hex", color: "gray", size: 18)
+ Text("Codync").font(.system(size: 11, weight: .semibold)).foregroundStyle(.white)
+ }
+ Text("See who needs you and who's still working.")
+ .font(.system(size: 8)).foregroundStyle(.white.opacity(0.6))
+ .multilineTextAlignment(.center)
+ .padding(.horizontal, 20)
+ BotsWidgetCard(bots: Bot.widgetPreview, wide: true)
+ .padding(12)
+ .frame(width: 164 / 0.62, height: Self.widgetHeight / 0.62)
+ .background(Color(white: 0.2), in: RoundedRectangle(cornerRadius: 22 / 0.62, style: .continuous))
+ .scaleEffect(0.62)
+ .frame(width: 164, height: Self.widgetHeight)
+ .padding(.top, 8)
+ HStack(spacing: 4) {
+ ForEach(0..<3) { i in Circle().fill(.white.opacity(i == 1 ? 0.9 : 0.3)).frame(width: 4, height: 4) }
+ }
+ Spacer()
+ Label("Add Widget", systemImage: "plus")
+ .font(.system(size: 10, weight: .semibold))
+ .foregroundStyle(.black)
+ .frame(width: 140, height: 28)
+ .background(.white.opacity(pressed(near: 5.75) ? 0.75 : 1), in: Capsule())
+ .scaleEffect(pressed(near: 5.75) ? 0.96 : 1)
+ .padding(.bottom, 26)
+ }
+ .frame(width: Self.size.width)
+ }
+
+ // MARK: finger
+
+ private func pressed(near tap: Double) -> Bool { abs(t - tap) < 0.12 }
+
+ private var fingerPoint: CGPoint {
+ let path = Self.path
+ guard let next = path.firstIndex(where: { $0.t > t }) else { return path.last!.p }
+ guard next > 0 else { return path[0].p }
+ let a = path[next - 1], b = path[next]
+ let k = ramp(t, a.t, b.t)
+ return CGPoint(x: a.p.x + (b.p.x - a.p.x) * k, y: a.p.y + (b.p.y - a.p.y) * k)
+ }
+
+ private var finger: some View {
+ let visible = ramp(t, 0.15, 0.4) * (1 - ramp(t, 7.5, 7.8))
+ let tapDepth = Self.taps.map { max(0, 1 - abs(t - $0) / 0.14) }.max() ?? 0
+ let holding = ramp(t, 0.95, 1.05) * (1 - ramp(t, 1.65, 1.75))
+ let hold = ramp(t, 1.0, 1.6)
+ let p = fingerPoint
+ return ZStack {
+ // The long press fills a ring before edit mode starts.
+ Circle().trim(from: 0, to: hold * holding)
+ .stroke(.white.opacity(0.8), style: StrokeStyle(lineWidth: 2, lineCap: .round))
+ .rotationEffect(.degrees(-90))
+ .frame(width: 34, height: 34)
+ Circle().fill(.white.opacity(0.35 + 0.25 * max(tapDepth, holding)))
+ .overlay(Circle().stroke(.white.opacity(0.85), lineWidth: 1.5))
+ .frame(width: 24, height: 24)
+ .scaleEffect(1 - 0.2 * max(tapDepth, holding))
+ }
+ .opacity(visible)
+ .position(p)
+ .frame(width: Self.size.width, height: Self.size.height, alignment: .topLeading)
+ }
+}
diff --git a/apps/macos/Views/ChatWindow.swift b/apps/macos/Views/ChatWindow.swift
index e239fa58..a5c79045 100644
--- a/apps/macos/Views/ChatWindow.swift
+++ b/apps/macos/Views/ChatWindow.swift
@@ -338,7 +338,7 @@ private struct ChatSplitView: View {
}
.codyncSheet(isPresented: Binding(get: { marketplace != nil }, set: { if !$0 { marketplace = nil } })) {
if let store = marketplace.flatMap(accounts.store(for:)) {
- MarketplaceView { marketplace = nil }
+ MarketplaceView()
.environment(store)
.frame(width: min(920, windowSize.width - 80), height: sheetHeight)
}
@@ -681,7 +681,7 @@ extension ChatSplitView {
let target = BotTarget(bot: bot, store: model)
return [
.init(title: bot.pinned ? "Unpin" : "Pin", icon: "pin", action: { model.setPinned(bot, !bot.pinned) }),
- .init(title: "Mark as Read", icon: "bell.badge", action: { model.markRead(bot.id) }),
+ .init(title: "Mark as Read", icon: "bell.badge", action: { model.markAllRead(bot.id) }),
.init(title: "Edit Profile…", icon: "square.and.pencil", divider: true,
action: { editing = EditTarget(request: EditorRequest(BotDraft(bot)), store: model) }),
.init(title: "Copy conversation ID", icon: "square.on.square", divider: true, action: {