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.

fix(ios): drag bots anywhere in the roster

leepokai427fa0d0d501
diff --git a/CLAUDE.md b/CLAUDE.md
index ed6ba1f4..86882f02 100644
--- a/CLAUDE.md
+++ b/CLAUDE.md
@@ -22,7 +22,7 @@ Bot-based remote for coding agents: persistent named bots on your computer, mess
- Clients: iOS app (SwiftUI), desktop app for macOS, Linux and Windows (`apps/desktop/`, Electron: menu bar/tray + chat window; why and how: [docs/architecture/desktop-app.md](docs/architecture/desktop-app.md)), terminal UI (`codync-host tui`, `host/src/tui/`, ratatui; layout and state vocabulary modeled on herdr). All talk to the host API.
- iPhone Swift package (`apps/ios/Kit/`, iOS only): `CodyncKit` (models, client, theme, avatars; also used by the widgets and the notification extension) + `CodyncUI` (`BotStore` + screens).
- UI principle: buttons an icon can express are icon-only (with tooltip / accessibility label); text only where an icon would be ambiguous (approval choices).
-- UI controls default to the shared custom components. Explicit exception: iOS BotListView and ThreadView use native navigation/toolbar items and automatic back navigation, and the iPhone root uses the system `TabView`, for system Liquid Glass, as specified in `docs/design/ui-conventions.md`. **iOS menus are always the system ones**: tap menus through `DropdownMenu`/`ChoicePicker` (native `Menu`), long-press through `.contextActions` (native `contextMenu`). Never hand-build a dropdown on iOS: a custom overlay lands in the wrong place (sheets, scroll views, the composer's + menu). The desktop app's menu bar/tray menu is the system menu. Keep system authentication and widget containers native. On iOS `.codyncSheet` presents the system sheet (grabber, swipe down). Outside these exceptions, avoid: no `Menu`/`Picker`, `.switch` toggles, `Form`/`List` styling, `confirmationDialog`/`alert`, `ProgressView`, `.sheet`/`.popover`/`.fullScreenCover`, `.toolbar`/navigation bars, `ContentUnavailableView`. Use `apps/ios/Kit/Sources/CodyncUI/Controls.swift` + `Chrome.swift` (`.codyncSheet`, `ModalHeader`, `ScreenHeader`, `.codyncDialog`, `ToggleStyle.codync`); on the desktop, `apps/desktop/src/renderer/components/` (`Sheet`, `Dialog`, `AnchoredMenu`, `ModalHeader`, `Controls.tsx`, `Icon` for SF Symbols). Every tap that shows/hides something animates (`Motion`). Anything with a background fill gets no border line.
+- UI controls default to the shared custom components. Explicit exception: iOS BotListView and ThreadView use native navigation/toolbar items and automatic back navigation, and the iPhone root uses the system `TabView`, for system Liquid Glass; BotListView is a `List` with its styling removed, for system drag-to-reorder; as specified in `docs/design/ui-conventions.md`. **iOS menus are always the system ones**: tap menus through `DropdownMenu`/`ChoicePicker` (native `Menu`), long-press through `.contextActions` (native `contextMenu`). Never hand-build a dropdown on iOS: a custom overlay lands in the wrong place (sheets, scroll views, the composer's + menu). The desktop app's menu bar/tray menu is the system menu. Keep system authentication and widget containers native. On iOS `.codyncSheet` presents the system sheet (grabber, swipe down). Outside these exceptions, avoid: no `Menu`/`Picker`, `.switch` toggles, `Form`/`List` styling, `confirmationDialog`/`alert`, `ProgressView`, `.sheet`/`.popover`/`.fullScreenCover`, `.toolbar`/navigation bars, `ContentUnavailableView`. Use `apps/ios/Kit/Sources/CodyncUI/Controls.swift` + `Chrome.swift` (`.codyncSheet`, `ModalHeader`, `ScreenHeader`, `.codyncDialog`, `ToggleStyle.codync`); on the desktop, `apps/desktop/src/renderer/components/` (`Sheet`, `Dialog`, `AnchoredMenu`, `ModalHeader`, `Controls.tsx`, `Icon` for SF Symbols). Every tap that shows/hides something animates (`Motion`). Anything with a background fill gets no border line.
- `host/` — **codync-host** (Rust, macOS + Linux + Windows; platform differences in `service/` and `shell.rs`). Detects installed harnesses (`agent/backends.rs`: login-shell PATH + known dirs) and the ACP registry (`agent/registry.rs`, cached in `~/.codync/registry.json`, binaries under `~/.codync/agents`). Drives agents over **ACP** (JSON-RPC on stdio, hand-rolled in `agent/acp.rs`, updates kept as `serde_json::Value` so new adapter variants never break parsing). One actor per bot (`agent/bot/`) owns the agent process + session and maps `session/update` onto transcript entries.
- Chat/session ownership, groups, collaboration, Engram memory and visible-message rules: [conversation runtime](docs/architecture/conversation-runtime.md).
- **Sync**: every mutation stamps a global `rev`. Clients call `GET /events?since=<rev>` (catch-up in rev order, then live). Emission happens under `Hub::emit_lock` so events leave in rev order. Clients upsert by id; never skip undecodable events (the iOS app rewinds to rev 0).
diff --git a/apps/Codync.xcodeproj/project.pbxproj b/apps/Codync.xcodeproj/project.pbxproj
index 6b80c39f..84bccef2 100644
--- a/apps/Codync.xcodeproj/project.pbxproj
+++ b/apps/Codync.xcodeproj/project.pbxproj
@@ -34,7 +34,6 @@
646410F85B1110297E5F54B9 /* CodyncBot-squircle-Tint.ttf in Resources */ = {isa = PBXBuildFile; fileRef = D5F23C3F9FCE63B4AFB4771A /* CodyncBot-squircle-Tint.ttf */; };
674BCFBAC7022359FB673FDB /* PrivacyInfo.xcprivacy in Resources */ = {isa = PBXBuildFile; fileRef = AD18A04CD014230F1B7B0535 /* PrivacyInfo.xcprivacy */; };
684F7F77EECBA0BD95BDD658 /* UsageView.swift in Sources */ = {isa = PBXBuildFile; fileRef = CFEBE2E6A9D0AF0A0D89FFE7 /* UsageView.swift */; };
- 6BFFA8A75324425132F1FC2C /* ComputerSectionGesture.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2A379E88F918744832CF0CB0 /* ComputerSectionGesture.swift */; };
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 */; };
@@ -48,7 +47,6 @@
8B78A34695AD94109AE82C0F /* CodyncBot-blob-Tint.ttf in Resources */ = {isa = PBXBuildFile; fileRef = D0E552136D473567E0C25ED4 /* CodyncBot-blob-Tint.ttf */; };
8BB3FC79EB798CE4347E6FD3 /* CodyncKit in Frameworks */ = {isa = PBXBuildFile; productRef = 50F314172CC2AD1C5CDC916A /* CodyncKit */; };
921ED46A1643AB90BB3D4CF7 /* Session.swift in Sources */ = {isa = PBXBuildFile; fileRef = F99C11684BFBEB49006600A9 /* Session.swift */; };
- 9230B7E6BFE8FB9D6F547955 /* BotRowDrop.swift in Sources */ = {isa = PBXBuildFile; fileRef = A59AE5FF815ED4C3E61279E1 /* BotRowDrop.swift */; };
9638BAA981354C4CE72884A0 /* HostLink.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8CC3E47D480A5F15CA95C504 /* HostLink.swift */; };
974A5D8D89758A61E7D8D1B6 /* Input.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8BA06CEE98A7CDED62678522 /* Input.swift */; };
980C29719BDE2E874C9AD53A /* CodyncBot-wedge-Tint.ttf in Resources */ = {isa = PBXBuildFile; fileRef = C3BB9F034194450254CE14EC /* CodyncBot-wedge-Tint.ttf */; };
@@ -118,7 +116,6 @@
1FECC371F3CD98687C0B69FA /* CodyncBot-pebble-Tint.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "CodyncBot-pebble-Tint.ttf"; sourceTree = "<group>"; };
203A43D8DF8D3832F95FA837 /* CodyncBot-teardrop-Ink.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "CodyncBot-teardrop-Ink.ttf"; sourceTree = "<group>"; };
28B2CB561A43ED9F2F1A4391 /* ScreenHelper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ScreenHelper.swift; sourceTree = "<group>"; };
- 2A379E88F918744832CF0CB0 /* ComputerSectionGesture.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ComputerSectionGesture.swift; sourceTree = "<group>"; };
2C0E04490F5C56FD070539E6 /* ViewingBadge.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewingBadge.swift; sourceTree = "<group>"; };
305DDCC18BB8AA6CD9D19CEF /* WidgetPreviews.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WidgetPreviews.swift; sourceTree = "<group>"; };
31BFDAD6DCCE1CC98642ACDD /* AccountSession.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AccountSession.swift; sourceTree = "<group>"; };
@@ -145,7 +142,6 @@
8D16AD9979C77D976BC832D1 /* Driver.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Driver.swift; sourceTree = "<group>"; };
8E783FFF5EC2697C16FA2E1B /* CodyncOrb-Ghost.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "CodyncOrb-Ghost.ttf"; sourceTree = "<group>"; };
9AD0BD16672E128A4F26272B /* SignInButtons.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SignInButtons.swift; sourceTree = "<group>"; };
- A59AE5FF815ED4C3E61279E1 /* BotRowDrop.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BotRowDrop.swift; sourceTree = "<group>"; };
A65FE0504B741D0B44DB2516 /* CodyncApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CodyncApp.swift; sourceTree = "<group>"; };
AAD970B8394F4EDFB85A8936 /* CodyncBot-cloud-Tint.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "CodyncBot-cloud-Tint.ttf"; sourceTree = "<group>"; };
AD18A04CD014230F1B7B0535 /* PrivacyInfo.xcprivacy */ = {isa = PBXFileReference; path = PrivacyInfo.xcprivacy; sourceTree = "<group>"; };
@@ -291,8 +287,6 @@
4EB282B31FBC94EE70D07638 /* AccountSwitcherView.swift */,
DD3DE9A4EEB369C4F75C9448 /* ActivityGalleryView.swift */,
0582B6169BFC36E4BCD51C0D /* BotListView.swift */,
- A59AE5FF815ED4C3E61279E1 /* BotRowDrop.swift */,
- 2A379E88F918744832CF0CB0 /* ComputerSectionGesture.swift */,
6BC00039A6C2C0D3F39A5F67 /* ComputerStatus.swift */,
6FC76D28AB02DF1427D530ED /* LaunchSplash.swift */,
ECD0B4EA4BBA2BB2826C4362 /* PairingView.swift */,
@@ -670,9 +664,7 @@
9BBB2FAEDBD35A83EAB02981 /* AccountSwitcherView.swift in Sources */,
00F78E3DAAF66E8E0933D091 /* ActivityGalleryView.swift in Sources */,
01A1F820EFEE49A8FCCFC3F3 /* BotListView.swift in Sources */,
- 9230B7E6BFE8FB9D6F547955 /* BotRowDrop.swift in Sources */,
7C20764DC05D499075BC5E8C /* CodyncApp.swift in Sources */,
- 6BFFA8A75324425132F1FC2C /* ComputerSectionGesture.swift in Sources */,
2002C16E427B4E4E7279E1C4 /* ComputerStatus.swift in Sources */,
35CFB641A4F10C0EBD21CB14 /* LaunchSplash.swift in Sources */,
E695251CFD06AC6F4E3396B7 /* OpenBotIntent.swift in Sources */,
diff --git a/apps/ios/Kit/Sources/CodyncUI/Store/BotStore+Actions.swift b/apps/ios/Kit/Sources/CodyncUI/Store/BotStore+Actions.swift
index 9bcd16f8..d0004543 100644
--- a/apps/ios/Kit/Sources/CodyncUI/Store/BotStore+Actions.swift
+++ b/apps/ios/Kit/Sources/CodyncUI/Store/BotStore+Actions.swift
@@ -177,43 +177,20 @@ extension BotStore {
// MARK: roster order
- /// Moves a dragged bot into `target`'s place, among bots with the same pin state. Shown at
- /// once; sent when the drag is dropped (`saveOrder`), or once it has been still a moment.
- @discardableResult
- public func move(_ botId: String, onto target: String) -> Bool {
- var ids = roster.map(\.id)
- guard botId != target, bots[botId]?.pinned == bots[target]?.pinned,
- let from = ids.firstIndex(of: botId), let to = ids.firstIndex(of: target) else { return false }
- ids.remove(at: from)
- ids.insert(botId, at: to)
- reorder(ids)
- orderSave = Task { [weak self] in
- // ponytail: a pause mid-drag sends early; the host's echo can briefly undo a move made right after.
- try? await Task.sleep(for: .seconds(1.5))
- if !Task.isCancelled { self?.saveOrder() }
- }
- return true
- }
-
- /// One place up (-1) or down (+1) among bots with the same pin state (VoiceOver), sent now.
- public func move(_ botId: String, by offset: Int) {
- let ids = roster.map(\.id)
- guard let i = ids.firstIndex(of: botId), ids.indices.contains(i + offset), move(botId, onto: ids[i + offset]) else { return }
- saveOrder()
- }
-
- /// Sends a dragged order that hasn't been sent.
- public func saveOrder() {
- guard let pending = orderSave else { return }
- pending.cancel()
- orderSave = nil
- let ids = roster.map(\.id)
+ /// Puts the roster in `ids` order (pinned bots still sort first) and sends it; the host
+ /// syncs it to every device.
+ public func reorder(_ ids: [String]) {
+ for (position, id) in ids.enumerated() { bots[id]?.position = position }
perform(replay: true) { try await $0.reorderBots(ids) }
}
- private func reorder(_ ids: [String]) {
- orderSave?.cancel()
- for (position, id) in ids.enumerated() { bots[id]?.position = position }
+ /// One place up (-1) or down (+1) among bots with the same pin state (VoiceOver).
+ public func move(_ botId: String, by offset: Int) {
+ var ids = roster.map(\.id)
+ guard let i = ids.firstIndex(of: botId), ids.indices.contains(i + offset),
+ bots[ids[i + offset]]?.pinned == bots[botId]?.pinned else { return }
+ ids.swapAt(i, i + offset)
+ reorder(ids)
}
public func delete(_ bot: Bot) {
diff --git a/apps/ios/Kit/Sources/CodyncUI/Store/BotStore.swift b/apps/ios/Kit/Sources/CodyncUI/Store/BotStore.swift
index 20870199..7aad8c8e 100644
--- a/apps/ios/Kit/Sources/CodyncUI/Store/BotStore.swift
+++ b/apps/ios/Kit/Sources/CodyncUI/Store/BotStore.swift
@@ -68,8 +68,6 @@ public final class BotStore {
/// Bots whose older history has been fully paged in.
public internal(set) var historyComplete: Set<String> = []
var composerDrafts: [String: String] = [:]
- /// A dragged order not sent yet (see `reorder`).
- var orderSave: Task<Void, Never>?
public var routineDrafts: [String: String] = [:]
public let fileDownloads = FileDownloads()
public var lastError: String?
diff --git a/apps/ios/Kit/Tests/CodyncUITests/RosterOrderTests.swift b/apps/ios/Kit/Tests/CodyncUITests/RosterOrderTests.swift
index edd9d3ef..f1afcb63 100644
--- a/apps/ios/Kit/Tests/CodyncUITests/RosterOrderTests.swift
+++ b/apps/ios/Kit/Tests/CodyncUITests/RosterOrderTests.swift
@@ -3,7 +3,7 @@ import Testing
@testable import CodyncKit
@testable import CodyncUI
-@MainActor @Test func draggingKeepsBotsAmongTheSamePinState() throws {
+@MainActor @Test func reorderingKeepsPinnedBotsOnTop() throws {
let suite = "RosterOrderTests.\(UUID().uuidString)"
defer { UserDefaults(suiteName: suite)?.removePersistentDomain(forName: suite) }
let storage = SharedStore.Context(accountID: UUID().uuidString, suite: suite)
@@ -17,11 +17,12 @@ import Testing
}
let order = { store.roster.map(\.id) }
#expect(order() == ["p", "a", "b", "c"]) // Never arranged: recent activity.
- #expect(store.move("c", onto: "a"))
+ store.reorder(["p", "c", "a", "b"])
+ #expect(order() == ["p", "c", "a", "b"])
+ store.move("a", by: -1)
+ #expect(order() == ["p", "a", "c", "b"])
+ store.move("a", by: -1) // An unpinned bot stays below the pinned ones.
+ #expect(order() == ["p", "a", "c", "b"])
+ store.reorder(["c", "p", "a", "b"]) // Dropped above a pinned bot: still listed below it.
#expect(order() == ["p", "c", "a", "b"])
- #expect(store.orderSave != nil) // Sent on drop, not on every pass.
- #expect(!store.move("a", onto: "p")) // An unpinned bot stays below the pinned ones.
- store.move("b", by: -1)
- #expect(order() == ["p", "c", "b", "a"])
- #expect(store.orderSave == nil)
}
diff --git a/apps/ios/Views/BotListView.swift b/apps/ios/Views/BotListView.swift
index 6e75537e..91335b0d 100644
--- a/apps/ios/Views/BotListView.swift
+++ b/apps/ios/Views/BotListView.swift
@@ -3,18 +3,16 @@ import CodyncUI
import SwiftUI
/// The roster: every bot on every computer is a person you can message (Grok Bot sidebar, phone-sized).
+/// A `List` with its styling taken away, for the system's reordering: touch and hold opens a bot's
+/// menu, and dragging it (before or after the menu shows) moves it.
struct BotListView: View {
@Environment(AppStore.self) private var app
@Environment(AccountStore.self) private var accounts
@State private var editing: EditTarget?
@State private var editingGroup: GroupTarget?
@State private var confirmDelete: RosterItem?
- /// The computer section being dragged by its long-pressed heading.
- @State private var drag: SectionDrag?
- /// Each computer section's height, to work out where a dragged one lands.
- @State private var sectionHeights: [ComputerID: CGFloat] = [:]
- /// The bot row being dragged among its computer's bots (see `BotRowDrop`).
- @State private var draggingBot: BotReference?
+ /// The bot whose row is lifted, to drag or for its menu.
+ @State private var lifted: String?
@Environment(\.accessibilityReduceMotion) private var reduceMotion
/// Computers left out of the list on this device, comma-separated IDs.
@AppStorage("hiddenComputers") private var hiddenComputers = ""
@@ -56,10 +54,21 @@ struct BotListView: View {
accounts.computers.compactMap { accounts.store(for: $0.id) }
}
+ /// The rows the user can drag: each shown computer's heading (with several computers), in the
+ /// order they were dragged into, followed by its bots unless it's folded away.
+ private var lines: [RosterLine] {
+ shownStores.flatMap { store -> [RosterLine] in
+ let id = store.computer.id
+ let bots = grouped && collapsedIDs.contains(id)
+ ? [] : accounts.roster.filter { $0.ref.computerId == id }.map { RosterLine.bot($0, store) }
+ return grouped ? [.computer(id, store)] + bots : bots
+ }
+ }
+
var body: some View {
let roster = accounts.roster.filter { shownIDs.contains($0.ref.computerId) }
- ScrollView {
- LazyVStack(spacing: 0) {
+ List {
+ Group {
// A newer app release (dismissible; everything still works). Computers update
// themselves, so a newer host gets no reminder here.
AppUpdateReminder()
@@ -72,50 +81,21 @@ struct BotListView: View {
EmptyRoster(canCreate: allStores.contains { $0.mismatch == nil }, hasComputer: !accounts.computers.isEmpty,
create: newBot, showComputers: { app.showComputers = true })
}
-
- if grouped {
- // A light heading per computer, in the order the user dragged them into.
- let ids = shownStores.map(\.computer.id)
- let landing = drag.map { landingIndex(ids, $0) }
- ForEach(shownStores, id: \.computer.id) { store in
- let id = store.computer.id
- let collapsed = collapsedIDs.contains(id)
- let lifted = drag?.id == id
- VStack(spacing: 0) {
- // Not synced while it needs an update: "No bots yet" wouldn't be true.
- ComputerSection(store: store, empty: store.mismatch == nil && !roster.contains { $0.ref.computerId == id },
- collapsed: collapsed, toggle: { toggleCollapsed(id) }, move: move)
- .modifier(ComputerSectionGesture(tap: { toggleCollapsed(id) }) { state, y in dragSection(id, state, y) })
- updateCard(store)
- if !collapsed {
- ForEach(roster.filter { $0.ref.computerId == id }) { row($0, store: store) }
- }
- }
- .background(lifted ? Palette.background : .clear, in: RoundedRectangle(cornerRadius: 18, style: .continuous))
- .scaleEffect(lifted ? 0.94 : 1)
- .shadow(color: .black.opacity(lifted ? 0.18 : 0), radius: 16, y: 6)
- .animation(Motion.reduced(Motion.layout, reduceMotion), value: lifted)
- .offset(y: sectionOffset(id, ids: ids, landing: landing))
- .zIndex(lifted ? 1 : 0)
- // The lifted section follows the finger; the others slide out of its way.
- .transaction { if lifted { $0.animation = nil } }
- .animation(Motion.reduced(Motion.layout, reduceMotion), value: landing)
- .onGeometryChange(for: CGFloat.self) { $0.size.height } action: { sectionHeights[id] = $0 }
- }
- } else {
- ForEach(roster) { item in
- if let store = accounts.store(for: item.ref.computerId) {
- row(item, store: store)
- }
+ ForEach(lines) { line in
+ switch line {
+ case let .computer(_, store): computerHeading(store, roster: roster)
+ case let .bot(item, store): row(item, store: store)
}
}
+ .onMove(perform: moveLines)
}
- .padding(.horizontal, 16)
+ .listRowInsets(EdgeInsets(top: 0, leading: 16, bottom: 0, trailing: 16))
+ .listRowSeparator(.hidden)
+ .listRowBackground(Color.clear)
}
- .scrollDisabled(drag != nil)
- .sensoryFeedback(.impact(weight: .medium), trigger: drag?.id) { _, new in new != nil }
- .sensoryFeedback(.selection, trigger: drag.map { landingIndex(shownStores.map(\.computer.id), $0) })
- .sensoryFeedback(.selection, trigger: roster.map(\.id)) { _, _ in draggingBot != nil }
+ .listStyle(.plain)
+ .scrollContentBackground(.hidden)
+ .environment(\.defaultMinListRowHeight, 0)
.background(Palette.background)
.navigationTitle("Bots")
.navigationBarTitleDisplayMode(.inline)
@@ -184,46 +164,24 @@ struct BotListView: View {
}
}
- /// Where the dragged section would land: past a neighbour once it's dragged over half of it.
- private func landingIndex(_ ids: [ComputerID], _ drag: SectionDrag) -> Int {
- guard let from = ids.firstIndex(of: drag.id) else { return 0 }
- var to = from, rest = drag.translation
- while to + 1 < ids.count, let h = sectionHeights[ids[to + 1]], rest > h / 2 { rest -= h; to += 1 }
- while to > 0, let h = sectionHeights[ids[to - 1]], rest < -h / 2 { rest += h; to -= 1 }
- return to
- }
-
- private func sectionOffset(_ id: ComputerID, ids: [ComputerID], landing: Int?) -> CGFloat {
- guard let drag, let landing, let from = ids.firstIndex(of: drag.id), let i = ids.firstIndex(of: id) else { return 0 }
- if id == drag.id { return drag.translation }
- let h = sectionHeights[drag.id] ?? 0
- if from < i && i <= landing { return -h }
- if landing <= i && i < from { return h }
- return 0
- }
-
- private func dragSection(_ id: ComputerID, _ state: UIGestureRecognizer.State, _ y: CGFloat) {
- switch state {
- case .began:
- drag = SectionDrag(id: id, startY: y, y: y)
- case .changed:
- drag?.y = y
- case .ended:
- guard var drag, drag.id == id else { return }
- drag.y = y
- let ids = shownStores.map(\.computer.id)
- let to = landingIndex(ids, drag)
- // The order changes as the offsets drop, so everything settles where it's shown.
- withAnimation(Motion.reduced(Motion.layout, reduceMotion)) {
- if ids.contains(id), ids.indices.contains(to), ids[to] != id {
- accounts.move(id, to: ids[to])
- }
- self.drag = nil
- }
- case .cancelled, .failed:
- withAnimation(Motion.reduced(Motion.layout, reduceMotion)) { drag = nil }
- default:
- break
+ /// A row the system's reordering dropped. A heading moves its computer (an order kept on this
+ /// device); a bot moves among its computer's bots, an order the host syncs to every device.
+ /// A bot dropped among another computer's bots goes back.
+ private func moveLines(from source: IndexSet, to destination: Int) {
+ let before = lines
+ guard let from = source.first, before.indices.contains(from) else { return }
+ var after = before
+ after.move(fromOffsets: source, toOffset: destination)
+ switch before[from] {
+ case let .computer(id, _):
+ let old = before.compactMap(\.computerId), new = after.compactMap(\.computerId)
+ guard let to = new.firstIndex(of: id), old[to] != id else { return }
+ withAnimation(Motion.reduced(Motion.layout, reduceMotion)) { accounts.move(id, to: old[to]) }
+ case let .bot(item, store):
+ let computerId = item.ref.computerId
+ let at = after.firstIndex { $0.id == before[from].id } ?? 0
+ if grouped, after[..<at].last(where: { $0.computerId != nil })?.computerId != computerId { return }
+ store.reorder(after.compactMap { $0.botId(on: computerId) })
}
}
@@ -235,14 +193,35 @@ struct BotListView: View {
}
}
+ /// A light heading per computer, with its update notice. Dragging it moves the computer; its
+ /// bots follow when it's dropped.
+ private func computerHeading(_ store: BotStore, roster: [RosterItem]) -> some View {
+ let id = store.computer.id
+ return VStack(spacing: 0) {
+ // Not synced while it needs an update: "No bots yet" wouldn't be true.
+ ComputerSection(store: store, empty: store.mismatch == nil && !roster.contains { $0.ref.computerId == id },
+ collapsed: collapsedIDs.contains(id), toggle: { toggleCollapsed(id) }, move: move)
+ .contentShape(Rectangle())
+ .onTapGesture { toggleCollapsed(id) }
+ updateCard(store)
+ }
+ }
+
private func row(_ item: RosterItem, store: BotStore) -> some View {
let bot = item.bot
+ let card = RoundedRectangle(cornerRadius: 16, style: .continuous)
// A plain button instead of a NavigationLink: same push, no chevron.
return Button { accounts.selection = item.ref } label: {
BotRow(bot: bot)
.environment(store)
}
.buttonStyle(.plain)
+ // Lifted, it's a rounded card with room around the avatar.
+ .padding(.horizontal, 8)
+ .background(lifted == bot.id ? Palette.surface : .clear, in: card)
+ .contentShape([.dragPreview, .contextMenuPreview], card)
+ .padding(.horizontal, -8)
+ .itemProvider { lift(bot.id) }
.accessibilityLabel(accounts.computers.count > 1 ? "\(bot.name), on \(store.hostName)" : bot.name)
.accessibilityActions {
Button("Move up") { withAnimation(Motion.reduced(Motion.layout, reduceMotion)) { store.move(bot.id, by: -1) } }
@@ -259,12 +238,12 @@ struct BotListView: View {
MenuItem("Delete", icon: "trash", destructive: true, divider: true) { confirmDelete = item },
]
}
- // Touch and hold, then drag: the menu gives way to the drag (iOS's usual pairing).
- .onDrag {
- draggingBot = item.ref
- return NSItemProvider(object: bot.name as NSString)
- }
- .onDrop(of: [.text], delegate: BotRowDrop(target: item, store: store, dragging: $draggingBot, reduceMotion: reduceMotion))
+ }
+
+ /// The system asks for a row's item as it lifts; the row shows as lifted until it lets go.
+ private func lift(_ id: String) -> NSItemProvider {
+ lifted = id
+ return LiftItem { Task { @MainActor in if lifted == id { lifted = nil } } }
}
/// A group chat gathers bots of one computer (the first one online; more computers are future work).
@@ -284,8 +263,43 @@ struct BotListView: View {
}
}
+/// One row the user can drag in the roster: a computer's heading or a bot.
+/// The item a lifted bot row carries (nothing): the system lets go of it when the drag or the
+/// menu ends.
+private final class LiftItem: NSItemProvider {
+ private let ended: @Sendable () -> Void
+
+ init(ended: @escaping @Sendable () -> Void) {
+ self.ended = ended
+ super.init()
+ }
+
+ deinit { ended() }
+}
+
+private enum RosterLine: Identifiable {
+ case computer(ComputerID, BotStore)
+ case bot(RosterItem, BotStore)
+
+ var id: String {
+ switch self {
+ case let .computer(id, _): "computer:\(id)"
+ case let .bot(item, _): "bot:\(item.ref.computerId):\(item.bot.id)"
+ }
+ }
+
+ /// The computer a heading stands for.
+ var computerId: ComputerID? {
+ if case let .computer(id, _) = self { id } else { nil }
+ }
+
+ func botId(on computerId: ComputerID) -> String? {
+ if case let .bot(item, _) = self, item.ref.computerId == computerId { item.bot.id } else { nil }
+ }
+}
+
/// A computer's heading above its bots: badge, name and connection. Tap folds its bots away;
-/// long-press lifts the whole section to drag it up or down.
+/// touch and hold, then drag, moves the computer (on this device).
private struct ComputerSection: View {
let store: BotStore
let empty: Bool
@@ -295,8 +309,6 @@ private struct ComputerSection: View {
var body: some View {
VStack(alignment: .leading, spacing: 6) {
- // The parent's tap/hold gesture owns touch input, so a release
- // after dragging cannot also trigger a nested button's collapse action.
heading
if empty && !collapsed {
Text("No bots yet")
@@ -351,13 +363,6 @@ private struct ComputerSection: View {
}
}
-private struct SectionDrag {
- let id: ComputerID
- let startY: CGFloat
- var y: CGFloat
- var translation: CGFloat { y - startY }
-}
-
private struct GroupTarget: Identifiable {
let id = UUID()
let computerId: ComputerID
diff --git a/apps/ios/Views/BotRowDrop.swift b/apps/ios/Views/BotRowDrop.swift
deleted file mode 100644
index 840ead7d..00000000
--- a/apps/ios/Views/BotRowDrop.swift
+++ /dev/null
@@ -1,32 +0,0 @@
-import CodyncKit
-import CodyncUI
-import SwiftUI
-
-/// A bot row others can be dragged onto, to reorder a computer's bots. It's a system drag,
-/// so touch and hold still opens the row's menu first. The store moves the dragged bot into
-/// each row it passes; the drop sends the order.
-struct BotRowDrop: DropDelegate {
- let target: RosterItem
- let store: BotStore
- @Binding var dragging: BotReference?
- let reduceMotion: Bool
-
- func validateDrop(info: DropInfo) -> Bool {
- dragging?.computerId == target.ref.computerId
- }
-
- func dropEntered(info: DropInfo) {
- guard let dragging, dragging.computerId == target.ref.computerId else { return }
- withAnimation(Motion.reduced(Motion.layout, reduceMotion)) { _ = store.move(dragging.botId, onto: target.bot.id) }
- }
-
- func dropUpdated(info: DropInfo) -> DropProposal? {
- DropProposal(operation: .move)
- }
-
- func performDrop(info: DropInfo) -> Bool {
- store.saveOrder()
- dragging = nil
- return true
- }
-}
diff --git a/apps/ios/Views/ComputerSectionGesture.swift b/apps/ios/Views/ComputerSectionGesture.swift
deleted file mode 100644
index 0d7c5654..00000000
--- a/apps/ios/Views/ComputerSectionGesture.swift
+++ /dev/null
@@ -1,46 +0,0 @@
-import SwiftUI
-import UIKit
-
-/// A shared hit area keeps short taps, scrolling and long-press reordering distinct.
-struct ComputerSectionGesture: ViewModifier {
- let tap: () -> Void
- let drag: (UIGestureRecognizer.State, CGFloat) -> Void
- @GestureState private var holding = false
- @State private var dragging = false
-
- func body(content: Content) -> some View {
- content
- .contentShape(Rectangle())
- .highPriorityGesture(hold.simultaneously(with: TapGesture().onEnded {
- if !dragging { tap() }
- }))
- .onChange(of: holding) { _, held in
- if !held && dragging {
- dragging = false
- drag(.cancelled, 0)
- }
- }
- }
-
- private var hold: some Gesture {
- LongPressGesture(minimumDuration: 0.35)
- .sequenced(before: DragGesture(minimumDistance: 0, coordinateSpace: .global))
- .updating($holding) { value, held, _ in
- if case .second(true, _) = value { held = true }
- }
- .onChanged { value in
- guard case let .second(true, movement?) = value else { return }
- if !dragging {
- dragging = true
- drag(.began, movement.startLocation.y)
- }
- drag(.changed, movement.location.y)
- }
- .onEnded { value in
- dragging = false
- if case let .second(true, movement?) = value {
- drag(.ended, movement.location.y)
- } else { drag(.cancelled, 0) }
- }
- }
-}
diff --git a/apps/ios/WhatsNew.md b/apps/ios/WhatsNew.md
index 520a0b96..223a975e 100644
--- a/apps/ios/WhatsNew.md
+++ b/apps/ios/WhatsNew.md
@@ -10,9 +10,11 @@ a version without one gets a generic "Bug fixes and improvements" line. Delete o
### zh-Hant
- 使用情況分析會一併記錄大概的地區(國家、城市),讓我們知道哪些地區的人在用;你的 IP 位址不會被保存。可隨時在「設定」關閉使用情況分析。
+- 長按 bot 後拖曳就能自由調整順序,拿起來時是圓角卡片;順序會同步到電腦上的 Codync。
- 其他小幅改進。
### en-US
- Usage analytics now include your approximate location (country and city), so we know where Codync is used; your IP address is never stored. Turn usage analytics off anytime in Settings.
+- Touch and hold a bot, then drag it anywhere in the list; it lifts as a rounded card, and the order syncs to Codync on your computer.
- Other small improvements.
diff --git a/docs/design/ui-conventions.md b/docs/design/ui-conventions.md
index c12c2015..8a1f4825 100644
--- a/docs/design/ui-conventions.md
+++ b/docs/design/ui-conventions.md
@@ -61,7 +61,7 @@ Other custom iPhone screens use `Chrome.swift` and `Controls.swift`. The desktop
| Toggle | `ToggleStyle.codync` |
| Form-like content | `CardForm`, `CardSection` (a small bold heading over a filled, rounded group; rows split by inset hairlines; a row is `ValueRow` with an optional one-line `detail`, and its picker is an outlined `ChoicePicker`) |
-Avoid adding stock `Menu`, `Picker`, `Form`/`List` styling, switch toggles, alerts, `ProgressView` or system sheets to these flows. System presentation APIs inside the shared chrome implementation are implementation details, not permission to bypass the components in feature screens. Native WidgetKit/ActivityKit containers and OS authentication/permission flows remain system integrations.
+Avoid adding stock `Menu`, `Picker`, `Form`/`List` styling, switch toggles, alerts, `ProgressView` or system sheets to these flows. The iPhone bot list is a `List` with its styling removed (plain, no separators or row backgrounds), only for the system's drag-to-reorder alongside each row's context menu ([bot order](../features/computer-order.md#bot-order)). System presentation APIs inside the shared chrome implementation are implementation details, not permission to bypass the components in feature screens. Native WidgetKit/ActivityKit containers and OS authentication/permission flows remain system integrations.
No scroll bars: scroll indicators never show (`.scrollIndicators(.never)` on the iPhone app's root, so every scroll view inherits it; hidden scrollbars in `apps/desktop/src/renderer/styles/theme.css`).
diff --git a/docs/features/computer-order.md b/docs/features/computer-order.md
index 17c8786c..2801490d 100644
--- a/docs/features/computer-order.md
+++ b/docs/features/computer-order.md
@@ -27,7 +27,7 @@ they return. Computer names and bots never become ordering keys, and an ordering
entry never grants access to a computer or imports another device's SSH connection.
On iOS, touch and hold a computer heading, then drag up or down and release to save
-the order. Cancelling a drag leaves the saved order unchanged. A tap folds or expands
+the order; its bots follow when it's dropped. Cancelling a drag leaves the saved order unchanged. A tap folds or expands
the section; Move up/down accessibility actions are also available. The desktop
app supports heading drags and Alt+Up/Down on macOS, Linux and Windows.
The terminal UI connects to one host, so it has no cross-computer ordering.
@@ -43,8 +43,12 @@ among bots with the same pin state. Until a computer's bots are first arranged,
position is 0 and they sort by recent activity; after that they stay put and a new bot
appears on top. Hidden bots keep their position for when they return.
-- **iPhone:** touch and hold a row, then drag it (the row's menu gives way to the drag, as
- elsewhere in iOS). Rows move out of the way as it passes; the drop saves the order
- (`BotStore.move(_:onto:)`, `apps/ios/Views/BotRowDrop.swift`). VoiceOver: Move up / Move down.
+- **iPhone:** touch and hold a row, then drag it. The roster is a `List` with its styling
+ removed, so the system does the reordering: holding still opens the row's menu, and dragging
+ the lifted row moves it, also once the menu shows, unless the finger goes into the menu. Lifted,
+ the row is a rounded card: it fills while the system holds its drag item (`BotListView.lift`). A bot
+ dropped among another computer's bots goes back. The drop saves the order (`BotListView.moveLines`,
+ `BotStore.reorder`). VoiceOver: Move up / Move down. SwiftUI's own drag and drop can't do this:
+ with a context menu on the row, a drag never starts on iPhone.
- **Desktop:** drag a row, or Alt+Up/Down on the selected bot (macOS, Linux, Windows).
- **Terminal UI:** `J` / `K` move the selected bot down / up.