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
refactor(kit): keep each platform's chat chrome in its own file
leepokaif9b8859498f0
diff --git a/AGENTS.md b/AGENTS.mdindex b3f0cc2a..bd01d7df 100644--- a/AGENTS.md+++ b/AGENTS.md@@ -48,6 +48,7 @@ Name Swift files after their main `UpperCamelCase` type; use `snake_case.rs` and- Keep shared features, actions, terminology, displayed information, and loading, empty, error, and permission states consistent. Adapt layout, controls, and input to each platform, including terminal keyboard interaction, while preserving the same user-facing behavior.- Inspect every client's corresponding implementation before finishing a UI task. Implement applicable changes together; do not silently defer another client. For a platform-only change or an unsupported capability, document which clients are unaffected and the concrete reason in the change summary.- Validate each affected client with its relevant build/tests and UI checks. Report any checks that could not run and why.+- Shared SwiftUI (`kit/`) builds into both iPhone and Mac: never change a shared view's or control's defaults for one platform, and keep one-platform chrome in platform files ([ui-conventions](docs/design/ui-conventions.md#shared-code-across-iphone-and-mac)).## Testing Guidelinesdiff --git a/CLAUDE.md b/CLAUDE.mdindex 45f9e82a..5c581ede 100644--- a/CLAUDE.md+++ b/CLAUDE.md@@ -41,6 +41,7 @@ Bot-based remote for coding agents: persistent named bots on your computer, mess- Keep shared features, actions, terminology, displayed information, and loading, empty, error, and permission states consistent. Adapt layout, controls, and input to each platform, including terminal keyboard interaction, while preserving the same user-facing behavior.- Inspect every client's corresponding implementation before finishing a UI task. Implement applicable changes together; do not silently defer another client. For a platform-only change or an unsupported capability, document which clients are unaffected and the concrete reason in the change summary.- Validate each affected client with its relevant build/tests and UI checks. Report any checks that could not run and why.+- Shared SwiftUI (`kit/`) builds into both iPhone and Mac: never change a shared view's or control's defaults for one platform, and keep one-platform chrome in platform files ([ui-conventions](docs/design/ui-conventions.md#shared-code-across-iphone-and-mac)).## Codync 1.x does not exist for usdiff --git a/docs/design/ui-conventions.md b/docs/design/ui-conventions.mdindex 7523ed9b..78eb27b7 100644--- a/docs/design/ui-conventions.md+++ b/docs/design/ui-conventions.md@@ -10,7 +10,7 @@ Do not wrap those toolbar controls in `IconButtonStyle`, hand-sized rounded backConnecting and reconnecting are background work. `BotStore` gives initial offline reports 1 second to recover and holds drops from online (including relay "computer offline" reports) for 5 seconds. "No access" shows immediately. Automatic read acknowledgements never open an error dialog and visible conversations are acknowledged again after reconnecting. An action taken during a reconnect (back in the foreground, a new network, a drop still inside its grace) waits for the link, up to 20 seconds, instead of failing; while one waits, headers read `Connecting…` and the conversation's connection label shows a spinner. Calls that are safe to repeat (send, stop, approvals, pin, hide, mark as read, delete) are tried again when the link drops under them. Tapping while the header says Offline because the computer can't be reached starts a fresh connection attempt and waits for it, instead of failing until the backoff gets there; a computer the relay reports as off fails at once, since the relay says when it is back. A permission card shows a spinner on the chosen option, dims the others and takes no second answer until the computer has it. The Linux app and the TUI follow the same rule over loopback: a command the host can't be reached for is retried for up to 20 seconds behind their "Reconnecting…" indicator (the `hello` probe that explains an unreachable host still answers at once), and their permission cards spin on the chosen option. The "Something went wrong" dialog is left for a computer that is off, a refused device, the computer's own answers, and reconnects that outlast the wait. Background work (cloud refresh, device registration, automatic access requests) logs connection, busy-cloud and stale-token failures instead of showing them. The iOS app disconnects only in `.background`, not `.inactive`. Connection status lives only in headers and their menus. The roster header shows a small summary (`1 connected`, `1/2 connected`, `2 offline`, or `Connecting…`). Its computer menu supports multiple selections, Show only, All computers, reconnect, and management. At least one available computer stays selected; if saved exclusions would hide every computer, the list falls back to all. Filters persist on the device. Bots sort pinned first, then by recency. On iPhone, when more than one computer is shown, each computer gets a light heading (badge, name, connection, and "No bots yet" when empty) above its own bots; with one computer the list stays flat. Tapping a heading folds that computer's bots away (chevron; saved on the device). Long-press a heading to lift the whole section and drag it up or down; the other sections slide out of its way and the order is saved on the device on release (`AccountStore.move`; VoiceOver: Move up / Move down). The Mac shows a flat roster. There are no connection banners. The compact Mac rail uses a computer icon for the same menu. Conversation headers show a small connection label, with the computer name available in the header menu or help text. Pull-to-refresh remains available on iPhone. Computer setup and access requests live under Manage computers.-Sources: `apps/ios/Views/BotListView.swift`, `AccountSwitcherView.swift`, `kit/Sources/CodyncUI/Thread/ThreadView.swift`, `Bots/ComputerFilterHeader.swift`, `Store/ComputerSelection.swift`, `Bots/BotRow.swift`.+Sources: `apps/ios/Views/BotListView.swift`, `AccountSwitcherView.swift`, `kit/Sources/CodyncUI/Thread/ThreadView+iOS.swift`, `Bots/ComputerFilterHeader.swift`, `Store/ComputerSelection.swift`, `Bots/BotRow.swift`.## macOS menu bar@@ -34,6 +34,14 @@ The chat window's account menu copies Grok Bot's: Usage, Get Codync for mobile,Source: `apps/macos/App/CodyncMacApp.swift`.+## Shared code across iPhone and Mac++`CodyncUI` is compiled into both apps, so editing a shared view or a control's default changes both. To keep a change for one platform from leaking into the other:++- A shared view or control must look the same on both platforms, apart from `InterfaceMetrics.value(mac:mobile:)` sizes. A one-platform look goes in that value's own side, or in a platform file; never change a shared default (fill, spacing, font) for one platform.+- Where a screen's chrome differs, it lives in a whole-file platform extension (`ThreadView+iOS.swift`, `ThreadView+macOS.swift`: `platformBody`, `platformChrome`, `header`), not in `#if os()` branches inside the shared body.+- A commit that touches `kit/` is scoped `kit`, not `macos` or `ios`, and is checked on both platforms.+## Shared application controlsOther custom screens use `Chrome.swift` and `Controls.swift`:diff --git a/kit/Sources/CodyncUI/Thread/ThreadView+iOS.swift b/kit/Sources/CodyncUI/Thread/ThreadView+iOS.swiftnew file mode 100644index 00000000..38990d37--- /dev/null+++ b/kit/Sources/CodyncUI/Thread/ThreadView+iOS.swift@@ -0,0 +1,76 @@+#if os(iOS)+import CodyncKit+import SwiftUI+import UIKit++extension ThreadView {+ var platformBody: some View {+ conversation+ .codyncSheet(item: $openThread) { target in+ RepliesView(botId: botId, rootId: target.id) { closeThread() }+ }+ }++ /// The system navigation bar: the title pill holds the bot's actions; the corner is the computer.+ func platformChrome(_ content: some View) -> some View {+ content+ .navigationBarTitleDisplayMode(.inline)+ .toolbar(.visible, for: .navigationBar)+ .toolbar {+ ToolbarItem(placement: .principal) {+ VStack(spacing: 0) {+ header+ connectionSubtitle+ }+ }+ if model.screen != nil {+ ToolbarItem(placement: .topBarTrailing) { computerButton }+ }+ }+ }++ var header: some View {+ // Like Grok Bot: the title pill holds the bot's actions; the corner is the computer.+ Menu {+ Text("\(model.hostName) · \(model.connectionLabel)")+ Button("Reconnect", systemImage: "arrow.clockwise") { model.restartStream() }+ Divider()+ Button("Details", systemImage: "info.circle", action: openDetails)+ ForEach(menuItems) { item in+ if item.divider { Divider() }+ Button(role: item.destructive ? .destructive : nil, action: item.action) {+ if let icon = item.icon { Label(item.title, systemImage: icon) } else { Text(item.title) }+ }+ }+ } label: {+ title+ }+ .accessibilityLabel("\(bot?.name ?? "Conversation") actions")+ }++ private func openDetails() {+ if bot?.isGroup == true { editingGroup = true } else if let bot { editing = EditorRequest(BotDraft(bot)) }+ }++ /// Opens the computer's screen; pulses while this bot is operating it (watch, then take over).+ private var computerButton: some View {+ let operating = model.screen?.agentBot == botId+ return Button("Computer", systemImage: "desktopcomputer") {+ model.screenRequest = operating ? ScreenRequest(watching: botId) : ScreenRequest()+ }+ .symbolEffect(.pulse, options: .repeating, isActive: operating)+ }++ func dismissChatKeyboard() {+ UIApplication.shared.sendAction(#selector(UIResponder.resignFirstResponder), to: nil, from: nil, for: nil)+ }++ func presentRoutine() {+ showRoutines = true+ }++ func editProfile(_ bot: Bot) {+ editing = EditorRequest(BotDraft(bot))+ }+}+#endifdiff --git a/kit/Sources/CodyncUI/Thread/ThreadView+macOS.swift b/kit/Sources/CodyncUI/Thread/ThreadView+macOS.swiftnew file mode 100644index 00000000..12663d5c--- /dev/null+++ b/kit/Sources/CodyncUI/Thread/ThreadView+macOS.swift@@ -0,0 +1,344 @@+#if os(macOS)+import CodyncKit+import SwiftUI++extension ThreadView {+ var platformBody: some View {+ GeometryReader { geometry in+ HStack(spacing: 0) {+ conversation.frame(maxWidth: .infinity)+ if let openThread, geometry.size.width >= 680 {+ HStack(spacing: 0) {+ Rectangle().fill(Palette.border).frame(width: 1)+ RepliesView(botId: botId, rootId: openThread.id) { closeThread() }+ .frame(width: min(420, geometry.size.width * 0.45))+ }+ .id(openThread.id)+ .transition(.move(edge: .trailing).combined(with: .opacity))+ } else if showSettings && geometry.size.width >= 680 {+ HStack(spacing: 0) {+ Rectangle().fill(Palette.border).frame(width: 1)+ detailsPanel.frame(width: 292)+ }+ .transition(.move(edge: .trailing).combined(with: .opacity))+ }+ }+ .clipped()+ .onGeometryChange(for: CGFloat.self) {+ $0.size.width+ } action: {+ availableWidth = $0+ }+ }+ .ignoresSafeArea(.container, edges: .top)+ .animation(Motion.reduced(Motion.layout, reduceMotion), value: openThread)+ .codyncSheet(isPresented: $compactDetails) {+ detailsPanel.frame(width: 340, height: 600)+ }+ .codyncSheet(isPresented: Binding(get: { openThread != nil && availableWidth < 680 }, set: { if !$0 { openThread = nil } })) {+ if let openThread {+ RepliesView(botId: botId, rootId: openThread.id) { closeThread() }.frame(width: 440, height: 600)+ }+ }+ }++ func platformChrome(_ content: some View) -> some View {+ content+ // Grok's desktop chat: no title bar. The chat blurs and fades as it scrolls up, with the bot+ // in a floating solid pill and the actions as glass buttons on the right.+ .safeAreaInset(edge: .top, spacing: 0) {+ ZStack {+ HStack(spacing: 8) {+ Spacer(minLength: 0)+ if !showSettings || availableWidth < 680 {+ IconButton("Conversation details", systemImage: "chevron.left.2") { toggleDetails() }+ .keyboardShortcut("i", modifiers: [.command, .option])+ .frosted(in: Circle())+ .transition(.opacity)+ }+ }+ VStack(spacing: 2) {+ header+ if model.shownConnection != .online || model.mismatch != nil { connectionSubtitle }+ }+ .padding(.leading, 10)+ .padding(.trailing, 16)+ .padding(.vertical, 9)+ .background(Palette.background, in: Capsule())+ .shadow(color: .black.opacity(0.12), radius: 16, y: 4)+ }+ .padding(.horizontal, 16)+ .padding(.top, 10)+ .padding(.bottom, 14)+ .background(alignment: .top) { TopFade() }+ }+ }++ var header: some View {+ Button(action: toggleDetails) { title }+ .buttonStyle(.plain)+ .accessibilityLabel("View conversation details")+ .help("View conversation details")+ }++ private func toggleDetails() {+ if availableWidth < 680 {+ compactDetails.toggle()+ } else {+ withAnimation(Motion.reduced(Motion.layout, reduceMotion)) { showSettings.toggle() }+ }+ }++ /// Its own view so it stays live inside the compact modal (which captures its content).+ private var detailsPanel: some View {+ DetailsPanel(botId: botId, routineId: routineId, editing: $editingDetails, editGroup: { editingGroup = true },+ share: {+ compactDetails = false+ if let bot { templateRequest = EditorRequest(BotDraft(bot)) }+ }) {+ withAnimation(Motion.reduced(Motion.layout, reduceMotion)) { showSettings = false }+ compactDetails = false+ }+ .id(routineRequest)+ }++ func presentRoutine() {+ editingDetails = false+ openThread = nil+ showSettings = true+ if availableWidth < 680 { compactDetails = true }+ }++ func editProfile(_ bot: Bot) {+ withAnimation(Motion.reduced(Motion.layout, reduceMotion)) {+ editingDetails = true+ showSettings = true+ }+ if availableWidth < 680 { compactDetails = true }+ }+}++/// A group's bots in the Mac inspector; clicking one opens its own chat.+private struct GroupMembersList: View {+ let group: Bot+ @Environment(BotStore.self) private var model++ var body: some View {+ ScrollView {+ VStack(alignment: .leading, spacing: 2) {+ Text("\(group.members.count) bots").appFont(.system(size: 13, weight: .semibold)).padding(.bottom, 6)+ ForEach(model.members(of: group)) { bot in+ Button { model.selection = bot.id } label: {+ HStack(spacing: 10) {+ CharacterAvatar(bot: bot, size: 26)+ VStack(alignment: .leading, spacing: 1) {+ Text(bot.name).appFont(.system(size: 13)).foregroundStyle(Palette.text)+ Text(bot.isWorking ? (bot.activity.isEmpty ? "Working…" : bot.activity) : bot.folderName)+ .appFont(.system(size: 11)).foregroundStyle(Palette.tertiary).lineLimit(1)+ }+ Spacer()+ }+ .padding(.vertical, 6)+ .contentShape(Rectangle())+ }+ .buttonStyle(PressScale())+ .help("Open \(bot.name)'s own chat")+ }+ }+ .padding(.horizontal, 16)+ }+ }+}++/// The Mac inspector beside a conversation: the computer, the agent, and the bot's settings.+private struct DetailsPanel: View {+ let botId: String+ let routineId: String?+ @Binding var editing: Bool+ let editGroup: () -> Void+ /// Shares the bot as a template.+ let share: () -> Void+ let close: () -> Void+ @Environment(BotStore.self) private var model+ @Environment(\.accessibilityReduceMotion) private var reduceMotion++ private var bot: Bot? { model.bots[botId] }++ var body: some View {+ VStack(spacing: 0) {+ HStack(spacing: 8) {+ if editing {+ roundButton("Back to details", "chevron.left") { setEditing(false) }+ panelTitle("Settings")+ Spacer()+ } else if bot?.isGroup == true {+ panelTitle("Members")+ Spacer()+ roundButton("Edit group", "gearshape", action: editGroup)+ } else {+ panelTitle("Details")+ Spacer()+ roundButton("Create template", "square.and.arrow.up", action: share)+ roundButton("Bot settings", "gearshape") { setEditing(true) }+ }+ roundButton("Close details", "chevron.right.2", action: close)+ .keyboardShortcut("i", modifiers: [.command, .option])+ }+ .padding(.horizontal, 12)+ .frame(height: 54)+ ZStack {+ if let bot, bot.isGroup {+ GroupMembersList(group: bot)+ } else if editing {+ BotSettingsPanel(botId: botId)+ .transition(.move(edge: .trailing).combined(with: .opacity))+ } else {+ details+ .transition(.move(edge: .leading).combined(with: .opacity))+ }+ }+ .frame(maxHeight: .infinity, alignment: .top)+ .clipped()+ }+ .background(Palette.background)+ }++ private func setEditing(_ on: Bool) {+ withAnimation(Motion.reduced(Motion.layout, reduceMotion)) { editing = on }+ }++ private func panelTitle(_ title: String) -> some View {+ Text(title)+ .appFont(.system(size: 15, weight: .semibold))+ .foregroundStyle(Palette.text)+ .padding(.leading, 4)+ }++ /// A round action in the panel's header, frosted like the chat's title pill (Grok's style).+ private func roundButton(_ label: String, _ symbol: String, action: @escaping () -> Void) -> some View {+ Button(action: action) {+ Image(systemName: symbol)+ .appFont(.system(size: 13, weight: .medium))+ .foregroundStyle(Palette.text)+ .frame(width: 32, height: 32)+ .frosted(in: Circle())+ .contentShape(Circle())+ }+ .buttonStyle(PressScale())+ .accessibilityLabel(label)+ .help(label)+ }++ private var details: some View {+ ScrollView {+ VStack(alignment: .leading, spacing: 28) {+ computerSummary+ RoutinesView(botId: botId, initialId: routineId)+ if let bot { agentSummary(bot) }+ }+ .padding(.horizontal, 16)+ .padding(.top, 4)+ .padding(.bottom, 24)+ }+ }++ private var computerSummary: some View {+ VStack(alignment: .leading, spacing: 16) {+ HStack(spacing: 12) {+ // Laptop, Mac mini, Linux…: the computer's own icon and color, as everywhere else.+ ComputerBadge(model.computer, size: 32)+ VStack(alignment: .leading, spacing: 4) {+ Text(model.hostName)+ .appFont(.system(size: 15, weight: .medium))+ .foregroundStyle(Palette.text)+ .lineLimit(2)+ Text("Remote screen")+ .appFont(.system(size: 13))+ .foregroundStyle(Palette.secondary)+ }+ }+ if !model.isOffline {+ Label(computerStatus, systemImage: computerStatusSymbol)+ .appFont(.system(size: 13))+ .foregroundStyle(Palette.text)+ .fixedSize(horizontal: false, vertical: true)+ }+ if screenReady {+ Text("View and control this Mac from your iPhone.")+ .appFont(.system(size: 12))+ .foregroundStyle(Palette.secondary)+ .fixedSize(horizontal: false, vertical: true)+ .padding(.top, -8)+ }+ }+ .frame(maxWidth: .infinity, alignment: .leading)+ .padding(16)+ .background(Palette.surface, in: RoundedRectangle(cornerRadius: 16, style: .continuous))+ }++ private func agentSummary(_ bot: Bot) -> some View {+ CardSection("Agent", footer: bot.description.isEmpty ? nil : bot.description) {+ infoRow("Runtime") {+ HStack(spacing: 6) {+ AgentIcon(registry: model.hello?.backends.first { $0.id == bot.backend }?.registry, size: 14)+ Text(model.backendName(bot.backend))+ }+ }+ infoRow(bot.managedWorkspace ? "Workspace" : "Folder") {+ Text(bot.managedWorkspace ? "Personal" : bot.folderName)+ .truncationMode(.middle)+ .help(bot.managedWorkspace ? "Personal workspace, managed by Codync" : bot.cwd)+ }+ if let chosen = bot.model, !chosen.isEmpty {+ infoRow("Model") { Text(chosen).truncationMode(.middle) }+ }+ }+ }++ /// Label on the left, value on the right, one line.+ private func infoRow(_ label: String, @ViewBuilder value: () -> some View) -> some View {+ HStack(spacing: 12) {+ Text(label).foregroundStyle(Palette.secondary)+ Spacer(minLength: 8)+ value().foregroundStyle(Palette.text).lineLimit(1)+ }+ .appFont(.system(size: 13))+ }++ private var screenReady: Bool {+ !model.isOffline && model.screen?.enabled == true+ && model.screen?.connected == true && model.screen?.capture == true+ }++ private var computerStatusSymbol: String {+ guard let screen = model.screen, screen.enabled else { return "power" }+ if !screen.connected { return "arrow.triangle.2.circlepath" }+ if !screen.capture { return "exclamationmark.circle" }+ return screen.agentBot == botId ? "cursorarrow.motionlines" : "checkmark.circle"+ }++ private var computerStatus: String {+ 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 to connect"+ }+}++/// The top edge of the chat: messages fade out gradually as they scroll under the title pill,+/// readable behind the pill and gone only at the very top.+private struct TopFade: View {+ var body: some View {+ ZStack {+ Rectangle().fill(.ultraThinMaterial)+ .mask(LinearGradient(colors: [.black, .clear], startPoint: .top, endPoint: .center))+ LinearGradient(stops: [.init(color: Palette.background, location: 0),+ .init(color: Palette.background.opacity(0.6), location: 0.35),+ .init(color: Palette.background.opacity(0), location: 1)],+ startPoint: .top, endPoint: .bottom)+ }+ .ignoresSafeArea(edges: .top)+ .allowsHitTesting(false)+ }+}+#endifdiff --git a/kit/Sources/CodyncUI/Thread/ThreadView.swift b/kit/Sources/CodyncUI/Thread/ThreadView.swiftindex d4f0ffce..befc4d4c 100644--- a/kit/Sources/CodyncUI/Thread/ThreadView.swift+++ b/kit/Sources/CodyncUI/Thread/ThreadView.swift@@ -1,8 +1,5 @@import CodyncKitimport SwiftUI-#if os(iOS)- import UIKit-#endif/// One endless conversation with a bot or a group chat. Only deliberate messages show/// here; tool calls and thinking live in the "Full conversation" sheet. Any message can@@ -11,85 +8,42 @@ public struct ThreadView: View {let botId: Stringpublic init(botId: String) { self.botId = botId }- @Environment(BotStore.self) private var model- @Environment(\.dismiss) private var dismiss- @State private var showTrace = false- @State private var openThread: ThreadTarget?- @State private var editingGroup = false- @State private var editing: EditorRequest?- @State private var templateRequest: EditorRequest?- @State private var confirmNewSession = false- @State private var confirmDelete: Bot?+ @Environment(BotStore.self) var model+ @Environment(\.dismiss) var dismiss+ @State var showTrace = false+ @State var openThread: ThreadTarget?+ @State var editingGroup = false+ @State var editing: EditorRequest?+ @State var templateRequest: EditorRequest?+ @State var confirmNewSession = false+ @State var confirmDelete: Bot?/// Desktop: the bot's settings as an inspector beside the chat.- @State private var showSettings = true- @State private var editingDetails = false- @State private var availableWidth: CGFloat = 800- @State private var compactDetails = false- @State private var calling = false- @State private var callSpeaking = false- @State private var interruptCall: (() -> Void)?- @State private var showRoutines = false- @State private var routineId: String?- @State private var routineRequest = UUID()- @State private var isAtBottom = true- @Environment(\.accessibilityReduceMotion) private var reduceMotion+ @State var showSettings = true+ @State var editingDetails = false+ @State var availableWidth: CGFloat = 800+ @State var compactDetails = false+ @State var calling = false+ @State var callSpeaking = false+ @State var interruptCall: (() -> Void)?+ @State var showRoutines = false+ @State var routineId: String?+ @State var routineRequest = UUID()+ @State var isAtBottom = true+ @Environment(\.accessibilityReduceMotion) var reduceMotion#if os(macOS)- @Environment(\.conversationTypography) private var typography+ @Environment(\.conversationTypography) var typography#endif- private var bot: Bot? { model.bots[botId] }+ 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 let openThread, geometry.size.width >= 680 {- HStack(spacing: 0) {- Rectangle().fill(Palette.border).frame(width: 1)- RepliesView(botId: botId, rootId: openThread.id) { closeThread() }- .frame(width: min(420, geometry.size.width * 0.45))- }- .id(openThread.id)- .transition(.move(edge: .trailing).combined(with: .opacity))- } else if showSettings && geometry.size.width >= 680 {- HStack(spacing: 0) {- Rectangle().fill(Palette.border).frame(width: 1)- detailsPanel.frame(width: 292)- }- .transition(.move(edge: .trailing).combined(with: .opacity))- }- }- .clipped()- .onGeometryChange(for: CGFloat.self) {- $0.size.width- } action: {- availableWidth = $0- }- }- .ignoresSafeArea(.container, edges: .top)- .animation(Motion.reduced(Motion.layout, reduceMotion), value: openThread)- .codyncSheet(isPresented: $compactDetails) {- detailsPanel.frame(width: 340, height: 600)- }- .codyncSheet(isPresented: Binding(get: { openThread != nil && availableWidth < 680 }, set: { if !$0 { openThread = nil } })) {- if let openThread {- RepliesView(botId: botId, rootId: openThread.id) { closeThread() }.frame(width: 440, height: 600)- }- }- #else- conversation- .codyncSheet(item: $openThread) { target in- RepliesView(botId: botId, rootId: target.id) { closeThread() }- }- #endif- }+ public var body: some View { platformBody }- private func closeThread() {+ func closeThread() {withAnimation(Motion.reduced(Motion.layout, reduceMotion)) { openThread = nil }}- @ViewBuilder private var conversation: some View {+ /// The messages and the composer, without the platform's top chrome.+ @ViewBuilder private var chat: some View {let thread = model.chat(botId)let items = ChatItem.build(thread, streaming: bot?.isWorking(in: botId, thread: nil) == true && !model.isOffline)ScrollViewReader { proxy in@@ -189,93 +143,46 @@ public struct ThreadView: View {}}.animation(Motion.reduced(Motion.layout, reduceMotion), value: calling)- #if os(iOS)- .navigationBarTitleDisplayMode(.inline)- .toolbar(.visible, for: .navigationBar)- .toolbar {- ToolbarItem(placement: .principal) {- VStack(spacing: 0) {- header- connectionSubtitle- }- }- if model.screen != nil {- ToolbarItem(placement: .topBarTrailing) { computerButton }- }- }- #endif- #if os(macOS)- // Grok's desktop chat: no title bar. The chat blurs and fades as it scrolls up, with the bot- // in a floating solid pill and the actions as glass buttons on the right.- .safeAreaInset(edge: .top, spacing: 0) {- ZStack {- HStack(spacing: 8) {- Spacer(minLength: 0)- if !showSettings || availableWidth < 680 {- IconButton("Conversation details", systemImage: "chevron.left.2") { toggleDetails() }- .keyboardShortcut("i", modifiers: [.command, .option])- .frosted(in: Circle())- .transition(.opacity)- }- }- VStack(spacing: 2) {- header- if model.shownConnection != .online || model.mismatch != nil { connectionSubtitle }- }- .padding(.leading, 10)- .padding(.trailing, 16)- .padding(.vertical, 9)- .background(Palette.background, in: Capsule())- .shadow(color: .black.opacity(0.12), radius: 16, y: 4)+ }++ var conversation: some View {+ platformChrome(chat)+ .readingConversation(botId)+ .codyncSheet(isPresented: $showTrace) {+ TraceView(botId: botId)+ #if os(macOS)+ .frame(width: 620, height: 560)+ #endif+ }+ .codyncSheet(item: $templateRequest) { request in+ BotTemplateView(draft: request.draft)+ }+ .codyncSheet(item: $editing) { request in+ BotEditorView(draft: request.draft)+ }+ .codyncSheet(isPresented: $editingGroup) {+ GroupEditorView(group: bot)+ #if os(macOS)+ .frame(width: 420, height: 560)+ #endif+ }+ .codyncDialog("Start a new session?", isPresented: $confirmNewSession,+ message: "The conversation stays here, but the agent starts with a fresh context.") {+ [DialogAction("New session") { model.newSession(botId) }]+ }+ .codyncSheet(isPresented: $showRoutines) {+ ScrollView {+ RoutinesView(botId: botId, initialId: routineId) {+ withAnimation(Motion.reduced(Motion.layout, reduceMotion)) { showRoutines = false }+ }.padding(20)}- .padding(.horizontal, 16)- .padding(.top, 10)- .padding(.bottom, 14)- .background(alignment: .top) { TopFade() }- }- #endif- .readingConversation(botId)- .codyncSheet(isPresented: $showTrace) {- TraceView(botId: botId)- #if os(macOS)- .frame(width: 620, height: 560)- #endif- }- .codyncSheet(item: $templateRequest) { request in- BotTemplateView(draft: request.draft)- }- .codyncSheet(item: $editing) { request in- BotEditorView(draft: request.draft)- }- .codyncSheet(isPresented: $editingGroup) {- GroupEditorView(group: bot)#if os(macOS)- .frame(width: 420, height: 560)+ .frame(width: 440, height: 580)#endif- }- .codyncDialog("Start a new session?", isPresented: $confirmNewSession,- message: "The conversation stays here, but the agent starts with a fresh context.") {- [DialogAction("New session") { model.newSession(botId) }]- }- .codyncSheet(isPresented: $showRoutines) {- ScrollView {- RoutinesView(botId: botId, initialId: routineId) {- withAnimation(Motion.reduced(Motion.layout, reduceMotion)) { showRoutines = false }- }.padding(20)}- #if os(macOS)- .frame(width: 440, height: 580)- #endif- }- .deleteBotConfirmation($confirmDelete) { dismiss() }+ .deleteBotConfirmation($confirmDelete) { dismiss() }}- #if os(iOS)- private func dismissChatKeyboard() {- UIApplication.shared.sendAction(#selector(UIResponder.resignFirstResponder), to: nil, from: nil, for: nil)- }- #endif-// MARK: rows@ViewBuilder private func row(_ item: ChatItem) -> some View {@@ -307,7 +214,7 @@ public struct ThreadView: View {// MARK: chrome- private var connectionSubtitle: some View {+ var connectionSubtitle: some View {HStack(spacing: 6) {Group {if model.shownConnection == .connecting {@@ -356,48 +263,7 @@ public struct ThreadView: View {}}- private var header: some View {- #if os(iOS)- // Like Grok Bot: the title pill holds the bot's actions; the corner is the computer.- Menu {- Text("\(model.hostName) · \(model.connectionLabel)")- Button("Reconnect", systemImage: "arrow.clockwise") { model.restartStream() }- Divider()- Button("Details", systemImage: "info.circle", action: openDetails)- ForEach(menuItems) { item in- if item.divider { Divider() }- Button(role: item.destructive ? .destructive : nil, action: item.action) {- if let icon = item.icon { Label(item.title, systemImage: icon) } else { Text(item.title) }- }- }- } label: {- title- }- .accessibilityLabel("\(bot?.name ?? "Conversation") actions")- #else- Button(action: toggleDetails) { title }- .buttonStyle(.plain)- .accessibilityLabel("View conversation details")- .help("View conversation details")- #endif- }-- #if os(iOS)- private func openDetails() {- if bot?.isGroup == true { editingGroup = true } else if let bot { editing = EditorRequest(BotDraft(bot)) }- }-- /// Opens the computer's screen; pulses while this bot is operating it (watch, then take over).- private var computerButton: some View {- let operating = model.screen?.agentBot == botId- return Button("Computer", systemImage: "desktopcomputer") {- model.screenRequest = operating ? ScreenRequest(watching: botId) : ScreenRequest()- }- .symbolEffect(.pulse, options: .repeating, isActive: operating)- }- #endif-- private var title: some View {+ var title: some View {HStack(spacing: 7) {if let bot {let size: CGFloat = 22@@ -410,45 +276,15 @@ public struct ThreadView: View {}}- #if os(macOS)- private func toggleDetails() {- if availableWidth < 680 {- compactDetails.toggle()- } else {- withAnimation(Motion.reduced(Motion.layout, reduceMotion)) { showSettings.toggle() }- }- }-- /// Its own view so it stays live inside the compact modal (which captures its content).- private var detailsPanel: some View {- DetailsPanel(botId: botId, routineId: routineId, editing: $editingDetails, editGroup: { editingGroup = true },- share: {- compactDetails = false- if let bot { templateRequest = EditorRequest(BotDraft(bot)) }- }) {- withAnimation(Motion.reduced(Motion.layout, reduceMotion)) { showSettings = false }- compactDetails = false- }- .id(routineRequest)- }- #endif-- private func openRoutine(_ id: String?) {+ func openRoutine(_ id: String?) {withAnimation(Motion.reduced(Motion.layout, reduceMotion)) {routineId = idroutineRequest = UUID()- #if os(macOS)- editingDetails = false- openThread = nil- showSettings = true- if availableWidth < 680 { compactDetails = true }- #else- showRoutines = true- #endif+ presentRoutine()}}- private var menuItems: [MenuItem] {+ var menuItems: [MenuItem] {var items = [MenuItem("Full conversation", icon: "list.bullet.rectangle") { showTrace = true }]if let bot, bot.isGroup {items.append(MenuItem("Edit group", icon: "person.2") { editingGroup = true })@@ -458,15 +294,7 @@ public struct ThreadView: View {}if let bot {items.append(MenuItem("Edit profile", icon: "pencil") {- #if os(macOS)- withAnimation(Motion.reduced(Motion.layout, reduceMotion)) {- editingDetails = true- showSettings = true- }- if availableWidth < 680 { compactDetails = true }- #else- editing = EditorRequest(BotDraft(bot))- #endif+ editProfile(bot)})items.append(MenuItem(bot.pinned ? "Unpin" : "Pin", icon: "pin") { model.setPinned(bot, !bot.pinned) })}@@ -554,40 +382,6 @@ private struct GroupIntroCard: View {}}-#if os(macOS)-/// A group's bots in the Mac inspector; clicking one opens its own chat.-private struct GroupMembersList: View {- let group: Bot- @Environment(BotStore.self) private var model-- var body: some View {- ScrollView {- VStack(alignment: .leading, spacing: 2) {- Text("\(group.members.count) bots").appFont(.system(size: 13, weight: .semibold)).padding(.bottom, 6)- ForEach(model.members(of: group)) { bot in- Button { model.selection = bot.id } label: {- HStack(spacing: 10) {- CharacterAvatar(bot: bot, size: 26)- VStack(alignment: .leading, spacing: 1) {- Text(bot.name).appFont(.system(size: 13)).foregroundStyle(Palette.text)- Text(bot.isWorking ? (bot.activity.isEmpty ? "Working…" : bot.activity) : bot.folderName)- .appFont(.system(size: 11)).foregroundStyle(Palette.tertiary).lineLimit(1)- }- Spacer()- }- .padding(.vertical, 6)- .contentShape(Rectangle())- }- .buttonStyle(PressScale())- .help("Open \(bot.name)'s own chat")- }- }- .padding(.horizontal, 16)- }- }-}-#endif-private struct IntroCard: View {let bot: Bot@Environment(BotStore.self) private var model@@ -617,183 +411,6 @@ private struct IntroCard: View {}}-#if os(macOS)-/// The Mac inspector beside a conversation: the computer, the agent, and the bot's settings.-private struct DetailsPanel: View {- let botId: String- let routineId: String?- @Binding var editing: Bool- let editGroup: () -> Void- /// Shares the bot as a template.- let share: () -> Void- let close: () -> Void- @Environment(BotStore.self) private var model- @Environment(\.accessibilityReduceMotion) private var reduceMotion-- private var bot: Bot? { model.bots[botId] }-- var body: some View {- VStack(spacing: 0) {- HStack(spacing: 8) {- if editing {- roundButton("Back to details", "chevron.left") { setEditing(false) }- panelTitle("Settings")- Spacer()- } else if bot?.isGroup == true {- panelTitle("Members")- Spacer()- roundButton("Edit group", "gearshape", action: editGroup)- } else {- panelTitle("Details")- Spacer()- roundButton("Create template", "square.and.arrow.up", action: share)- roundButton("Bot settings", "gearshape") { setEditing(true) }- }- roundButton("Close details", "chevron.right.2", action: close)- .keyboardShortcut("i", modifiers: [.command, .option])- }- .padding(.horizontal, 12)- .frame(height: 54)- ZStack {- if let bot, bot.isGroup {- GroupMembersList(group: bot)- } else if editing {- BotSettingsPanel(botId: botId)- .transition(.move(edge: .trailing).combined(with: .opacity))- } else {- details- .transition(.move(edge: .leading).combined(with: .opacity))- }- }- .frame(maxHeight: .infinity, alignment: .top)- .clipped()- }- .background(Palette.background)- }-- private func setEditing(_ on: Bool) {- withAnimation(Motion.reduced(Motion.layout, reduceMotion)) { editing = on }- }-- private func panelTitle(_ title: String) -> some View {- Text(title)- .appFont(.system(size: 15, weight: .semibold))- .foregroundStyle(Palette.text)- .padding(.leading, 4)- }-- /// A round action in the panel's header, frosted like the chat's title pill (Grok's style).- private func roundButton(_ label: String, _ symbol: String, action: @escaping () -> Void) -> some View {- Button(action: action) {- Image(systemName: symbol)- .appFont(.system(size: 13, weight: .medium))- .foregroundStyle(Palette.text)- .frame(width: 32, height: 32)- .frosted(in: Circle())- .contentShape(Circle())- }- .buttonStyle(PressScale())- .accessibilityLabel(label)- .help(label)- }-- private var details: some View {- ScrollView {- VStack(alignment: .leading, spacing: 28) {- computerSummary- RoutinesView(botId: botId, initialId: routineId)- if let bot { agentSummary(bot) }- }- .padding(.horizontal, 16)- .padding(.top, 4)- .padding(.bottom, 24)- }- }-- private var computerSummary: some View {- VStack(alignment: .leading, spacing: 16) {- HStack(spacing: 12) {- // Laptop, Mac mini, Linux…: the computer's own icon and color, as everywhere else.- ComputerBadge(model.computer, size: 32)- VStack(alignment: .leading, spacing: 4) {- Text(model.hostName)- .appFont(.system(size: 15, weight: .medium))- .foregroundStyle(Palette.text)- .lineLimit(2)- Text("Remote screen")- .appFont(.system(size: 13))- .foregroundStyle(Palette.secondary)- }- }- if !model.isOffline {- Label(computerStatus, systemImage: computerStatusSymbol)- .appFont(.system(size: 13))- .foregroundStyle(Palette.text)- .fixedSize(horizontal: false, vertical: true)- }- if screenReady {- Text("View and control this Mac from your iPhone.")- .appFont(.system(size: 12))- .foregroundStyle(Palette.secondary)- .fixedSize(horizontal: false, vertical: true)- .padding(.top, -8)- }- }- .frame(maxWidth: .infinity, alignment: .leading)- .padding(16)- .background(Palette.surface, in: RoundedRectangle(cornerRadius: 16, style: .continuous))- }-- private func agentSummary(_ bot: Bot) -> some View {- CardSection("Agent", footer: bot.description.isEmpty ? nil : bot.description) {- infoRow("Runtime") {- HStack(spacing: 6) {- AgentIcon(registry: model.hello?.backends.first { $0.id == bot.backend }?.registry, size: 14)- Text(model.backendName(bot.backend))- }- }- infoRow(bot.managedWorkspace ? "Workspace" : "Folder") {- Text(bot.managedWorkspace ? "Personal" : bot.folderName)- .truncationMode(.middle)- .help(bot.managedWorkspace ? "Personal workspace, managed by Codync" : bot.cwd)- }- if let chosen = bot.model, !chosen.isEmpty {- infoRow("Model") { Text(chosen).truncationMode(.middle) }- }- }- }-- /// Label on the left, value on the right, one line.- private func infoRow(_ label: String, @ViewBuilder value: () -> some View) -> some View {- HStack(spacing: 12) {- Text(label).foregroundStyle(Palette.secondary)- Spacer(minLength: 8)- value().foregroundStyle(Palette.text).lineLimit(1)- }- .appFont(.system(size: 13))- }-- private var screenReady: Bool {- !model.isOffline && model.screen?.enabled == true- && model.screen?.connected == true && model.screen?.capture == true- }-- private var computerStatusSymbol: String {- guard let screen = model.screen, screen.enabled else { return "power" }- if !screen.connected { return "arrow.triangle.2.circlepath" }- if !screen.capture { return "exclamationmark.circle" }- return screen.agentBot == botId ? "cursorarrow.motionlines" : "checkmark.circle"- }-- private var computerStatus: String {- 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 to connect"- }-}-#endif-private extension View {@ViewBuilder func conversationInitialBottomAnchor() -> some View {if #available(iOS 18, macOS 15, *) {@@ -824,21 +441,3 @@ private extension View {}}-#if os(macOS)- /// The top edge of the chat: messages fade out gradually as they scroll under the title pill,- /// readable behind the pill and gone only at the very top.- private struct TopFade: View {- var body: some View {- ZStack {- Rectangle().fill(.ultraThinMaterial)- .mask(LinearGradient(colors: [.black, .clear], startPoint: .top, endPoint: .center))- LinearGradient(stops: [.init(color: Palette.background, location: 0),- .init(color: Palette.background.opacity(0.6), location: 0.35),- .init(color: Palette.background.opacity(0), location: 1)],- startPoint: .top, endPoint: .bottom)- }- .ignoresSafeArea(edges: .top)- .allowsHitTesting(false)- }- }-#endif