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(kit): add Apple sign-in on iOS and macOS

leepokaif99a9fcc387c
diff --git a/apps/Codync.xcodeproj/project.pbxproj b/apps/Codync.xcodeproj/project.pbxproj
index baca7a69..7c522aed 100644
--- a/apps/Codync.xcodeproj/project.pbxproj
+++ b/apps/Codync.xcodeproj/project.pbxproj
@@ -32,6 +32,7 @@
719EABCBBAC0A973D729363A /* PairingView.swift in Sources */ = {isa = PBXBuildFile; fileRef = ECD0B4EA4BBA2BB2826C4362 /* PairingView.swift */; };
72A907055F1AAEF8F10EAD72 /* NotificationService.appex in Embed Foundation Extensions */ = {isa = PBXBuildFile; fileRef = 7B7E845BA1B8696B266CF578 /* NotificationService.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
75C4B7F344DF1E52A1EADEFC /* Capture.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE63C84233B14A2D63640EAA /* Capture.swift */; };
+ 76E77CC8A2B7C74213512FAB /* SignInButtons.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9AD0BD16672E128A4F26272B /* SignInButtons.swift */; };
7C20764DC05D499075BC5E8C /* CodyncApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = A65FE0504B741D0B44DB2516 /* CodyncApp.swift */; };
8157F3E9CFB390CBCB1A9F9A /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 4815867922559696EDCA47FD /* Assets.xcassets */; };
8517F8FC5AFAFF1527369829 /* NotificationService.swift in Sources */ = {isa = PBXBuildFile; fileRef = F6932F782C1B87C9608359A6 /* NotificationService.swift */; };
@@ -154,6 +155,7 @@
8BA06CEE98A7CDED62678522 /* Input.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Input.swift; sourceTree = "<group>"; };
8CC3E47D480A5F15CA95C504 /* HostLink.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HostLink.swift; sourceTree = "<group>"; };
991A0FD3EAAD4B446F3BF14E /* macOS.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = macOS.app; sourceTree = BUILT_PRODUCTS_DIR; };
+ 9AD0BD16672E128A4F26272B /* SignInButtons.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SignInButtons.swift; sourceTree = "<group>"; };
9F70117FA3097C5A6F28C89B /* ComputersView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ComputersView.swift; sourceTree = "<group>"; };
A65FE0504B741D0B44DB2516 /* CodyncApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CodyncApp.swift; sourceTree = "<group>"; };
AD18A04CD014230F1B7B0535 /* PrivacyInfo.xcprivacy */ = {isa = PBXFileReference; path = PrivacyInfo.xcprivacy; sourceTree = "<group>"; };
@@ -318,6 +320,7 @@
ECD0B4EA4BBA2BB2826C4362 /* PairingView.swift */,
B6E13F8EA6C7B0DA4D899FEE /* RootView.swift */,
0A87B0091DAF0E4807D62017 /* SettingsView.swift */,
+ 9AD0BD16672E128A4F26272B /* SignInButtons.swift */,
CFEBE2E6A9D0AF0A0D89FFE7 /* UsageView.swift */,
D57A7C09154869DD84BACE19 /* WelcomeView.swift */,
5B22589689593E0089118FDB /* WidgetGalleryView.swift */,
@@ -729,6 +732,7 @@
89CA3972915769DBA315876F /* Push.swift in Sources */,
0631979397E0D6822747E03A /* RootView.swift in Sources */,
BF77DD7946621D8818EDAB9B /* SettingsView.swift in Sources */,
+ 76E77CC8A2B7C74213512FAB /* SignInButtons.swift in Sources */,
684F7F77EECBA0BD95BDD658 /* UsageView.swift in Sources */,
501377099B6CF42761B230CB /* WelcomeView.swift in Sources */,
B3554D38F39916698E961A37 /* WidgetGalleryView.swift in Sources */,
diff --git a/apps/ios/Resources/iOS.entitlements b/apps/ios/Resources/iOS.entitlements
index 80ae842f..6c20193e 100644
--- a/apps/ios/Resources/iOS.entitlements
+++ b/apps/ios/Resources/iOS.entitlements
@@ -2,6 +2,10 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
+ <key>com.apple.developer.applesignin</key>
+ <array>
+ <string>Default</string>
+ </array>
<key>aps-environment</key>
<string>development</string>
<key>com.apple.developer.usernotifications.communication</key>
diff --git a/apps/ios/Views/AccountSwitcherView.swift b/apps/ios/Views/AccountSwitcherView.swift
index 42911f5b..027cbbef 100644
--- a/apps/ios/Views/AccountSwitcherView.swift
+++ b/apps/ios/Views/AccountSwitcherView.swift
@@ -26,6 +26,7 @@ struct AccountSwitcherView: View {
@State private var showSettings = false
@State private var confirmSignOut = false
@State private var pairing = false
+ @State private var addingAccount = false
var body: some View {
CardForm {
@@ -49,6 +50,7 @@ struct AccountSwitcherView: View {
if account.isSignedIn, account.supportsMultipleAccounts || account.accounts.count > 1 {
switcher
+ if addingAccount { SignInButtons().transition(.opacity.combined(with: .move(edge: .top))) }
}
CardSection {
@@ -85,6 +87,7 @@ struct AccountSwitcherView: View {
}
.animation(Motion.layout, value: account.userID)
.animation(Motion.fade, value: account.errorMessage)
+ .onChange(of: account.userID) { _, _ in withAnimation(Motion.layout) { addingAccount = false } }
.hidesSystemNavigationBar()
.navigationDestination(isPresented: $showSettings) { SettingsView(pushed: true) }
.codyncSheet(isPresented: $pairing) { PairingView(inModal: true) }
@@ -94,20 +97,11 @@ struct AccountSwitcherView: View {
}
}
- /// The big picture: your face and address when signed in, the Google button when not.
+ /// The big picture: your face and address when signed in, both login options when not.
@ViewBuilder private var profile: some View {
if account.isSignedIn {
VStack(spacing: 10) {
AccountAvatar(url: account.avatarURL, email: account.email, size: 76)
- .overlay(alignment: .bottomTrailing) {
- Image("google")
- .resizable()
- .frame(width: 16, height: 16)
- .padding(5)
- .background(Palette.background, in: Circle())
- .offset(x: 2, y: 2)
- .accessibilityHidden(true)
- }
Text(account.email ?? "")
.font(.subheadline.weight(.medium))
.foregroundStyle(Palette.text)
@@ -125,7 +119,7 @@ struct AccountSwitcherView: View {
}
.accessibilityHidden(true)
if account.isConfigured {
- GoogleSignInButton()
+ SignInButtons()
} else {
Label("QR pairing only in this build", systemImage: "qrcode")
.font(.footnote)
@@ -153,7 +147,7 @@ struct AccountSwitcherView: View {
.accessibilityAddTraits(current ? .isSelected : [])
}
if account.supportsMultipleAccounts {
- Button { Task { await account.signIn() } } label: {
+ Button { withAnimation(Motion.layout) { addingAccount.toggle() } } label: {
Image(systemName: "plus")
.font(.system(size: 18, weight: .medium))
.foregroundStyle(Palette.secondary)
@@ -162,7 +156,7 @@ struct AccountSwitcherView: View {
}
.buttonStyle(PressScale())
.disabled(account.isBusy)
- .accessibilityLabel("Add Google account")
+ .accessibilityLabel("Add account")
}
}
.padding(.horizontal, 4)
diff --git a/apps/ios/Views/PairingView.swift b/apps/ios/Views/PairingView.swift
index 9389c86c..1c5b1c3f 100644
--- a/apps/ios/Views/PairingView.swift
+++ b/apps/ios/Views/PairingView.swift
@@ -231,8 +231,8 @@ private struct ScanPage: View {
.transition(.opacity)
}
- // The other way in: computers on your Google account show up and ask for access themselves.
- if account.isConfigured && !account.isSignedIn { GoogleSignInButton() }
+ // Signed in, account computers show up and ask for access themselves.
+ if account.isConfigured && !account.isSignedIn { SignInButtons() }
// How it connects is never a choice here: every paired computer gets every route.
VStack(alignment: .leading, spacing: 8) {
diff --git a/apps/ios/Views/SignInButtons.swift b/apps/ios/Views/SignInButtons.swift
new file mode 100644
index 00000000..3d844642
--- /dev/null
+++ b/apps/ios/Views/SignInButtons.swift
@@ -0,0 +1,29 @@
+import CodyncKit
+import CodyncUI
+import SwiftUI
+
+/// Equal access to both account providers at every sign-in entry point.
+struct SignInButtons: View {
+ @Environment(AccountSession.self) private var account
+
+ var body: some View {
+ VStack(spacing: 10) {
+ Button { Task { await account.signIn(provider: .apple) } } label: {
+ ZStack {
+ HStack(spacing: 10) {
+ Image(systemName: "apple.logo").font(.system(size: 20))
+ Text("Continue with Apple")
+ }
+ .opacity(account.isBusy ? 0 : 1)
+ if account.isBusy { Spinner(size: 18) }
+ }
+ .font(.headline)
+ .frame(maxWidth: .infinity, minHeight: 50)
+ }
+ .buttonStyle(.primary)
+ .disabled(account.isBusy)
+ .animation(Motion.fade, value: account.isBusy)
+ GoogleSignInButton()
+ }
+ }
+}
diff --git a/apps/ios/Views/WelcomeView.swift b/apps/ios/Views/WelcomeView.swift
index 21660b8f..211cdac3 100644
--- a/apps/ios/Views/WelcomeView.swift
+++ b/apps/ios/Views/WelcomeView.swift
@@ -11,6 +11,24 @@ struct WelcomeView: View {
@State private var beat = 0
var body: some View {
+ GeometryReader { geometry in
+ ScrollView {
+ content
+ .frame(minHeight: geometry.size.height)
+ }
+ .scrollBounceBehavior(.basedOnSize)
+ }
+ .background(Palette.background)
+ .task {
+ if reduceMotion { beat = 4; return }
+ for next in 1...4 {
+ try? await Task.sleep(for: .milliseconds(next == 1 ? 150 : 280))
+ withAnimation(.spring(duration: 0.6, bounce: 0.25)) { beat = next }
+ }
+ }
+ }
+
+ private var content: some View {
VStack(alignment: .leading, spacing: 0) {
Spacer(minLength: 24)
@@ -20,13 +38,14 @@ struct WelcomeView: View {
Spacer(minLength: 24)
ChatGlimpse(shown: beat >= 2)
- .padding(.bottom, 32)
+ .padding(.bottom, 24)
VStack(alignment: .leading, spacing: 10) {
Text("Your coding agents,\nas teammates.")
.font(.system(size: 34, weight: .semibold))
.tracking(-0.6)
.foregroundStyle(Palette.text)
+ .fixedSize(horizontal: false, vertical: true)
Text("Give each one a name and a project. They work on your computer while you're away.")
.font(.body)
.foregroundStyle(Palette.secondary)
@@ -42,7 +61,7 @@ struct WelcomeView: View {
}
.buttonStyle(.primary)
// Signed in, the computers on the account show up without scanning a code.
- if account.isConfigured { GoogleSignInButton() }
+ if account.isConfigured { SignInButtons() }
if let message = account.errorMessage {
Text(message).font(.footnote).foregroundStyle(Palette.danger)
.transition(.opacity)
@@ -52,14 +71,6 @@ struct WelcomeView: View {
}
.padding(.horizontal, 24)
.padding(.bottom, 12)
- .background(Palette.background)
- .task {
- if reduceMotion { beat = 4; return }
- for next in 1...4 {
- try? await Task.sleep(for: .milliseconds(next == 1 ? 150 : 280))
- withAnimation(.spring(duration: 0.6, bounce: 0.25)) { beat = next }
- }
- }
}
}
@@ -90,7 +101,7 @@ private struct Crew: View {
}
}
}
- .frame(height: 200)
+ .frame(height: 170)
}
}
diff --git a/apps/macos/Resources/Assets.xcassets/google.imageset/Contents.json b/apps/macos/Resources/Assets.xcassets/google.imageset/Contents.json
new file mode 100644
index 00000000..56369403
--- /dev/null
+++ b/apps/macos/Resources/Assets.xcassets/google.imageset/Contents.json
@@ -0,0 +1,5 @@
+{
+ "images" : [ { "filename" : "google.svg", "idiom" : "universal" } ],
+ "info" : { "author" : "xcode", "version" : 1 },
+ "properties" : { "preserves-vector-representation" : true, "template-rendering-intent" : "original" }
+}
diff --git a/apps/macos/Resources/Assets.xcassets/google.imageset/google.svg b/apps/macos/Resources/Assets.xcassets/google.imageset/google.svg
new file mode 100644
index 00000000..afd6b4f6
--- /dev/null
+++ b/apps/macos/Resources/Assets.xcassets/google.imageset/google.svg
@@ -0,0 +1 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 0 48 48"><path fill="#EA4335" d="M24 9.5c3.54 0 6.71 1.22 9.21 3.6l6.85-6.85C35.9 2.38 30.47 0 24 0 14.62 0 6.51 5.38 2.56 13.22l7.98 6.19C12.43 13.72 17.74 9.5 24 9.5z"/><path fill="#4285F4" d="M46.98 24.55c0-1.57-.15-3.09-.38-4.55H24v9.02h12.94c-.58 2.96-2.26 5.48-4.78 7.18l7.73 6c4.51-4.18 7.09-10.36 7.09-17.65z"/><path fill="#FBBC05" d="M10.53 28.59c-.48-1.45-.76-2.99-.76-4.59s.27-3.14.76-4.59l-7.98-6.19C.92 16.46 0 20.12 0 24c0 3.88.92 7.54 2.56 10.78l7.97-6.19z"/><path fill="#34A853" d="M24 48c6.48 0 11.93-2.13 15.89-5.81l-7.73-6c-2.15 1.45-4.92 2.3-8.16 2.3-6.26 0-11.57-4.22-13.47-9.91l-7.98 6.19C6.51 42.62 14.62 48 24 48z"/></svg>
diff --git a/apps/macos/Views/ChatWindow.swift b/apps/macos/Views/ChatWindow.swift
index 7393f001..2ea743a0 100644
--- a/apps/macos/Views/ChatWindow.swift
+++ b/apps/macos/Views/ChatWindow.swift
@@ -6,22 +6,47 @@ import SwiftUI
/// (Grok Bot's desktop layout), sharing its views with the iPhone app.
struct ChatWindow: View {
@Environment(HostController.self) private var host
+ @Environment(AccountSession.self) private var account
@Environment(\.accessibilityReduceMotion) private var reduceMotion
+ @AppStorage("macAccountOnboardingCompleted") private var accountOnboardingCompleted = false
private var showsChat: Bool { host.state == .running || !host.accounts.computers.isEmpty }
var body: some View {
ZStack {
- if showsChat {
- ChatSplitView().id(host.contextID)
+ if account.isSignedIn || accountOnboardingCompleted {
+ if showsChat {
+ ChatSplitView().id(host.contextID)
+ .transition(.opacity)
+ } else {
+ hostState
+ .transition(.opacity.combined(with: .scale(scale: 0.97)))
+ }
+ } else if !account.isReady {
+ AccountRestoreView(onContinue: { accountOnboardingCompleted = true })
.transition(.opacity)
} else {
- hostState
- .transition(.opacity.combined(with: .scale(scale: 0.97)))
+ AccountWelcomeView(
+ isConfigured: account.isConfigured,
+ isBusy: account.isBusy,
+ errorMessage: account.errorMessage,
+ onContinue: { accountOnboardingCompleted = true },
+ onSignIn: { provider in
+ Task { await account.signIn(provider: provider) }
+ }
+ )
+ .transition(.opacity)
}
}
.animation(Motion.reduced(Motion.layout, reduceMotion), value: showsChat)
.animation(Motion.reduced(Motion.layout, reduceMotion), value: host.state)
+ .animation(Motion.reduced(Motion.fade, reduceMotion), value: accountOnboardingCompleted)
+ .onChange(of: account.isSignedIn) { _, signedIn in
+ if signedIn { accountOnboardingCompleted = true }
+ }
+ .task {
+ if account.isSignedIn { accountOnboardingCompleted = true }
+ }
.frame(minWidth: 760, minHeight: 500)
.frame(maxWidth: .infinity, maxHeight: .infinity)
.background(Palette.background)
@@ -39,6 +64,222 @@ struct ChatWindow: View {
}
}
+/// Keep first-run sign-in choices behind Clerk's persisted-session restoration on launch.
+private struct AccountRestoreView: View {
+ let onContinue: () -> Void
+
+ var body: some View {
+ VStack(spacing: 14) {
+ Spinner(size: 24)
+ Text("Checking for a saved account…")
+ .font(.callout)
+ .foregroundStyle(Palette.secondary)
+ Button("Continue on this Mac", action: onContinue)
+ .buttonStyle(.plain)
+ .foregroundStyle(Palette.secondary)
+ }
+ .frame(maxWidth: .infinity, maxHeight: .infinity)
+ }
+}
+
+/// First-run account choice. Existing Clerk sessions skip this screen as soon as Clerk restores them.
+private struct AccountWelcomeView: View {
+ let isConfigured: Bool
+ let isBusy: Bool
+ let errorMessage: String?
+ let onContinue: () -> Void
+ let onSignIn: (AccountSession.SignInProvider) -> Void
+ @Environment(\.accessibilityReduceMotion) private var reduceMotion
+ @State private var beat = 0
+
+ var body: some View {
+ GeometryReader { geometry in
+ ScrollView {
+ content
+ .frame(minHeight: geometry.size.height)
+ .frame(maxWidth: 480)
+ .frame(maxWidth: .infinity)
+ }
+ .scrollBounceBehavior(.basedOnSize)
+ }
+ .background(Palette.background)
+ .task {
+ if reduceMotion { beat = 4; return }
+ for next in 1...4 {
+ try? await Task.sleep(for: .milliseconds(next == 1 ? 150 : 280))
+ withAnimation(.spring(duration: 0.6, bounce: 0.25)) { beat = next }
+ }
+ }
+ }
+
+ private var content: some View {
+ VStack(alignment: .leading, spacing: 0) {
+ Spacer(minLength: 24)
+
+ WelcomeCrew(shown: beat >= 1)
+ .frame(maxWidth: .infinity)
+
+ Spacer(minLength: 24)
+
+ WelcomeChatGlimpse(shown: beat >= 2)
+ .padding(.bottom, 24)
+
+ VStack(alignment: .leading, spacing: 10) {
+ Text("Your coding agents,\nas teammates.")
+ .font(.system(size: 34, weight: .semibold))
+ .tracking(-0.6)
+ .foregroundStyle(Palette.text)
+ .fixedSize(horizontal: false, vertical: true)
+ Text("Give each one a name and a project. They work on your computer while you're away.")
+ .font(.body)
+ .foregroundStyle(Palette.secondary)
+ }
+ .opacity(beat >= 3 ? 1 : 0)
+ .offset(y: beat >= 3 ? 0 : 14)
+
+ Spacer(minLength: 32)
+
+ VStack(spacing: 10) {
+ Button("Continue on this Mac", action: onContinue)
+ .font(.headline)
+ .frame(maxWidth: .infinity, minHeight: 50)
+ .buttonStyle(.primary)
+
+ Button { onSignIn(.apple) } label: {
+ ZStack {
+ HStack(spacing: 10) {
+ Image(systemName: "apple.logo").font(.system(size: 20))
+ Text("Continue with Apple")
+ }
+ .opacity(isBusy ? 0 : 1)
+ if isBusy { Spinner(size: 18) }
+ }
+ .font(.headline)
+ .frame(maxWidth: .infinity, minHeight: 50)
+ }
+ .buttonStyle(.primary)
+ .disabled(!isConfigured || isBusy)
+
+ Button { onSignIn(.google) } label: {
+ ZStack {
+ HStack(spacing: 10) {
+ Image("google")
+ .resizable()
+ .scaledToFit()
+ .frame(width: 20, height: 20)
+ Text("Continue with Google")
+ }
+ .opacity(isBusy ? 0 : 1)
+ if isBusy { Spinner(size: 18) }
+ }
+ .font(.headline)
+ .frame(maxWidth: .infinity, minHeight: 50)
+ }
+ .buttonStyle(.secondary)
+ .disabled(!isConfigured || isBusy)
+
+ if !isConfigured {
+ Text("Sign-in isn't configured in this build. You can still use Codync on this Mac.")
+ .font(.footnote)
+ .foregroundStyle(Palette.tertiary)
+ .fixedSize(horizontal: false, vertical: true)
+ }
+ if let errorMessage {
+ Text(errorMessage)
+ .font(.footnote)
+ .foregroundStyle(Palette.warning)
+ .fixedSize(horizontal: false, vertical: true)
+ }
+ }
+ .opacity(beat >= 4 ? 1 : 0)
+ .offset(y: beat >= 4 ? 0 : 14)
+ }
+ .padding(.horizontal, 24)
+ .padding(.bottom, 12)
+ }
+}
+
+/// The animated bot group from the first iPhone onboarding screen.
+private struct WelcomeCrew: View {
+ let shown: Bool
+ @Environment(\.accessibilityReduceMotion) private var reduceMotion
+
+ private let members: [(shape: String, color: String, size: CGFloat, x: CGFloat, y: CGFloat, mood: CharacterAvatar.Mood)] = [
+ ("blob", "blue", 92, 0, 0, .working),
+ ("squircle", "orange", 64, -104, -34, .idle),
+ ("teardrop", "violet", 58, 100, -46, .working),
+ ("hex", "green", 48, -76, 64, .idle),
+ ("cloud", "magenta", 52, 84, 58, .needsInput),
+ ]
+
+ var body: some View {
+ TimelineView(.animation(paused: reduceMotion || !shown)) { context in
+ let time = context.date.timeIntervalSinceReferenceDate
+ ZStack {
+ ForEach(members.indices, id: \.self) { index in
+ let member = members[index]
+ CharacterAvatar(shape: member.shape, color: member.color, size: member.size, mood: member.mood)
+ .offset(x: member.x, y: member.y + (reduceMotion ? 0 : sin(time * 1.3 + Double(index) * 1.7) * 5))
+ .scaleEffect(shown ? 1 : 0.3)
+ .opacity(shown ? 1 : 0)
+ .animation(.spring(duration: 0.7, bounce: 0.4).delay(Double(index) * 0.07), value: shown)
+ }
+ }
+ }
+ .frame(height: 170)
+ .accessibilityHidden(true)
+ }
+}
+
+/// A short animated user and bot exchange, matching the iPhone onboarding preview.
+private struct WelcomeChatGlimpse: View {
+ let shown: Bool
+ @Environment(\.accessibilityReduceMotion) private var reduceMotion
+ @State private var replied = false
+
+ var body: some View {
+ VStack(alignment: .leading, spacing: 10) {
+ Text("Fix the flaky login test")
+ .font(.subheadline)
+ .foregroundStyle(Palette.text)
+ .padding(.horizontal, 14)
+ .padding(.vertical, 9)
+ .background(Palette.bubbleUser, in: RoundedRectangle(cornerRadius: 18))
+ .frame(maxWidth: .infinity, alignment: .trailing)
+ .opacity(shown ? 1 : 0)
+ .offset(y: shown ? 0 : 14)
+
+ HStack(alignment: .bottom, spacing: 8) {
+ CharacterAvatar(shape: "blob", color: "blue", size: 28, mood: replied ? .idle : .working)
+ if replied {
+ Text("Done. It raced the session refresh; tests pass on fix/login.")
+ .font(.subheadline)
+ .foregroundStyle(Palette.text)
+ .padding(.horizontal, 14)
+ .padding(.vertical, 9)
+ .background(Palette.bubbleAgent, in: RoundedRectangle(cornerRadius: 18))
+ .transition(.opacity.combined(with: .scale(scale: 0.92, anchor: .bottomLeading)))
+ } else {
+ Text("Working…")
+ .font(.subheadline)
+ .foregroundStyle(Palette.tertiary)
+ .transition(.opacity)
+ }
+ }
+ .opacity(shown ? 1 : 0)
+ .offset(y: shown ? 0 : 14)
+ }
+ .accessibilityElement(children: .combine)
+ .onChange(of: shown) { _, isShown in
+ guard isShown else { return }
+ Task {
+ try? await Task.sleep(for: .seconds(reduceMotion ? 0 : 1.6))
+ withAnimation(Motion.reduced(.spring(duration: 0.45, bounce: 0.2), reduceMotion)) { replied = true }
+ }
+ }
+ }
+}
+
/// What stands between this Mac and the chat, with the one action that fixes it.
private extension ChatWindow {
@ViewBuilder var hostState: some View {
@@ -327,12 +568,22 @@ private struct ChatSplitView: View {
email: account.email,
busy: account.isBusy,
errorMessage: account.errorMessage,
- onAuthenticate: {
+ onSignIn: { provider in
+ dismissAccountMenu()
+ Task {
+ await account.signIn(provider: provider)
+ if account.errorMessage != nil {
+ withAnimation(Motion.fade) { showAccount = true }
+ }
+ }
+ },
+ onSignOut: {
dismissAccountMenu()
Task {
- if account.isSignedIn { await host.signOut() }
- else { await account.signIn() }
- if account.errorMessage != nil { showAccount = true }
+ await host.signOut()
+ if account.errorMessage != nil {
+ withAnimation(Motion.fade) { showAccount = true }
+ }
}
},
compact: compact,
@@ -779,7 +1030,8 @@ private struct SidebarAccountPanel: View {
let email: String?
let busy: Bool
let errorMessage: String?
- let onAuthenticate: () -> Void
+ let onSignIn: (AccountSession.SignInProvider) -> Void
+ let onSignOut: () -> Void
let compact: Bool
let usage: Double?
let approvals: Int
@@ -796,6 +1048,7 @@ private struct SidebarAccountPanel: View {
private struct Item {
let title: String
let icon: String
+ var assetIcon: String? = nil
var detail: String? = nil
var chevron = false
var disabled = false
@@ -827,12 +1080,22 @@ private struct SidebarAccountPanel: View {
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)
- ]
+ Item(title: compact ? "Expand sidebar" : "Collapse sidebar", icon: "sidebar.left", action: onToggleSidebar)
+ ] + authenticationItems
+ }
+ }
+
+ private var authenticationItems: [Item] {
+ if signedIn {
+ return [Item(title: busy ? "Please wait…" : "Sign out",
+ icon: "rectangle.portrait.and.arrow.right", disabled: busy, action: onSignOut)]
}
+ return [
+ Item(title: "Continue with Apple", icon: "apple.logo", disabled: busy,
+ action: { onSignIn(.apple) }),
+ Item(title: "Continue with Google", icon: "person.crop.circle.badge.plus", assetIcon: "google", disabled: busy,
+ action: { onSignIn(.google) })
+ ]
}
var body: some View {
@@ -870,7 +1133,7 @@ private struct SidebarAccountPanel: View {
@ViewBuilder private func menuRow(_ item: Item, index: Int) -> some View {
if index == (page == "main" ? 5 : 1) { divider }
if page == "main" && index == 6 { accountIdentity }
- AccountPanelRow(title: item.title, icon: item.icon, detail: item.detail,
+ AccountPanelRow(title: item.title, icon: item.icon, assetIcon: item.assetIcon, detail: item.detail,
chevron: item.chevron, keyboardFocused: highlighted == index, action: item.action)
.disabled(item.disabled)
.onHover { if $0 { highlighted = index } }
@@ -920,6 +1183,7 @@ private struct SidebarAccountPanel: View {
private struct AccountPanelRow: View {
let title: String
let icon: String
+ var assetIcon: String? = nil
let detail: String?
let chevron: Bool
let keyboardFocused: Bool
@@ -930,7 +1194,11 @@ private struct AccountPanelRow: View {
var body: some View {
Button(action: action) {
HStack(spacing: 8) {
- Image(systemName: icon).font(.system(size: 14, weight: .regular)).frame(width: 20)
+ if let assetIcon {
+ Image(assetIcon).resizable().scaledToFit().frame(width: 16, height: 16).frame(width: 20)
+ } else {
+ Image(systemName: icon).font(.system(size: 14, weight: .regular)).frame(width: 20)
+ }
Text(title).font(.system(size: 12)).lineLimit(1)
Spacer(minLength: 8)
if let detail { Text(detail).font(.system(size: 13)).foregroundStyle(Palette.secondary) }
diff --git a/apps/macos/Views/ComputersView.swift b/apps/macos/Views/ComputersView.swift
index bec333d8..3723f203 100644
--- a/apps/macos/Views/ComputersView.swift
+++ b/apps/macos/Views/ComputersView.swift
@@ -358,7 +358,7 @@ private struct ManagedComputerCard: View {
}]
}
.codyncDialog("Let account devices in without a code?", isPresented: $confirmAutoApproval,
- message: "Any device signed in to your account gets full control of \(store.hostName): its files, terminals and bots, with no check here. If someone gets into your Google account, or Codync's cloud is ever compromised, they could add their own device and you'd have no chance to stop it. Devices paired with a QR code aren't affected.") {
+ message: "Any device signed in to your account gets full control of \(store.hostName): its files, terminals and bots, with no check here. If someone gets into your account, or Codync's cloud is ever compromised, they could add their own device and you'd have no chance to stop it. Devices paired with a QR code aren't affected.") {
[DialogAction("Skip the check", destructive: true) { setApproval(.auto) }]
}
.codyncDialog("Remove \(store.hostName) from the account?", isPresented: $confirmUnclaim,
diff --git a/apps/shared/AccountSession.swift b/apps/shared/AccountSession.swift
index 9dcac0c7..cbe33320 100644
--- a/apps/shared/AccountSession.swift
+++ b/apps/shared/AccountSession.swift
@@ -36,6 +36,9 @@ final class AccountSession {
var supportsMultipleAccounts: Bool { clerk?.environment?.authConfig.singleSessionMode == false }
var isConfigured: Bool { clerk != nil }
+ /// Clerk restores the persisted Keychain session during configuration. Don't offer a fresh sign-in
+ /// until that restore has completed, or an update can briefly look like a signed-out install.
+ var isReady: Bool { clerk?.isLoaded ?? true }
/// The Codync cloud (accounts and the encrypted relay); nil in builds without one.
let cloudURL: URL?
var isSignedIn: Bool { userID != nil }
@@ -86,7 +89,12 @@ final class AccountSession {
var errorDescription: String? { "Sign in again to reach your account." }
}
- func signIn() async {
+ enum SignInProvider: String {
+ case google = "Google"
+ case apple = "Apple"
+ }
+
+ func signIn(provider: SignInProvider = .google) async {
guard !isBusy else { return }
guard let clerk else {
errorMessage = "Sign-in setup isn't finished yet. You can continue using local pairing."
@@ -96,20 +104,34 @@ final class AccountSession {
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, prefersEphemeralWebBrowserSession: isSignedIn)
+ // Both providers use Clerk's transfer flow and activate the same kind of session.
+ let result: TransferFlowResult
+ switch provider {
+ case .google:
+ result = try await clerk.auth.signInWithOAuth(provider: .google, prefersEphemeralWebBrowserSession: isSignedIn)
+ case .apple:
+ #if os(macOS)
+ // The desktop OAuth flow uses the Services ID grouped with our iOS App ID.
+ // Clerk therefore receives the same Apple identity, including Hide My Email.
+ result = try await clerk.auth.signInWithOAuth(provider: .apple, prefersEphemeralWebBrowserSession: isSignedIn)
+ #else
+ result = try await clerk.auth.signInWithApple()
+ #endif
+ }
switch result {
case .signIn(let signIn):
if signIn.status != .complete {
- errorMessage = "Google sign-in needs additional verification. Your account is not signed in yet."
+ errorMessage = "\(provider.rawValue) 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."
+ errorMessage = "\(provider.rawValue) sign-up needs additional account information. Your account is not signed in yet."
}
}
} catch let error as ASWebAuthenticationSessionError where error.code == .canceledLogin {
return
+ } catch let error as ASAuthorizationError where error.code == .canceled {
+ return
} catch is CancellationError {
return
} catch {
diff --git a/cloud/test/api.test.ts b/cloud/test/api.test.ts
index bbcff6bd..9d50069c 100644
--- a/cloud/test/api.test.ts
+++ b/cloud/test/api.test.ts
@@ -110,6 +110,20 @@ describe("Clerk", () => {
expect(r.body).toMatchObject({ userId, email: "[email protected]" });
});
+ it.each([undefined, "[email protected]"])("registers a native device without a real email (%s)", async (email) => {
+ const userId = uid("apple");
+ const token = await clerkToken(userId, { email });
+ const key = ref.signKey();
+ const registered = await call("POST", "/v1/devices", {
+ token, key, body: { name: "iPhone", platform: "ios" },
+ });
+ expect(registered.status).toBe(200);
+ expect((await call("GET", "/v1/me", { token })).body).toMatchObject({ userId, email: email ?? null });
+ const computers = await call("GET", "/v1/computers", { token, key });
+ expect(computers.status).toBe(200);
+ expect(computers.body.computers).toEqual([]);
+ });
+
it("rejects missing, foreign-issuer, session-less and tampered tokens", async () => {
const userId = uid("bad");
expect((await call("GET", "/v1/me")).body.error.code).toBe("unauthenticated");
diff --git a/docs/guides/accounts-and-ssh.md b/docs/guides/accounts-and-ssh.md
index 27487193..3d035c2b 100644
--- a/docs/guides/accounts-and-ssh.md
+++ b/docs/guides/accounts-and-ssh.md
@@ -8,7 +8,98 @@ The footer displays **Account**, never the Mac user's local name.
Both Apple apps use `apps/shared/AccountSession.swift`. Public keys and cloud URLs come from `apps/shared/Config/<env>.plist`, copied into the bundle as `AccountConfig.plist` by `project.yml`. Debug selects dev; Release selects main. See [environments](environments-and-deployment.md).
-Confirm Google sign-in, Native API and the native app registrations in the intended Clerk instance. macOS uses `com.pokai.Codync`, iOS uses `com.pokai.Codync.ios`, with their matching `://callback` URLs. Dashboard configuration and actual OAuth consent must be verified independently of the checked-in plist. Do not bundle Clerk secret keys.
+Confirm Apple and Google sign-in, Native API and the native app registrations in the intended Clerk instance. macOS uses `com.pokai.Codync`, iOS uses `com.pokai.Codync.ios`, with their matching `://callback` URLs. Dashboard configuration and actual OAuth consent must be verified independently of the checked-in plist. Do not bundle Clerk secret keys.
+
+### macOS Sign in with Apple
+
+The sidebar account menu offers **Continue with Apple** and **Continue with
+Google** with the same row styling in both sidebar layouts. Both actions are
+disabled while authentication is in progress; cancellation stays silent and
+errors reopen the account menu. Signed-in accounts retain the existing Log out
+action.
+
+On macOS, `AccountSession.signIn(provider: .apple)` uses
+`clerk.auth.signInWithOAuth(provider: .apple)` in a system authentication browser.
+This uses Clerk's Apple Services ID and does not require the native Sign in with
+Apple entitlement on the independently distributed Mac app. iOS continues using
+Clerk's native Apple authorization.
+
+The production Services ID `com.pokai.Codync.signin` is associated with primary
+App ID `com.pokai.Codync.ios` in Apple Developer. Keep that association: Apple's
+web and native authorization must represent the same identity rather than being
+joined by email. The Mac's `com.pokai.Codync://callback` must also remain allowed
+in Clerk. See [Apple's web configuration guide](https://developer.apple.com/help/account/capabilities/configure-sign-in-with-apple-for-the-web/)
+and [Clerk's Apple OAuth guide](https://clerk.com/docs/guides/configure/auth-strategies/social-connections/apple).
+
+To check cross-device discovery, use **Release** on both devices (the same Clerk
+production instance), select the same Apple Account, and verify that Clerk has
+one user ID. Debug uses the separate development instance; its shared Apple OAuth
+credentials do not validate production identity matching. Then verify that the
+Mac joins the account and the phone requests access with the existing approval
+flow. Hide My Email does not change the device approval requirement.
+
+Verified on 2026-09-30: the Mac Debug build completed Apple OAuth and displayed
+the signed-in private relay address and Log out action. The Apple and Google
+rows use the same font and sizing, and both disable during the pending flow.
+The iOS simulator build also passed after introducing the platform-specific
+Apple authentication route. The Mac Release build passed as well. Production
+cross-device identity matching still needs an Apple sign-in on that build.
+
+### iOS Sign in with Apple
+
+The welcome, pairing and account screens offer **Continue with Apple** alongside
+Google, with matching headline typography and button sizing. Apple's native
+authorization is presented by Clerk. Adding another account lets the user choose
+either provider. `AccountSession.signIn(provider: .apple)` calls
+`clerk.auth.signInWithApple()`; Clerk owns Apple's credential exchange, new-user
+transfer, session activation and persistence. Cancellation is silent and
+incomplete sign-in/sign-up results remain explicit errors.
+
+Enable Apple for sign-up and sign-in in both Clerk environments, and register
+`7FUM8A8H72.com.pokai.Codync.ios` under Native applications. Enable the App ID's
+`APPLE_ID_AUTH` capability as a primary App ID and retain
+`com.apple.developer.applesignin: [Default]` in `iOS.entitlements`. Regenerate
+provisioning profiles after adding this entitlement. Native setup is described
+in [Clerk's Apple sign-in guide](https://clerk.com/docs/ios/guides/configure/auth-strategies/sign-in-with-apple).
+
+On 2026-09-30, Apple sign-up/sign-in was enabled in Codync's development and
+production Clerk instances. Production's connection required custom credentials:
+Services ID `com.pokai.Codync.signin`, primary App ID `com.pokai.Codync.ios`,
+domain `clerk.codync.dev` and return URL
+`https://clerk.codync.dev/v1/oauth_callback`. The Sign in with Apple key is stored
+privately outside the repository and supplied only to Clerk. Never add its P8
+contents to app resources, logs or documentation.
+
+Apple Private Email Relay also has the production Clerk sender domain
+`clkmail.codync.dev` and sender
+`[email protected]` registered as email sources. Registration
+does not replace an actual delivery test to an Apple relay address.
+
+Account storage and computer approval still use the Clerk user ID, regardless of
+login provider. Apple **Hide My Email** can create a different Clerk user from an
+existing Google account; do not merge users by unverified email or assume both
+providers reach the same computers. Test new-user registration with Hide My Email,
+returning-user login, cancellation, restoration, account switching and sign-out
+on a real device before release. Build success and enabled dashboard settings do
+not prove that an Apple authorization completed successfully.
+
+QR pairing does not require matching email addresses or even a signed-in computer.
+
+On the Mac, open Codync in the menu bar and choose **Pair iPhone**, then scan the
+code on the phone (or paste its `codync://pair` link). The host approves the phone's
+device key; the phone saves the computer in its current account context. This
+works when the phone uses Apple Hide My Email and the Mac uses Google. Automatic
+account discovery, in contrast, requires the same Clerk user ID on both devices.
+
+On 2026-09-30, the production dashboard confirmed a successful Apple registration
+with a private relay address. The subsequent native `/v1/devices` and
+`/v1/computers` requests failed with 401 because the Worker's `CLERK_SECRET_KEY`
+contained the dashboard's abbreviated value. The complete key was verified
+against production JWKS and stored in the Worker. Relaunching the Release build
+on the physical iPhone restored the Apple session, and both endpoints returned
+200 without warnings. The cloud API regression tests
+cover native device registration and computer listing with both an absent email
+claim and an Apple relay address.
## Flow
@@ -32,12 +123,12 @@ computer approves each device after comparing a 6-digit code
- Build the macOS scheme after `xcodegen generate --spec apps/project.yml`.
- 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
+- Sign in with Apple and Google test users, 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
+Dashboard creation and the end-to-end Apple/Google flows require the user's browser
consent; compilation alone does not verify those steps.
References: