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(apps): never resend a message without the files it had
leepokai81e8c39d5156
diff --git a/apps/desktop/src/renderer/store/bot-store.ts b/apps/desktop/src/renderer/store/bot-store.tsindex eb39acf6..e622c7e5 100644--- a/apps/desktop/src/renderer/store/bot-store.ts+++ b/apps/desktop/src/renderer/store/bot-store.ts@@ -17,13 +17,14 @@ import type { CallLine } from '@shared/calls'import type { HostClient } from '../client/host-client'import { readSharedFile } from '../../shared/files.ts'import { latestOnly } from '../lib/latest-only'+import { trNow } from '../lib/l10n.ts'import { prefs } from '../lib/prefs'import { updatePayload } from './bot-draft'import { FileDownloads } from './file-downloads'import { BotSections } from './bot-sections'import { DevServerCommands } from './dev-servers'import { BotSync, sleep } from './bot-sync'-import type { OutgoingFile } from './outgoing-files.ts'+import { filesToResend, type OutgoingFile } from './outgoing-files.ts'export { builtInBackendName, type Connection } from './bot-mirror'@@ -111,7 +112,8 @@ export class BotStore extends BotSync {}retry(entry: Entry) {- const files = (entry.data.clientNonce && this.outgoingFiles.get(entry.data.clientNonce)) || []+ const files = filesToResend(entry, this.outgoingFiles)+ if (!files) return this.setError(trNow("This message's files aren't on this device anymore. Delete it and attach them again."))const text = entry.data.text ?? ''if (!text && !files.length) returnthis.dropEntry(entry)diff --git a/apps/desktop/src/renderer/store/outgoing-files.test.ts b/apps/desktop/src/renderer/store/outgoing-files.test.tsnew file mode 100644index 00000000..222bcd34--- /dev/null+++ b/apps/desktop/src/renderer/store/outgoing-files.test.ts@@ -0,0 +1,20 @@+import assert from 'node:assert/strict'+import { test } from 'node:test'+import type { Entry } from '@shared/models'+import { filesToResend, type OutgoingFile } from './outgoing-files.ts'++const file: OutgoingFile = { id: 'f1', name: 'a.txt', data: new Uint8Array([1]) }+const message = (attachments?: Entry['data']['attachments']) =>+ ({ data: { text: 'see this', clientNonce: 'n1', attachments } }) as Entry++test('Resend takes the files still kept for its message', () => {+ assert.deepEqual(filesToResend(message([{ id: 'f1', name: 'a.txt', size: 1 }]), new Map([['n1', [file]]])), [file])+})++test('Resend refuses a message whose files went with the app, so its text never goes alone', () => {+ assert.equal(filesToResend(message([{ id: 'f1', name: 'a.txt', size: 1 }]), new Map()), null)+})++test('a message without files resends with none', () => {+ assert.deepEqual(filesToResend(message(), new Map()), [])+})diff --git a/apps/desktop/src/renderer/store/outgoing-files.ts b/apps/desktop/src/renderer/store/outgoing-files.tsindex 34af06d2..7a9623ad 100644--- a/apps/desktop/src/renderer/store/outgoing-files.ts+++ b/apps/desktop/src/renderer/store/outgoing-files.ts@@ -1,3 +1,5 @@+import type { Entry } from '@shared/models'+/** A file picked in the composer, sent with the next message. */export interface OutgoingFile {id: string@@ -7,3 +9,12 @@ export interface OutgoingFile {/** Anything larger is refused by the computer. */export const MAX_FILE_SIZE = 100 * 1024 * 1024++/**+ * The files Resend sends again, or null when the message had files that are gone: they're kept only in+ * memory, so after a relaunch it would go half sent.+ */+export function filesToResend(entry: Entry, kept: ReadonlyMap<string, OutgoingFile[]>): OutgoingFile[] | null {+ const files = entry.data.clientNonce ? kept.get(entry.data.clientNonce) : undefined+ return files ?? (entry.data.attachments?.length ? null : [])+}diff --git a/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/de.json b/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/de.jsonindex 0ec50a27..21f80c12 100644--- a/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/de.json+++ b/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/de.json@@ -1881,5 +1881,6 @@"{email} wants to use this computer, which then joins {email}'s account.": "{email} möchte diesen Computer verwenden, der dann dem Konto von {email} beitritt.","Sign in there with {email} and add it to your account, and it shows up here.": "Melde dich dort mit {email} an und füge ihn deinem Konto hinzu, dann erscheint er hier.","Scan with the Codync app or the iPhone Camera.": "Scanne mit der Codync-App oder der iPhone-Kamera.",- "Phones paired without this account lose access and must pair again.": "Nicht mit diesem Konto gekoppelte Telefone verlieren den Zugriff und müssen neu gekoppelt werden."+ "Phones paired without this account lose access and must pair again.": "Nicht mit diesem Konto gekoppelte Telefone verlieren den Zugriff und müssen neu gekoppelt werden.",+ "This message's files aren't on this device anymore. Delete it and attach them again.": "Die Dateien dieser Nachricht sind nicht mehr auf diesem Gerät. Lösche sie und hänge die Dateien erneut an."}diff --git a/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/es.json b/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/es.jsonindex ff85b4d9..e6725fcf 100644--- a/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/es.json+++ b/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/es.json@@ -1881,5 +1881,6 @@"{email} wants to use this computer, which then joins {email}'s account.": "{email} quiere usar este ordenador, que luego se une a la cuenta de {email}.","Sign in there with {email} and add it to your account, and it shows up here.": "Inicia sesión allí con {email} y añádelo a tu cuenta, y aparecerá aquí.","Scan with the Codync app or the iPhone Camera.": "Escanea con la app de Codync o la cámara del iPhone.",- "Phones paired without this account lose access and must pair again.": "Los teléfonos emparejados sin esta cuenta pierden el acceso y deben emparejarse de nuevo."+ "Phones paired without this account lose access and must pair again.": "Los teléfonos emparejados sin esta cuenta pierden el acceso y deben emparejarse de nuevo.",+ "This message's files aren't on this device anymore. Delete it and attach them again.": "Los archivos de este mensaje ya no están en este dispositivo. Elimínalo y vuelve a adjuntarlos."}diff --git a/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/fr.json b/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/fr.jsonindex e2fab904..7e1ef02a 100644--- a/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/fr.json+++ b/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/fr.json@@ -1881,5 +1881,6 @@"{email} wants to use this computer, which then joins {email}'s account.": "{email} veut utiliser cet ordinateur, qui rejoint alors le compte de {email}.","Sign in there with {email} and add it to your account, and it shows up here.": "Connectez-vous-y avec {email} et ajoutez-le à votre compte : il apparaîtra ici.","Scan with the Codync app or the iPhone Camera.": "Scannez avec l'app Codync ou l'appareil photo de l'iPhone.",- "Phones paired without this account lose access and must pair again.": "Les téléphones jumelés sans ce compte perdent l'accès et devront être jumelés à nouveau."+ "Phones paired without this account lose access and must pair again.": "Les téléphones jumelés sans ce compte perdent l'accès et devront être jumelés à nouveau.",+ "This message's files aren't on this device anymore. Delete it and attach them again.": "Les fichiers de ce message ne sont plus sur cet appareil. Supprimez-le et joignez-les à nouveau."}diff --git a/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/it.json b/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/it.jsonindex 62fa6085..f47832b7 100644--- a/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/it.json+++ b/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/it.json@@ -1881,5 +1881,6 @@"{email} wants to use this computer, which then joins {email}'s account.": "{email} vuole usare questo computer, che poi entra nell'account di {email}.","Sign in there with {email} and add it to your account, and it shows up here.": "Accedi lì con {email} e aggiungilo al tuo account: comparirà qui.","Scan with the Codync app or the iPhone Camera.": "Scansiona con l'app Codync o la fotocamera dell'iPhone.",- "Phones paired without this account lose access and must pair again.": "I telefoni associati senza questo account perdono l'accesso e devono essere associati di nuovo."+ "Phones paired without this account lose access and must pair again.": "I telefoni associati senza questo account perdono l'accesso e devono essere associati di nuovo.",+ "This message's files aren't on this device anymore. Delete it and attach them again.": "I file di questo messaggio non sono più su questo dispositivo. Eliminalo e allega di nuovo i file."}diff --git a/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/ja.json b/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/ja.jsonindex 66c6b9cd..306886bb 100644--- a/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/ja.json+++ b/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/ja.json@@ -1881,5 +1881,6 @@"{email} wants to use this computer, which then joins {email}'s account.": "{email} がこのコンピュータを使おうとしています。このコンピュータは {email} のアカウントに参加します。","Sign in there with {email} and add it to your account, and it shows up here.": "そこで {email} でサインインしてアカウントに追加すると、ここに表示されます。","Scan with the Codync app or the iPhone Camera.": "Codync アプリまたは iPhone のカメラでスキャンしてください。",- "Phones paired without this account lose access and must pair again.": "このアカウントでペアリングしていないスマートフォンはアクセスを失い、再度ペアリングが必要です。"+ "Phones paired without this account lose access and must pair again.": "このアカウントでペアリングしていないスマートフォンはアクセスを失い、再度ペアリングが必要です。",+ "This message's files aren't on this device anymore. Delete it and attach them again.": "このメッセージのファイルはこの端末にもうありません。メッセージを削除して、もう一度ファイルを添付してください。"}diff --git a/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/ko.json b/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/ko.jsonindex 66f78a49..382409c0 100644--- a/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/ko.json+++ b/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/ko.json@@ -1881,5 +1881,6 @@"{email} wants to use this computer, which then joins {email}'s account.": "{email}이(가) 이 컴퓨터를 사용하려고 합니다. 컴퓨터는 {email} 계정에 참여합니다.","Sign in there with {email} and add it to your account, and it shows up here.": "거기서 {email}(으)로 로그인하고 계정에 추가하면 여기에 표시됩니다.","Scan with the Codync app or the iPhone Camera.": "Codync 앱 또는 iPhone 카메라로 스캔하세요.",- "Phones paired without this account lose access and must pair again.": "이 계정으로 페어링하지 않은 휴대폰은 접근 권한을 잃으며 다시 페어링해야 합니다."+ "Phones paired without this account lose access and must pair again.": "이 계정으로 페어링하지 않은 휴대폰은 접근 권한을 잃으며 다시 페어링해야 합니다.",+ "This message's files aren't on this device anymore. Delete it and attach them again.": "이 메시지의 파일이 더 이상 이 기기에 없습니다. 메시지를 삭제하고 파일을 다시 첨부하세요."}diff --git a/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/pt-BR.json b/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/pt-BR.jsonindex 94a2da4b..c88f1519 100644--- a/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/pt-BR.json+++ b/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/pt-BR.json@@ -1881,5 +1881,6 @@"{email} wants to use this computer, which then joins {email}'s account.": "{email} quer usar este computador, que depois entra na conta de {email}.","Sign in there with {email} and add it to your account, and it shows up here.": "Entre lá com {email} e adicione-o à sua conta, e ele aparece aqui.","Scan with the Codync app or the iPhone Camera.": "Escaneie com o app Codync ou a câmera do iPhone.",- "Phones paired without this account lose access and must pair again.": "Celulares pareados sem esta conta perdem o acesso e precisam parear de novo."+ "Phones paired without this account lose access and must pair again.": "Celulares pareados sem esta conta perdem o acesso e precisam parear de novo.",+ "This message's files aren't on this device anymore. Delete it and attach them again.": "Os arquivos desta mensagem não estão mais neste dispositivo. Exclua a mensagem e anexe os arquivos de novo."}diff --git a/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/ru.json b/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/ru.jsonindex 2fb80745..9e5a670b 100644--- a/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/ru.json+++ b/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/ru.json@@ -1881,5 +1881,6 @@"{email} wants to use this computer, which then joins {email}'s account.": "{email} хочет использовать этот компьютер, который затем присоединится к аккаунту {email}.","Sign in there with {email} and add it to your account, and it shows up here.": "Войдите там как {email} и добавьте его в аккаунт: он появится здесь.","Scan with the Codync app or the iPhone Camera.": "Отсканируйте в приложении Codync или камерой iPhone.",- "Phones paired without this account lose access and must pair again.": "Телефоны, сопряжённые без этого аккаунта, потеряют доступ, и их нужно будет сопрячь заново."+ "Phones paired without this account lose access and must pair again.": "Телефоны, сопряжённые без этого аккаунта, потеряют доступ, и их нужно будет сопрячь заново.",+ "This message's files aren't on this device anymore. Delete it and attach them again.": "Файлов этого сообщения больше нет на этом устройстве. Удалите его и прикрепите файлы заново."}diff --git a/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/zh-Hans.json b/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/zh-Hans.jsonindex 9f53cd77..b07709f6 100644--- a/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/zh-Hans.json+++ b/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/zh-Hans.json@@ -1881,5 +1881,6 @@"{email} wants to use this computer, which then joins {email}'s account.": "{email} 想使用这台电脑,电脑随后会加入 {email} 的账户。","Sign in there with {email} and add it to your account, and it shows up here.": "在那里用 {email} 登录并将电脑加入账户,它就会显示在这里。","Scan with the Codync app or the iPhone Camera.": "用 Codync App 或 iPhone 相机扫描。",- "Phones paired without this account lose access and must pair again.": "未用此账户配对的手机将失去访问权限,必须重新配对。"+ "Phones paired without this account lose access and must pair again.": "未用此账户配对的手机将失去访问权限,必须重新配对。",+ "This message's files aren't on this device anymore. Delete it and attach them again.": "此消息的文件已不在此设备上。请删除这条消息并重新添加文件。"}diff --git a/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/zh-Hant.json b/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/zh-Hant.jsonindex ed6ab2cc..d100c379 100644--- a/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/zh-Hant.json+++ b/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/zh-Hant.json@@ -1881,5 +1881,6 @@"{email} wants to use this computer, which then joins {email}'s account.": "{email} 想使用這台電腦,電腦隨後會加入 {email} 的賬戶。","Sign in there with {email} and add it to your account, and it shows up here.": "在那裡用 {email} 登入並將電腦加入賬戶,它就會顯示在這裡。","Scan with the Codync app or the iPhone Camera.": "用 Codync App 或 iPhone 相機掃描。",- "Phones paired without this account lose access and must pair again.": "未用此賬戶配對的手機將失去存取權,必須重新配對。"+ "Phones paired without this account lose access and must pair again.": "未用此賬戶配對的手機將失去存取權,必須重新配對。",+ "This message's files aren't on this device anymore. Delete it and attach them again.": "這則訊息的檔案已不在此裝置上。請刪除這則訊息並重新新增檔案。"}diff --git a/apps/ios/Kit/Sources/CodyncUI/Store/BotStore+Sending.swift b/apps/ios/Kit/Sources/CodyncUI/Store/BotStore+Sending.swiftindex 56396e2b..1ed346e8 100644--- a/apps/ios/Kit/Sources/CodyncUI/Store/BotStore+Sending.swift+++ b/apps/ios/Kit/Sources/CodyncUI/Store/BotStore+Sending.swift@@ -250,13 +250,11 @@ extension BotStore {saveCache()}- /// The computer is back: what waited on this phone goes now, with the same nonces. Files are- /// kept only in memory: a message whose files went with the app stays for the user to resend, not half sent.+ /// The computer is back: what waited on this phone goes now, with the same nonces.private func sendHeld(_ held: [Entry]) {guard !held.isEmpty else { return }for entry in held.sorted(by: { $0.createdAt < $1.createdAt }) {- let filesGone = entry.data.attachments?.isEmpty == false && entry.data.clientNonce.flatMap { outgoingFiles[$0] } == nil- if filesGone, let nonce = entry.data.clientNonce {+ if filesGone(entry), let nonce = entry.data.clientNonce {markLocal(nonce: nonce, botId: entry.botId, status: "failed")} else {retry(entry)@@ -265,7 +263,16 @@ extension BotStore {saveCache()}+ /// Files are kept only in memory: a message whose files went with the app can't go again, or it would go half sent.+ private func filesGone(_ entry: Entry) -> Bool {+ entry.data.attachments?.isEmpty == false && entry.data.clientNonce.flatMap { outgoingFiles[$0] } == nil+ }+public func retry(_ entry: Entry) {+ guard !filesGone(entry) else {+ lastError = "This message's files aren't on this device anymore. Delete it and attach them again."+ return+ }let files = entry.data.clientNonce.flatMap { outgoingFiles[$0] } ?? []guard let text = entry.data.text, !text.isEmpty || !files.isEmpty else { return }entries[entry.botId]?.removeAll { $0.id == entry.id }diff --git a/apps/ios/Kit/Tests/CodyncUITests/HeldMessageTests.swift b/apps/ios/Kit/Tests/CodyncUITests/HeldMessageTests.swiftindex f0654e02..1eb0d916 100644--- a/apps/ios/Kit/Tests/CodyncUITests/HeldMessageTests.swift+++ b/apps/ios/Kit/Tests/CodyncUITests/HeldMessageTests.swift@@ -87,9 +87,27 @@ import Testingstore.upsert(Entry(id: "local-n1", seq: .max, botId: "b1", rev: 0, kind: "user", turn: 0, data: data, createdAt: 1, updatedAt: 0))await phone.back()#expect(await until { store.chat("b1").first?.data.status == "failed" })+ #expect(store.lastError == nil)+ store.retry(try #require(store.chat("b1").first))+ #expect(store.lastError != nil)+ #expect(store.chat("b1").first?.data.status == "failed")#expect(await phone.sent().isEmpty, "not without its files")}+@MainActor @Test func aResendWhileTheAppIsOpenKeepsItsFiles() async throws {+ let phone = NoRelay()+ defer { phone.end() }+ await phone.start()+ let store = phone.store+ store.send("see this", to: "b1", files: [OutgoingFile(name: "a.txt", data: Data("x".utf8))])+ #expect(await until { store.chat("b1").first?.data.status == "held" })+ store.lastError = nil+ store.retry(try #require(store.chat("b1").first))+ #expect(store.lastError == nil)+ #expect(store.chat("b1").first?.data.status == "sending")+ #expect(store.chat("b1").first?.data.attachments?.count == 1)+}+@MainActor @Test func aResendKeepsTheCallItWasSaidIn() async throws {let phone = NoRelay()defer { phone.end() }diff --git a/docs/features/file-attachments.md b/docs/features/file-attachments.mdindex 2310e1c9..014f3a22 100644--- a/docs/features/file-attachments.md+++ b/docs/features/file-attachments.md@@ -23,7 +23,9 @@ Files travel in both directions: users attach inputs, and bots explicitly share`readUpload` refuses them. A message Stop dropped keeps its files, for the chat's *Not sent* row.- Files don't go through the relay mailbox: while the computer is offline, a message with fileswaits in the composer's send button (disabled) instead. A failed send keeps its files on the device- for Resend until the app quits.+ for Resend until the app quits. After that the iPhone and desktop refuse Resend with an error and the+ message stays failed, never sent as text alone (`filesGone`, `filesToResend`); Android saves the files+ with the pending row and the terminal keeps them in its draft.- Chat: images show as pictures (tap for full size), other files as cards. Other devices fetch asent file with `readUpload {botId, uploadId, offset}` (384 KiB chunks) and cache it; the sendercaches its own copy at upload.diff --git a/web/content/docs/conversations.mdx b/web/content/docs/conversations.mdxindex 1304ddf0..9d290714 100644--- a/web/content/docs/conversations.mdx+++ b/web/content/docs/conversations.mdx@@ -33,7 +33,7 @@ In the terminal, the waiting messages show above the input; press `esc`, then `S**When the computer is offline**, the iPhone can still take a text message: it shows **Waiting for the computer to come online** and goes out when the computer is back. It waits in the Codync relay, encrypted for your computer, for up to 24 hours; after that it shows **Failed to send**. With no relay (a computer in no account), it waits on the phone instead and goes when the phone reaches the computer again. Tap the cancel button beside it to take it back. A message with files can't wait; its send button stays off until the computer is online.-If a message fails to send, it shows **Failed to send** with buttons to resend or delete it.+If a message fails to send, it shows **Failed to send** with buttons to resend or delete it. On **iPhone** and **Desktop**, a message's files stay on the device only until the app closes. After that, resending it shows an error instead of sending the text without its files: delete it and attach them again.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.