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
Codync's own modals, headers, icon buttons and tab bar
leepokai39ad258fab84
diff --git a/Codync.xcodeproj/project.pbxproj b/Codync.xcodeproj/project.pbxprojindex 30295682..aa7ef37b 100644--- a/Codync.xcodeproj/project.pbxproj+++ b/Codync.xcodeproj/project.pbxproj@@ -14,7 +14,6 @@25FCB36A2661833502357807 /* Session.swift in Sources */ = {isa = PBXBuildFile; fileRef = D0A657FB98BBE0D73807B263 /* Session.swift */; };28DE92C4209739829F6AD1A1 /* AccountSwitcherView.swift in Sources */ = {isa = PBXBuildFile; fileRef = AFE4E0839DCD380109300DF1 /* AccountSwitcherView.swift */; };2CC074683AE086D6C77CC1E8 /* WidgetKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B274A0195CB3B2409EA4C194 /* WidgetKit.framework */; };- 2D724C1001CF872BAFCAE7EA /* IconButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = D3831394C093AF3A4E504BC5 /* IconButton.swift */; };2F0A1C29DBBD1D700C10BE46 /* CodyncApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = F45CCA6BBDCF412897AEC105 /* CodyncApp.swift */; };31A78A067C217F77FBDEDFD0 /* Push.swift in Sources */ = {isa = PBXBuildFile; fileRef = 55AABA9596547D7459B1CC5B /* Push.swift */; };331338197BF906B069159B11 /* SSHTunnel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3A4EBC39B2AC89EAA4F5033F /* SSHTunnel.swift */; };@@ -161,7 +160,6 @@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>"; };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>"; };E1B79D48C1D6F90D53751B3F /* RootView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RootView.swift; sourceTree = "<group>"; };E4B8EAB09016D328195FE2AD /* AccountSession.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AccountSession.swift; sourceTree = "<group>"; };@@ -321,7 +319,6 @@children = (9A59E3A7670EAF57F2F4C9B9 /* ChatWindow.swift */,57DFD81025893713D631B5D7 /* ComputersView.swift */,- D3831394C093AF3A4E504BC5 /* IconButton.swift */,);path = Views;sourceTree = "<group>";@@ -744,7 +741,6 @@9593C1951D727D36D6B8C0E9 /* ComputerStatus.swift in Sources */,76E73EDD79B063940B5D8B8E /* ComputersView.swift in Sources */,F0A26FABD15480810021C86A /* HostController.swift in Sources */,- 2D724C1001CF872BAFCAE7EA /* IconButton.swift in Sources */,331338197BF906B069159B11 /* SSHTunnel.swift in Sources */,);runOnlyForDeploymentPostprocessing = 0;diff --git a/apps/macos/Views/IconButton.swift b/apps/macos/Views/IconButton.swiftdeleted file mode 100644index 71b1bce6..00000000--- a/apps/macos/Views/IconButton.swift+++ /dev/null@@ -1,47 +0,0 @@-import CodyncKit-import SwiftUI--/// Plain icon button that lights up on hover and on press, like toolbar buttons.-struct IconButton: View {- let title: String- let systemImage: String- var selected = false- let action: () -> Void-- init(_ title: String, systemImage: String, selected: Bool = false, action: @escaping () -> Void) {- self.title = title- self.systemImage = systemImage- self.selected = selected- self.action = action- }-- var body: some View {- Button(title, systemImage: systemImage, action: action)- .labelStyle(.iconOnly)- .buttonStyle(IconButtonStyle(selected: selected))- .help(title)- }-}--struct IconButtonStyle: ButtonStyle {- var selected = false- var size: CGFloat = 28- @State private var hovering = false-- func makeBody(configuration: Configuration) -> some View {- configuration.label- .font(.system(size: size / 2, weight: .medium))- .foregroundStyle(selected ? Palette.onAccent : hovering ? Palette.text : Palette.secondary)- .frame(width: size, height: size)- .background(- selected ? Palette.accentFill : Palette.text.opacity(configuration.isPressed ? 0.14 : hovering ? 0.08 : 0),- in: RoundedRectangle(cornerRadius: size * 0.28, style: .continuous)- )- .scaleEffect(configuration.isPressed ? Motion.pressScale : 1)- .animation(Motion.press, value: configuration.isPressed)- .animation(Motion.hover, value: hovering)- .animation(Motion.hover, value: selected)- .contentShape(Rectangle())- .onHover { hovering = $0 }- }-}diff --git a/kit/Sources/CodyncUI/Chrome.swift b/kit/Sources/CodyncUI/Chrome.swiftnew file mode 100644index 00000000..8e0be889--- /dev/null+++ b/kit/Sources/CodyncUI/Chrome.swift@@ -0,0 +1,440 @@+import CodyncKit+import SwiftUI+#if os(iOS)+import UIKit+#endif++// Codync's own screen chrome: modals, headers, icon buttons and the iPhone tab bar.+// Never use `.sheet`, `.popover`, `.toolbar`/`ToolbarItem`, navigation bars or+// `TabView`: present with `.codyncSheet`, title with `ModalHeader` / `ScreenHeader`.+// Every transition animates (Motion.layout / Motion.fade), honoring Reduce Motion.++// MARK: - Icon button++/// Plain icon button that lights up on hover and press. Icon-only, labelled for VoiceOver.+public struct IconButton: View {+ let title: String+ let systemImage: String+ var selected: Bool+ let action: () -> Void++ public init(_ title: String, systemImage: String, selected: Bool = false, action: @escaping () -> Void) {+ self.title = title+ self.systemImage = systemImage+ self.selected = selected+ self.action = action+ }++ public var body: some View {+ Button(title, systemImage: systemImage, action: action)+ .labelStyle(.iconOnly)+ .buttonStyle(IconButtonStyle(selected: selected))+ .help(title)+ }+}++public struct IconButtonStyle: ButtonStyle {+ var selected: Bool+ var size: CGFloat++ public init(selected: Bool = false, size: CGFloat? = nil) {+ self.selected = selected+ self.size = size ?? InterfaceMetrics.value(mac: 28, mobile: 36)+ }++ public func makeBody(configuration: Configuration) -> some View {+ IconButtonBody(configuration: configuration, selected: selected, size: size)+ }++ private struct IconButtonBody: View {+ let configuration: Configuration+ let selected: Bool+ let size: CGFloat+ @State private var hovering = false+ @Environment(\.isEnabled) private var isEnabled++ var body: some View {+ configuration.label+ .font(.system(size: size / 2, weight: .medium))+ .foregroundStyle(selected ? Palette.onAccent : hovering ? Palette.text : Palette.secondary)+ .frame(width: size, height: size)+ .background(+ selected ? Palette.accentFill : Palette.text.opacity(configuration.isPressed ? 0.14 : hovering ? 0.08 : 0),+ in: RoundedRectangle(cornerRadius: size * 0.28, style: .continuous)+ )+ .opacity(isEnabled ? 1 : 0.35)+ .scaleEffect(configuration.isPressed ? Motion.pressScale : 1)+ .animation(Motion.press, value: configuration.isPressed)+ .animation(Motion.hover, value: hovering)+ .animation(Motion.hover, value: selected)+ .contentShape(Rectangle())+ .onHover { hovering = $0 }+ }+ }+}++// MARK: - Headers++/// A modal's title row: title, optional trailing actions, and a close button.+public struct ModalHeader<Trailing: View>: View {+ let title: String+ let trailing: Trailing+ @Environment(\.dismissModal) private var dismiss++ public init(_ title: String, @ViewBuilder trailing: () -> Trailing) {+ self.title = title+ self.trailing = trailing()+ }++ public var body: some View {+ HStack(spacing: 8) {+ Text(title)+ .font(InterfaceMetrics.body.weight(.semibold))+ .foregroundStyle(Palette.text)+ .lineLimit(1)+ Spacer(minLength: 8)+ trailing+ IconButton("Close", systemImage: "xmark") { dismiss() }+ .keyboardShortcut(.cancelAction)+ }+ .padding(.leading, InterfaceMetrics.value(mac: 16, mobile: 20))+ .padding(.trailing, InterfaceMetrics.value(mac: 10, mobile: 12))+ .frame(height: InterfaceMetrics.value(mac: 48, mobile: 56))+ }+}++public extension ModalHeader where Trailing == EmptyView {+ init(_ title: String) { self.init(title) { EmptyView() } }+}++/// A full screen's top bar (replaces the navigation bar): leading, centered title, trailing.+public struct ScreenHeader<Leading: View, Title: View, Trailing: View>: View {+ let leading: Leading+ let title: Title+ let trailing: Trailing++ public init(@ViewBuilder leading: () -> Leading, @ViewBuilder title: () -> Title, @ViewBuilder trailing: () -> Trailing) {+ self.leading = leading()+ self.title = title()+ self.trailing = trailing()+ }++ public var body: some View {+ ZStack {+ title.frame(maxWidth: .infinity)+ HStack(spacing: 6) {+ leading+ Spacer(minLength: 8)+ trailing+ }+ }+ .padding(.horizontal, InterfaceMetrics.value(mac: 12, mobile: 12))+ .frame(height: InterfaceMetrics.value(mac: 44, mobile: 52))+ .background(Palette.background)+ }+}++/// The back button for a pushed screen.+public struct BackButton: View {+ let action: () -> Void++ public init(action: @escaping () -> Void) { self.action = action }++ public var body: some View {+ IconButton("Back", systemImage: "chevron.left", action: action)+ }+}++// MARK: - Modals++/// Closes the modal the view is in (the replacement for `\.dismiss` inside `.codyncSheet`).+public struct DismissModalAction: Sendable {+ let action: @MainActor @Sendable () -> Void++ public init(_ action: @escaping @MainActor @Sendable () -> Void) { self.action = action }++ @MainActor public func callAsFunction() { action() }+}++public extension EnvironmentValues {+ @Entry var dismissModal = DismissModalAction {}+}++public extension View {+ /// Presents a Codync modal: a centered card on the Mac, a bottom sheet on iPhone.+ /// Content titles itself with `ModalHeader` and closes with `\.dismissModal`.+ func codyncSheet<Sheet: View>(isPresented: Binding<Bool>, @ViewBuilder content: @escaping () -> Sheet) -> some View {+ modifier(CodyncSheet(isPresented: isPresented, sheet: content))+ }++ func codyncSheet<Item: Identifiable, Sheet: View>(item: Binding<Item?>, @ViewBuilder content: @escaping (Item) -> Sheet) -> some View {+ let shown = Binding(get: { item.wrappedValue != nil }, set: { if !$0 { item.wrappedValue = nil } })+ return modifier(CodyncSheet(isPresented: shown, sheet: { item.wrappedValue.map(content) }))+ }++ /// Mac: the window root that hosts every `.codyncSheet` below it, so modals cover the+ /// whole window rather than the column that opened them.+ @ViewBuilder func modalHost() -> some View {+ #if os(macOS)+ modifier(ModalHostModifier())+ #else+ self+ #endif+ }+}++#if os(iOS)+private struct CodyncSheet<Sheet: View>: ViewModifier {+ @Binding var isPresented: Bool+ let sheet: () -> Sheet++ func body(content: Content) -> some View {+ content+ .fullScreenCover(isPresented: $isPresented) {+ BottomSheet(close: { isPresented = false }, content: sheet)+ .presentationBackground(.clear)+ }+ // Our own slide replaces the system one.+ .transaction(value: isPresented) { $0.disablesAnimations = true }+ }+}++/// The iPhone modal: slides up over a dim, drags down (from the grabber) to close.+private struct BottomSheet<Content: View>: View {+ let close: () -> Void+ @ViewBuilder let content: () -> Content+ @State private var shown = false+ @State private var drag: CGFloat = 0+ @Environment(\.accessibilityReduceMotion) private var reduceMotion++ var body: some View {+ GeometryReader { geo in+ let height = geo.size.height + geo.safeAreaInsets.bottom+ ZStack(alignment: .bottom) {+ Color.black.opacity(shown ? 0.4 : 0)+ .ignoresSafeArea()+ .onTapGesture(perform: animateClose)+ .accessibilityHidden(true)+ VStack(spacing: 0) {+ Capsule().fill(Palette.tertiary.opacity(0.6)).frame(width: 36, height: 5)+ .frame(maxWidth: .infinity, minHeight: 22)+ .contentShape(Rectangle())+ .gesture(dragToClose)+ .accessibilityHidden(true)+ content()+ .environment(\.dismissModal, DismissModalAction { animateClose() })+ .frame(maxWidth: .infinity, maxHeight: .infinity)+ }+ .background(Palette.background)+ .clipShape(UnevenRoundedRectangle(topLeadingRadius: 28, topTrailingRadius: 28, style: .continuous))+ .padding(.top, 10)+ .offset(y: shown ? drag : height)+ .ignoresSafeArea(.container, edges: .bottom)+ }+ }+ .onAppear { withAnimation(Motion.reduced(Motion.layout, reduceMotion)) { shown = true } }+ .accessibilityAction(.escape, animateClose)+ }++ private var dragToClose: some Gesture {+ DragGesture()+ .onChanged { drag = max(0, $0.translation.height) }+ .onEnded { value in+ if value.translation.height > 120 || value.predictedEndTranslation.height > 320 {+ animateClose()+ } else {+ withAnimation(Motion.layout) { drag = 0 }+ }+ }+ }++ private func animateClose() {+ withAnimation(Motion.reduced(Motion.layout, reduceMotion)) {+ shown = false+ } completion: {+ var t = Transaction()+ t.disablesAnimations = true+ withTransaction(t) { close() }+ }+ }+}++/// Keeps the edge swipe back working on screens whose navigation bar we replaced.+public struct SwipeBackEnabler: UIViewControllerRepresentable {+ public init() {}++ public func makeUIViewController(context: Context) -> Controller { Controller() }+ public func updateUIViewController(_ controller: Controller, context: Context) {}++ public final class Controller: UIViewController, UIGestureRecognizerDelegate {+ override public func didMove(toParent parent: UIViewController?) {+ super.didMove(toParent: parent)+ navigationController?.interactivePopGestureRecognizer?.delegate = self+ }++ public func gestureRecognizerShouldBegin(_ gestureRecognizer: UIGestureRecognizer) -> Bool {+ (navigationController?.viewControllers.count ?? 0) > 1+ }+ }+}++public extension View {+ /// Hides the system navigation bar (we draw `ScreenHeader`) and keeps swipe-back.+ func hidesSystemNavigationBar() -> some View {+ toolbar(.hidden, for: .navigationBar)+ .background(SwipeBackEnabler().frame(width: 0, height: 0))+ }+}+#else+@MainActor @Observable+final class ModalHost {+ struct Entry: Identifiable {+ let id: UUID+ var content: AnyView+ var shown = false+ }++ var entries: [Entry] = []++ func present(_ id: UUID, _ content: AnyView) {+ if let index = entries.firstIndex(where: { $0.id == id }) {+ entries[index].content = content+ return+ }+ entries.append(Entry(id: id, content: content))+ withAnimation(Motion.layout) {+ if let index = entries.firstIndex(where: { $0.id == id }) { entries[index].shown = true }+ }+ }++ func close(_ id: UUID) {+ guard let index = entries.firstIndex(where: { $0.id == id }), entries[index].shown else { return }+ withAnimation(Motion.layout) {+ entries[index].shown = false+ } completion: {+ self.entries.removeAll { $0.id == id && !$0.shown }+ }+ }+}++extension EnvironmentValues {+ @Entry var modalHost: ModalHost?+}++private struct ModalHostModifier: ViewModifier {+ @State private var host = ModalHost()++ func body(content: Content) -> some View {+ content+ .environment(\.modalHost, host)+ .overlay {+ ZStack {+ ForEach(host.entries) { entry in+ ModalCard(shown: entry.shown) { entry.content }+ }+ }+ }+ }+}++/// The Mac modal: a centered card over a dim; the content sizes it.+private struct ModalCard<Content: View>: View {+ let shown: Bool+ @ViewBuilder let content: () -> Content++ var body: some View {+ ZStack {+ Color.black.opacity(shown ? 0.4 : 0)+ .ignoresSafeArea()+ .contentShape(Rectangle())+ .onTapGesture {}+ .accessibilityHidden(true)+ content()+ .background(Palette.background)+ .clipShape(RoundedRectangle(cornerRadius: 20, style: .continuous))+ .shadow(color: .black.opacity(0.3), radius: 30, y: 12)+ .scaleEffect(shown ? 1 : 0.96)+ .opacity(shown ? 1 : 0)+ .padding(24)+ }+ .accessibilityAddTraits(.isModal)+ }+}++private struct CodyncSheet<Sheet: View>: ViewModifier {+ @Binding var isPresented: Bool+ let sheet: () -> Sheet+ @Environment(\.modalHost) private var host+ @Environment(BotStore.self) private var store: BotStore?+ @Environment(AccountStore.self) private var accounts: AccountStore?+ @State private var id = UUID()++ func body(content: Content) -> some View {+ content+ .onChange(of: isPresented, initial: true) { _, _ in sync() }+ .onDisappear { host?.close(id) }+ }++ private func sync() {+ guard let host else { return }+ guard isPresented else { return host.close(id) }+ let binding = $isPresented+ // ponytail: the card's content is captured when it opens; state it reads through+ // stores and bindings stays live, plain values passed in don't refresh.+ host.present(id, AnyView(+ sheet()+ .environment(store)+ .environment(accounts)+ .environment(\.modalHost, host)+ .environment(\.dismissModal, DismissModalAction { binding.wrappedValue = false })+ ))+ }+}++public extension View {+ func hidesSystemNavigationBar() -> some View { self }+}+#endif++// MARK: - Tab bar++/// The iPhone's bottom bar (replaces `TabView`): a floating capsule of icon tabs.+public struct TabBar<ID: Hashable>: View {+ @Binding var selection: ID+ let tabs: [(id: ID, title: String, icon: String)]+ @Namespace private var thumb+ @Environment(\.accessibilityReduceMotion) private var reduceMotion++ public init(selection: Binding<ID>, tabs: [(id: ID, title: String, icon: String)]) {+ _selection = selection+ self.tabs = tabs+ }++ public var body: some View {+ HStack(spacing: 4) {+ ForEach(tabs, id: \.id) { tab in+ let on = tab.id == selection+ Button {+ withAnimation(Motion.reduced(Motion.morph, reduceMotion)) { selection = tab.id }+ } label: {+ VStack(spacing: 3) {+ Image(systemName: tab.icon).font(.system(size: 18, weight: .medium))+ Text(tab.title).font(.caption2.weight(.medium))+ }+ .foregroundStyle(on ? Palette.text : Palette.secondary)+ .frame(width: 76, height: 50)+ .background {+ if on {+ Capsule().fill(Palette.text.opacity(0.08)).matchedGeometryEffect(id: "tab", in: thumb)+ }+ }+ .contentShape(Capsule())+ }+ .buttonStyle(PressScale())+ .accessibilityAddTraits(on ? .isSelected : [])+ }+ }+ .padding(5)+ .glass(in: Capsule())+ }+}diff --git a/kit/Sources/CodyncUI/Screen/ScreenView.swift b/kit/Sources/CodyncUI/Screen/ScreenView.swiftindex 16f3a422..6ca855a8 100644--- a/kit/Sources/CodyncUI/Screen/ScreenView.swift+++ b/kit/Sources/CodyncUI/Screen/ScreenView.swift@@ -89,7 +89,7 @@ public struct ScreenView: View {private var topBar: some View {HStack(spacing: 8) {- IconButton("Close", "xmark") { dismiss() }+ OverlayButton("Close", "xmark") { dismiss() }if let agent, !interactive {Label("\(agent.name) is using the computer", systemImage: "cursorarrow.motionlines").font(.caption.weight(.medium))@@ -100,14 +100,14 @@ public struct ScreenView: View {Spacer()if session != nil {if interactive {- IconButton(keyboard ? "Hide keyboard" : "Keyboard", keyboard ? "keyboard.chevron.compact.down" : "keyboard") { keyboard.toggle() }- IconButton(mode == .trackpad ? "Touch mode: trackpad" : "Touch mode: direct", mode == .trackpad ? "rectangle.and.hand.point.up.left" : "hand.point.up.left") {+ OverlayButton(keyboard ? "Hide keyboard" : "Keyboard", keyboard ? "keyboard.chevron.compact.down" : "keyboard") { keyboard.toggle() }+ OverlayButton(mode == .trackpad ? "Touch mode: trackpad" : "Touch mode: direct", mode == .trackpad ? "rectangle.and.hand.point.up.left" : "hand.point.up.left") {mode = mode == .trackpad ? .direct : .trackpad}clipboardMenu}if zoomed {- IconButton("Fit screen", "arrow.down.right.and.arrow.up.left") { resetToken += 1 }+ OverlayButton("Fit screen", "arrow.down.right.and.arrow.up.left") { resetToken += 1 }}if let displays = screen?.displays, displays.count > 1 {DropdownMenu {@@ -120,7 +120,7 @@ public struct ScreenView: View {}} label: { IconLabel("Displays", "display.2") }}- IconButton(interactive ? "Hand back to bots" : "Take over", interactive ? "hand.raised.slash" : "hand.raised") {+ OverlayButton(interactive ? "Hand back to bots" : "Take over", interactive ? "hand.raised.slash" : "hand.raised") {setInteractive(!interactive)}}@@ -207,7 +207,7 @@ private struct Overlay: View {}}-private struct IconButton: View {+private struct OverlayButton: View {let label: Stringlet icon: Stringlet action: () -> Void