Skip to content

Linux + iPhone Continuity / iMessage / SMS

feat(ui): remove conversations

Zack Bartelc5d389b8065a
diff --git a/docs/PROTOCOL.md b/docs/PROTOCOL.md
index 5635825..2b7bea6 100644
--- a/docs/PROTOCOL.md
+++ b/docs/PROTOCOL.md
@@ -529,6 +529,16 @@ codes still reach the vault. Their popup is shown only when it carries a code or
a short code or sender ID, and offers no reply. Answered with `bt_status` and `bt_threads`
broadcasts; reported as `hide_unknown_senders` in `bt_status`.
+#### `bt_remove_thread` (Client -> Daemon, broadcast)
+**Payload**: `{"command": "bt_remove_thread", "thread": "tel:+15035550101", "before": 1792951200}`
+Local to this computer and display only: nothing is deleted from the phone or the journal.
+`bt_threads` and `bt_messages` leave out the thread's messages timestamped at or before
+`before`, and no popup is shown for them unless it carries a code. Send the thread's
+`timestamp` from `bt_threads`, so a message arriving meanwhile stays visible; anything newer
+brings the thread back. Every spelling of a number shares one entry, and repeats keep the
+later cutoff. Persisted under the retention mode, memory only under `none`. Both fields are
+required. Answered with a `bt_threads` broadcast.
+
#### `bt_list_messages` (Client -> Daemon, answered directly)
**Payload**: `{"command": "bt_list_messages", "thread": "tel:+15035550101"}`
**Response**: `{"command": "bt_messages", "thread": ..., "messages": [...]}` with `handle`,
diff --git a/po/cs.po b/po/cs.po
index 3d24283..b9934ec 100644
--- a/po/cs.po
+++ b/po/cs.po
@@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: tether\n"
"Report-Msgid-Bugs-To: [email protected]\n"
-"POT-Creation-Date: 2026-10-24 20:22-0700\n"
+"POT-Creation-Date: 2026-10-25 10:20-0700\n"
"PO-Revision-Date: 2026-08-23\n"
"Last-Translator: Tether project\n"
"Language-Team: Czech\n"
@@ -2691,6 +2691,16 @@ msgstr "Odesláno"
msgid "New Message"
msgstr "Nová zpráva"
+#: src/gtk/messages_view.cpp src/tui/messages.cpp
+#, c-format
+msgid "Remove the conversation with %s?"
+msgstr "Odebrat konverzaci s %s?"
+
+#: src/gtk/messages_view.cpp src/tui/messages.cpp
+msgid ""
+"It stays on your iPhone, and comes back here when a new message arrives."
+msgstr "Na iPhonu zůstane a vrátí se sem, jakmile přijde nová zpráva."
+
#: src/gtk/messages_view.cpp
msgid "Search conversations"
msgstr "Hledat konverzace"
@@ -2703,6 +2713,10 @@ msgstr "Komu:"
msgid "Phone number or email"
msgstr "Telefonní číslo nebo e-mail"
+#: src/gtk/messages_view.cpp
+msgid "Remove Conversation"
+msgstr "Odebrat konverzaci"
+
#: src/gtk/messages_view.cpp
msgid "Send"
msgstr "Odeslat"
@@ -2878,7 +2892,9 @@ msgstr "Skrýt zprávy od neznámých odesílatelů"
msgid ""
"Threads from numbers not in your contacts are hidden. Codes still pop up and "
"autofill."
-msgstr "Konverzace s čísly, která nemáte v kontaktech, jsou skryté. Kódy se stále zobrazí a vyplní automaticky."
+msgstr ""
+"Konverzace s čísly, která nemáte v kontaktech, jsou skryté. Kódy se stále "
+"zobrazí a vyplní automaticky."
#: src/gtk/settings_view.cpp src/tui/settings.cpp
msgid ""
@@ -3008,8 +3024,8 @@ msgid "New message, or dial on Calls"
msgstr "Nová zpráva, na kartě Hovory vytočit číslo"
#: src/tui/main.cpp
-msgid "Dismiss, forget, unpair, or hang up"
-msgstr "Zavřít, zapomenout, zrušit spárování nebo zavěsit"
+msgid "Dismiss, forget, unpair, hang up, or remove a conversation"
+msgstr "Zavřít, zapomenout, zrušit spárování, zavěsit nebo odebrat konverzaci"
#: src/tui/main.cpp
msgid "Copy the highlighted address or text"
diff --git a/po/de.po b/po/de.po
index 91de7fb..611977c 100644
--- a/po/de.po
+++ b/po/de.po
@@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: tether\n"
"Report-Msgid-Bugs-To: [email protected]\n"
-"POT-Creation-Date: 2026-10-24 20:22-0700\n"
+"POT-Creation-Date: 2026-10-25 10:20-0700\n"
"PO-Revision-Date: 2026-08-22\n"
"Last-Translator: Tether project\n"
"Language-Team: German\n"
@@ -2755,6 +2755,16 @@ msgstr "Gesendet"
msgid "New Message"
msgstr "Neue Nachricht"
+#: src/gtk/messages_view.cpp src/tui/messages.cpp
+#, c-format
+msgid "Remove the conversation with %s?"
+msgstr "Die Unterhaltung mit %s entfernen?"
+
+#: src/gtk/messages_view.cpp src/tui/messages.cpp
+msgid ""
+"It stays on your iPhone, and comes back here when a new message arrives."
+msgstr "Sie bleibt auf deinem iPhone und erscheint hier wieder, sobald eine neue Nachricht eintrifft."
+
#: src/gtk/messages_view.cpp
msgid "Search conversations"
msgstr "Unterhaltungen durchsuchen"
@@ -2767,6 +2777,10 @@ msgstr "An:"
msgid "Phone number or email"
msgstr "Telefonnummer oder E-Mail"
+#: src/gtk/messages_view.cpp
+msgid "Remove Conversation"
+msgstr "Unterhaltung entfernen"
+
#: src/gtk/messages_view.cpp
msgid "Send"
msgstr "Senden"
@@ -2947,7 +2961,9 @@ msgstr "Nachrichten von unbekannten Absendern ausblenden"
msgid ""
"Threads from numbers not in your contacts are hidden. Codes still pop up and "
"autofill."
-msgstr "Unterhaltungen mit Nummern, die nicht in deinen Kontakten sind, werden ausgeblendet. Codes erscheinen weiterhin und werden automatisch ausgefüllt."
+msgstr ""
+"Unterhaltungen mit Nummern, die nicht in deinen Kontakten sind, werden "
+"ausgeblendet. Codes erscheinen weiterhin und werden automatisch ausgefüllt."
#: src/gtk/settings_view.cpp src/tui/settings.cpp
msgid ""
@@ -3080,8 +3096,8 @@ msgid "New message, or dial on Calls"
msgstr "Neue Nachricht, unter Anrufe wählen"
#: src/tui/main.cpp
-msgid "Dismiss, forget, unpair, or hang up"
-msgstr "Verwerfen, vergessen, entkoppeln oder auflegen"
+msgid "Dismiss, forget, unpair, hang up, or remove a conversation"
+msgstr "Verwerfen, vergessen, entkoppeln, auflegen oder Unterhaltung entfernen"
#: src/tui/main.cpp
msgid "Copy the highlighted address or text"
diff --git a/po/es.po b/po/es.po
index 112ab06..9392973 100644
--- a/po/es.po
+++ b/po/es.po
@@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: tether\n"
"Report-Msgid-Bugs-To: [email protected]\n"
-"POT-Creation-Date: 2026-10-24 20:22-0700\n"
+"POT-Creation-Date: 2026-10-25 10:20-0700\n"
"PO-Revision-Date: 2026-08-22\n"
"Last-Translator: Tether project\n"
"Language-Team: Spanish\n"
@@ -2733,6 +2733,16 @@ msgstr "Enviado"
msgid "New Message"
msgstr "Mensaje nuevo"
+#: src/gtk/messages_view.cpp src/tui/messages.cpp
+#, c-format
+msgid "Remove the conversation with %s?"
+msgstr "¿Quitar la conversación con %s?"
+
+#: src/gtk/messages_view.cpp src/tui/messages.cpp
+msgid ""
+"It stays on your iPhone, and comes back here when a new message arrives."
+msgstr "Se mantiene en tu iPhone y vuelve a aparecer aquí cuando llega un mensaje nuevo."
+
#: src/gtk/messages_view.cpp
msgid "Search conversations"
msgstr "Buscar conversaciones"
@@ -2745,6 +2755,10 @@ msgstr "Para:"
msgid "Phone number or email"
msgstr "Número de teléfono o correo electrónico"
+#: src/gtk/messages_view.cpp
+msgid "Remove Conversation"
+msgstr "Quitar conversación"
+
#: src/gtk/messages_view.cpp
msgid "Send"
msgstr "Enviar"
@@ -2924,7 +2938,9 @@ msgstr "Ocultar mensajes de remitentes desconocidos"
msgid ""
"Threads from numbers not in your contacts are hidden. Codes still pop up and "
"autofill."
-msgstr "Las conversaciones con números que no están en tus contactos se ocultan. Los códigos siguen apareciendo y se rellenan automáticamente."
+msgstr ""
+"Las conversaciones con números que no están en tus contactos se ocultan. Los "
+"códigos siguen apareciendo y se rellenan automáticamente."
#: src/gtk/settings_view.cpp src/tui/settings.cpp
msgid ""
@@ -3058,8 +3074,8 @@ msgid "New message, or dial on Calls"
msgstr "Nuevo mensaje, o marcar en Llamadas"
#: src/tui/main.cpp
-msgid "Dismiss, forget, unpair, or hang up"
-msgstr "Descartar, olvidar, desemparejar o colgar"
+msgid "Dismiss, forget, unpair, hang up, or remove a conversation"
+msgstr "Descartar, olvidar, desemparejar, colgar o quitar una conversación"
#: src/tui/main.cpp
msgid "Copy the highlighted address or text"
diff --git a/po/fr.po b/po/fr.po
index 5c5f1be..1b91323 100644
--- a/po/fr.po
+++ b/po/fr.po
@@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: tether\n"
"Report-Msgid-Bugs-To: [email protected]\n"
-"POT-Creation-Date: 2026-10-24 20:22-0700\n"
+"POT-Creation-Date: 2026-10-25 10:20-0700\n"
"PO-Revision-Date: 2026-08-22\n"
"Last-Translator: Tether project\n"
"Language-Team: French\n"
@@ -2740,6 +2740,16 @@ msgstr "Envoyé"
msgid "New Message"
msgstr "Nouveau message"
+#: src/gtk/messages_view.cpp src/tui/messages.cpp
+#, c-format
+msgid "Remove the conversation with %s?"
+msgstr "Retirer la conversation avec %s ?"
+
+#: src/gtk/messages_view.cpp src/tui/messages.cpp
+msgid ""
+"It stays on your iPhone, and comes back here when a new message arrives."
+msgstr "Elle reste sur votre iPhone et réapparaît ici à l’arrivée d’un nouveau message."
+
#: src/gtk/messages_view.cpp
msgid "Search conversations"
msgstr "Rechercher des conversations"
@@ -2752,6 +2762,10 @@ msgstr "À :"
msgid "Phone number or email"
msgstr "Numéro de téléphone ou e-mail"
+#: src/gtk/messages_view.cpp
+msgid "Remove Conversation"
+msgstr "Retirer la conversation"
+
#: src/gtk/messages_view.cpp
msgid "Send"
msgstr "Envoyer"
@@ -2933,7 +2947,9 @@ msgstr "Masquer les messages d’expéditeurs inconnus"
msgid ""
"Threads from numbers not in your contacts are hidden. Codes still pop up and "
"autofill."
-msgstr "Les conversations avec des numéros absents de vos contacts sont masquées. Les codes s’affichent toujours et sont remplis automatiquement."
+msgstr ""
+"Les conversations avec des numéros absents de vos contacts sont masquées. "
+"Les codes s’affichent toujours et sont remplis automatiquement."
#: src/gtk/settings_view.cpp src/tui/settings.cpp
msgid ""
@@ -3068,8 +3084,8 @@ msgid "New message, or dial on Calls"
msgstr "Nouveau message, ou composer dans Appels"
#: src/tui/main.cpp
-msgid "Dismiss, forget, unpair, or hang up"
-msgstr "Ignorer, oublier, dissocier ou raccrocher"
+msgid "Dismiss, forget, unpair, hang up, or remove a conversation"
+msgstr "Ignorer, oublier, dissocier, raccrocher ou retirer une conversation"
#: src/tui/main.cpp
msgid "Copy the highlighted address or text"
diff --git a/po/it.po b/po/it.po
index b953e57..8173efb 100644
--- a/po/it.po
+++ b/po/it.po
@@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: tether\n"
"Report-Msgid-Bugs-To: [email protected]\n"
-"POT-Creation-Date: 2026-10-24 20:22-0700\n"
+"POT-Creation-Date: 2026-10-25 10:20-0700\n"
"PO-Revision-Date: 2026-08-23\n"
"Last-Translator: Tether project\n"
"Language-Team: Italian\n"
@@ -2730,6 +2730,16 @@ msgstr "Inviato"
msgid "New Message"
msgstr "Nuovo messaggio"
+#: src/gtk/messages_view.cpp src/tui/messages.cpp
+#, c-format
+msgid "Remove the conversation with %s?"
+msgstr "Rimuovere la conversazione con %s?"
+
+#: src/gtk/messages_view.cpp src/tui/messages.cpp
+msgid ""
+"It stays on your iPhone, and comes back here when a new message arrives."
+msgstr "Resta sull’iPhone e ricompare qui quando arriva un nuovo messaggio."
+
#: src/gtk/messages_view.cpp
msgid "Search conversations"
msgstr "Cerca conversazioni"
@@ -2742,6 +2752,10 @@ msgstr "A:"
msgid "Phone number or email"
msgstr "Numero di telefono o email"
+#: src/gtk/messages_view.cpp
+msgid "Remove Conversation"
+msgstr "Rimuovi conversazione"
+
#: src/gtk/messages_view.cpp
msgid "Send"
msgstr "Invia"
@@ -2921,7 +2935,9 @@ msgstr "Nascondi i messaggi da mittenti sconosciuti"
msgid ""
"Threads from numbers not in your contacts are hidden. Codes still pop up and "
"autofill."
-msgstr "Le conversazioni con numeri non presenti nei contatti vengono nascoste. I codici compaiono comunque e vengono compilati automaticamente."
+msgstr ""
+"Le conversazioni con numeri non presenti nei contatti vengono nascoste. I "
+"codici compaiono comunque e vengono compilati automaticamente."
#: src/gtk/settings_view.cpp src/tui/settings.cpp
msgid ""
@@ -3055,8 +3071,8 @@ msgid "New message, or dial on Calls"
msgstr "Nuovo messaggio, o componi in Chiamate"
#: src/tui/main.cpp
-msgid "Dismiss, forget, unpair, or hang up"
-msgstr "Ignora, dimentica, dissocia o riaggancia"
+msgid "Dismiss, forget, unpair, hang up, or remove a conversation"
+msgstr "Ignora, dimentica, dissocia, riaggancia o rimuovi una conversazione"
#: src/tui/main.cpp
msgid "Copy the highlighted address or text"
diff --git a/po/ja.po b/po/ja.po
index f3f4f8a..de40c83 100644
--- a/po/ja.po
+++ b/po/ja.po
@@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: tether\n"
"Report-Msgid-Bugs-To: [email protected]\n"
-"POT-Creation-Date: 2026-10-24 20:22-0700\n"
+"POT-Creation-Date: 2026-10-25 10:20-0700\n"
"PO-Revision-Date: 2026-08-23\n"
"Last-Translator: Tether project\n"
"Language-Team: Japanese\n"
@@ -2693,6 +2693,16 @@ msgstr "送信済み"
msgid "New Message"
msgstr "新規メッセージ"
+#: src/gtk/messages_view.cpp src/tui/messages.cpp
+#, c-format
+msgid "Remove the conversation with %s?"
+msgstr "%s とのスレッドを一覧から外しますか?"
+
+#: src/gtk/messages_view.cpp src/tui/messages.cpp
+msgid ""
+"It stays on your iPhone, and comes back here when a new message arrives."
+msgstr "iPhone には残り、新しいメッセージが届くとここに再び表示されます。"
+
#: src/gtk/messages_view.cpp
msgid "Search conversations"
msgstr "会話を検索"
@@ -2705,6 +2715,10 @@ msgstr "宛先:"
msgid "Phone number or email"
msgstr "電話番号またはメールアドレス"
+#: src/gtk/messages_view.cpp
+msgid "Remove Conversation"
+msgstr "スレッドを一覧から外す"
+
#: src/gtk/messages_view.cpp
msgid "Send"
msgstr "送信"
@@ -2883,7 +2897,9 @@ msgstr "不明な差出人からのメッセージを非表示"
msgid ""
"Threads from numbers not in your contacts are hidden. Codes still pop up and "
"autofill."
-msgstr "連絡先にない番号とのスレッドは非表示になります。コードは引き続き通知され、自動入力されます。"
+msgstr ""
+"連絡先にない番号とのスレッドは非表示になります。コードは引き続き通知され、自"
+"動入力されます。"
#: src/gtk/settings_view.cpp src/tui/settings.cpp
msgid ""
@@ -3014,8 +3030,8 @@ msgid "New message, or dial on Calls"
msgstr "新規メッセージ、通話タブでは発信"
#: src/tui/main.cpp
-msgid "Dismiss, forget, unpair, or hang up"
-msgstr "消去、削除、ペアリング解除、または終話"
+msgid "Dismiss, forget, unpair, hang up, or remove a conversation"
+msgstr "消去、削除、ペアリング解除、終話、またはスレッドを一覧から外す"
#: src/tui/main.cpp
msgid "Copy the highlighted address or text"
diff --git a/po/ko.po b/po/ko.po
index c8f6f6d..53c19bf 100644
--- a/po/ko.po
+++ b/po/ko.po
@@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: tether\n"
"Report-Msgid-Bugs-To: [email protected]\n"
-"POT-Creation-Date: 2026-10-24 20:22-0700\n"
+"POT-Creation-Date: 2026-10-25 10:20-0700\n"
"PO-Revision-Date: 2026-08-23\n"
"Last-Translator: Tether project\n"
"Language-Team: Korean\n"
@@ -2653,6 +2653,16 @@ msgstr "보냄"
msgid "New Message"
msgstr "새 메시지"
+#: src/gtk/messages_view.cpp src/tui/messages.cpp
+#, c-format
+msgid "Remove the conversation with %s?"
+msgstr "%s 님과의 대화를 목록에서 제거할까요?"
+
+#: src/gtk/messages_view.cpp src/tui/messages.cpp
+msgid ""
+"It stays on your iPhone, and comes back here when a new message arrives."
+msgstr "iPhone에는 그대로 남아 있으며, 새 메시지가 오면 여기에 다시 표시됩니다."
+
#: src/gtk/messages_view.cpp
msgid "Search conversations"
msgstr "대화 검색"
@@ -2665,6 +2675,10 @@ msgstr "받는 사람:"
msgid "Phone number or email"
msgstr "전화번호 또는 이메일"
+#: src/gtk/messages_view.cpp
+msgid "Remove Conversation"
+msgstr "대화 제거"
+
#: src/gtk/messages_view.cpp
msgid "Send"
msgstr "보내기"
@@ -2840,7 +2854,9 @@ msgstr "알 수 없는 발신자의 메시지 숨기기"
msgid ""
"Threads from numbers not in your contacts are hidden. Codes still pop up and "
"autofill."
-msgstr "연락처에 없는 번호와의 대화는 숨겨집니다. 코드는 계속 알림으로 표시되고 자동 입력됩니다."
+msgstr ""
+"연락처에 없는 번호와의 대화는 숨겨집니다. 코드는 계속 알림으로 표시되고 자동 "
+"입력됩니다."
#: src/gtk/settings_view.cpp src/tui/settings.cpp
msgid ""
@@ -2971,8 +2987,8 @@ msgid "New message, or dial on Calls"
msgstr "새 메시지, 통화 탭에서는 전화 걸기"
#: src/tui/main.cpp
-msgid "Dismiss, forget, unpair, or hang up"
-msgstr "닫기, 삭제, 페어링 해제 또는 끊기"
+msgid "Dismiss, forget, unpair, hang up, or remove a conversation"
+msgstr "닫기, 삭제, 페어링 해제, 끊기 또는 대화 제거"
#: src/tui/main.cpp
msgid "Copy the highlighted address or text"
diff --git a/po/nl.po b/po/nl.po
index a2105a1..d901e75 100644
--- a/po/nl.po
+++ b/po/nl.po
@@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: tether\n"
"Report-Msgid-Bugs-To: [email protected]\n"
-"POT-Creation-Date: 2026-10-24 20:22-0700\n"
+"POT-Creation-Date: 2026-10-25 10:20-0700\n"
"PO-Revision-Date: 2026-08-23\n"
"Last-Translator: Tether project\n"
"Language-Team: Dutch\n"
@@ -2721,6 +2721,16 @@ msgstr "Verstuurd"
msgid "New Message"
msgstr "Nieuw bericht"
+#: src/gtk/messages_view.cpp src/tui/messages.cpp
+#, c-format
+msgid "Remove the conversation with %s?"
+msgstr "Het gesprek met %s verwijderen?"
+
+#: src/gtk/messages_view.cpp src/tui/messages.cpp
+msgid ""
+"It stays on your iPhone, and comes back here when a new message arrives."
+msgstr "Het blijft op je iPhone en komt hier terug zodra er een nieuw bericht binnenkomt."
+
#: src/gtk/messages_view.cpp
msgid "Search conversations"
msgstr "Gesprekken doorzoeken"
@@ -2733,6 +2743,10 @@ msgstr "Aan:"
msgid "Phone number or email"
msgstr "Telefoonnummer of e-mailadres"
+#: src/gtk/messages_view.cpp
+msgid "Remove Conversation"
+msgstr "Gesprek verwijderen"
+
#: src/gtk/messages_view.cpp
msgid "Send"
msgstr "Versturen"
@@ -2912,7 +2926,9 @@ msgstr "Berichten van onbekende afzenders verbergen"
msgid ""
"Threads from numbers not in your contacts are hidden. Codes still pop up and "
"autofill."
-msgstr "Gesprekken met nummers die niet in je contacten staan worden verborgen. Codes verschijnen nog steeds en worden automatisch ingevuld."
+msgstr ""
+"Gesprekken met nummers die niet in je contacten staan worden verborgen. "
+"Codes verschijnen nog steeds en worden automatisch ingevuld."
#: src/gtk/settings_view.cpp src/tui/settings.cpp
msgid ""
@@ -3045,8 +3061,8 @@ msgid "New message, or dial on Calls"
msgstr "Nieuw bericht, of bellen onder Gesprekken"
#: src/tui/main.cpp
-msgid "Dismiss, forget, unpair, or hang up"
-msgstr "Negeren, vergeten, ontkoppelen of ophangen"
+msgid "Dismiss, forget, unpair, hang up, or remove a conversation"
+msgstr "Negeren, vergeten, ontkoppelen, ophangen of een gesprek verwijderen"
#: src/tui/main.cpp
msgid "Copy the highlighted address or text"
diff --git a/po/pl.po b/po/pl.po
index 80b222a..ab0524a 100644
--- a/po/pl.po
+++ b/po/pl.po
@@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: tether\n"
"Report-Msgid-Bugs-To: [email protected]\n"
-"POT-Creation-Date: 2026-10-24 20:22-0700\n"
+"POT-Creation-Date: 2026-10-25 10:20-0700\n"
"PO-Revision-Date: 2026-08-23\n"
"Last-Translator: Tether project\n"
"Language-Team: Polish\n"
@@ -2718,6 +2718,16 @@ msgstr "Wysłano"
msgid "New Message"
msgstr "Nowa wiadomość"
+#: src/gtk/messages_view.cpp src/tui/messages.cpp
+#, c-format
+msgid "Remove the conversation with %s?"
+msgstr "Usunąć wątek z %s z listy?"
+
+#: src/gtk/messages_view.cpp src/tui/messages.cpp
+msgid ""
+"It stays on your iPhone, and comes back here when a new message arrives."
+msgstr "Pozostaje na iPhonie i wróci tutaj, gdy nadejdzie nowa wiadomość."
+
#: src/gtk/messages_view.cpp
msgid "Search conversations"
msgstr "Szukaj rozmów"
@@ -2730,6 +2740,10 @@ msgstr "Do:"
msgid "Phone number or email"
msgstr "Numer telefonu lub e-mail"
+#: src/gtk/messages_view.cpp
+msgid "Remove Conversation"
+msgstr "Usuń wątek"
+
#: src/gtk/messages_view.cpp
msgid "Send"
msgstr "Wyślij"
@@ -2908,7 +2922,9 @@ msgstr "Ukryj wiadomości od nieznanych nadawców"
msgid ""
"Threads from numbers not in your contacts are hidden. Codes still pop up and "
"autofill."
-msgstr "Wątki z numerami spoza kontaktów są ukryte. Kody nadal się pojawiają i są wypełniane automatycznie."
+msgstr ""
+"Wątki z numerami spoza kontaktów są ukryte. Kody nadal się pojawiają i są "
+"wypełniane automatycznie."
#: src/gtk/settings_view.cpp src/tui/settings.cpp
msgid ""
@@ -3040,8 +3056,8 @@ msgid "New message, or dial on Calls"
msgstr "Nowa wiadomość lub wybieranie w Połączeniach"
#: src/tui/main.cpp
-msgid "Dismiss, forget, unpair, or hang up"
-msgstr "Odrzuć, zapomnij, rozparuj lub rozłącz"
+msgid "Dismiss, forget, unpair, hang up, or remove a conversation"
+msgstr "Odrzuć, zapomnij, rozparuj, rozłącz lub usuń wątek"
#: src/tui/main.cpp
msgid "Copy the highlighted address or text"
diff --git a/po/pt_BR.po b/po/pt_BR.po
index 2d810cb..4013466 100644
--- a/po/pt_BR.po
+++ b/po/pt_BR.po
@@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: tether\n"
"Report-Msgid-Bugs-To: [email protected]\n"
-"POT-Creation-Date: 2026-10-24 20:22-0700\n"
+"POT-Creation-Date: 2026-10-25 10:20-0700\n"
"PO-Revision-Date: 2026-08-23\n"
"Last-Translator: Tether project\n"
"Language-Team: Brazilian Portuguese\n"
@@ -2720,6 +2720,16 @@ msgstr "Enviado"
msgid "New Message"
msgstr "Nova mensagem"
+#: src/gtk/messages_view.cpp src/tui/messages.cpp
+#, c-format
+msgid "Remove the conversation with %s?"
+msgstr "Remover a conversa com %s?"
+
+#: src/gtk/messages_view.cpp src/tui/messages.cpp
+msgid ""
+"It stays on your iPhone, and comes back here when a new message arrives."
+msgstr "Ela continua no seu iPhone e volta a aparecer aqui quando chegar uma nova mensagem."
+
#: src/gtk/messages_view.cpp
msgid "Search conversations"
msgstr "Pesquisar conversas"
@@ -2732,6 +2742,10 @@ msgstr "Para:"
msgid "Phone number or email"
msgstr "Número de telefone ou e-mail"
+#: src/gtk/messages_view.cpp
+msgid "Remove Conversation"
+msgstr "Remover conversa"
+
#: src/gtk/messages_view.cpp
msgid "Send"
msgstr "Enviar"
@@ -2910,7 +2924,9 @@ msgstr "Ocultar mensagens de remetentes desconhecidos"
msgid ""
"Threads from numbers not in your contacts are hidden. Codes still pop up and "
"autofill."
-msgstr "Conversas com números que não estão nos seus contatos ficam ocultas. Os códigos ainda aparecem e são preenchidos automaticamente."
+msgstr ""
+"Conversas com números que não estão nos seus contatos ficam ocultas. Os "
+"códigos ainda aparecem e são preenchidos automaticamente."
#: src/gtk/settings_view.cpp src/tui/settings.cpp
msgid ""
@@ -3040,8 +3056,8 @@ msgid "New message, or dial on Calls"
msgstr "Nova mensagem, ou discar em Chamadas"
#: src/tui/main.cpp
-msgid "Dismiss, forget, unpair, or hang up"
-msgstr "Dispensar, esquecer, desparear ou desligar"
+msgid "Dismiss, forget, unpair, hang up, or remove a conversation"
+msgstr "Dispensar, esquecer, desparear, desligar ou remover uma conversa"
#: src/tui/main.cpp
msgid "Copy the highlighted address or text"
diff --git a/po/ru.po b/po/ru.po
index 44b9aa0..e3493c8 100644
--- a/po/ru.po
+++ b/po/ru.po
@@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: tether\n"
"Report-Msgid-Bugs-To: [email protected]\n"
-"POT-Creation-Date: 2026-10-24 20:22-0700\n"
+"POT-Creation-Date: 2026-10-25 10:20-0700\n"
"PO-Revision-Date: 2026-08-23\n"
"Last-Translator: Tether project\n"
"Language-Team: Russian\n"
@@ -2718,6 +2718,16 @@ msgstr "Отправлено"
msgid "New Message"
msgstr "Новое сообщение"
+#: src/gtk/messages_view.cpp src/tui/messages.cpp
+#, c-format
+msgid "Remove the conversation with %s?"
+msgstr "Убрать переписку с %s?"
+
+#: src/gtk/messages_view.cpp src/tui/messages.cpp
+msgid ""
+"It stays on your iPhone, and comes back here when a new message arrives."
+msgstr "Она останется на iPhone и снова появится здесь, когда придёт новое сообщение."
+
#: src/gtk/messages_view.cpp
msgid "Search conversations"
msgstr "Поиск переписок"
@@ -2730,6 +2740,10 @@ msgstr "Кому:"
msgid "Phone number or email"
msgstr "Номер телефона или эл. почта"
+#: src/gtk/messages_view.cpp
+msgid "Remove Conversation"
+msgstr "Убрать переписку"
+
#: src/gtk/messages_view.cpp
msgid "Send"
msgstr "Отправить"
@@ -2910,7 +2924,9 @@ msgstr "Скрывать сообщения от неизвестных отпр
msgid ""
"Threads from numbers not in your contacts are hidden. Codes still pop up and "
"autofill."
-msgstr "Переписки с номерами, которых нет в контактах, скрыты. Коды по-прежнему показываются и подставляются автоматически."
+msgstr ""
+"Переписки с номерами, которых нет в контактах, скрыты. Коды по-прежнему "
+"показываются и подставляются автоматически."
#: src/gtk/settings_view.cpp src/tui/settings.cpp
msgid ""
@@ -3042,8 +3058,8 @@ msgid "New message, or dial on Calls"
msgstr "Новое сообщение или набор номера во вкладке «Звонки»"
#: src/tui/main.cpp
-msgid "Dismiss, forget, unpair, or hang up"
-msgstr "Скрыть, забыть, разорвать сопряжение или завершить звонок"
+msgid "Dismiss, forget, unpair, hang up, or remove a conversation"
+msgstr "Скрыть, забыть, разорвать сопряжение, завершить звонок или убрать переписку"
#: src/tui/main.cpp
msgid "Copy the highlighted address or text"
diff --git a/po/sv.po b/po/sv.po
index 63c425a..77221e1 100644
--- a/po/sv.po
+++ b/po/sv.po
@@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: tether\n"
"Report-Msgid-Bugs-To: [email protected]\n"
-"POT-Creation-Date: 2026-10-24 20:22-0700\n"
+"POT-Creation-Date: 2026-10-25 10:20-0700\n"
"PO-Revision-Date: 2026-08-23\n"
"Last-Translator: Tether project\n"
"Language-Team: Swedish\n"
@@ -2689,6 +2689,16 @@ msgstr "Skickat"
msgid "New Message"
msgstr "Nytt meddelande"
+#: src/gtk/messages_view.cpp src/tui/messages.cpp
+#, c-format
+msgid "Remove the conversation with %s?"
+msgstr "Ta bort tråden med %s?"
+
+#: src/gtk/messages_view.cpp src/tui/messages.cpp
+msgid ""
+"It stays on your iPhone, and comes back here when a new message arrives."
+msgstr "Den finns kvar på din iPhone och dyker upp här igen när ett nytt meddelande kommer."
+
#: src/gtk/messages_view.cpp
msgid "Search conversations"
msgstr "Sök konversationer"
@@ -2701,6 +2711,10 @@ msgstr "Till:"
msgid "Phone number or email"
msgstr "Telefonnummer eller e-post"
+#: src/gtk/messages_view.cpp
+msgid "Remove Conversation"
+msgstr "Ta bort tråd"
+
#: src/gtk/messages_view.cpp
msgid "Send"
msgstr "Skicka"
@@ -2880,7 +2894,9 @@ msgstr "Dölj meddelanden från okända avsändare"
msgid ""
"Threads from numbers not in your contacts are hidden. Codes still pop up and "
"autofill."
-msgstr "Trådar med nummer som inte finns bland dina kontakter döljs. Koder visas fortfarande och fylls i automatiskt."
+msgstr ""
+"Trådar med nummer som inte finns bland dina kontakter döljs. Koder visas "
+"fortfarande och fylls i automatiskt."
#: src/gtk/settings_view.cpp src/tui/settings.cpp
msgid ""
@@ -3011,8 +3027,8 @@ msgid "New message, or dial on Calls"
msgstr "Nytt meddelande, eller ring under Samtal"
#: src/tui/main.cpp
-msgid "Dismiss, forget, unpair, or hang up"
-msgstr "Avvisa, glöm, ta bort parkoppling eller lägg på"
+msgid "Dismiss, forget, unpair, hang up, or remove a conversation"
+msgstr "Avvisa, glöm, ta bort parkoppling, lägg på eller ta bort en tråd"
#: src/tui/main.cpp
msgid "Copy the highlighted address or text"
diff --git a/po/tether.pot b/po/tether.pot
index 4fb689a..cbec1b3 100644
--- a/po/tether.pot
+++ b/po/tether.pot
@@ -6,9 +6,9 @@
#, fuzzy
msgid ""
msgstr ""
-"Project-Id-Version: tether 0.2.40\n"
+"Project-Id-Version: tether 0.2.41\n"
"Report-Msgid-Bugs-To: [email protected]\n"
-"POT-Creation-Date: 2026-10-24 20:22-0700\n"
+"POT-Creation-Date: 2026-10-25 10:20-0700\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <[email protected]>\n"
@@ -2442,6 +2442,16 @@ msgstr ""
msgid "New Message"
msgstr ""
+#: src/gtk/messages_view.cpp src/tui/messages.cpp
+#, c-format
+msgid "Remove the conversation with %s?"
+msgstr ""
+
+#: src/gtk/messages_view.cpp src/tui/messages.cpp
+msgid ""
+"It stays on your iPhone, and comes back here when a new message arrives."
+msgstr ""
+
#: src/gtk/messages_view.cpp
msgid "Search conversations"
msgstr ""
@@ -2454,6 +2464,10 @@ msgstr ""
msgid "Phone number or email"
msgstr ""
+#: src/gtk/messages_view.cpp
+msgid "Remove Conversation"
+msgstr ""
+
#: src/gtk/messages_view.cpp
msgid "Send"
msgstr ""
@@ -2752,7 +2766,7 @@ msgid "New message, or dial on Calls"
msgstr ""
#: src/tui/main.cpp
-msgid "Dismiss, forget, unpair, or hang up"
+msgid "Dismiss, forget, unpair, hang up, or remove a conversation"
msgstr ""
#: src/tui/main.cpp
diff --git a/po/tr.po b/po/tr.po
index 35dd234..d03e013 100644
--- a/po/tr.po
+++ b/po/tr.po
@@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: tether\n"
"Report-Msgid-Bugs-To: [email protected]\n"
-"POT-Creation-Date: 2026-10-24 20:22-0700\n"
+"POT-Creation-Date: 2026-10-25 10:20-0700\n"
"PO-Revision-Date: 2026-08-23\n"
"Last-Translator: Tether project\n"
"Language-Team: Turkish\n"
@@ -2683,6 +2683,16 @@ msgstr "Gönderildi"
msgid "New Message"
msgstr "Yeni mesaj"
+#: src/gtk/messages_view.cpp src/tui/messages.cpp
+#, c-format
+msgid "Remove the conversation with %s?"
+msgstr "%s ile olan yazışma kaldırılsın mı?"
+
+#: src/gtk/messages_view.cpp src/tui/messages.cpp
+msgid ""
+"It stays on your iPhone, and comes back here when a new message arrives."
+msgstr "iPhone'unuzda kalır ve yeni bir mesaj geldiğinde burada yeniden görünür."
+
#: src/gtk/messages_view.cpp
msgid "Search conversations"
msgstr "Konuşmalarda ara"
@@ -2695,6 +2705,10 @@ msgstr "Kime:"
msgid "Phone number or email"
msgstr "Telefon numarası ya da e-posta"
+#: src/gtk/messages_view.cpp
+msgid "Remove Conversation"
+msgstr "Yazışmayı kaldır"
+
#: src/gtk/messages_view.cpp
msgid "Send"
msgstr "Gönder"
@@ -2875,7 +2889,9 @@ msgstr "Bilinmeyen gönderenlerin mesajlarını gizle"
msgid ""
"Threads from numbers not in your contacts are hidden. Codes still pop up and "
"autofill."
-msgstr "Kişilerinizde olmayan numaralarla olan yazışmalar gizlenir. Kodlar yine de bildirim olarak görünür ve otomatik doldurulur."
+msgstr ""
+"Kişilerinizde olmayan numaralarla olan yazışmalar gizlenir. Kodlar yine de "
+"bildirim olarak görünür ve otomatik doldurulur."
#: src/gtk/settings_view.cpp src/tui/settings.cpp
msgid ""
@@ -3006,8 +3022,8 @@ msgid "New message, or dial on Calls"
msgstr "Yeni ileti veya Aramalar'da numara çevir"
#: src/tui/main.cpp
-msgid "Dismiss, forget, unpair, or hang up"
-msgstr "Kapat, unut, eşleştirmeyi kaldır veya aramayı sonlandır"
+msgid "Dismiss, forget, unpair, hang up, or remove a conversation"
+msgstr "Kapat, unut, eşleştirmeyi kaldır, aramayı sonlandır veya yazışmayı kaldır"
#: src/tui/main.cpp
msgid "Copy the highlighted address or text"
diff --git a/po/uk.po b/po/uk.po
index 17eb15e..d2c21c4 100644
--- a/po/uk.po
+++ b/po/uk.po
@@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: tether\n"
"Report-Msgid-Bugs-To: [email protected]\n"
-"POT-Creation-Date: 2026-10-24 20:22-0700\n"
+"POT-Creation-Date: 2026-10-25 10:20-0700\n"
"PO-Revision-Date: 2026-08-23\n"
"Last-Translator: Tether project\n"
"Language-Team: Ukrainian\n"
@@ -2713,6 +2713,16 @@ msgstr "Надіслано"
msgid "New Message"
msgstr "Нове повідомлення"
+#: src/gtk/messages_view.cpp src/tui/messages.cpp
+#, c-format
+msgid "Remove the conversation with %s?"
+msgstr "Прибрати розмову з %s?"
+
+#: src/gtk/messages_view.cpp src/tui/messages.cpp
+msgid ""
+"It stays on your iPhone, and comes back here when a new message arrives."
+msgstr "Вона залишиться на iPhone і знову з’явиться тут, коли надійде нове повідомлення."
+
#: src/gtk/messages_view.cpp
msgid "Search conversations"
msgstr "Пошук розмов"
@@ -2725,6 +2735,10 @@ msgstr "Кому:"
msgid "Phone number or email"
msgstr "Номер телефону або ел. пошта"
+#: src/gtk/messages_view.cpp
+msgid "Remove Conversation"
+msgstr "Прибрати розмову"
+
#: src/gtk/messages_view.cpp
msgid "Send"
msgstr "Надіслати"
@@ -2904,7 +2918,9 @@ msgstr "Приховувати повідомлення від невідоми
msgid ""
"Threads from numbers not in your contacts are hidden. Codes still pop up and "
"autofill."
-msgstr "Розмови з номерами, яких немає в контактах, приховано. Коди й надалі з’являються та підставляються автоматично."
+msgstr ""
+"Розмови з номерами, яких немає в контактах, приховано. Коди й надалі "
+"з’являються та підставляються автоматично."
#: src/gtk/settings_view.cpp src/tui/settings.cpp
msgid ""
@@ -3035,8 +3051,8 @@ msgid "New message, or dial on Calls"
msgstr "Нове повідомлення або набір номера на вкладці «Дзвінки»"
#: src/tui/main.cpp
-msgid "Dismiss, forget, unpair, or hang up"
-msgstr "Приховати, забути, роз'єднати пару або завершити дзвінок"
+msgid "Dismiss, forget, unpair, hang up, or remove a conversation"
+msgstr "Приховати, забути, роз'єднати пару, завершити дзвінок або прибрати розмову"
#: src/tui/main.cpp
msgid "Copy the highlighted address or text"
diff --git a/po/zh_CN.po b/po/zh_CN.po
index 6a740ed..07a31af 100644
--- a/po/zh_CN.po
+++ b/po/zh_CN.po
@@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: tether\n"
"Report-Msgid-Bugs-To: [email protected]\n"
-"POT-Creation-Date: 2026-10-24 20:22-0700\n"
+"POT-Creation-Date: 2026-10-25 10:20-0700\n"
"PO-Revision-Date: 2026-08-23\n"
"Last-Translator: Tether project\n"
"Language-Team: Simplified Chinese\n"
@@ -2591,6 +2591,16 @@ msgstr "已发送"
msgid "New Message"
msgstr "新信息"
+#: src/gtk/messages_view.cpp src/tui/messages.cpp
+#, c-format
+msgid "Remove the conversation with %s?"
+msgstr "要移除与 %s 的会话吗?"
+
+#: src/gtk/messages_view.cpp src/tui/messages.cpp
+msgid ""
+"It stays on your iPhone, and comes back here when a new message arrives."
+msgstr "会话仍保留在 iPhone 上,收到新消息时会重新显示在这里。"
+
#: src/gtk/messages_view.cpp
msgid "Search conversations"
msgstr "搜索会话"
@@ -2603,6 +2613,10 @@ msgstr "收件人:"
msgid "Phone number or email"
msgstr "电话号码或电子邮件"
+#: src/gtk/messages_view.cpp
+msgid "Remove Conversation"
+msgstr "移除会话"
+
#: src/gtk/messages_view.cpp
msgid "Send"
msgstr "发送"
@@ -2902,8 +2916,8 @@ msgid "New message, or dial on Calls"
msgstr "新消息,在通话页中为拨号"
#: src/tui/main.cpp
-msgid "Dismiss, forget, unpair, or hang up"
-msgstr "忽略、忘记、取消配对或挂断"
+msgid "Dismiss, forget, unpair, hang up, or remove a conversation"
+msgstr "忽略、忘记、取消配对、挂断或移除会话"
#: src/tui/main.cpp
msgid "Copy the highlighted address or text"
diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt
index e8dd44e..48abf60 100644
--- a/src/core/CMakeLists.txt
+++ b/src/core/CMakeLists.txt
@@ -28,6 +28,7 @@ add_library(tether STATIC
src/bluetooth/messages.cpp
src/bluetooth/map_session.cpp
src/bluetooth/contacts.cpp
+ src/bluetooth/removed_threads.cpp
src/bluetooth/journal.cpp
src/bluetooth/pbap_session.cpp
src/bluetooth/obex_transfer.cpp
diff --git a/src/core/include/tether/bluetooth/messages.hpp b/src/core/include/tether/bluetooth/messages.hpp
index bc7d639..bb6ffc7 100644
--- a/src/core/include/tether/bluetooth/messages.hpp
+++ b/src/core/include/tether/bluetooth/messages.hpp
@@ -3,6 +3,7 @@
#include "tether/bluetooth/bmessage.hpp"
#include <cstdint>
+#include <functional>
#include <map>
#include <nlohmann/json.hpp>
#include <string>
@@ -71,10 +72,15 @@ namespace tether::bluetooth {
const Message* find(const std::string& handle) const;
+ // Messages `visible` rejects are left out before anything is counted.
+ // Empty means all of them.
+ using Visible = std::function<bool(const Message&)>;
+
// Newest activity first.
- std::vector<Thread> threads() const;
+ std::vector<Thread> threads(const Visible& visible = {}) const;
// Oldest first within a thread, limited to the most recent `limit`.
- std::vector<Message> messages(const std::string& thread_key, size_t limit = 200) const;
+ std::vector<Message>
+ messages(const std::string& thread_key, size_t limit = 200, const Visible& visible = {}) const;
size_t size() const { return by_handle_.size(); }
diff --git a/src/core/include/tether/bluetooth/removed_threads.hpp b/src/core/include/tether/bluetooth/removed_threads.hpp
new file mode 100644
index 0000000..a98def9
--- /dev/null
+++ b/src/core/include/tether/bluetooth/removed_threads.hpp
@@ -0,0 +1,48 @@
+#pragma once
+
+#include "tether/bluetooth/messages.hpp"
+#include "tether/secret_store.hpp"
+
+#include <cstdint>
+#include <map>
+#include <string>
+
+namespace tether::bluetooth {
+
+ // Conversations the user removed from Tether. Display only: nothing is
+ // deleted, a removed thread just hides every message at or before its
+ // cutoff, so anything newer brings it back.
+ class RemovedThreads {
+ public:
+ // `cutoff` is the newest timestamp the user saw in the thread. Repeats
+ // keep the later cutoff.
+ void remove(const std::string& thread_key, int64_t cutoff);
+
+ bool hides(const Message& message) const;
+
+ size_t size() const { return cutoffs_.size(); }
+ const std::map<std::string, int64_t>& cutoffs() const { return cutoffs_; }
+
+ private:
+ // Keyed by thread_bucket, so every spelling of a number shares one entry.
+ std::map<std::string, int64_t> cutoffs_;
+ };
+
+ std::string removed_threads_path(Retention mode);
+
+ // Rewrites the file from one mode's path into the other's and removes the
+ // source. No-op unless the source exists and the destination does not.
+ bool migrate_removed_threads(Retention from, Retention to);
+
+ bool save_removed_threads(const RemovedThreads& removed);
+ // Empty when retention is off, the wallet is locked, or the file is unreadable.
+ RemovedThreads load_removed_threads();
+
+ std::string serialize_removed_threads(const RemovedThreads& removed);
+ // Anything malformed yields fewer entries, never a broader one.
+ RemovedThreads deserialize_removed_threads(const std::string& text);
+
+ // Guarded by message_store_mutex().
+ RemovedThreads& removed_threads();
+
+} // namespace tether::bluetooth
diff --git a/src/core/src/bluetooth/connection.cpp b/src/core/src/bluetooth/connection.cpp
index a669a81..cf47454 100644
--- a/src/core/src/bluetooth/connection.cpp
+++ b/src/core/src/bluetooth/connection.cpp
@@ -9,6 +9,7 @@
#include "tether/bluetooth/monitor.hpp"
#include "tether/bluetooth/pairing.hpp"
#include "tether/bluetooth/pbap_session.hpp"
+#include "tether/bluetooth/removed_threads.hpp"
#include "tether/log.hpp"
#include "tether/net.hpp"
#include "tether/secret_store.hpp"
@@ -65,6 +66,18 @@ namespace tether::bluetooth {
}
return sender_invalidates_route(sender_key, members);
}
+
+ // Loads the saved list, keeping anything removed while it could not be
+ // read. Caller holds g_messages_mutex.
+ void restore_removed_threads() {
+ RemovedThreads loaded = load_removed_threads();
+ const bool unsaved = removed_threads().size() > 0;
+ for (const auto& [key, cutoff] : removed_threads().cutoffs())
+ loaded.remove(key, cutoff);
+ removed_threads() = std::move(loaded);
+ if (unsaved)
+ save_removed_threads(removed_threads());
+ }
} // namespace
MessageStore& message_store() { return g_messages; }
@@ -177,6 +190,8 @@ namespace tether::bluetooth {
std::lock_guard<std::mutex> lock(g_messages_mutex);
g_journal.close();
migrate_contacts(previous, next);
+ if (!migrate_removed_threads(previous, next) && removed_threads().size() > 0)
+ save_removed_threads(removed_threads());
}
void set_group_replies_enabled(bool enabled) {
@@ -857,6 +872,7 @@ namespace tether::bluetooth {
contact_store() = load_contacts();
else
save_contacts(contact_store());
+ restore_removed_threads();
auto history = g_journal.load(now);
for (const auto& message : history)
g_messages.add(message);
@@ -1464,6 +1480,7 @@ namespace tether::bluetooth {
{
std::lock_guard<std::mutex> lock(g_messages_mutex);
contact_store() = load_contacts();
+ restore_removed_threads();
if (g_journal.open()) {
const int64_t now = static_cast<int64_t>(std::time(nullptr));
auto history = g_journal.load(now);
diff --git a/src/core/src/bluetooth/messages.cpp b/src/core/src/bluetooth/messages.cpp
index 23a50ca..58de51f 100644
--- a/src/core/src/bluetooth/messages.cpp
+++ b/src/core/src/bluetooth/messages.cpp
@@ -138,11 +138,11 @@ namespace tether::bluetooth {
}
}
- std::vector<Thread> MessageStore::threads() const {
+ std::vector<Thread> MessageStore::threads(const Visible& visible) const {
std::map<std::string, Thread> grouped;
for (const auto& [handle, message] : by_handle_) {
- if (message.thread_key.empty())
+ if (message.thread_key.empty() || (visible && !visible(message)))
continue;
Thread& thread = grouped[message.thread_key];
thread.key = message.thread_key;
@@ -180,12 +180,13 @@ namespace tether::bluetooth {
return result;
}
- std::vector<Message> MessageStore::messages(const std::string& thread_key, size_t limit) const {
+ std::vector<Message>
+ MessageStore::messages(const std::string& thread_key, size_t limit, const Visible& visible) const {
// Matched on the bucket, not the string
const std::string bucket = thread_bucket(thread_key);
std::vector<Message> result;
for (const auto& [handle, message] : by_handle_) {
- if (thread_bucket(message.thread_key) == bucket)
+ if (thread_bucket(message.thread_key) == bucket && (!visible || visible(message)))
result.push_back(message);
}
diff --git a/src/core/src/bluetooth/removed_threads.cpp b/src/core/src/bluetooth/removed_threads.cpp
new file mode 100644
index 0000000..353b68e
--- /dev/null
+++ b/src/core/src/bluetooth/removed_threads.cpp
@@ -0,0 +1,165 @@
+#include "tether/bluetooth/removed_threads.hpp"
+#include "tether/bluetooth/bmessage.hpp"
+#include "tether/log.hpp"
+#include "tether/paths.hpp"
+
+#include <algorithm>
+#include <fcntl.h>
+#include <filesystem>
+#include <fstream>
+#include <nlohmann/json.hpp>
+#include <unistd.h>
+
+namespace tether::bluetooth {
+
+ namespace {
+
+ // Write-then-rename at mode 0600, fsynced before the rename.
+ bool write_private(const std::string& path, const std::string& body) {
+ std::error_code ec;
+ std::filesystem::create_directories(std::filesystem::path(path).parent_path(), ec);
+
+ const std::string tmp = path + ".tmp";
+ {
+ std::ofstream out(tmp, std::ios::trunc);
+ if (!out.is_open()) {
+ debug::log(ERR, "bluetooth: cannot write {}", tmp);
+ return false;
+ }
+ out << body;
+ if (!out) {
+ debug::log(ERR, "bluetooth: failed writing {}", tmp);
+ return false;
+ }
+ }
+ std::filesystem::permissions(tmp,
+ std::filesystem::perms::owner_read | std::filesystem::perms::owner_write,
+ std::filesystem::perm_options::replace,
+ ec);
+ if (const int fd = ::open(tmp.c_str(), O_RDONLY); fd >= 0) {
+ ::fsync(fd);
+ ::close(fd);
+ }
+ std::filesystem::rename(tmp, path, ec);
+ if (ec) {
+ debug::log(ERR, "bluetooth: cannot replace {}: {}", path, ec.message());
+ std::filesystem::remove(tmp, ec);
+ return false;
+ }
+ return true;
+ }
+
+ bool read_all(const std::string& path, std::string& out) {
+ std::ifstream in(path);
+ if (!in.is_open())
+ return false;
+ out.assign((std::istreambuf_iterator<char>(in)), std::istreambuf_iterator<char>());
+ return true;
+ }
+
+ } // namespace
+
+ void RemovedThreads::remove(const std::string& thread_key, int64_t cutoff) {
+ if (thread_key.empty())
+ return;
+ auto [at, fresh] = cutoffs_.emplace(thread_bucket(thread_key), cutoff);
+ if (!fresh)
+ at->second = std::max(at->second, cutoff);
+ }
+
+ bool RemovedThreads::hides(const Message& message) const {
+ if (cutoffs_.empty() || message.thread_key.empty())
+ return false;
+ auto at = cutoffs_.find(thread_bucket(message.thread_key));
+ return at != cutoffs_.end() && message.timestamp <= at->second;
+ }
+
+ std::string removed_threads_path(Retention mode) {
+ const std::filesystem::path dir = paths::data_dir();
+ if (dir.empty() || mode == Retention::None)
+ return {};
+ return (dir / (mode == Retention::Encrypted ? "removed_threads.json.enc" : "removed_threads.json")).string();
+ }
+
+ std::string serialize_removed_threads(const RemovedThreads& removed) {
+ nlohmann::json j;
+ j["removed"] = removed.cutoffs();
+ return secret::seal(j.dump());
+ }
+
+ RemovedThreads deserialize_removed_threads(const std::string& text) {
+ RemovedThreads removed;
+ std::string plain;
+ if (!secret::unseal(text, plain))
+ return removed;
+ try {
+ auto j = nlohmann::json::parse(plain);
+ if (!j.is_object() || !j.contains("removed") || !j["removed"].is_object())
+ return removed;
+ for (const auto& [key, cutoff] : j["removed"].items()) {
+ if (cutoff.is_number_integer())
+ removed.remove(key, cutoff.get<int64_t>());
+ }
+ } catch (const std::exception&) {
+ return RemovedThreads();
+ }
+ return removed;
+ }
+
+ bool save_removed_threads(const RemovedThreads& removed) {
+ const std::string path = removed_threads_path(secret::retention());
+ if (path.empty())
+ return false;
+ const std::string body = serialize_removed_threads(removed);
+ return !body.empty() && write_private(path, body);
+ }
+
+ RemovedThreads load_removed_threads() {
+ const Retention mode = secret::retention();
+ if (mode == Retention::None || !secret::have_key())
+ return {};
+
+ // No-op unless a file written under the other mode is still there.
+ migrate_removed_threads(mode == Retention::Encrypted ? Retention::Plaintext : Retention::Encrypted, mode);
+
+ std::string text;
+ if (!read_all(removed_threads_path(mode), text))
+ return {};
+ return deserialize_removed_threads(text);
+ }
+
+ bool migrate_removed_threads(Retention from, Retention to) {
+ const std::string source = removed_threads_path(from);
+ const std::string destination = removed_threads_path(to);
+ if (source.empty() || destination.empty() || source == destination)
+ return false;
+ if (!std::filesystem::exists(source))
+ return false;
+
+ // A destination already there means an earlier migration was interrupted
+ // between the rename and the unlink.
+ std::error_code ec;
+ if (std::filesystem::exists(destination)) {
+ std::filesystem::remove(source, ec);
+ return !ec;
+ }
+
+ std::string text;
+ std::string plain;
+ if (!read_all(source, text) || !secret::unseal(text, plain, from)) {
+ debug::log(WARN, "bluetooth: cannot read {} to migrate it; leaving it in place", source);
+ return false;
+ }
+ const std::string sealed = secret::seal(plain, to);
+ if (sealed.empty() || !write_private(destination, sealed))
+ return false;
+ std::filesystem::remove(source, ec);
+ return true;
+ }
+
+ RemovedThreads& removed_threads() {
+ static RemovedThreads removed;
+ return removed;
+ }
+
+} // namespace tether::bluetooth
diff --git a/src/core/src/net.cpp b/src/core/src/net.cpp
index 1da108e..d46bbf1 100644
--- a/src/core/src/net.cpp
+++ b/src/core/src/net.cpp
@@ -24,6 +24,7 @@
#include "tether/bluetooth/diagnostics.hpp"
#include "tether/bluetooth/monitor.hpp"
#include "tether/bluetooth/pairing.hpp"
+#include "tether/bluetooth/removed_threads.hpp"
#include "tether/client.hpp"
#include "tether/crypto.hpp"
#include "tether/discovery.hpp"
@@ -780,7 +781,9 @@ namespace tether {
const bool hide_unknown = bluetooth::load_config().hide_unknown_senders;
{
std::lock_guard<std::mutex> lock(bluetooth::message_store_mutex());
- for (const auto& thread : bluetooth::message_store().threads()) {
+ const auto& removed = bluetooth::removed_threads();
+ const auto visible = [&removed](const bluetooth::Message& m) { return !removed.hides(m); };
+ for (const auto& thread : bluetooth::message_store().threads(visible)) {
if (hide_unknown && bluetooth::contact_store().is_unknown_sender(thread.key, thread.replied))
continue;
auto entry = bluetooth::to_json(thread);
@@ -829,7 +832,9 @@ namespace tether {
{
std::lock_guard<std::mutex> lock(bluetooth::message_store_mutex());
const std::string name = bluetooth::contact_store().name_for(thread_key);
- for (const auto& message : bluetooth::message_store().messages(thread_key)) {
+ const auto& removed = bluetooth::removed_threads();
+ const auto visible = [&removed](const bluetooth::Message& m) { return !removed.hides(m); };
+ for (const auto& message : bluetooth::message_store().messages(thread_key, 200, visible)) {
auto entry = bluetooth::to_json(message);
if (!name.empty() && !message.outgoing)
entry["name"] = name;
@@ -1397,6 +1402,23 @@ namespace tether {
handles.push_back(j["handle"].get<std::string>());
}
bluetooth::mark_messages_read_async(std::move(handles), j.value("read", true));
+ } else if (j.contains("command") && j["command"] == "bt_remove_thread") {
+ // `before` is the newest timestamp the user saw, so a message
+ // arriving meanwhile stays visible. Nothing is deleted.
+ const bool valid = j.contains("thread") && j["thread"].is_string() &&
+ !j["thread"].get<std::string>().empty() && j.contains("before") &&
+ j["before"].is_number_integer();
+ if (valid) {
+ {
+ std::lock_guard<std::mutex> lock(bluetooth::message_store_mutex());
+ bluetooth::removed_threads().remove(j["thread"].get<std::string>(),
+ j["before"].get<int64_t>());
+ bluetooth::save_removed_threads(bluetooth::removed_threads());
+ }
+ broadcast_local_event(build_bt_threads().dump());
+ } else {
+ debug::log(WARN, "bt_remove_thread: needs a thread and an integer before");
+ }
} else if (j.contains("command") && j["command"] == "bt_send_message" && j.contains("thread") &&
j.contains("body")) {
send_bt_message_async(j["thread"].get<std::string>(),
@@ -1587,6 +1609,7 @@ namespace tether {
for (auto mode : {Retention::Encrypted, Retention::Plaintext}) {
std::filesystem::remove(bluetooth::journal_path(mode), ec);
std::filesystem::remove(bluetooth::contacts_path(mode), ec);
+ std::filesystem::remove(bluetooth::removed_threads_path(mode), ec);
}
} else {
bluetooth::move_retained_store(previous, config.retention);
diff --git a/src/daemon/main.cpp b/src/daemon/main.cpp
index ba12166..4c87d1a 100644
--- a/src/daemon/main.cpp
+++ b/src/daemon/main.cpp
@@ -16,6 +16,7 @@
#include <tether/bluetooth/contacts.hpp>
#include <tether/bluetooth/monitor.hpp>
#include <tether/bluetooth/pairing.hpp>
+#include <tether/bluetooth/removed_threads.hpp>
#include <tether/core.hpp>
#include <tether/crypto.hpp>
#include <tether/discovery.hpp>
@@ -267,11 +268,15 @@ int main(int argc, char** argv) {
const bool hide_unknown = tether::bluetooth::load_config().hide_unknown_senders;
std::string who;
bool unknown = false;
+ bool hidden = false;
{
std::lock_guard<std::mutex> lock(tether::bluetooth::message_store_mutex());
who = tether::bluetooth::contact_store().name_for(message.thread_key);
+ const auto& removed = tether::bluetooth::removed_threads();
+ hidden = removed.hides(message);
if (hide_unknown) {
- const auto thread = tether::bluetooth::message_store().messages(message.thread_key);
+ const auto thread = tether::bluetooth::message_store().messages(
+ message.thread_key, 200, [&removed](const auto& m) { return !removed.hides(m); });
const bool replied =
std::any_of(thread.begin(), thread.end(), [](const auto& m) { return m.outgoing; });
unknown = tether::bluetooth::contact_store().is_unknown_sender(message.thread_key, replied);
@@ -280,6 +285,8 @@ int main(int argc, char** argv) {
// hidden sender still pops up with a code,
if (unknown && otp.empty() && !tether::bluetooth::is_short_code(message.thread_key))
return;
+ if (hidden && otp.empty())
+ return;
if (who.empty())
who = message.peer_name.empty() ? message.peer_address : message.peer_name;
tether::bluetooth::ancs::Notification as_notification;
diff --git a/src/gtk/messages_view.cpp b/src/gtk/messages_view.cpp
index 18a391e..83cdf09 100644
--- a/src/gtk/messages_view.cpp
+++ b/src/gtk/messages_view.cpp
@@ -30,6 +30,7 @@ namespace tether::ui {
GtkWidget* thread_list = nullptr;
GtkWidget* conversation = nullptr;
GtkWidget* conversation_header = nullptr;
+ GtkWidget* remove_button = nullptr;
GtkWidget* conversation_scroll = nullptr;
GtkWidget* composer = nullptr;
GtkWidget* send_button = nullptr;
@@ -44,6 +45,7 @@ namespace tether::ui {
std::string selected_thread;
std::string selected_name;
+ int64_t selected_timestamp = 0;
bool visible = false;
bool map_open = false;
bool threads_known = false;
@@ -204,6 +206,7 @@ namespace tether::ui {
g_object_set_data_full(
G_OBJECT(row), "reply_reason", g_strdup(thread.value("reply_reason", "").c_str()), g_free);
g_object_set_data(G_OBJECT(row), "group", GINT_TO_POINTER(thread.value("group", false) ? 1 : 0));
+ g_object_set_data_full(G_OBJECT(row), "timestamp", g_strdup(std::to_string(stamp).c_str()), g_free);
GtkWidget* box = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 8);
gtk_container_set_border_width(GTK_CONTAINER(box), 10);
@@ -793,6 +796,8 @@ namespace tether::ui {
void clear_selection() {
switch_thread("");
+ gtk_widget_hide(g_messages.remove_button);
+ g_messages.selected_timestamp = 0;
g_messages.selected_name.clear();
g_messages.selected_repliable = false;
g_messages.selected_block_reason.clear();
@@ -806,8 +811,11 @@ namespace tether::ui {
const char* thread = (const char*)g_object_get_data(G_OBJECT(row), "thread");
const char* name = (const char*)g_object_get_data(G_OBJECT(row), "name");
const char* block_reason = (const char*)g_object_get_data(G_OBJECT(row), "reply_reason");
+ const char* stamp = (const char*)g_object_get_data(G_OBJECT(row), "timestamp");
switch_thread(thread ? thread : "");
+ g_messages.selected_timestamp = stamp ? g_ascii_strtoll(stamp, nullptr, 10) : 0;
+ gtk_widget_set_visible(g_messages.remove_button, thread && *thread);
g_messages.selected_name = name ? name : "";
g_messages.selected_repliable = g_object_get_data(G_OBJECT(row), "repliable") != nullptr;
@@ -889,6 +897,7 @@ namespace tether::ui {
g_messages.composing = true;
g_messages.compose_requested_key.clear();
+ gtk_widget_hide(g_messages.remove_button);
contact_completion_request();
clear_list_box(g_messages.conversation);
@@ -940,6 +949,33 @@ namespace tether::ui {
void on_thread_activated(GtkListBox*, GtkListBoxRow*, gpointer) { focus_composer_soon(); }
+ void on_remove_thread_clicked(GtkWidget*, gpointer) {
+ if (g_messages.selected_thread.empty() || g_messages.composing)
+ return;
+ // Taken before the dialog runs: the list can refresh underneath it,
+ // and a message arriving meanwhile must stay visible.
+ const std::string thread = g_messages.selected_thread;
+ const int64_t before = g_messages.selected_timestamp;
+ const std::string name = g_messages.selected_name.empty() ? thread : g_messages.selected_name;
+
+ GtkWidget* dialog = gtk_message_dialog_new(GTK_WINDOW(main_window()),
+ GTK_DIALOG_MODAL,
+ GTK_MESSAGE_QUESTION,
+ GTK_BUTTONS_OK_CANCEL,
+ _("Remove the conversation with %s?"),
+ name.c_str());
+ gtk_message_dialog_format_secondary_text(
+ GTK_MESSAGE_DIALOG(dialog),
+ "%s",
+ _("It stays on your iPhone, and comes back here when a new message arrives."));
+ const bool confirmed = gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_OK;
+ gtk_widget_destroy(dialog);
+ if (!confirmed)
+ return;
+
+ daemon_send({{"command", "bt_remove_thread"}, {"thread", thread}, {"before", before}});
+ }
+
} // namespace
void messages_view_handle_disconnect() {
@@ -1175,6 +1211,13 @@ namespace tether::ui {
gtk_label_set_xalign(GTK_LABEL(g_messages.conversation_header), 0.0);
gtk_label_set_ellipsize(GTK_LABEL(g_messages.conversation_header), PANGO_ELLIPSIZE_END);
gtk_box_pack_start(GTK_BOX(conversation_header_box), g_messages.conversation_header, TRUE, TRUE, 0);
+ g_messages.remove_button = gtk_button_new_from_icon_name("user-trash-symbolic", GTK_ICON_SIZE_BUTTON);
+ gtk_button_set_relief(GTK_BUTTON(g_messages.remove_button), GTK_RELIEF_NONE);
+ gtk_widget_set_tooltip_text(g_messages.remove_button, _("Remove Conversation"));
+ set_accessible_name(g_messages.remove_button, _("Remove Conversation"));
+ g_signal_connect(g_messages.remove_button, "clicked", G_CALLBACK(on_remove_thread_clicked), nullptr);
+ gtk_widget_set_no_show_all(g_messages.remove_button, TRUE);
+ gtk_box_pack_end(GTK_BOX(conversation_header_box), g_messages.remove_button, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(conversation_box), conversation_header_box, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(conversation_box), gtk_separator_new(GTK_ORIENTATION_HORIZONTAL), FALSE, FALSE, 0);
diff --git a/src/tui/main.cpp b/src/tui/main.cpp
index e1b35ce..df2f79a 100644
--- a/src/tui/main.cpp
+++ b/src/tui/main.cpp
@@ -591,7 +591,7 @@ namespace tether::tui {
{"i a", N_("Write in the open conversation")},
{"Enter / C-j", N_("Send / new line (insert mode)")},
{"o", N_("New message, or dial on Calls")},
- {"dd", N_("Dismiss, forget, unpair, or hang up")},
+ {"dd", N_("Dismiss, forget, unpair, hang up, or remove a conversation")},
{"yy", N_("Copy the highlighted address or text")},
{"r", N_("Refresh, or scan for devices")},
{":send FILE…", N_("Send files to the selected device")},
diff --git a/src/tui/messages.cpp b/src/tui/messages.cpp
index 99fbb25..5806764 100644
--- a/src/tui/messages.cpp
+++ b/src/tui/messages.cpp
@@ -1,6 +1,7 @@
#include "app.hpp"
#include <ctime>
+#include <glib.h>
#include <map>
#include <message_format.hpp>
#include <set>
@@ -71,6 +72,8 @@ namespace tether::tui {
return rows;
}
+ void cursor_moved(const std::string& id) override { cursor_ = id; }
+
void open(const std::string& key) override {
const json* thread = find_thread(key);
if (!thread)
@@ -176,6 +179,10 @@ namespace tether::tui {
request_messages(selected_thread_);
return true;
}
+ if (action == "delete") {
+ remove_thread(cursor_.empty() ? selected_thread_ : cursor_);
+ return true;
+ }
return false;
}
@@ -190,6 +197,10 @@ namespace tether::tui {
address(args);
return true;
}
+ if (name == "remove") {
+ remove_thread(cursor_.empty() ? selected_thread_ : cursor_);
+ return true;
+ }
if (name == "perms" || name == "solicit") {
if (!app::send({{"command", "bt_solicit"}}))
app::status(_("Could not reach the Tether daemon."));
@@ -276,6 +287,26 @@ namespace tether::tui {
app::send({{"command", "bt_list_messages"}, {"thread", key}});
}
+ // Taken before the prompt: the list can refresh underneath it, and a
+ // message arriving meanwhile must stay visible.
+ void remove_thread(const std::string& key) {
+ const json* thread = find_thread(key);
+ if (!thread)
+ return;
+ const std::string thread_key = thread->value("thread", "");
+ const int64_t before = thread->value("timestamp", static_cast<int64_t>(0));
+ const std::string name = thread->value("name", thread->value("address", thread_key));
+
+ gchar* question = g_strdup_printf(_("Remove the conversation with %s?"), name.c_str());
+ const std::string text = std::string(question ? question : "") + "\n" +
+ _("It stays on your iPhone, and comes back here when a new message arrives.");
+ g_free(question);
+ app::confirm(text, [thread_key, before] {
+ if (!app::send({{"command", "bt_remove_thread"}, {"thread", thread_key}, {"before", before}}))
+ app::status(_("Could not reach the Tether daemon."));
+ });
+ }
+
const json* find_thread(const std::string& key) const {
for (const auto& thread : threads_)
if (same_thread(thread.value("thread", ""), key))
@@ -488,6 +519,8 @@ namespace tether::tui {
std::string selected_thread_;
std::string selected_name_;
+ // List row under the cursor, which may differ from the open thread.
+ std::string cursor_;
bool selected_repliable_ = false;
std::string selected_block_reason_;
bool composing_ = false;
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index 416a76a..a0f491a 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -17,6 +17,7 @@ add_executable(tether_test
test_telephony.cpp
test_vcard.cpp
test_journal.cpp
+ test_removed_threads.cpp
test_crypto.cpp
test_secret_store.cpp
secret_test_env.cpp
diff --git a/test/test_removed_threads.cpp b/test/test_removed_threads.cpp
new file mode 100644
index 0000000..281d616
--- /dev/null
+++ b/test/test_removed_threads.cpp
@@ -0,0 +1,254 @@
+#include "scoped_env.hpp"
+
+#include <gtest/gtest.h>
+#include <tether/bluetooth/messages.hpp>
+#include <tether/bluetooth/removed_threads.hpp>
+#include <tether/secret_store.hpp>
+
+#include <filesystem>
+#include <fstream>
+#include <string>
+
+using namespace tether;
+using namespace tether::bluetooth;
+
+namespace {
+
+ using tether::testing::ScopedEnv;
+
+ class ScopedHome {
+ public:
+ explicit ScopedHome(const std::filesystem::path& dir, Retention mode = Retention::Encrypted)
+ : home_("HOME", dir) {
+ secret::reset_for_test();
+ secret::set_retention(mode);
+ }
+
+ ~ScopedHome() { secret::reset_for_test(); }
+
+ private:
+ ScopedEnv home_;
+ };
+
+ std::filesystem::path scratch(const std::string& name) {
+ const auto dir = std::filesystem::temp_directory_path() / ("tether-removed-" + name);
+ std::filesystem::remove_all(dir);
+ std::filesystem::create_directories(dir);
+ return dir;
+ }
+
+ std::filesystem::path store_dir(const std::filesystem::path& home) { return home / ".local" / "share" / "tether"; }
+
+ Message make(const std::string& handle, const std::string& thread, int64_t ts, bool read = false) {
+ Message m;
+ m.handle = handle;
+ m.thread_key = thread;
+ m.peer_address = thread;
+ m.body = "body " + handle;
+ m.timestamp = ts;
+ m.read = read;
+ return m;
+ }
+
+ MessageStore::Visible visible_with(const RemovedThreads& removed) {
+ return [&removed](const Message& m) { return !removed.hides(m); };
+ }
+
+} // namespace
+
+TEST(RemovedThreads, HidesUpToAndIncludingTheCutoff) {
+ RemovedThreads removed;
+ removed.remove("tel:+15551234567", 100);
+
+ EXPECT_TRUE(removed.hides(make("a", "tel:+15551234567", 99)));
+ EXPECT_TRUE(removed.hides(make("b", "tel:+15551234567", 100)));
+ EXPECT_FALSE(removed.hides(make("c", "tel:+15551234567", 101))) << "a newer message must bring the thread back";
+ EXPECT_FALSE(removed.hides(make("d", "tel:+15559999999", 50))) << "other threads are untouched";
+}
+
+TEST(RemovedThreads, NothingRemovedHidesNothing) {
+ RemovedThreads removed;
+ EXPECT_FALSE(removed.hides(make("a", "tel:+15551234567", 0)));
+ removed.remove("", 100);
+ EXPECT_EQ(removed.size(), 0u);
+ EXPECT_FALSE(removed.hides(make("b", "", 0)));
+}
+
+// The phone lists the same person both ways, and the store merges them.
+TEST(RemovedThreads, EverySpellingOfANumberSharesOneEntry) {
+ RemovedThreads removed;
+ removed.remove("tel:5551234567", 100);
+ removed.remove("tel:+15551234567", 50);
+
+ EXPECT_EQ(removed.size(), 1u);
+ EXPECT_TRUE(removed.hides(make("a", "tel:+15551234567", 100))) << "repeats keep the later cutoff";
+ EXPECT_TRUE(removed.hides(make("b", "tel:5551234567", 100)));
+}
+
+TEST(RemovedThreads, GroupAndEmailKeysAreTheirOwnEntry) {
+ RemovedThreads removed;
+ removed.remove("group:abc", 100);
+ removed.remove("email:[email protected]", 100);
+
+ EXPECT_TRUE(removed.hides(make("a", "group:abc", 100)));
+ EXPECT_TRUE(removed.hides(make("b", "email:[email protected]", 100)));
+ EXPECT_FALSE(removed.hides(make("c", "group:abd", 100)));
+}
+
+TEST(RemovedThreads, ThreadsLeaveOutHiddenMessagesBeforeCounting) {
+ MessageStore store;
+ store.add(make("old1", "tel:+15551234567", 100));
+ store.add(make("old2", "tel:+15551234567", 200));
+ store.add(make("other", "tel:+15559999999", 150));
+
+ RemovedThreads removed;
+ removed.remove("tel:+15551234567", 200);
+ const auto visible = visible_with(removed);
+
+ auto threads = store.threads(visible);
+ ASSERT_EQ(threads.size(), 1u);
+ EXPECT_EQ(threads[0].key, "tel:+15559999999");
+
+ store.add(make("new", "tel:+15551234567", 300));
+ threads = store.threads(visible);
+ ASSERT_EQ(threads.size(), 2u);
+ EXPECT_EQ(threads[0].key, "tel:+15551234567");
+ EXPECT_EQ(threads[0].count, 1) << "the returning thread counts only what is shown";
+ EXPECT_EQ(threads[0].unread, 1) << "hidden unread messages must not reach the tray badge";
+ EXPECT_EQ(threads[0].last_body, "body new");
+ EXPECT_EQ(threads[0].last_timestamp, 300);
+
+ auto messages = store.messages("tel:+15551234567", 200, visible);
+ ASSERT_EQ(messages.size(), 1u);
+ EXPECT_EQ(messages[0].handle, "new");
+
+ EXPECT_EQ(store.threads().size(), 2u);
+ EXPECT_EQ(store.messages("tel:+15551234567").size(), 3u) << "nothing is deleted";
+}
+
+TEST(RemovedThreads, ReplyStateComesFromWhatIsShown) {
+ MessageStore store;
+ Message reply = make("sent", "tel:+15551234567", 100, true);
+ reply.outgoing = true;
+ store.add(reply);
+ store.add(make("new", "tel:+15551234567", 300));
+
+ RemovedThreads removed;
+ removed.remove("tel:+15551234567", 100);
+
+ auto threads = store.threads(visible_with(removed));
+ ASSERT_EQ(threads.size(), 1u);
+ EXPECT_FALSE(threads[0].replied);
+}
+
+TEST(RemovedThreads, MessagesFilterBeforeTheLimit) {
+ MessageStore store;
+ for (int i = 0; i < 10; ++i)
+ store.add(make("h" + std::to_string(i), "tel:+15551234567", 100 + i));
+
+ RemovedThreads removed;
+ removed.remove("tel:+15551234567", 107);
+
+ auto messages = store.messages("tel:+15551234567", 5, visible_with(removed));
+ ASSERT_EQ(messages.size(), 2u);
+ EXPECT_EQ(messages[0].handle, "h8");
+ EXPECT_EQ(messages[1].handle, "h9");
+}
+
+TEST(RemovedThreads, StaysHiddenAfterTheStoreRekeysTheThread) {
+ MessageStore store;
+ store.add(make("a", "tel:5551234567", 100));
+
+ RemovedThreads removed;
+ removed.remove("tel:5551234567", 100);
+
+ // A better spelling arrives and the store moves the conversation to it.
+ store.add(make("b", "tel:+15551234567", 90));
+ ASSERT_EQ(store.threads().size(), 1u);
+ EXPECT_EQ(store.threads()[0].key, "tel:+15551234567");
+
+ EXPECT_TRUE(store.threads(visible_with(removed)).empty());
+}
+
+TEST(RemovedThreads, RoundTripsEncryptedWithNothingInTheClear) {
+ const auto home = scratch("encrypted");
+ {
+ ScopedHome scoped(home);
+ RemovedThreads removed;
+ removed.remove("tel:+15551234567", 100);
+ ASSERT_TRUE(save_removed_threads(removed));
+
+ const auto path = store_dir(home) / "removed_threads.json.enc";
+ ASSERT_TRUE(std::filesystem::exists(path));
+ std::ifstream in(path);
+ const std::string text((std::istreambuf_iterator<char>(in)), std::istreambuf_iterator<char>());
+ EXPECT_EQ(text.find("5551234567"), std::string::npos) << "the phone number is on disk in the clear";
+ EXPECT_EQ(std::filesystem::status(path).permissions() & std::filesystem::perms::all,
+ std::filesystem::perms::owner_read | std::filesystem::perms::owner_write);
+
+ auto loaded = load_removed_threads();
+ EXPECT_EQ(loaded.size(), 1u);
+ EXPECT_TRUE(loaded.hides(make("a", "tel:+15551234567", 100)));
+ EXPECT_FALSE(loaded.hides(make("b", "tel:+15551234567", 101)));
+ }
+ std::filesystem::remove_all(home);
+}
+
+TEST(RemovedThreads, ACorruptFileHidesNothing) {
+ const auto home = scratch("corrupt");
+ {
+ ScopedHome scoped(home);
+ std::filesystem::create_directories(store_dir(home));
+ std::ofstream(store_dir(home) / "removed_threads.json.enc") << "not a sealed record";
+ EXPECT_EQ(load_removed_threads().size(), 0u);
+ }
+ std::filesystem::remove_all(home);
+}
+
+TEST(RemovedThreads, MalformedEntriesAreSkipped) {
+ const auto home = scratch("malformed");
+ {
+ ScopedHome scoped(home, Retention::Plaintext);
+ auto removed = deserialize_removed_threads(
+ R"({"removed": {"tel:5551234567": 100, "tel:5559999999": "100", "tel:5558888888": 1.5}})");
+ EXPECT_EQ(removed.size(), 1u);
+ EXPECT_TRUE(removed.hides(make("a", "tel:+15551234567", 100)));
+
+ EXPECT_EQ(deserialize_removed_threads(R"({"removed": []})").size(), 0u);
+ EXPECT_EQ(deserialize_removed_threads(R"([1, 2])").size(), 0u);
+ EXPECT_EQ(deserialize_removed_threads("{").size(), 0u);
+ }
+ std::filesystem::remove_all(home);
+}
+
+TEST(RemovedThreads, RetentionNoneWritesNothing) {
+ const auto home = scratch("none");
+ {
+ ScopedHome scoped(home, Retention::None);
+ RemovedThreads removed;
+ removed.remove("tel:+15551234567", 100);
+ EXPECT_FALSE(save_removed_threads(removed));
+ EXPECT_FALSE(std::filesystem::exists(store_dir(home) / "removed_threads.json"));
+ EXPECT_FALSE(std::filesystem::exists(store_dir(home) / "removed_threads.json.enc"));
+ }
+ std::filesystem::remove_all(home);
+}
+
+TEST(RemovedThreads, MigratesToTheOtherModeOnLoad) {
+ const auto home = scratch("migrate");
+ {
+ ScopedHome scoped(home, Retention::Plaintext);
+ RemovedThreads removed;
+ removed.remove("tel:+15551234567", 100);
+ ASSERT_TRUE(save_removed_threads(removed));
+ ASSERT_TRUE(std::filesystem::exists(store_dir(home) / "removed_threads.json"));
+ }
+ {
+ ScopedHome scoped(home);
+ auto loaded = load_removed_threads();
+ EXPECT_TRUE(loaded.hides(make("a", "tel:+15551234567", 100))) << "migration lost the entry";
+ EXPECT_FALSE(std::filesystem::exists(store_dir(home) / "removed_threads.json"));
+ EXPECT_TRUE(std::filesystem::exists(store_dir(home) / "removed_threads.json.enc"));
+ }
+ std::filesystem::remove_all(home);
+}