Open source Grok Bot alternative, Bring your own agent and subscription: message Claude Code, Codex, Gemini CLI, Cursor, Copilot and 40+ AI agents as bots on your own computer, from iPhone, Mac, Windows, Linux or terminal. Agent-agnostic and free. Also a Muse and Dots alternative. Built in Rust.
Rust acpagent-client-protocolai-agentsai-assistantclaudeclaude-codecodexcoding-agentscursorgeminigemini-cligrok-bot-alternativeiosiphonelinuxmacosmcpopen-sourcerustself-hosted
feat(macos): refine Grok-style UI and add Clerk Google sign-in
leepokaie25c02e25c41
diff --git a/Codync.xcodeproj/project.pbxproj b/Codync.xcodeproj/project.pbxprojindex bec21107..5df13042 100644--- a/Codync.xcodeproj/project.pbxproj+++ b/Codync.xcodeproj/project.pbxproj@@ -9,7 +9,7 @@/* Begin PBXBuildFile section */03774684DC8344D81AFED53B /* ChatWindow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9A59E3A7670EAF57F2F4C9B9 /* ChatWindow.swift */; };1C2F108FE28961E13EF9AF61 /* ViewingBadge.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1F16B11B2920E9D05621AFE7 /* ViewingBadge.swift */; };- 24DF3CB466CC877FCB8BAED6 /* CodyncUI in Frameworks */ = {isa = PBXBuildFile; productRef = BEE30A9D5C73E5A151F34180 /* CodyncUI */; };+ 24DF3CB466CC877FCB8BAED6 /* CodyncKit in Frameworks */ = {isa = PBXBuildFile; productRef = 80868F96B9905FF52DCDFAE2 /* CodyncKit */; };25667EBFCCC64B96FDCE95A9 /* CodyncKit in Frameworks */ = {isa = PBXBuildFile; productRef = 59F5D19A417A7A50596902FA /* CodyncKit */; };25FCB36A2661833502357807 /* Session.swift in Sources */ = {isa = PBXBuildFile; fileRef = D0A657FB98BBE0D73807B263 /* Session.swift */; };2CC074683AE086D6C77CC1E8 /* WidgetKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B274A0195CB3B2409EA4C194 /* WidgetKit.framework */; };@@ -22,6 +22,7 @@513F59BF65DED5379AB950A1 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = D2C705F063CD20F5B3036BD4 /* Assets.xcassets */; };52CF04B855C6AAEC47B75B8F /* CodyncUI in Frameworks */ = {isa = PBXBuildFile; productRef = 06C9F37C6502131CAF0F145E /* CodyncUI */; };5F9AE9B8E7FF66F194162BDC /* ScreenHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = AB932B6C1849B8DF7CF7C2E3 /* ScreenHelper.swift */; };+ 6A15821964A5EE5AEBB0C420 /* ClerkConfig.plist in Resources */ = {isa = PBXBuildFile; fileRef = 19D41F16A62FEF37BE0AD1FC /* ClerkConfig.plist */; };826FEDA23997E436D632E579 /* PrivacyInfo.xcprivacy in Resources */ = {isa = PBXBuildFile; fileRef = 4CFB70DD8757C90695CDA211 /* PrivacyInfo.xcprivacy */; };8CD641A45F144BF41D703D2A /* CodyncMacApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2969919CCC8BC89F277C43A6 /* CodyncMacApp.swift */; };AA601649E43A5AF73DCF5B5E /* WebRTC in Frameworks */ = {isa = PBXBuildFile; productRef = 2D9748E611692583AFC5A152 /* WebRTC */; };@@ -29,8 +30,10 @@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 */; };+ B8B86B2B7F8D9EE8639A9E09 /* CodyncUI in Frameworks */ = {isa = PBXBuildFile; productRef = BEE30A9D5C73E5A151F34180 /* CodyncUI */; };C937F66F810AA238B73E8363 /* PrivacyInfo.xcprivacy in Resources */ = {isa = PBXBuildFile; fileRef = 4EDD440CC0624F03363AC1BA /* PrivacyInfo.xcprivacy */; };CC9F6FB8055C38D5D625F738 /* BotListView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C5E57711E223A292872322C5 /* BotListView.swift */; };+ D1374E0F041B7FEA4DFB33E7 /* AccountSession.swift in Sources */ = {isa = PBXBuildFile; fileRef = D1D2C6A291E95D607E9EB1E7 /* AccountSession.swift */; };D4AB92074A9C0D9C72B4080A /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = E8B808BC2A9AA0ECD666A454 /* Assets.xcassets */; };DEF7478AB86DB605F52905F5 /* SettingsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = DE4AE9A34F61B3D28E0C2550 /* SettingsView.swift */; };E430F9317B690366F62164DB /* RootView.swift in Sources */ = {isa = PBXBuildFile; fileRef = E1B79D48C1D6F90D53751B3F /* RootView.swift */; };@@ -40,7 +43,7 @@F0A26FABD15480810021C86A /* HostController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 93A9881C76B67297BE26D8FD /* HostController.swift */; };F191B13B972C72CB4253B449 /* CodyncWidgets.swift in Sources */ = {isa = PBXBuildFile; fileRef = 00F135A0B168269BD6C2A199 /* CodyncWidgets.swift */; };F842AE1C5ED96AF9A7F5D16C /* Widgets.appex in Embed Foundation Extensions */ = {isa = PBXBuildFile; fileRef = 6D734BEE7CD3F84677B0218B /* Widgets.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };- F93D9960F7C20B2E629C1736 /* CodyncKit in Frameworks */ = {isa = PBXBuildFile; productRef = 80868F96B9905FF52DCDFAE2 /* CodyncKit */; };+ F93D9960F7C20B2E629C1736 /* ClerkKit in Frameworks */ = {isa = PBXBuildFile; productRef = 7D524C19E9D41C0CF635A619 /* ClerkKit */; };/* End PBXBuildFile section *//* Begin PBXContainerItemProxy section */@@ -97,6 +100,7 @@/* Begin PBXFileReference section */00F135A0B168269BD6C2A199 /* CodyncWidgets.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CodyncWidgets.swift; sourceTree = "<group>"; };+ 19D41F16A62FEF37BE0AD1FC /* ClerkConfig.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist; path = ClerkConfig.plist; 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>"; };@@ -124,6 +128,7 @@C5E57711E223A292872322C5 /* BotListView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BotListView.swift; sourceTree = "<group>"; };CE4D28E8291EEB43E17B11FA /* Capture.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Capture.swift; sourceTree = "<group>"; };D0A657FB98BBE0D73807B263 /* Session.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Session.swift; sourceTree = "<group>"; };+ D1D2C6A291E95D607E9EB1E7 /* AccountSession.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AccountSession.swift; sourceTree = "<group>"; };D2C705F063CD20F5B3036BD4 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };D3831394C093AF3A4E504BC5 /* IconButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IconButton.swift; sourceTree = "<group>"; };DE4AE9A34F61B3D28E0C2550 /* SettingsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsView.swift; sourceTree = "<group>"; };@@ -138,8 +143,9 @@isa = PBXFrameworksBuildPhase;buildActionMask = 2147483647;files = (- F93D9960F7C20B2E629C1736 /* CodyncKit in Frameworks */,- 24DF3CB466CC877FCB8BAED6 /* CodyncUI in Frameworks */,+ F93D9960F7C20B2E629C1736 /* ClerkKit in Frameworks */,+ 24DF3CB466CC877FCB8BAED6 /* CodyncKit in Frameworks */,+ B8B86B2B7F8D9EE8639A9E09 /* CodyncUI in Frameworks */,);runOnlyForDeploymentPostprocessing = 0;};@@ -282,6 +288,7 @@BDFF077DDD37FEC8B83F2AED /* App */ = {isa = PBXGroup;children = (+ D1D2C6A291E95D607E9EB1E7 /* AccountSession.swift */,2969919CCC8BC89F277C43A6 /* CodyncMacApp.swift */,93A9881C76B67297BE26D8FD /* HostController.swift */,);@@ -338,6 +345,7 @@isa = PBXGroup;children = (E8B808BC2A9AA0ECD666A454 /* Assets.xcassets */,+ 19D41F16A62FEF37BE0AD1FC /* ClerkConfig.plist */,);path = Resources;sourceTree = "<group>";@@ -363,6 +371,7 @@);name = macOS;packageProductDependencies = (+ 7D524C19E9D41C0CF635A619 /* ClerkKit */,80868F96B9905FF52DCDFAE2 /* CodyncKit */,BEE30A9D5C73E5A151F34180 /* CodyncUI */,);@@ -470,6 +479,7 @@mainGroup = C9B7D3953422AE726DDC6347;minimizedProjectReferenceProxies = 1;packageReferences = (+ 2C830647014432C6F20C557C /* XCRemoteSwiftPackageReference "clerk-ios" */,979123F21565A4068586B502 /* XCRemoteSwiftPackageReference "WebRTC" */,0E2B25AB265C8FA83E7E1560 /* XCLocalSwiftPackageReference "kit" */,);@@ -491,6 +501,7 @@buildActionMask = 2147483647;files = (D4AB92074A9C0D9C72B4080A /* Assets.xcassets in Resources */,+ 6A15821964A5EE5AEBB0C420 /* ClerkConfig.plist in Resources */,);runOnlyForDeploymentPostprocessing = 0;};@@ -577,6 +588,7 @@isa = PBXSourcesBuildPhase;buildActionMask = 2147483647;files = (+ D1374E0F041B7FEA4DFB33E7 /* AccountSession.swift in Sources */,03774684DC8344D81AFED53B /* ChatWindow.swift in Sources */,8CD641A45F144BF41D703D2A /* CodyncMacApp.swift in Sources */,F0A26FABD15480810021C86A /* HostController.swift in Sources */,@@ -979,6 +991,14 @@/* End XCLocalSwiftPackageReference section *//* Begin XCRemoteSwiftPackageReference section */+ 2C830647014432C6F20C557C /* XCRemoteSwiftPackageReference "clerk-ios" */ = {+ isa = XCRemoteSwiftPackageReference;+ repositoryURL = "https://github.com/clerk/clerk-ios";+ requirement = {+ kind = exactVersion;+ version = 1.5.6;+ };+ };979123F21565A4068586B502 /* XCRemoteSwiftPackageReference "WebRTC" */ = {isa = XCRemoteSwiftPackageReference;repositoryURL = "https://github.com/stasel/WebRTC";@@ -1007,6 +1027,11 @@isa = XCSwiftPackageProductDependency;productName = CodyncKit;};+ 7D524C19E9D41C0CF635A619 /* ClerkKit */ = {+ isa = XCSwiftPackageProductDependency;+ package = 2C830647014432C6F20C557C /* XCRemoteSwiftPackageReference "clerk-ios" */;+ productName = ClerkKit;+ };80868F96B9905FF52DCDFAE2 /* CodyncKit */ = {isa = XCSwiftPackageProductDependency;productName = CodyncKit;diff --git a/apps/macos/App/AccountSession.swift b/apps/macos/App/AccountSession.swiftnew file mode 100644index 00000000..8b185aea--- /dev/null+++ b/apps/macos/App/AccountSession.swift@@ -0,0 +1,85 @@+import AuthenticationServices+import ClerkKit+import Foundation+import Observation++/// Clerk owns OAuth, session restoration and Keychain persistence. Host pairing+/// remains separate: an account session never grants access to a local host.+@MainActor+@Observable+final class AccountSession {+ private let clerk: Clerk?+ private(set) var isBusy = false+ var errorMessage: String?++ var isConfigured: Bool { clerk != nil }+ var isSignedIn: Bool { clerk?.user != nil }+ var email: String? { clerk?.user?.primaryEmailAddress?.emailAddress }+ var avatarURL: URL? {+ guard let image = clerk?.user?.imageUrl, let url = URL(string: image), url.scheme == "https" else { return nil }+ return url+ }++ init() {+ let environmentKey = ProcessInfo.processInfo.environment["CODYNC_CLERK_PUBLISHABLE_KEY"]+ let config = Bundle.main.url(forResource: "ClerkConfig", withExtension: "plist")+ .flatMap { try? Data(contentsOf: $0) }+ .flatMap { try? PropertyListDecoder().decode(Configuration.self, from: $0) }+ let key = (environmentKey ?? config?.publishableKey ?? "").trimmingCharacters(in: .whitespacesAndNewlines)+ guard key.hasPrefix("pk_test_") || key.hasPrefix("pk_live_") else {+ clerk = nil+ return+ }+ clerk = Clerk.configure(publishableKey: key, options: .init(+ telemetryEnabled: false,+ redirectConfig: .init(redirectUrl: "com.pokai.Codync://callback", callbackUrlScheme: "com.pokai.Codync")+ ))+ }++ func signIn() async {+ guard !isBusy else { return }+ guard let clerk else {+ errorMessage = "Sign-in setup isn't finished yet. You can continue using Codync on this Mac."+ return+ }+ isBusy = true+ errorMessage = nil+ defer { isBusy = false }+ do {+ // Start Google directly; Clerk transfers new users into sign-up.+ let result = try await clerk.auth.signInWithOAuth(provider: .google)+ switch result {+ case .signIn(let signIn):+ if signIn.status != .complete {+ errorMessage = "Google sign-in needs additional verification. Your account is not signed in yet."+ }+ case .signUp(let signUp):+ if signUp.status != .complete {+ errorMessage = "Google sign-up needs additional account information. Your account is not signed in yet."+ }+ }+ } catch let error as ASWebAuthenticationSessionError where error.code == .canceledLogin {+ return+ } catch is CancellationError {+ return+ } catch {+ errorMessage = "Couldn't sign in. Check your connection and try again."+ }+ }++ func signOut() async {+ guard !isBusy, let clerk else { return }+ isBusy = true+ errorMessage = nil+ defer { isBusy = false }+ do {+ try await clerk.auth.signOut()+ } catch {+ errorMessage = "Couldn't sign out. Check your connection and try again."+ }+ }++ private struct Configuration: Decodable {+ let publishableKey: String+ }+}diff --git a/apps/macos/App/CodyncMacApp.swift b/apps/macos/App/CodyncMacApp.swiftindex 0c674d79..7a52a263 100644--- a/apps/macos/App/CodyncMacApp.swift+++ b/apps/macos/App/CodyncMacApp.swift@@ -6,24 +6,32 @@ import SwiftUI@mainstruct CodyncMacApp: App {@State private var host = HostController()+ @State private var account = AccountSession()+ @Environment(\.openWindow) private var openWindowvar body: some Scene {MenuBarExtra {MenuView().environment(host)+ .environment(account).frame(width: 340)} label: {// The Codync mark; a dot joins it when a bot needs you.Image(host.needsAttention ? "MenuBarIconAlert" : "MenuBarIcon")- .task { host.start() }+ .task {+ host.start()+ openWindow(id: "chat")+ }}.menuBarExtraStyle(.window)Window("Codync", id: "chat") {ChatWindow().environment(host)+ .environment(account)}.defaultSize(width: 1100, height: 760)+ .windowStyle(.hiddenTitleBar)}}diff --git a/apps/macos/Resources/ClerkConfig.plist b/apps/macos/Resources/ClerkConfig.plistnew file mode 100644index 00000000..400a55f7--- /dev/null+++ b/apps/macos/Resources/ClerkConfig.plist@@ -0,0 +1,8 @@+<?xml version="1.0" encoding="UTF-8"?>+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">+<plist version="1.0">+<dict>+ <key>publishableKey</key>+ <string>pk_test_c3VubnktbW9sbHVzay04NjUxLmNsZXJrLmFjY291bnRzLmRldiQ</string>+</dict>+</plist>diff --git a/apps/macos/Views/ChatWindow.swift b/apps/macos/Views/ChatWindow.swiftindex a0253571..2a23144e 100644--- a/apps/macos/Views/ChatWindow.swift+++ b/apps/macos/Views/ChatWindow.swift@@ -22,17 +22,28 @@ struct ChatWindow: View {.frame(minWidth: 760, minHeight: 500).background(Palette.background).tint(Palette.accent)+ .ignoresSafeArea(.container, edges: .top)}}private struct ChatSplitView: View {@Environment(BotStore.self) private var model+ @Environment(AccountSession.self) private var account@State private var editing: EditorRequest?@State private var confirmDelete: Bot?@State private var composing = false- @State private var columns: NavigationSplitViewVisibility = .all+ @State private var previousSelection: String?+ @State private var hoveredBot: String?@State private var showPlugins = false+ @State private var search = ""+ @State private var showUsage = false+ @State private var showAccount = false+ @State private var hoveredFooter: String?+ @FocusState private var searchFocused: Bool+ @FocusState private var profileFocused: Bool@AppStorage("sidebarCompact") private var compact = false+ @AppStorage("desktopSidebarWidth") private var sidebarWidth = 296.0+ @State private var dragStartWidth: Double?@Environment(\.accessibilityReduceMotion) private var reduceMotion/// Sheets hang from the window's title bar; sized from it so they never run past its bottom edge.@State private var windowSize = CGSize(width: 1100, height: 760)@@ -40,84 +51,184 @@ private struct ChatSplitView: View {private var sheetHeight: CGFloat { max(420, windowSize.height - 76) }var body: some View {- @Bindable var model = model- NavigationSplitView(columnVisibility: $columns) {- List(selection: $model.selection) {- if compact {- ForEach(model.roster) { bot in- AvatarWithStatus(bot: bot, size: 40)- .frame(maxWidth: .infinity)- .padding(.vertical, 4)- .help(bot.name)+ HStack(spacing: 0) {+ VStack(spacing: 0) {+ HStack {+ Spacer()+ Button("New chat", systemImage: "plus", action: compose)+ .labelStyle(.iconOnly)+ .buttonStyle(.plain)+ .help("New chat (⌘N)")+ .keyboardShortcut("n")+ .disabled(model.connection != .online)+ }+ .padding(.leading, compact ? 0 : 80)+ .padding(.trailing, 18)+ .frame(height: 44)+ .opacity(compact ? 0 : 1)+ .allowsHitTesting(!compact)+ .accessibilityHidden(compact)+ ScrollView {+ LazyVStack(spacing: 2) {+ ForEach(filteredBots) { bot in+ Button {+ model.selection = bot.id+ } label: {+ BotRow(bot: bot, compact: compact)+ .padding(.horizontal, compact ? 0 : 8)+ .frame(maxWidth: .infinity, alignment: .leading)+ .background(+ model.selection == bot.id+ ? Palette.bubbleUser : hoveredBot == bot.id ? Palette.bubbleAgent : Color.clear,+ in: RoundedRectangle(cornerRadius: 10)+ )+ .contentShape(Rectangle())+ }+ .buttonStyle(.plain).accessibilityLabel(bot.name)- .tag(bot.id)+ .accessibilityAddTraits(model.selection == bot.id ? .isSelected : [])+ .help(bot.name)+ .onHover { hoveredBot = $0 ? bot.id : nil }.contextMenu { botMenu(bot) }+ }}- } else {- ConnectionBanner()- if !model.usage.providers.isEmpty {- UsageStrip(usage: model.usage)- .listRowSeparator(.hidden)- }- ForEach(model.roster) { bot in- BotRow(bot: bot)- .tag(bot.id)- .contextMenu { botMenu(bot) }+ .padding(.horizontal, 12)+ .padding(.top, 4)+ }+ .onMoveCommand { direction in+ guard direction == .up || direction == .down, !filteredBots.isEmpty else { return }+ let current = filteredBots.firstIndex { $0.id == model.selection } ?? -1+ let next = direction == .down ? min(current + 1, filteredBots.count - 1) : max(current - 1, 0)+ model.selection = filteredBots[next].id+ }+ .scrollContentBackground(.hidden)+ .background(Palette.surface)+ .safeAreaInset(edge: .top, spacing: 0) {+ if !compact {+ VStack(spacing: 0) {+ searchField+ ConnectionBanner().padding(.horizontal, 12)+ }+ .frame(width: sidebarWidth)+ .transition(.opacity)}}- }- .safeAreaInset(edge: .bottom) {- if compact { railActions }- }- .navigationSplitViewColumnWidth(min: 260, ideal: 300, max: 420)- .background(SidebarWidth(compact: compact, animated: !reduceMotion))- .navigationTitle(model.hostName)- .toolbar {- if !compact {- ToolbarItem {- Button("Marketplace", systemImage: "square.grid.2x2") { showPlugins = true }- .help("Marketplace: agents, connectors and skills")+ .overlay {+ if filteredBots.isEmpty && !compact {+ VStack(spacing: 8) {+ Text(search.isEmpty ? "No bots yet" : "No matching bots")+ .font(.system(size: 13, weight: .medium))+ Text(search.isEmpty ? "Use + to start a new chat." : "Try another name or message.")+ .font(.system(size: 12)).foregroundStyle(Palette.secondary)+ }+ .allowsHitTesting(false)}- ToolbarItem {- Button("New Message", systemImage: "square.and.pencil", action: compose)- .keyboardShortcut("n")- .disabled(model.connection != .online)+ }+ .safeAreaInset(edge: .bottom) {+ ZStack(alignment: .bottom) {+ if compact {+ railActions+ .frame(width: 76)+ .transition(.opacity)+ } else {+ sidebarFooter+ .frame(width: sidebarWidth)+ .transition(.opacity)+ }}- ToolbarItem { collapseButton }+ .frame(maxWidth: .infinity)}}- .toolbar(removing: .sidebarToggle)- } detail: {- if composing {- // The To: row takes the title bar's place instead of sitting under an empty one.- NewChatView { composing = false }+ .frame(width: compact ? 76 : sidebarWidth)+ .frame(maxHeight: .infinity)+ .background(Palette.surface)+ .clipped()+ sidebarDivider+ Group {+ if composing {+ // The To: row takes the title bar's place instead of sitting under an empty one.+ NewChatView {+ composing = false+ if model.selection == nil { model.selection = previousSelection }+ }.ignoresSafeArea(.container, edges: .top)- .toolbarBackground(.hidden, for: .windowToolbar)- } else if let id = model.selection, model.bots[id] != nil {- NavigationStack { ThreadView(botId: id) }- .id(id)- .transition(.asymmetric(insertion: .opacity, removal: .identity))- } else {- VStack(spacing: 14) {- HStack(spacing: -10) {- CharacterAvatar(shape: "blob", color: "blue", size: 60, mood: .working)- CharacterAvatar(shape: "squircle", color: "orange", size: 60)- CharacterAvatar(shape: "teardrop", color: "violet", size: 60, mood: .working)++ } else if let id = model.selection, model.bots[id] != nil {+ ThreadView(botId: id)+ .id(id)+ .transition(.asymmetric(insertion: .opacity, removal: .identity))+ } else {+ VStack(spacing: 14) {+ HStack(spacing: -10) {+ CharacterAvatar(shape: "blob", color: "blue", size: 60, mood: .working)+ CharacterAvatar(shape: "squircle", color: "orange", size: 60)+ CharacterAvatar(shape: "teardrop", color: "violet", size: 60, mood: .working)+ }+ Text("Your coding agents, as teammates.").font(.title2.weight(.semibold))+ Text("Pick a bot, or create one for each kind of work and point it at a project.")+ .foregroundStyle(Palette.secondary)+ .multilineTextAlignment(.center)+ .frame(maxWidth: 420)+ Button("New Bot", action: compose)+ .buttonStyle(.plain)+ .font(.body.weight(.semibold))+ .padding(.horizontal, 18)+ .padding(.vertical, 9)+ .background(Palette.accentFill, in: Capsule())+ .foregroundStyle(Palette.onAccent)}- Text("Your coding agents, as teammates.").font(.title2.weight(.semibold))- Text("Pick a bot, or create one for each kind of work and point it at a project.")- .foregroundStyle(Palette.secondary)- Button("New Bot") { composing = true }- .buttonStyle(.plain)- .font(.body.weight(.semibold))- .padding(.horizontal, 18)- .padding(.vertical, 9)- .background(Palette.accentFill, in: Capsule())- .foregroundStyle(Palette.onAccent)+ .padding(32)+ .frame(maxWidth: .infinity, maxHeight: .infinity)+ }+ }+ .frame(minWidth: 420, maxWidth: .infinity, maxHeight: .infinity)+ }+ // Animate mode changes from every entry point, while ordinary resizing tracks the pointer.+ .animation(Motion.reduced(Motion.layout, reduceMotion), value: compact)+ .coordinateSpace(name: "chat-window")+ .allowsHitTesting(!showAccount)+ .accessibilityHidden(showAccount)+ .overlay(alignment: .bottomLeading) {+ if showAccount {+ ZStack(alignment: .bottomLeading) {+ Color.black.opacity(0.001)+ .contentShape(Rectangle())+ .onTapGesture { dismissAccountMenu() }+ .accessibilityLabel("Dismiss account menu")+ .accessibilityAddTraits(.isButton)+ SidebarAccountPanel(+ name: localProfileName,+ signedIn: account.isSignedIn,+ email: account.email,+ busy: account.isBusy,+ errorMessage: account.errorMessage,+ onAuthenticate: {+ dismissAccountMenu()+ Task {+ if account.isSignedIn { await account.signOut() }+ else { await account.signIn() }+ if account.errorMessage != nil { showAccount = true }+ }+ },+ compact: compact,+ usage: model.usage.providers.flatMap(\.windows).map(\.percent).max(),+ onDismiss: dismissAccountMenu,+ onUsage: { dismissAccountMenu(); showUsage = true },+ onToggleSidebar: {+ dismissAccountMenu()+ compact.toggle()+ },+ onSearch: { dismissAccountMenu(); compact = false; searchFocused = true }+ )+ .frame(width: min(288, windowSize.width - 32))+ .padding(.leading, 16)+ .padding(.bottom, compact ? 68 : 64)+ .transition(.scale(scale: 0.97, anchor: .bottomLeading).combined(with: .opacity))}- .frame(maxWidth: .infinity, maxHeight: .infinity)}}+ .animation(Motion.reduced(Motion.fade, reduceMotion), value: showAccount)+ .ignoresSafeArea(.container, edges: .top).sheet(item: $editing) { request inNavigationStack { BotEditorView(draft: request.draft) }.frame(width: 520, height: min(680, sheetHeight))@@ -128,67 +239,266 @@ private struct ChatSplitView: View {}.frame(width: min(920, windowSize.width - 80), height: sheetHeight)}- .onGeometryChange(for: CGSize.self) { $0.size } action: { windowSize = $0 }+ .sheet(isPresented: $showUsage) {+ VStack(alignment: .leading, spacing: 20) {+ HStack {+ Text("Usage").font(.title2.bold())+ Spacer()+ Button("Done") { showUsage = false }.keyboardShortcut(.cancelAction)+ }+ if model.usage.providers.isEmpty {+ Text("No usage information yet.").foregroundStyle(Palette.secondary)+ } else {+ UsageStrip(usage: model.usage)+ }+ }+ .padding(24)+ .frame(width: 520)+ }+ .background {+ collapseButton.hidden()+ Button("Search bots") {+ compact = false+ searchFocused = true+ }+ .keyboardShortcut("f")+ .hidden()+ }+ .onGeometryChange(for: CGSize.self) {+ $0.size+ } action: {+ windowSize = $0+ sidebarWidth = min(sidebarWidth, max(260, $0.width - 420))+ }.hiddenWindowTitle().deleteBotConfirmation($confirmDelete).storeErrorAlert(model).animation(Motion.reduced(Motion.fade, reduceMotion), value: model.selection).animation(Motion.reduced(Motion.fade, reduceMotion), value: composing).onChange(of: model.selection) { _, id in if id != nil { composing = false } }- // Dragging the divider shut lands on the rail, not on nothing.- .onChange(of: columns) { _, visibility in- if visibility == .detailOnly {- compact = true- columns = .all+ #if DEBUG+ .onAppear {+ // Screenshot/UI checks: CODYNC_DEBUG_OPEN=compose | plugins | <bot name>+ let target = ProcessInfo.processInfo.environment["CODYNC_DEBUG_OPEN"]+ if target == "compose" {+ composing = true+ } else if target == "plugins" {+ showPlugins = true+ } else if let target, let bot = model.roster.first(where: { $0.name == target }) {+ model.selection = bot.id+ }+ }+ #endif+ }+}++extension ChatSplitView {+ fileprivate var sidebarDivider: some View {+ Rectangle()+ .fill(Palette.border)+ .frame(width: 1)+ .overlay {+ Color.clear.frame(width: 9)+ .contentShape(Rectangle())+ .gesture(+ DragGesture(minimumDistance: 0, coordinateSpace: .named("chat-window"))+ .onChanged { value in+ if dragStartWidth == nil { dragStartWidth = compact ? 76 : sidebarWidth }+ let proposed = (dragStartWidth ?? 296) + value.translation.width+ compact = proposed < 180+ if !compact {+ sidebarWidth = min(max(260, proposed), min(420, windowSize.width - 420))+ }+ }+ .onEnded { _ in dragStartWidth = nil }+ )+ .onHover { hovering in+ if hovering { NSCursor.resizeLeftRight.push() } else { NSCursor.pop() }+ }+ }+ .accessibilityLabel("Resize sidebar")+ .accessibilityValue("\(compact ? 76 : Int(sidebarWidth)) points")+ .accessibilityAdjustableAction { direction in+ switch direction {+ case .increment:+ if compact { compact = false }+ else { sidebarWidth = min(sidebarWidth + 20, min(420, windowSize.width - 420)) }+ case .decrement:+ if sidebarWidth <= 260 { compact = true }+ else { sidebarWidth = max(260, sidebarWidth - 20) }+ @unknown default: break+ }}+ }++ fileprivate var filteredBots: [Bot] {+ let query = search.trimmingCharacters(in: .whitespacesAndNewlines)+ if compact { return model.roster }+ return model.roster.filter {+ query.isEmpty || $0.name.localizedCaseInsensitiveContains(query)+ || ($0.lastMessage?.localizedCaseInsensitiveContains(query) ?? false)}- #if DEBUG- .onAppear {- // Screenshot/UI checks: CODYNC_DEBUG_OPEN=compose | plugins | <bot name>- let target = ProcessInfo.processInfo.environment["CODYNC_DEBUG_OPEN"]- if target == "compose" {- composing = true- } else if target == "plugins" {+ }++ fileprivate var searchField: some View {+ HStack(spacing: 6) {+ Image(systemName: "magnifyingglass").foregroundStyle(Palette.secondary)+ TextField("Search", text: $search)+ .textFieldStyle(.plain)+ .focused($searchFocused)+ .accessibilityLabel("Search bots")+ .onKeyPress(.escape) {+ search = ""+ searchFocused = false+ return .handled+ }+ if !search.isEmpty {+ Button("Clear search", systemImage: "xmark.circle.fill") { search = "" }+ .labelStyle(.iconOnly).buttonStyle(.plain)+ .foregroundStyle(Palette.secondary)+ }+ }+ .font(.system(size: 13))+ .padding(.horizontal, 9)+ .frame(height: 32)+ .background(Palette.bubbleAgent, in: RoundedRectangle(cornerRadius: 8))+ .overlay(RoundedRectangle(cornerRadius: 8).stroke(Palette.border, lineWidth: 0.5))+ .padding(.horizontal, 12)+ .padding(.top, 4)+ .padding(.bottom, 8)+ .background(Palette.surface)+ }++ private var localProfileName: String { "Account" }++ private var profileAvatar: some View {+ Group {+ if let url = account.avatarURL {+ AsyncImage(url: url) { image in image.resizable().scaledToFill() } placeholder: { profilePlaceholder }+ } else { profilePlaceholder }+ }+ .frame(width: 32, height: 32)+ .background(Palette.bubbleUser, in: Circle())+ .clipShape(Circle())+ .overlay(Circle().strokeBorder(Palette.text.opacity(0.08), lineWidth: 0.5))+ .overlay { if account.isBusy { ProgressView().controlSize(.small) } }+ .accessibilityHidden(true)+ }++ private var profilePlaceholder: some View {+ Image(systemName: "person.fill")+ .font(.system(size: 15, weight: .medium))+ .foregroundStyle(Palette.secondary)+ .frame(maxWidth: .infinity, maxHeight: .infinity)+ }++ fileprivate var sidebarFooter: some View {+ VStack(spacing: 4) {+ Button {showPlugins = true- } else if let target, let bot = model.roster.first(where: { $0.name == target }) {- model.selection = bot.id+ } label: {+ HStack(spacing: 10) {+ Image(systemName: "square.grid.2x2")+ .font(.system(size: 14, weight: .regular))+ .frame(width: 30, height: 30)+ .background(Palette.text.opacity(0.025), in: Circle())+ .overlay(Circle().strokeBorder(Palette.text.opacity(0.1), lineWidth: 0.5))+ Text("Marketplace")+ Spacer(minLength: 0)+ }+ .padding(.horizontal, 8)+ .frame(height: 42)+ .background(hoveredFooter == "marketplace" ? Palette.bubbleAgent : .clear,+ in: RoundedRectangle(cornerRadius: 10))+ .contentShape(Rectangle())+ }+ .onHover { hoveredFooter = $0 ? "marketplace" : nil }++ Button {+ showAccount.toggle()+ } label: {+ HStack(spacing: 10) {+ profileAvatar+ Text(localProfileName)+ .lineLimit(1)+ .truncationMode(.tail)+ Spacer(minLength: 8)++ }+ .padding(.horizontal, 8)+ .frame(height: 44)+ .background(hoveredFooter == "account" || showAccount ? Palette.bubbleAgent : .clear,+ in: RoundedRectangle(cornerRadius: 10))+ .contentShape(Rectangle())}+ .onHover { hoveredFooter = $0 ? "account" : nil }+ .accessibilityLabel("Open account menu for \(localProfileName)")+ .help("Account menu")+ .focused($profileFocused)}- #endif+ .buttonStyle(.plain)+ .font(.system(size: 13, weight: .medium))+ .foregroundStyle(Palette.text)+ .padding(.horizontal, 12)+ .padding(.top, 6)+ .padding(.bottom, 10)+ .background(Palette.surface)}-}-private extension ChatSplitView {- func compose() {+ fileprivate func compose() {+ if !composing { previousSelection = model.selection }model.selection = nilcomposing = true}- var collapseButton: some View {+ fileprivate var collapseButton: some View {Button(compact ? "Expand Sidebar" : "Collapse Sidebar", systemImage: "sidebar.left") {- withAnimation(Motion.reduced(Motion.morph, reduceMotion)) { compact.toggle() }+ compact.toggle()}.keyboardShortcut("s", modifiers: [.control, .command]).help(compact ? "Expand sidebar" : "Collapse sidebar")}- /// Rail footer: what the toolbar holds when the sidebar is wide.- var railActions: some View {- VStack(spacing: 6) {- Button("New Message", systemImage: "plus", action: compose)+ private func dismissAccountMenu() {+ showAccount = false+ profileFocused = true+ }++ /// The compact rail keeps the same destinations as the expanded footer.+ fileprivate var railActions: some View {+ VStack(spacing: 4) {+ Button("New chat", systemImage: "plus", action: compose).disabled(model.connection != .online)- .help("New message")+ .help("New chat")+ .labelStyle(.iconOnly)+ .buttonStyle(IconButtonStyle(size: 36))Button("Marketplace", systemImage: "square.grid.2x2") { showPlugins = true }- .help("Marketplace: agents, connectors and skills")- collapseButton+ .help("Marketplace")+ .labelStyle(.iconOnly)+ .buttonStyle(IconButtonStyle(size: 36))+ Button { showAccount.toggle() } label: {+ profileAvatar+ .overlay(alignment: .bottomTrailing) {+ Circle().fill(model.connection == .online ? Palette.switchOn : Palette.tertiary)+ .frame(width: 7, height: 7)+ .overlay(Circle().stroke(Palette.surface, lineWidth: 1.5))+ }+ .frame(width: 44, height: 44)+ .background(showAccount ? Palette.bubbleAgent : .clear, in: RoundedRectangle(cornerRadius: 12))+ .contentShape(Rectangle())+ }+ .buttonStyle(.plain)+ .focused($profileFocused)+ .accessibilityLabel("Open account menu for \(localProfileName)")+ .help(localProfileName)+ .padding(.top, 4)}- .labelStyle(.iconOnly)- .buttonStyle(IconButtonStyle(size: 34)).frame(maxWidth: .infinity)- .padding(.vertical, 12)+ .padding(.top, 8)+ .padding(.bottom, 10)}- @ViewBuilder func botMenu(_ bot: Bot) -> some View {+ @ViewBuilder fileprivate func botMenu(_ bot: Bot) -> some View {Button(bot.pinned ? "Unpin" : "Pin") { model.setPinned(bot, !bot.pinned) }Button("Edit Profile…") { editing = EditorRequest(BotDraft(bot)) }Button("Mark as Read") { model.markRead(bot.id) }@@ -198,65 +508,178 @@ private extension ChatSplitView {}}-/// Collapsed = an avatar rail (Grok Bot), never a hidden sidebar. SwiftUI applies-/// `navigationSplitViewColumnWidth` only once, so the rail resizes the AppKit split item directly.-private struct SidebarWidth: NSViewRepresentable {+extension View {+ @ViewBuilder fileprivate func hiddenWindowTitle() -> some View {+ if #available(macOS 15.0, *) { toolbar(removing: .title) } else { self }+ }+}++/// Window-local floating surface: no NSMenu, NSPopover or system menu styling.+private struct SidebarAccountPanel: View {+ let name: String+ let signedIn: Bool+ let email: String?+ let busy: Bool+ let errorMessage: String?+ let onAuthenticate: () -> Voidlet compact: Bool- let animated: Bool+ let usage: Double?+ let onDismiss: () -> Void+ let onUsage: () -> Void+ let onToggleSidebar: () -> Void+ let onSearch: () -> Void+ @State private var page = "main"+ @State private var highlighted = 0+ @FocusState private var menuFocused: Bool++ private struct Item {+ let title: String+ let icon: String+ var detail: String? = nil+ var chevron = false+ var disabled = false+ let action: () -> Void+ }++ private var items: [Item] {+ switch page {+ case "support":+ return [+ Item(title: "Support", icon: "chevron.left", action: { navigate("main") }),+ Item(title: "Help & documentation", icon: "book", chevron: true,+ action: { open("https://github.com/leepokai/codync#readme") }),+ Item(title: "Report an issue", icon: "bubble.left", chevron: true,+ action: { open("https://github.com/leepokai/codync/issues") })+ ]+ case "settings":+ return [+ Item(title: "Settings", icon: "chevron.left", action: { navigate("main") }),+ Item(title: compact ? "Expand sidebar" : "Collapse sidebar", icon: "sidebar.left", action: onToggleSidebar),+ Item(title: "Search bots", icon: "magnifyingglass", detail: "⌘F", action: onSearch)+ ]+ default:+ return [+ Item(title: "Usage", icon: "gauge.with.dots.needle.33percent",+ detail: usage.map { "\(Int($0.rounded()))%" }, chevron: true, action: onUsage),+ Item(title: "Get Codync for mobile", icon: "iphone", action: { open("https://apps.apple.com/app/id6760984418") }),+ Item(title: "Support", icon: "book.closed", chevron: true, action: { navigate("support") }),+ Item(title: "Settings", icon: "gearshape", action: { navigate("settings") }),+ Item(title: compact ? "Expand sidebar" : "Collapse sidebar", icon: "sidebar.left", action: onToggleSidebar),+ Item(title: busy ? "Please wait…" : signedIn ? "Log out" : "Continue with Google",+ icon: signedIn ? "rectangle.portrait.and.arrow.right" : "person.crop.circle.badge.plus",+ disabled: busy, action: onAuthenticate)+ ]+ }+ }- final class Coordinator {- var applied = false- var glide: Task<Void, Never>?+ var body: some View {+ menuContent+ .padding(7)+ .background(Color(light: 0xFAFAFA, dark: 0x1B1B1B), in: RoundedRectangle(cornerRadius: 18))+ .overlay(RoundedRectangle(cornerRadius: 18).strokeBorder(Palette.text.opacity(0.15), lineWidth: 0.5))+ .shadow(color: .black.opacity(0.25), radius: 20, x: 0, y: 8)+ .accessibilityElement(children: .contain)+ .accessibilityLabel("Account menu")+ .focusable()+ .focused($menuFocused)+ .focusEffectDisabled()+ .onKeyPress(.escape) { onDismiss(); return .handled }+ .onKeyPress(.downArrow) { moveFocus(1); return .handled }+ .onKeyPress(.upArrow) { moveFocus(-1); return .handled }+ .onKeyPress(.tab, phases: .down) { press in moveFocus(press.modifiers.contains(.shift) ? -1 : 1); return .handled }+ .onKeyPress(.return) { activate(); return .handled }+ .onKeyPress(.space) { activate(); return .handled }+ .task { await Task.yield(); menuFocused = true }}- func makeCoordinator() -> Coordinator { Coordinator() }-- func makeNSView(context: Context) -> NSView { NSView() }-- func updateNSView(_ view: NSView, context: Context) {- let compact = compact- // Only on a toggle, so a width the user dragged to stays put.- guard compact != context.coordinator.applied else { return }- context.coordinator.applied = compact- // The view joins the window's split view only after the first layout pass.- DispatchQueue.main.async {- var ancestor = view.superview- while let current = ancestor, !(current is NSSplitView) { ancestor = current.superview }- guard let split = ancestor as? NSSplitView,- let controller = split.delegate as? NSSplitViewController,- let item = controller.splitViewItems.first else { return }- let width: CGFloat = compact ? 76 : 300- item.canCollapse = false- let from = item.viewController.view.frame.width- // Let the divider travel the whole way; the final limits apply once it lands.- item.minimumThickness = min(from, width, compact ? 76 : 260)- item.maximumThickness = max(from, width, compact ? 76 : 420)- let land = {- item.minimumThickness = compact ? 76 : 260- item.maximumThickness = compact ? 76 : 420- split.setPosition(width, ofDividerAt: 0)+ private var menuContent: some View {+ VStack(spacing: 2) {+ ForEach(items.indices, id: \.self) { index in+ menuRow(items[index], index: index)}- context.coordinator.glide?.cancel()- guard animated, abs(from - width) > 1 else { return land() }- context.coordinator.glide = Task { @MainActor in- let start = ContinuousClock.now- let duration = Duration.milliseconds(260) // Grok's rail cluster: width .26s cubic-bezier(.22,1,.36,1)- var t = 0.0- while t < 1 {- try? await Task.sleep(for: .milliseconds(8))- if Task.isCancelled { return }- t = min(1, (ContinuousClock.now - start) / duration)- split.setPosition(from + (width - from) * Motion.morphCurve.value(at: t), ofDividerAt: 0)- }- land()+ if let errorMessage, page == "main" {+ Text(errorMessage).font(.system(size: 12)).foregroundStyle(Palette.warning)+ .fixedSize(horizontal: false, vertical: true)+ .padding(.horizontal, 12).padding(.vertical, 8)}}}++ @ViewBuilder private func menuRow(_ item: Item, index: Int) -> some View {+ if index == (page == "main" ? 4 : 1) { divider }+ if page == "main" && index == 5 { accountIdentity }+ AccountPanelRow(title: item.title, icon: item.icon, detail: item.detail,+ chevron: item.chevron, keyboardFocused: highlighted == index, action: item.action)+ .disabled(item.disabled)+ .onHover { if $0 { highlighted = index } }+ }++ private var accountIdentity: some View {+ HStack(spacing: 10) {+ Image(systemName: "person.crop.circle").font(.system(size: 18))+ Text(email ?? name).font(.system(size: 12)).lineLimit(1)+ Spacer()+ if !signedIn { Text("Not signed in").font(.system(size: 11)) }+ }+ .foregroundStyle(Palette.secondary)+ .padding(.horizontal, 12)+ .frame(height: 38)+ }++ private var divider: some View {+ Rectangle().fill(Palette.text.opacity(0.13)).frame(height: 0.5)+ .padding(.horizontal, 10).padding(.vertical, 7)+ }++ private func navigate(_ destination: String) {+ page = destination+ highlighted = 0+ menuFocused = true+ }++ private func moveFocus(_ delta: Int) {+ highlighted = (highlighted + delta + items.count) % items.count+ }++ private func activate() {+ guard items.indices.contains(highlighted), !items[highlighted].disabled else { return }+ items[highlighted].action()+ }++ private func open(_ string: String) {+ guard let url = URL(string: string) else { return }+ onDismiss()+ NSWorkspace.shared.open(url)+ }}-private extension View {- /// The toolbar shows icons only, no "Codync" title next to them.- @ViewBuilder func hiddenWindowTitle() -> some View {- if #available(macOS 15.0, *) { toolbar(removing: .title) } else { self }+private struct AccountPanelRow: View {+ let title: String+ let icon: String+ let detail: String?+ let chevron: Bool+ let keyboardFocused: Bool+ let action: () -> Void+ @State private var hovered = false++ var body: some View {+ Button(action: action) {+ HStack(spacing: 10) {+ Image(systemName: icon).font(.system(size: 16, weight: .regular)).frame(width: 20)+ Text(title).font(.system(size: 14)).lineLimit(1)+ Spacer(minLength: 8)+ if let detail { Text(detail).font(.system(size: 13)).foregroundStyle(Palette.secondary) }+ if chevron { Image(systemName: "chevron.right").font(.system(size: 11)).foregroundStyle(Palette.secondary) }+ }+ .foregroundStyle(Palette.text)+ .padding(.horizontal, 12)+ .frame(height: 40)+ .background(hovered || keyboardFocused ? Palette.text.opacity(0.08) : .clear,+ in: RoundedRectangle(cornerRadius: 10))+ .contentShape(Rectangle())+ }+ .buttonStyle(.plain)+ .focusEffectDisabled()+ .onHover { hovered = $0 }}}diff --git a/docs/clerk-macos.md b/docs/clerk-macos.mdnew file mode 100644index 00000000..5d98881e--- /dev/null+++ b/docs/clerk-macos.md@@ -0,0 +1,55 @@+# macOS account authentication++The macOS app uses the official ClerkKit SDK (1.5.6). The sidebar's account+panel is a custom SwiftUI overlay, independent of the system authentication browser.+The footer displays **Account**, never the Mac user's local name.++## Dashboard setup++1. Create a Clerk application named **Codync** and enable Google sign-in.+2. Enable the Native API under **Native applications**.+3. Register the native application for team `7FUM8A8H72` and bundle identifier+ `com.pokai.Codync`, following Clerk's Apple/native configuration instructions.+4. Allow the native callback `com.pokai.Codync://callback` where Clerk's dashboard+ requests allowed redirect URLs.+5. Copy only the **publishable key** into+ `apps/macos/Resources/ClerkConfig.plist` (`publishableKey`). A development+ launch can override it with `CODYNC_CLERK_PUBLISHABLE_KEY`.++The checked-in public configuration uses the Codync development instance+`sunny-mollusk-8651.clerk.accounts.dev`. Native API is enabled, the Apple app+is registered, and `com.pokai.Codync://callback` is allowlisted. Google and+email sign-in are enabled. Production deployment needs its own Clerk instance+and publishable key. Never put a Clerk secret key in the Mac bundle or this file.++## Flow++`AccountSession` configures Clerk once. Continue with Google calls `clerk.auth.signInWithOAuth(provider: .google)`+directly, without the Clerk Account Portal intermediary. Google authorization+uses the SDK's system browser authentication session. Clerk handles new-user+transfer, callback validation, session restoration and Keychain storage.+Incomplete sign-in/sign-up results are reported explicitly; additional MFA or+required profile fields need a separate continuation UI if enabled later. Browser cancellation is silent;+network failures leave the user in the custom account menu with a retryable+error. Log out calls Clerk's sign-out API.++The custom account menu displays the authenticated email and avatar when+available. A Clerk session does not replace the local host pairing token,+authorize remote host access, upload conversations, or migrate local data.++## Verification++- Build the macOS scheme after `xcodegen generate`.+- Open the account menu from either sidebar layout; test arrows, Return, Escape+ and clicking outside the panel.+- Sign in with a test Google user, verify the avatar/email, restart the app and+ verify session restoration, then log out and verify the anonymous state.+- Cancel the browser flow and verify no error; retry with networking unavailable+ and verify that the application stays usable.++Dashboard creation and the end-to-end Google flow require the user's browser+consent; compilation alone does not verify those steps.++References:+- https://clerk.com/docs/ios/getting-started/quickstart+- https://github.com/clerk/clerk-iosdiff --git a/kit/Sources/CodyncUI/Bots/BotEditorView.swift b/kit/Sources/CodyncUI/Bots/BotEditorView.swiftindex 7437c280..a17b1245 100644--- a/kit/Sources/CodyncUI/Bots/BotEditorView.swift+++ b/kit/Sources/CodyncUI/Bots/BotEditorView.swift@@ -99,15 +99,32 @@ struct BotSettingsForm: View {let error: String?@Environment(BotStore.self) private var model@State private var pickingFolder = false+ @State private var pickingAvatar = falsevar body: some View {ScrollView {VStack(alignment: .leading, spacing: 18) {VStack(spacing: 16) {+ #if os(macOS)+ Button { pickingAvatar.toggle() } label: {+ CharacterAvatar(shape: draft.avatarShape, color: draft.avatarColor, size: 80)+ .padding(18)+ .background(Palette.bubbleAgent, in: RoundedRectangle(cornerRadius: 20))+ }+ .buttonStyle(.plain)+ .accessibilityLabel("Edit Bot avatar")+ .help("Edit Bot avatar")+ .popover(isPresented: $pickingAvatar) {+ AvatarPicker(shape: $draft.avatarShape, color: $draft.avatarColor)+ .padding(20)+ .frame(width: 300)+ }+ #elseCharacterAvatar(shape: draft.avatarShape, color: draft.avatarColor, size: 96).padding(18).background(Palette.bubbleAgent, in: RoundedRectangle(cornerRadius: 24, style: .continuous))AvatarPicker(shape: $draft.avatarShape, color: $draft.avatarColor)+ #endif}.frame(maxWidth: .infinity)diff --git a/kit/Sources/CodyncUI/Bots/BotRow.swift b/kit/Sources/CodyncUI/Bots/BotRow.swiftindex d7a84387..f956ef73 100644--- a/kit/Sources/CodyncUI/Bots/BotRow.swift+++ b/kit/Sources/CodyncUI/Bots/BotRow.swift@@ -3,14 +3,18 @@ import SwiftUIpublic struct BotRow: View {let bot: Bot+ let compact: Bool@Environment(BotStore.self) private var model- public init(bot: Bot) { self.bot = bot }+ public init(bot: Bot, compact: Bool = false) {+ self.bot = bot+ self.compact = compact+ }// A Mac sidebar row is denser than a phone row (Grok Bot's desktop sidebar).#if os(macOS)private let avatar: CGFloat = 36- private let rowPadding: CGFloat = 4+ private let rowPadding: CGFloat = 8private let lineSpacing: CGFloat = 1#elseprivate let avatar: CGFloat = 46@@ -19,7 +23,7 @@ public struct BotRow: View {#endifpublic var body: some View {- HStack(spacing: 12) {+ HStack(spacing: compact ? 0 : 12) {AvatarWithStatus(bot: bot, size: avatar)VStack(alignment: .leading, spacing: lineSpacing) {HStack(alignment: .firstTextBaseline) {@@ -37,9 +41,11 @@ public struct BotRow: View {.accessibilityLabel("Using the computer")}Spacer(minLength: 8)+ #if os(iOS)Text(RelativeTime.day(Date(milliseconds: bot.lastAt))).font(.subheadline).foregroundStyle(bot.unread > 0 ? Palette.text : Palette.tertiary)+ #endif}HStack(alignment: .firstTextBaseline, spacing: 6) {preview@@ -54,7 +60,12 @@ public struct BotRow: View {}}}+ .frame(width: compact ? 0 : nil, alignment: .leading)+ .opacity(compact ? 0 : 1)+ .clipped()+ .accessibilityHidden(compact)}+ .frame(maxWidth: .infinity, alignment: compact ? .center : .leading).padding(.vertical, rowPadding).contentShape(Rectangle()).accessibilityElement(children: .combine)diff --git a/kit/Sources/CodyncUI/Bots/NewChatView.swift b/kit/Sources/CodyncUI/Bots/NewChatView.swiftindex 04ec935a..1ca6d3c6 100644--- a/kit/Sources/CodyncUI/Bots/NewChatView.swift+++ b/kit/Sources/CodyncUI/Bots/NewChatView.swift@@ -83,7 +83,10 @@ public struct NewChatView: View {.padding(16)}.background(Palette.background)- .onAppear { toFocused = true }+ .task {+ await Task.yield()+ toFocused = true+ }}private func pick(_ bot: Bot) {diff --git a/kit/Sources/CodyncUI/Platform.swift b/kit/Sources/CodyncUI/Platform.swiftindex d12ac05c..05265914 100644--- a/kit/Sources/CodyncUI/Platform.swift+++ b/kit/Sources/CodyncUI/Platform.swift@@ -60,7 +60,7 @@ extension View {/// hairline border and a soft shadow (as in Grok Bot's desktop app).@ViewBuilder func composerSurface(in shape: some Shape) -> some View {#if os(macOS)- background(Palette.background, in: shape)+ background(Palette.bubbleUser, in: shape).overlay(shape.stroke(Palette.border)).shadow(color: .black.opacity(0.06), radius: 10, y: 2)#elsediff --git a/kit/Sources/CodyncUI/Thread/ChatRows.swift b/kit/Sources/CodyncUI/Thread/ChatRows.swiftindex d785dc20..2bb5d4ea 100644--- a/kit/Sources/CodyncUI/Thread/ChatRows.swift+++ b/kit/Sources/CodyncUI/Thread/ChatRows.swift@@ -42,7 +42,11 @@ struct UserBubble: View {case "cancelled":Text("Not sent — stopped").font(.caption2).foregroundStyle(Palette.tertiary)default:- EmptyView()+ #if os(macOS)+ Text(entry.date, style: .time).font(.system(size: 10)).foregroundStyle(Palette.tertiary)+ #else+ EmptyView()+ #endif}}}@@ -52,16 +56,28 @@ struct AgentBubble: View {let openTrace: () -> Voidvar body: some View {- MarkdownText(entry.data.text ?? "")- .padding(.horizontal, 16)- .padding(.vertical, 10)- .background(Palette.bubbleAgent, in: RoundedRectangle(cornerRadius: 22, style: .continuous))- .contextMenu {- Button("Copy", systemImage: "doc.on.doc") { Pasteboard.copy(entry.data.text) }- Button("Show what it did", systemImage: "list.bullet.rectangle", action: openTrace)- }- .frame(maxWidth: .infinity, alignment: .leading)+ VStack(alignment: .leading, spacing: 4) {+ MarkdownText(entry.data.text ?? "")+ .padding(.horizontal, 16)+ .padding(.vertical, 10)+ .background(Palette.bubbleAgent, in: RoundedRectangle(cornerRadius: 22, style: .continuous))+ .contextMenu {+ Button("Copy", systemImage: "doc.on.doc") { Pasteboard.copy(entry.data.text) }+ Button("Show what it did", systemImage: "list.bullet.rectangle", action: openTrace)+ }+ #if os(macOS)+ Text(entry.date, style: .time)+ .font(.system(size: 10))+ .foregroundStyle(Palette.tertiary)+ .padding(.leading, 12)+ #endif+ }+ .frame(maxWidth: .infinity, alignment: .leading)+ #if os(macOS)+ .padding(.trailing, 64)+ #else.padding(.trailing, 40)+ #endif}}diff --git a/kit/Sources/CodyncUI/Thread/ThreadView.swift b/kit/Sources/CodyncUI/Thread/ThreadView.swiftindex 9874c03d..e2be90e0 100644--- a/kit/Sources/CodyncUI/Thread/ThreadView.swift+++ b/kit/Sources/CodyncUI/Thread/ThreadView.swift@@ -15,12 +15,40 @@ public struct ThreadView: View {@State private var confirmNewSession = false@State private var confirmDelete: Bot?/// Desktop: the bot's settings as an inspector beside the chat.- @State private var showSettings = false+ @State private var showSettings = true+ @State private var editingDetails = false+ @State private var availableWidth: CGFloat = 800+ @State private var compactDetails = false@FocusState private var composerFocused: Boolprivate var bot: Bot? { model.bots[botId] }public var body: some View {+ #if os(macOS)+ GeometryReader { geometry in+ HStack(spacing: 0) {+ conversation.frame(maxWidth: .infinity)+ if showSettings && geometry.size.width >= 680 {+ Rectangle().fill(Palette.border).frame(width: 1)+ detailsPanel.frame(width: 320)+ }+ }+ .onGeometryChange(for: CGFloat.self) {+ $0.size.width+ } action: {+ availableWidth = $0+ }+ }+ .ignoresSafeArea(.container, edges: .top)+ .sheet(isPresented: $compactDetails) {+ detailsPanel.frame(width: 340, height: 600)+ }+ #else+ conversation+ #endif+ }++ @ViewBuilder private var conversation: some View {let thread = model.thread(botId)let items = ChatItem.build(thread)ScrollViewReader { proxy in@@ -47,8 +75,12 @@ public struct ThreadView: View {}Color.clear.frame(height: 8).id("bottom")}- .padding(.horizontal, 14)+ .padding(.horizontal, 16).padding(.top, 8)+ #if os(macOS)+ .frame(maxWidth: 820)+ .frame(maxWidth: .infinity)+ #endif}.defaultScrollAnchor(.bottom).scrollDismissesKeyboard(.interactively)@@ -63,43 +95,66 @@ public struct ThreadView: View {.background(Palette.background).safeAreaInset(edge: .bottom) {VStack(spacing: 6) {- ConnectionBanner().padding(.horizontal, 14)+ #if os(iOS)+ ConnectionBanner().padding(.horizontal, 14)+ #endifcomposer}}.inlineNavigationTitle().toolbar {- ToolbarItem(placement: .principal) { header }#if os(iOS)- if model.screen?.agentBot == botId {- ToolbarItem(placement: .primaryAction) {- // The bot is operating the computer: watch it live (and take over from there).- Button("Watch the screen", systemImage: "cursorarrow.motionlines") {- model.screenRequest = ScreenRequest(watching: botId)+ ToolbarItem(placement: .principal) { header }+ #endif+ #if os(iOS)+ if model.screen?.agentBot == botId {+ ToolbarItem(placement: .primaryAction) {+ // The bot is operating the computer: watch it live (and take over from there).+ Button("Watch the screen", systemImage: "cursorarrow.motionlines") {+ model.screenRequest = ScreenRequest(watching: botId)+ }+ .symbolEffect(.pulse, options: .repeating)+ .tint(Palette.accent)}- .symbolEffect(.pulse, options: .repeating)- .tint(Palette.accent)}- }#endif- ToolbarItem(placement: .primaryAction) { menu }- #if os(macOS)- ToolbarItem(placement: .primaryAction) {- Button("Settings", systemImage: "sidebar.right") { showSettings.toggle() }- .help("Bot settings")- }+ #if os(iOS)+ ToolbarItem(placement: .primaryAction) { menu }#endif}#if os(macOS)- .inspector(isPresented: $showSettings) {- BotSettingsPanel(botId: botId)- .inspectorColumnWidth(min: 300, ideal: 360, max: 460)- }- .onAppear { if bot?.name == "New Bot", model.thread(botId).isEmpty { showSettings = true } }+ .safeAreaInset(edge: .top, spacing: 0) {+ VStack(spacing: 0) {+ HStack {+ header+ Spacer(minLength: 8)+ menu+ if !showSettings || availableWidth < 680 {+ Button("Conversation details", systemImage: "chevron.right.2") { toggleDetails() }+ .labelStyle(.iconOnly)+ .help("Show conversation details")+ .keyboardShortcut("i", modifiers: [.command, .option])+ }+ }+ .buttonStyle(.plain)+ .foregroundStyle(Palette.secondary)+ .padding(.horizontal, 16)+ .frame(height: 44)+ Divider().overlay(Palette.border)+ ConnectionBanner().padding(.horizontal, 16).padding(.top, model.isOffline ? 8 : 0)+ }+ .background(Palette.background)+ }+ .onAppear {+ if bot?.name == "New Bot", model.thread(botId).isEmpty { editingDetails = true }+ }#endif.onAppear { model.markRead(botId) }.sheet(isPresented: $showTrace) {NavigationStack { TraceView(botId: botId) }+ #if os(macOS)+ .frame(width: 620, height: 560)+ #endif.presentationDetents([.medium, .large]).presentationDragIndicator(.visible)}@@ -118,14 +173,14 @@ public struct ThreadView: View {@ViewBuilder private func row(_ item: ChatItem) -> some View {switch item.kind {- case let .separator(date):+ case .separator(let date):Text(RelativeTime.separator(date)).font(.footnote).foregroundStyle(Palette.tertiary).frame(maxWidth: .infinity).padding(.top, 18).padding(.bottom, 6)- case let .entry(e, groupStart):+ case .entry(let e, let groupStart):switch e.kind {case "user":UserBubble(entry: e, botWorking: bot?.isWorking == true)@@ -147,39 +202,153 @@ public struct ThreadView: View {// MARK: chromeprivate var header: some View {- // A pill with the bot and its name; the avatar itself shows working / needs you.- HStack(spacing: 8) {- if let bot { CharacterAvatar(bot: bot, size: 26) }- Text(bot?.name ?? "")- .font(.body.weight(.semibold))- .foregroundStyle(Palette.text)- .lineLimit(1)- }- .padding(.leading, 8)- .padding(.trailing, 16)- .padding(.vertical, 6)- .glass(in: Capsule())- .onTapGesture {+ Button {#if os(macOS)- showSettings.toggle()+ toggleDetails()#else- if let bot { editing = EditorRequest(BotDraft(bot)) }+ if let bot { editing = EditorRequest(BotDraft(bot)) }+ #endif+ } label: {+ HStack(spacing: 7) {+ if let bot { CharacterAvatar(bot: bot, size: 22) }+ Text(bot?.name ?? "")+ .font(.system(size: 13, weight: .semibold))+ .foregroundStyle(Palette.text)+ .lineLimit(1)+ }+ #if os(iOS)+ .padding(.horizontal, 12)+ .padding(.vertical, 6)+ .glass(in: Capsule())#endif}+ .buttonStyle(.plain)+ .accessibilityLabel("View conversation details")+ .help("View conversation details")}+ #if os(macOS)+ private func toggleDetails() {+ if availableWidth < 680 { compactDetails.toggle() } else { showSettings.toggle() }+ }++ private var detailsPanel: some View {+ VStack(spacing: 0) {+ HStack(spacing: 10) {+ if editingDetails {+ Button("Back to details", systemImage: "chevron.left") { editingDetails = false }+ .labelStyle(.iconOnly)+ Text("Settings").font(.system(size: 13, weight: .semibold))+ Spacer()+ } else {+ Spacer()+ Button("Bot settings", systemImage: "gearshape") { editingDetails = true }+ .labelStyle(.iconOnly)+ .help("Bot settings")+ }+ Button("Close details", systemImage: "chevron.right.2") {+ showSettings = false+ compactDetails = false+ }+ .labelStyle(.iconOnly)+ .help("Close details")+ .keyboardShortcut("i", modifiers: [.command, .option])+ }+ .buttonStyle(.plain)+ .foregroundStyle(Palette.secondary)+ .padding(.horizontal, 16)+ .frame(height: 44)+ if editingDetails {+ BotSettingsPanel(botId: botId)+ } else {+ ScrollView {+ VStack(alignment: .leading, spacing: 22) {+ VStack(spacing: 12) {+ VStack(spacing: 12) {+ Image(systemName: "desktopcomputer")+ .font(.system(size: 32, weight: .light))+ Text(computerStatus)+ .font(.system(size: 12))+ .multilineTextAlignment(.center)+ .foregroundStyle(Palette.secondary)+ }+ .frame(maxWidth: .infinity)+ .frame(height: 164)+ .background(Palette.surface, in: RoundedRectangle(cornerRadius: 8))+ .overlay(RoundedRectangle(cornerRadius: 8).stroke(Palette.border, lineWidth: 0.5))+ Text(model.hostName)+ .font(.caption)+ .foregroundStyle(Palette.tertiary)+ }+ if let bot {+ VStack(alignment: .leading, spacing: 8) {+ Text("Agent").font(.system(size: 13, weight: .semibold))+ Text(model.backendName(bot.backend)).foregroundStyle(Palette.secondary)+ Text(bot.cwd)+ .font(.system(size: 12))+ .foregroundStyle(Palette.secondary)+ .textSelection(.enabled)+ if !bot.description.isEmpty {+ Text(bot.description).foregroundStyle(Palette.secondary)+ }+ }+ .font(.system(size: 13))+ }+ Button {+ showTrace = true+ } label: {+ HStack {+ Label("Full conversation", systemImage: "list.bullet.rectangle")+ Spacer()+ Image(systemName: "chevron.right").font(.caption2)+ }+ .font(.system(size: 13))+ .padding(12)+ .background(Palette.surface, in: RoundedRectangle(cornerRadius: 8))+ }+ .buttonStyle(.plain)+ }+ .padding(.horizontal, 16)+ .padding(.bottom, 16)+ }+ }+ }+ .background(Palette.background)+ }++ private var computerStatus: String {+ guard !model.isOffline else { return "Computer is offline" }+ guard let screen = model.screen, screen.enabled else { return "Remote screen is off" }+ guard screen.connected else { return "Connecting to computer…" }+ guard screen.capture else { return "Screen recording permission needed" }+ return screen.agentBot == botId ? "This bot is using your Mac" : "Ready · View this Mac from your iPhone"+ }+ #endif+private var menu: some View {Menu {Button("Full conversation", systemImage: "list.bullet.rectangle") { showTrace = true }if let bot {- Button("Edit profile", systemImage: "pencil") { editing = EditorRequest(BotDraft(bot)) }+ Button("Edit profile", systemImage: "pencil") {+ #if os(macOS)+ editingDetails = true+ showSettings = true+ if availableWidth < 680 { compactDetails = true }+ #else+ editing = EditorRequest(BotDraft(bot))+ #endif+ }Button(bot.pinned ? "Unpin" : "Pin", systemImage: "pin") { model.setPinned(bot, !bot.pinned) }}Button("New session", systemImage: "arrow.counterclockwise") { confirmNewSession = true }Divider()Button("Delete bot", systemImage: "trash", role: .destructive) { confirmDelete = bot }} label: {+ #if os(macOS)+ Image(systemName: "square.and.arrow.up")+ #elseImage(systemName: "ellipsis.circle")+ #endif}}@@ -203,7 +372,9 @@ public struct ThreadView: View {.padding(.vertical, 10).sendOnReturn(submit)if working && draft.isEmpty {- Button { model.stop(botId) } label: {+ Button {+ model.stop(botId)+ } label: {Image(systemName: "stop.fill").font(.system(size: 12, weight: .bold)).frame(width: 34, height: 34)@@ -231,9 +402,13 @@ public struct ThreadView: View {.padding(.trailing, 6).padding(.vertical, 6).composerSurface(in: RoundedRectangle(cornerRadius: 24, style: .continuous))- .padding(.horizontal, 12)+ .padding(.horizontal, 16).padding(.top, 6)- .padding(.bottom, 10)+ .padding(.bottom, 16)+ #if os(macOS)+ .frame(maxWidth: 820)+ .frame(maxWidth: .infinity)+ #endif}}diff --git a/project.yml b/project.ymlindex 6800df2f..e02f8434 100644--- a/project.yml+++ b/project.yml@@ -7,6 +7,9 @@ options:macOS: "14.0"createIntermediateGroups: truepackages:+ Clerk:+ url: https://github.com/clerk/clerk-ios+ exactVersion: 1.5.6CodyncKit:path: kitWebRTC:@@ -37,6 +40,8 @@ targets:destination: wrappersubpath: Contents/Library/LaunchAgentsdependencies:+ - package: Clerk+ product: ClerkKit- package: CodyncKitproduct: CodyncKit- package: CodyncKit