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
fix(ios): reset selection when replacing chat drafts
leepokaiad53887ed706
diff --git a/apps/ios/Kit/Sources/CodyncUI/Thread/Composer.swift b/apps/ios/Kit/Sources/CodyncUI/Thread/Composer.swiftindex a170c088..b8cd964d 100644--- a/apps/ios/Kit/Sources/CodyncUI/Thread/Composer.swift+++ b/apps/ios/Kit/Sources/CodyncUI/Thread/Composer.swift@@ -20,9 +20,13 @@ struct Composer: View {@Environment(\.accessibilityReduceMotion) private var reduceMotion/// The field owns its text; the store only keeps a copy. A field bound straight to the/// store loses a hardware keyboard's IME composition (Zhuyin, Pinyin, Kana) on iPad.- @State private var draft = ""- /// The cursor, so a hardware keyboard's Return starts a new line where it is.- @State private var selection: TextSelection?+ @State private var input = ComposerText()+ /// Programmatic edits must discard indices into the previous string. Keyboard edits+ /// bind directly to `input.text` so SwiftUI can maintain selection and IME composition.+ private var draft: String {+ get { input.text }+ nonmutating set { input.replace(with: newValue) }+ }/// Files going out with the next message.@State private var files: [OutgoingFile] = []@State private var pickingFiles = false@@ -250,7 +254,7 @@ struct Composer: View {private var box: some View {HStack(alignment: .bottom, spacing: 8) {- TextField(placeholder, text: $draft, selection: $selection, axis: .vertical)+ TextField(placeholder, text: $input.text, selection: $input.selection, axis: .vertical).lineLimit(1...8).font(.body).textFieldStyle(.plain)@@ -398,13 +402,7 @@ struct Composer: View {/// An empty box gets none, also right after ⌘↩ sent it (the field submits after the shortcut).private func newline() {focused = true- guard !draft.isEmpty else { return }- // A selection left from text that has since changed (dictation, a mention) means the end.- let range = if case .selection(let r) = selection?.indices, r.upperBound <= draft.endIndex { r } else { draft.endIndex..<draft.endIndex }- // Counted in scalars: a "\n" after a lone "\r" joins it into one Character.- let offset = draft.unicodeScalars.distance(from: draft.startIndex, to: range.lowerBound)- draft.replaceSubrange(range, with: "\n")- selection = TextSelection(insertionPoint: draft.unicodeScalars.index(draft.startIndex, offsetBy: offset + 1))+ input.insertNewline()}private func submit() {diff --git a/apps/ios/Kit/Sources/CodyncUI/Thread/ComposerText.swift b/apps/ios/Kit/Sources/CodyncUI/Thread/ComposerText.swiftnew file mode 100644index 00000000..3a47d324--- /dev/null+++ b/apps/ios/Kit/Sources/CodyncUI/Thread/ComposerText.swift@@ -0,0 +1,30 @@+import SwiftUI++/// Text and its selection travel together when the composer replaces a draft.+struct ComposerText {+ var text = ""+ var selection: TextSelection?++ mutating func replace(with replacement: String) {+ // iOS 18 converts the old selection to UTF-16 offsets during the next field+ // update. Clearing or shortening text without clearing its indices can trap.+ selection = nil+ text = replacement+ }++ mutating func insertNewline() {+ guard !text.isEmpty else { return }+ let range = if case .selection(let range) = selection?.indices,+ range.upperBound <= text.endIndex {+ range+ } else {+ text.endIndex..<text.endIndex+ }+ // A newline after a lone carriage return forms one Character; count scalars.+ let offset = text.unicodeScalars.distance(from: text.startIndex, to: range.lowerBound)+ var replacement = text+ replacement.replaceSubrange(range, with: "\n")+ replace(with: replacement)+ selection = TextSelection(insertionPoint: text.unicodeScalars.index(text.startIndex, offsetBy: offset + 1))+ }+}diff --git a/apps/ios/Kit/Tests/CodyncUITests/ComposerTextTests.swift b/apps/ios/Kit/Tests/CodyncUITests/ComposerTextTests.swiftnew file mode 100644index 00000000..573c04af--- /dev/null+++ b/apps/ios/Kit/Tests/CodyncUITests/ComposerTextTests.swift@@ -0,0 +1,51 @@+import SwiftUI+import Testing+@testable import CodyncUI++@MainActor @Test(arguments: ["", "1", "中文", "👨👩👧👦", "replacement text"])+func replacingComposerTextDiscardsPreviousSelection(_ replacement: String) {+ var input = ComposerText(text: "previous draft")+ input.selection = TextSelection(insertionPoint: input.text.endIndex)++ input.replace(with: replacement)++ #expect(input.text == replacement)+ #expect(input.selection == nil)+}++@MainActor @Test func composerReturnReplacesSelectionAndMovesCursorAfterNewline() {+ var input = ComposerText(text: "A👨👩👧👦中B")+ let start = input.text.index(after: input.text.startIndex)+ let end = input.text.index(before: input.text.endIndex)+ input.selection = TextSelection(range: start..<end)++ input.insertNewline()++ #expect(input.text == "A\nB")+ guard case .selection(let range) = input.selection?.indices else {+ Issue.record("Expected an insertion point after Return")+ return+ }+ #expect(range.isEmpty)+ #expect(range.lowerBound == input.text.index(input.text.startIndex, offsetBy: 2))+}++@MainActor @Test func composerReturnAfterCarriageReturnKeepsValidCursor() {+ var input = ComposerText(text: "a\r")+ input.insertNewline()+ #expect(input.text == "a\r\n")+ guard case .selection(let range) = input.selection?.indices else {+ Issue.record("Expected a cursor at the end")+ return+ }+ #expect(range.lowerBound == input.text.endIndex)+}++@MainActor @Test func composerReturnAfterSendingDoesNotRestoreOldDraft() {+ var input = ComposerText(text: "1")+ input.selection = TextSelection(insertionPoint: input.text.endIndex)+ input.replace(with: "")+ input.insertNewline()+ #expect(input.text.isEmpty)+ #expect(input.selection == nil)+}diff --git a/apps/ios/WhatsNew.md b/apps/ios/WhatsNew.mdindex 5e28fb38..b3a3255a 100644--- a/apps/ios/WhatsNew.md+++ b/apps/ios/WhatsNew.md@@ -9,6 +9,7 @@ a version without one gets a generic "Bug fixes and improvements" line. Delete o## 2.26.2### zh-Hant+- 修正 iOS 18 在送出文字、清空或替換聊天草稿時可能閃退的問題。- Bot 傳來的圖片會直接顯示在聊天裡,點一下可以放大看,不用先下載。- 電腦上的 Codync 版本太舊時,更新提示多了「Update now」按鈕,直接從手機叫那台電腦更新。- 擴充套件一次顯示一個分類:智慧體、聯結器或技能,每個列表都分頁。點列表兩側的圓形按鈕或左右滑動就能翻頁,下方可選每頁 6、10、20 或 50 筆,並顯示目前在第幾頁。@@ -19,6 +20,7 @@ a version without one gets a generic "Bug fixes and improvements" line. Delete o- 用量也會顯示這台電腦上其他 agent 的額度,包括 oh-my-pi、Amp、Kiro、Kimi、Antigravity、OpenCode、Mistral Vibe 和 Junie。Cursor 會用本機已登入的帳號向 cursor.com 查詢用量。### en-US+- Fixed a possible crash on iOS 18 when sending text or clearing or replacing a chat draft.- Images a bot sends now show right in the chat; tap one to see it full size, no download needed.- When a computer's Codync is too old for this app, Update now on the notice updates that computer from your phone.- Extensions shows one section at a time: Agents, Connectors or Skills, each in pages. Tap the round buttons beside the list or swipe left or right to turn the page; under it, pick 6, 10, 20 or 50 per page and see which page you're on.diff --git a/docs/guides/composer.md b/docs/guides/composer.mdindex fda334ae..0ed0b857 100644--- a/docs/guides/composer.md+++ b/docs/guides/composer.md@@ -17,6 +17,9 @@ The Electron composer restores the draft and layout behavior previously fixed inboth opening and closing. Rapid toggles cancel pending reveal callbacks.Reduced Motion removes these transitions.- iOS keeps its native multiline field, keyboard and existing Motion animations.+ Programmatic draft replacements clear the previous `TextSelection` before changing+ the string; iOS 18 can otherwise trap while converting stale indices to UTF-16.+ Keyboard edits bind directly to the local text and selection to preserve IME input.With a hardware keyboard (iPhone/iPad), Return inserts a newline at the cursorand ⌘↩ sends (send state only); on Android, Enter inserts a newline andCtrl/Meta+Enter sends (send state only).diff --git a/web/content/docs/conversations.mdx b/web/content/docs/conversations.mdxindex aa71723d..9053a2c3 100644--- a/web/content/docs/conversations.mdx+++ b/web/content/docs/conversations.mdx@@ -30,6 +30,8 @@ Each chat keeps its own draft on each device, and the draft comes back when youIf a message fails to send, it shows **Failed to send** with buttons to resend or delete it.+On iPhone, sending clears the message box so you can type your next message. You can add text with dictation or switch to another chat's saved draft.+**From Shortcuts (iPhone):** Codync's **Send Text to Bot** action sends a message without typing it in the chat. Pick a **Bot** and fill in **Text**. **Open Chat** is off by default, so the message goes out in the background; turn it on to open the chat. The action finishes when the computer accepts the message, or reports it queued when the computer is offline. The iPhone has to be unlocked, also from Siri ("Send text with Codync"). Only the current account's visible bots are listed.## Files