Linux + iPhone Continuity / iMessage / SMS
feat(gtk): ui improvements
Zack Bartel1fc9400e61eb
diff --git a/po/POTFILES.in b/po/POTFILES.inindex b1398ce..bae1e52 100644--- a/po/POTFILES.in+++ b/po/POTFILES.in@@ -11,6 +11,7 @@ src/daemon/notification.cppsrc/gtk/daemon_client.cppsrc/gtk/devices_view.cppsrc/gtk/main.cpp+src/gtk/message_format.cppsrc/gtk/messages_view.cppsrc/gtk/notifications_view.cppsrc/gtk/tray.cppdiff --git a/po/cs.po b/po/cs.poindex 6d3d1b0..845b6c8 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-08-25 20:55-0700\n"+"POT-Creation-Date: 2026-08-25 22:13-0700\n""PO-Revision-Date: 2026-08-23\n""Last-Translator: Tether project\n""Language-Team: Czech\n"@@ -103,7 +103,9 @@ msgstr "Spárovat iPhone přes Bluetooth."msgid """Ask the iPhone to authenticate directly instead of connecting first. Tether ""falls back to this on its own; use it to skip straight there."-msgstr "Požádat iPhone o přímé ověření místo prvotního připojení. Tether se k tomu uchýlí sám; použijte pro přímý přechod."+msgstr ""+"Požádat iPhone o přímé ověření místo prvotního připojení. Tether se k tomu "+"uchýlí sám; použijte pro přímý přechod."#: src/cli/main.cppmsgid "Remove a Bluetooth bond."@@ -1204,6 +1206,14 @@ msgstr "Otevřít na této kartě"msgid "Open the messages tab on this conversation"msgstr "Otevřít kartu zpráv na této konverzaci"+#: src/gtk/message_format.cpp+msgid "Yesterday"+msgstr ""++#: src/gtk/message_format.cpp+msgid "Today"+msgstr ""+#: src/gtk/messages_view.cppmsgid "Sending…"msgstr "Odesílání…"@@ -1236,6 +1246,11 @@ msgstr "Odesláno"msgid "New Message"msgstr "Nová zpráva"+#: src/gtk/messages_view.cpp+#, fuzzy+msgid "Search conversations"+msgstr "Vyberte konverzaci"+#: src/gtk/messages_view.cppmsgid "Select a conversation"msgstr "Vyberte konverzaci"@@ -1252,6 +1267,10 @@ msgstr "Telefonní číslo nebo e-mail"msgid "Send"msgstr "Odeslat"+#: src/gtk/messages_view.cpp+msgid "Retry"+msgstr ""+#: src/gtk/notifications_view.cppmsgid "New notification"msgstr "Nové oznámení"diff --git a/po/de.po b/po/de.poindex f59d5ce..de2ef41 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-08-25 20:55-0700\n"+"POT-Creation-Date: 2026-08-25 22:13-0700\n""PO-Revision-Date: 2026-08-22\n""Last-Translator: Tether project\n""Language-Team: German\n"@@ -103,7 +103,10 @@ msgstr "Ein iPhone per Bluetooth koppeln."msgid """Ask the iPhone to authenticate directly instead of connecting first. Tether ""falls back to this on its own; use it to skip straight there."-msgstr "Das iPhone direkt zur Authentifizierung auffordern, statt zuerst zu verbinden. Tether greift von selbst darauf zurück; hiermit springen Sie direkt dorthin."+msgstr ""+"Das iPhone direkt zur Authentifizierung auffordern, statt zuerst zu "+"verbinden. Tether greift von selbst darauf zurück; hiermit springen Sie "+"direkt dorthin."#: src/cli/main.cppmsgid "Remove a Bluetooth bond."@@ -1228,6 +1231,14 @@ msgstr "In diesem Tab öffnen"msgid "Open the messages tab on this conversation"msgstr "Den Nachrichten-Tab bei dieser Unterhaltung öffnen"+#: src/gtk/message_format.cpp+msgid "Yesterday"+msgstr ""++#: src/gtk/message_format.cpp+msgid "Today"+msgstr ""+#: src/gtk/messages_view.cppmsgid "Sending…"msgstr "Wird gesendet…"@@ -1263,6 +1274,11 @@ msgstr "Gesendet"msgid "New Message"msgstr "Neue Nachricht"+#: src/gtk/messages_view.cpp+#, fuzzy+msgid "Search conversations"+msgstr "Wählen Sie eine Unterhaltung"+#: src/gtk/messages_view.cppmsgid "Select a conversation"msgstr "Wählen Sie eine Unterhaltung"@@ -1279,6 +1295,10 @@ msgstr "Telefonnummer oder E-Mail"msgid "Send"msgstr "Senden"+#: src/gtk/messages_view.cpp+msgid "Retry"+msgstr ""+#: src/gtk/notifications_view.cppmsgid "New notification"msgstr "Neue Mitteilung"diff --git a/po/es.po b/po/es.poindex a398d00..0b0bd2f 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-08-25 20:55-0700\n"+"POT-Creation-Date: 2026-08-25 22:13-0700\n""PO-Revision-Date: 2026-08-22\n""Last-Translator: Tether project\n""Language-Team: Spanish\n"@@ -104,7 +104,9 @@ msgstr "Emparejar con un iPhone por Bluetooth."msgid """Ask the iPhone to authenticate directly instead of connecting first. Tether ""falls back to this on its own; use it to skip straight there."-msgstr "Pedir al iPhone que se autentique directamente en lugar de conectarse primero. Tether recurre a esto por su cuenta; úsalo para ir directamente ahí."+msgstr ""+"Pedir al iPhone que se autentique directamente en lugar de conectarse "+"primero. Tether recurre a esto por su cuenta; úsalo para ir directamente ahí."#: src/cli/main.cppmsgid "Remove a Bluetooth bond."@@ -1219,6 +1221,14 @@ msgstr "Abrir en esta pestaña"msgid "Open the messages tab on this conversation"msgstr "Abrir la pestaña de mensajes en esta conversación"+#: src/gtk/message_format.cpp+msgid "Yesterday"+msgstr ""++#: src/gtk/message_format.cpp+msgid "Today"+msgstr ""+#: src/gtk/messages_view.cppmsgid "Sending…"msgstr "Enviando…"@@ -1252,6 +1262,11 @@ msgstr "Enviado"msgid "New Message"msgstr "Mensaje nuevo"+#: src/gtk/messages_view.cpp+#, fuzzy+msgid "Search conversations"+msgstr "Seleccione una conversación"+#: src/gtk/messages_view.cppmsgid "Select a conversation"msgstr "Seleccione una conversación"@@ -1268,6 +1283,10 @@ msgstr "Número de teléfono o correo electrónico"msgid "Send"msgstr "Enviar"+#: src/gtk/messages_view.cpp+msgid "Retry"+msgstr ""+#: src/gtk/notifications_view.cppmsgid "New notification"msgstr "Notificación nueva"diff --git a/po/fr.po b/po/fr.poindex 1dd6833..56ff170 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-08-25 20:55-0700\n"+"POT-Creation-Date: 2026-08-25 22:13-0700\n""PO-Revision-Date: 2026-08-22\n""Last-Translator: Tether project\n""Language-Team: French\n"@@ -105,7 +105,10 @@ msgstr "Appairer un iPhone en Bluetooth."msgid """Ask the iPhone to authenticate directly instead of connecting first. Tether ""falls back to this on its own; use it to skip straight there."-msgstr "Demander à l'iPhone de s'authentifier directement au lieu de se connecter d'abord. Tether y recourt de lui-même ; utilisez cette option pour y aller directement."+msgstr ""+"Demander à l'iPhone de s'authentifier directement au lieu de se connecter "+"d'abord. Tether y recourt de lui-même ; utilisez cette option pour y aller "+"directement."#: src/cli/main.cppmsgid "Remove a Bluetooth bond."@@ -1222,6 +1225,14 @@ msgstr "Ouvrir sur cet onglet"msgid "Open the messages tab on this conversation"msgstr "Ouvrir l'onglet Messages sur cette conversation"+#: src/gtk/message_format.cpp+msgid "Yesterday"+msgstr ""++#: src/gtk/message_format.cpp+msgid "Today"+msgstr ""+#: src/gtk/messages_view.cppmsgid "Sending…"msgstr "Envoi…"@@ -1255,6 +1266,11 @@ msgstr "Envoyé"msgid "New Message"msgstr "Nouveau message"+#: src/gtk/messages_view.cpp+#, fuzzy+msgid "Search conversations"+msgstr "Sélectionnez une conversation"+#: src/gtk/messages_view.cppmsgid "Select a conversation"msgstr "Sélectionnez une conversation"@@ -1271,6 +1287,10 @@ msgstr "Numéro de téléphone ou e-mail"msgid "Send"msgstr "Envoyer"+#: src/gtk/messages_view.cpp+msgid "Retry"+msgstr ""+#: src/gtk/notifications_view.cppmsgid "New notification"msgstr "Nouvelle notification"diff --git a/po/it.po b/po/it.poindex 98a32ad..8aedb72 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-08-25 20:55-0700\n"+"POT-Creation-Date: 2026-08-25 22:13-0700\n""PO-Revision-Date: 2026-08-23\n""Last-Translator: Tether project\n""Language-Team: Italian\n"@@ -105,7 +105,9 @@ msgstr "Accoppia un iPhone tramite Bluetooth."msgid """Ask the iPhone to authenticate directly instead of connecting first. Tether ""falls back to this on its own; use it to skip straight there."-msgstr "Chiedere all'iPhone di autenticarsi direttamente invece di connettersi prima. Tether vi ricorre da solo; usalo per andare direttamente lì."+msgstr ""+"Chiedere all'iPhone di autenticarsi direttamente invece di connettersi "+"prima. Tether vi ricorre da solo; usalo per andare direttamente lì."#: src/cli/main.cppmsgid "Remove a Bluetooth bond."@@ -1215,6 +1217,14 @@ msgstr "Apri su questa scheda"msgid "Open the messages tab on this conversation"msgstr "Apri la scheda messaggi su questa conversazione"+#: src/gtk/message_format.cpp+msgid "Yesterday"+msgstr ""++#: src/gtk/message_format.cpp+msgid "Today"+msgstr ""+#: src/gtk/messages_view.cppmsgid "Sending…"msgstr "Invio…"@@ -1250,6 +1260,11 @@ msgstr "Inviato"msgid "New Message"msgstr "Nuovo messaggio"+#: src/gtk/messages_view.cpp+#, fuzzy+msgid "Search conversations"+msgstr "Seleziona una conversazione"+#: src/gtk/messages_view.cppmsgid "Select a conversation"msgstr "Seleziona una conversazione"@@ -1266,6 +1281,10 @@ msgstr "Numero di telefono o email"msgid "Send"msgstr "Invia"+#: src/gtk/messages_view.cpp+msgid "Retry"+msgstr ""+#: src/gtk/notifications_view.cppmsgid "New notification"msgstr "Nuova notifica"diff --git a/po/ja.po b/po/ja.poindex 5bfa57c..cc90d20 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-08-25 20:55-0700\n"+"POT-Creation-Date: 2026-08-25 22:13-0700\n""PO-Revision-Date: 2026-08-23\n""Last-Translator: Tether project\n""Language-Team: Japanese\n"@@ -103,7 +103,9 @@ msgstr "Bluetooth で iPhone とペアリングします。"msgid """Ask the iPhone to authenticate directly instead of connecting first. Tether ""falls back to this on its own; use it to skip straight there."-msgstr "最初に接続するのではなく、iPhone に直接認証を要求します。Tether は自動的にこれにフォールバックします。すぐにこの方法を使う場合に指定します。"+msgstr ""+"最初に接続するのではなく、iPhone に直接認証を要求します。Tether は自動的にこ"+"れにフォールバックします。すぐにこの方法を使う場合に指定します。"#: src/cli/main.cppmsgid "Remove a Bluetooth bond."@@ -1185,6 +1187,14 @@ msgstr "このタブで開く"msgid "Open the messages tab on this conversation"msgstr "この会話でメッセージタブを開く"+#: src/gtk/message_format.cpp+msgid "Yesterday"+msgstr ""++#: src/gtk/message_format.cpp+msgid "Today"+msgstr ""+#: src/gtk/messages_view.cppmsgid "Sending…"msgstr "送信中…"@@ -1219,6 +1229,11 @@ msgstr "送信済み"msgid "New Message"msgstr "新規メッセージ"+#: src/gtk/messages_view.cpp+#, fuzzy+msgid "Search conversations"+msgstr "会話を選択"+#: src/gtk/messages_view.cppmsgid "Select a conversation"msgstr "会話を選択"@@ -1235,6 +1250,10 @@ msgstr "電話番号またはメールアドレス"msgid "Send"msgstr "送信"+#: src/gtk/messages_view.cpp+msgid "Retry"+msgstr ""+#: src/gtk/notifications_view.cppmsgid "New notification"msgstr "新しい通知"diff --git a/po/ko.po b/po/ko.poindex 4fa6435..eec81fc 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-08-25 20:55-0700\n"+"POT-Creation-Date: 2026-08-25 22:13-0700\n""PO-Revision-Date: 2026-08-23\n""Last-Translator: Tether project\n""Language-Team: Korean\n"@@ -102,7 +102,9 @@ msgstr "Bluetooth로 iPhone과 페어링합니다."msgid """Ask the iPhone to authenticate directly instead of connecting first. Tether ""falls back to this on its own; use it to skip straight there."-msgstr "먼저 연결하는 대신 iPhone에 직접 인증을 요청합니다. Tether가 자동으로 이 방식으로 전환합니다. 바로 사용하려면 지정하세요."+msgstr ""+"먼저 연결하는 대신 iPhone에 직접 인증을 요청합니다. Tether가 자동으로 이 방식"+"으로 전환합니다. 바로 사용하려면 지정하세요."#: src/cli/main.cppmsgid "Remove a Bluetooth bond."@@ -1174,6 +1176,14 @@ msgstr "이 탭에서 열기"msgid "Open the messages tab on this conversation"msgstr "이 대화에서 메시지 탭 열기"+#: src/gtk/message_format.cpp+msgid "Yesterday"+msgstr ""++#: src/gtk/message_format.cpp+msgid "Today"+msgstr ""+#: src/gtk/messages_view.cppmsgid "Sending…"msgstr "보내는 중…"@@ -1206,6 +1216,11 @@ msgstr "보냄"msgid "New Message"msgstr "새 메시지"+#: src/gtk/messages_view.cpp+#, fuzzy+msgid "Search conversations"+msgstr "대화 선택"+#: src/gtk/messages_view.cppmsgid "Select a conversation"msgstr "대화 선택"@@ -1222,6 +1237,10 @@ msgstr "전화번호 또는 이메일"msgid "Send"msgstr "보내기"+#: src/gtk/messages_view.cpp+msgid "Retry"+msgstr ""+#: src/gtk/notifications_view.cppmsgid "New notification"msgstr "새 알림"diff --git a/po/nl.po b/po/nl.poindex e4cffed..3d53a9e 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-08-25 20:55-0700\n"+"POT-Creation-Date: 2026-08-25 22:13-0700\n""PO-Revision-Date: 2026-08-23\n""Last-Translator: Tether project\n""Language-Team: Dutch\n"@@ -103,7 +103,10 @@ msgstr "Een iPhone via Bluetooth koppelen."msgid """Ask the iPhone to authenticate directly instead of connecting first. Tether ""falls back to this on its own; use it to skip straight there."-msgstr "Vraag de iPhone om zich direct te authenticeren in plaats van eerst te verbinden. Tether valt hier vanzelf op terug; gebruik dit om er meteen naartoe te gaan."+msgstr ""+"Vraag de iPhone om zich direct te authenticeren in plaats van eerst te "+"verbinden. Tether valt hier vanzelf op terug; gebruik dit om er meteen "+"naartoe te gaan."#: src/cli/main.cppmsgid "Remove a Bluetooth bond."@@ -1211,6 +1214,14 @@ msgstr "Op dit tabblad openen"msgid "Open the messages tab on this conversation"msgstr "Het tabblad Berichten op dit gesprek openen"+#: src/gtk/message_format.cpp+msgid "Yesterday"+msgstr ""++#: src/gtk/message_format.cpp+msgid "Today"+msgstr ""+#: src/gtk/messages_view.cppmsgid "Sending…"msgstr "Versturen…"@@ -1243,6 +1254,11 @@ msgstr "Verstuurd"msgid "New Message"msgstr "Nieuw bericht"+#: src/gtk/messages_view.cpp+#, fuzzy+msgid "Search conversations"+msgstr "Selecteer een gesprek"+#: src/gtk/messages_view.cppmsgid "Select a conversation"msgstr "Selecteer een gesprek"@@ -1259,6 +1275,10 @@ msgstr "Telefoonnummer of e-mailadres"msgid "Send"msgstr "Versturen"+#: src/gtk/messages_view.cpp+msgid "Retry"+msgstr ""+#: src/gtk/notifications_view.cppmsgid "New notification"msgstr "Nieuwe melding"diff --git a/po/pl.po b/po/pl.poindex 311d59e..add3ab0 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-08-25 20:55-0700\n"+"POT-Creation-Date: 2026-08-25 22:13-0700\n""PO-Revision-Date: 2026-08-23\n""Last-Translator: Tether project\n""Language-Team: Polish\n"@@ -104,7 +104,9 @@ msgstr "Sparuj iPhone'a przez Bluetooth."msgid """Ask the iPhone to authenticate directly instead of connecting first. Tether ""falls back to this on its own; use it to skip straight there."-msgstr "Poproś iPhone'a o bezpośrednie uwierzytelnienie zamiast najpierw łączenia. Tether sam się do tego ucieka; użyj, aby przejść od razu."+msgstr ""+"Poproś iPhone'a o bezpośrednie uwierzytelnienie zamiast najpierw łączenia. "+"Tether sam się do tego ucieka; użyj, aby przejść od razu."#: src/cli/main.cppmsgid "Remove a Bluetooth bond."@@ -1216,6 +1218,14 @@ msgstr "Otwórz na tej karcie"msgid "Open the messages tab on this conversation"msgstr "Otwórz kartę wiadomości na tej rozmowie"+#: src/gtk/message_format.cpp+msgid "Yesterday"+msgstr ""++#: src/gtk/message_format.cpp+msgid "Today"+msgstr ""+#: src/gtk/messages_view.cppmsgid "Sending…"msgstr "Wysyłanie…"@@ -1250,6 +1260,11 @@ msgstr "Wysłano"msgid "New Message"msgstr "Nowa wiadomość"+#: src/gtk/messages_view.cpp+#, fuzzy+msgid "Search conversations"+msgstr "Wybierz rozmowę"+#: src/gtk/messages_view.cppmsgid "Select a conversation"msgstr "Wybierz rozmowę"@@ -1266,6 +1281,10 @@ msgstr "Numer telefonu lub e-mail"msgid "Send"msgstr "Wyślij"+#: src/gtk/messages_view.cpp+msgid "Retry"+msgstr ""+#: src/gtk/notifications_view.cppmsgid "New notification"msgstr "Nowe powiadomienie"diff --git a/po/pt_BR.po b/po/pt_BR.poindex bf77c41..bc2df4f 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-08-25 20:55-0700\n"+"POT-Creation-Date: 2026-08-25 22:13-0700\n""PO-Revision-Date: 2026-08-23\n""Last-Translator: Tether project\n""Language-Team: Brazilian Portuguese\n"@@ -104,7 +104,9 @@ msgstr "Parear com um iPhone por Bluetooth."msgid """Ask the iPhone to authenticate directly instead of connecting first. Tether ""falls back to this on its own; use it to skip straight there."-msgstr "Pedir ao iPhone que se autentique diretamente em vez de conectar primeiro. O Tether recorre a isso sozinho; use para ir direto a essa opção."+msgstr ""+"Pedir ao iPhone que se autentique diretamente em vez de conectar primeiro. O "+"Tether recorre a isso sozinho; use para ir direto a essa opção."#: src/cli/main.cppmsgid "Remove a Bluetooth bond."@@ -1208,6 +1210,14 @@ msgstr "Abrir nesta aba"msgid "Open the messages tab on this conversation"msgstr "Abrir a aba de mensagens nesta conversa"+#: src/gtk/message_format.cpp+msgid "Yesterday"+msgstr ""++#: src/gtk/message_format.cpp+msgid "Today"+msgstr ""+#: src/gtk/messages_view.cppmsgid "Sending…"msgstr "Enviando…"@@ -1241,6 +1251,11 @@ msgstr "Enviado"msgid "New Message"msgstr "Nova mensagem"+#: src/gtk/messages_view.cpp+#, fuzzy+msgid "Search conversations"+msgstr "Selecione uma conversa"+#: src/gtk/messages_view.cppmsgid "Select a conversation"msgstr "Selecione uma conversa"@@ -1257,6 +1272,10 @@ msgstr "Número de telefone ou e-mail"msgid "Send"msgstr "Enviar"+#: src/gtk/messages_view.cpp+msgid "Retry"+msgstr ""+#: src/gtk/notifications_view.cppmsgid "New notification"msgstr "Nova notificação"diff --git a/po/ru.po b/po/ru.poindex 65ebc72..f2e668c 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-08-25 20:55-0700\n"+"POT-Creation-Date: 2026-08-25 22:13-0700\n""PO-Revision-Date: 2026-08-23\n""Last-Translator: Tether project\n""Language-Team: Russian\n"@@ -104,7 +104,9 @@ msgstr "Создать пару с iPhone по Bluetooth."msgid """Ask the iPhone to authenticate directly instead of connecting first. Tether ""falls back to this on its own; use it to skip straight there."-msgstr "Запросить у iPhone прямую аутентификацию вместо предварительного подключения. Tether сам переходит к этому; используйте, чтобы перейти сразу."+msgstr ""+"Запросить у iPhone прямую аутентификацию вместо предварительного "+"подключения. Tether сам переходит к этому; используйте, чтобы перейти сразу."#: src/cli/main.cppmsgid "Remove a Bluetooth bond."@@ -1217,6 +1219,14 @@ msgstr "Открыть на этой вкладке"msgid "Open the messages tab on this conversation"msgstr "Открыть вкладку сообщений на этой переписке"+#: src/gtk/message_format.cpp+msgid "Yesterday"+msgstr ""++#: src/gtk/message_format.cpp+msgid "Today"+msgstr ""+#: src/gtk/messages_view.cppmsgid "Sending…"msgstr "Отправка…"@@ -1249,6 +1259,11 @@ msgstr "Отправлено"msgid "New Message"msgstr "Новое сообщение"+#: src/gtk/messages_view.cpp+#, fuzzy+msgid "Search conversations"+msgstr "Выберите переписку"+#: src/gtk/messages_view.cppmsgid "Select a conversation"msgstr "Выберите переписку"@@ -1265,6 +1280,10 @@ msgstr "Номер телефона или эл. почта"msgid "Send"msgstr "Отправить"+#: src/gtk/messages_view.cpp+msgid "Retry"+msgstr ""+#: src/gtk/notifications_view.cppmsgid "New notification"msgstr "Новое уведомление"diff --git a/po/sv.po b/po/sv.poindex 02a12cd..354e729 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-08-25 20:55-0700\n"+"POT-Creation-Date: 2026-08-25 22:13-0700\n""PO-Revision-Date: 2026-08-23\n""Last-Translator: Tether project\n""Language-Team: Swedish\n"@@ -104,7 +104,9 @@ msgstr "Parkoppla en iPhone via Bluetooth."msgid """Ask the iPhone to authenticate directly instead of connecting first. Tether ""falls back to this on its own; use it to skip straight there."-msgstr "Be iPhone autentisera direkt i stället för att ansluta först. Tether faller tillbaka på detta av sig självt; använd för att gå direkt dit."+msgstr ""+"Be iPhone autentisera direkt i stället för att ansluta först. Tether faller "+"tillbaka på detta av sig självt; använd för att gå direkt dit."#: src/cli/main.cppmsgid "Remove a Bluetooth bond."@@ -1199,6 +1201,14 @@ msgstr "Öppna på den här fliken"msgid "Open the messages tab on this conversation"msgstr "Öppna meddelandefliken på den här konversationen"+#: src/gtk/message_format.cpp+msgid "Yesterday"+msgstr ""++#: src/gtk/message_format.cpp+msgid "Today"+msgstr ""+#: src/gtk/messages_view.cppmsgid "Sending…"msgstr "Skickar…"@@ -1231,6 +1241,11 @@ msgstr "Skickat"msgid "New Message"msgstr "Nytt meddelande"+#: src/gtk/messages_view.cpp+#, fuzzy+msgid "Search conversations"+msgstr "Välj en konversation"+#: src/gtk/messages_view.cppmsgid "Select a conversation"msgstr "Välj en konversation"@@ -1247,6 +1262,10 @@ msgstr "Telefonnummer eller e-post"msgid "Send"msgstr "Skicka"+#: src/gtk/messages_view.cpp+msgid "Retry"+msgstr ""+#: src/gtk/notifications_view.cppmsgid "New notification"msgstr "Ny avisering"diff --git a/po/tether.pot b/po/tether.potindex 2edbdb4..6790bb6 100644--- a/po/tether.pot+++ b/po/tether.pot@@ -8,7 +8,7 @@ msgid ""msgstr """Project-Id-Version: tether 0.2.12\n""Report-Msgid-Bugs-To: [email protected]\n"-"POT-Creation-Date: 2026-08-25 20:55-0700\n"+"POT-Creation-Date: 2026-08-25 22:13-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"@@ -1096,6 +1096,14 @@ msgstr ""msgid "Open the messages tab on this conversation"msgstr ""+#: src/gtk/message_format.cpp+msgid "Yesterday"+msgstr ""++#: src/gtk/message_format.cpp+msgid "Today"+msgstr ""+#: src/gtk/messages_view.cppmsgid "Sending…"msgstr ""@@ -1128,6 +1136,10 @@ msgstr ""msgid "New Message"msgstr ""+#: src/gtk/messages_view.cpp+msgid "Search conversations"+msgstr ""+#: src/gtk/messages_view.cppmsgid "Select a conversation"msgstr ""@@ -1144,6 +1156,10 @@ msgstr ""msgid "Send"msgstr ""+#: src/gtk/messages_view.cpp+msgid "Retry"+msgstr ""+#: src/gtk/notifications_view.cppmsgid "New notification"msgstr ""diff --git a/po/tr.po b/po/tr.poindex 9ca99bb..29722c7 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-08-25 20:55-0700\n"+"POT-Creation-Date: 2026-08-25 22:13-0700\n""PO-Revision-Date: 2026-08-23\n""Last-Translator: Tether project\n""Language-Team: Turkish\n"@@ -102,7 +102,9 @@ msgstr "Bluetooth üzerinden bir iPhone ile eşleş."msgid """Ask the iPhone to authenticate directly instead of connecting first. Tether ""falls back to this on its own; use it to skip straight there."-msgstr "Önce bağlanmak yerine iPhone'dan doğrudan kimlik doğrulaması iste. Tether buna kendiliğinden geri döner; doğrudan geçmek için kullanın."+msgstr ""+"Önce bağlanmak yerine iPhone'dan doğrudan kimlik doğrulaması iste. Tether "+"buna kendiliğinden geri döner; doğrudan geçmek için kullanın."#: src/cli/main.cppmsgid "Remove a Bluetooth bond."@@ -1196,6 +1198,14 @@ msgstr "Bu sekmede aç"msgid "Open the messages tab on this conversation"msgstr "Mesajlar sekmesini bu konuşmada aç"+#: src/gtk/message_format.cpp+msgid "Yesterday"+msgstr ""++#: src/gtk/message_format.cpp+msgid "Today"+msgstr ""+#: src/gtk/messages_view.cppmsgid "Sending…"msgstr "Gönderiliyor…"@@ -1228,6 +1238,11 @@ msgstr "Gönderildi"msgid "New Message"msgstr "Yeni mesaj"+#: src/gtk/messages_view.cpp+#, fuzzy+msgid "Search conversations"+msgstr "Bir konuşma seçin"+#: src/gtk/messages_view.cppmsgid "Select a conversation"msgstr "Bir konuşma seçin"@@ -1244,6 +1259,10 @@ msgstr "Telefon numarası ya da e-posta"msgid "Send"msgstr "Gönder"+#: src/gtk/messages_view.cpp+msgid "Retry"+msgstr ""+#: src/gtk/notifications_view.cppmsgid "New notification"msgstr "Yeni bildirim"diff --git a/po/uk.po b/po/uk.poindex 46457fe..7be8a7e 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-08-25 20:55-0700\n"+"POT-Creation-Date: 2026-08-25 22:13-0700\n""PO-Revision-Date: 2026-08-23\n""Last-Translator: Tether project\n""Language-Team: Ukrainian\n"@@ -105,7 +105,9 @@ msgstr "Створити пару з iPhone через Bluetooth."msgid """Ask the iPhone to authenticate directly instead of connecting first. Tether ""falls back to this on its own; use it to skip straight there."-msgstr "Запитати в iPhone пряму автентифікацію замість спершу під'єднання. Tether сам переходить до цього; використовуйте, щоб перейти одразу."+msgstr ""+"Запитати в iPhone пряму автентифікацію замість спершу під'єднання. Tether "+"сам переходить до цього; використовуйте, щоб перейти одразу."#: src/cli/main.cppmsgid "Remove a Bluetooth bond."@@ -1213,6 +1215,14 @@ msgstr "Відкрити на цій вкладці"msgid "Open the messages tab on this conversation"msgstr "Відкрити вкладку повідомлень на цій розмові"+#: src/gtk/message_format.cpp+msgid "Yesterday"+msgstr ""++#: src/gtk/message_format.cpp+msgid "Today"+msgstr ""+#: src/gtk/messages_view.cppmsgid "Sending…"msgstr "Надсилання…"@@ -1246,6 +1256,11 @@ msgstr "Надіслано"msgid "New Message"msgstr "Нове повідомлення"+#: src/gtk/messages_view.cpp+#, fuzzy+msgid "Search conversations"+msgstr "Виберіть розмову"+#: src/gtk/messages_view.cppmsgid "Select a conversation"msgstr "Виберіть розмову"@@ -1262,6 +1277,10 @@ msgstr "Номер телефону або ел. пошта"msgid "Send"msgstr "Надіслати"+#: src/gtk/messages_view.cpp+msgid "Retry"+msgstr ""+#: src/gtk/notifications_view.cppmsgid "New notification"msgstr "Нове сповіщення"diff --git a/po/zh_CN.po b/po/zh_CN.poindex 3ea8549..42647df 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-08-25 20:55-0700\n"+"POT-Creation-Date: 2026-08-25 22:13-0700\n""PO-Revision-Date: 2026-08-23\n""Last-Translator: Tether project\n""Language-Team: Simplified Chinese\n"@@ -102,7 +102,9 @@ msgstr "通过蓝牙与 iPhone 配对。"msgid """Ask the iPhone to authenticate directly instead of connecting first. Tether ""falls back to this on its own; use it to skip straight there."-msgstr "请求 iPhone 直接进行身份验证,而不是先建立连接。Tether 会自动回退到此方式;使用该选项可直接跳转到它。"+msgstr ""+"请求 iPhone 直接进行身份验证,而不是先建立连接。Tether 会自动回退到此方式;使"+"用该选项可直接跳转到它。"#: src/cli/main.cppmsgid "Remove a Bluetooth bond."@@ -1150,6 +1152,14 @@ msgstr "在此标签页中打开"msgid "Open the messages tab on this conversation"msgstr "在此会话中打开信息标签页"+#: src/gtk/message_format.cpp+msgid "Yesterday"+msgstr ""++#: src/gtk/message_format.cpp+msgid "Today"+msgstr ""+#: src/gtk/messages_view.cppmsgid "Sending…"msgstr "正在发送……"@@ -1182,6 +1192,11 @@ msgstr "已发送"msgid "New Message"msgstr "新信息"+#: src/gtk/messages_view.cpp+#, fuzzy+msgid "Search conversations"+msgstr "选择一个会话"+#: src/gtk/messages_view.cppmsgid "Select a conversation"msgstr "选择一个会话"@@ -1198,6 +1213,10 @@ msgstr "电话号码或电子邮件"msgid "Send"msgstr "发送"+#: src/gtk/messages_view.cpp+msgid "Retry"+msgstr ""+#: src/gtk/notifications_view.cppmsgid "New notification"msgstr "新通知"diff --git a/src/gtk/CMakeLists.txt b/src/gtk/CMakeLists.txtindex cb72a90..272784c 100644--- a/src/gtk/CMakeLists.txt+++ b/src/gtk/CMakeLists.txt@@ -4,6 +4,8 @@ pkg_check_modules(GTK3 REQUIRED gtk+-3.0)add_executable(tether-gtkmain.cppui_util.cpp+ prefs.cpp+ message_format.cppdaemon_client.cppdevices_view.cppmessages_view.cppdiff --git a/src/gtk/daemon_client.cpp b/src/gtk/daemon_client.cppindex e969bae..aedf1fc 100644--- a/src/gtk/daemon_client.cpp+++ b/src/gtk/daemon_client.cpp@@ -9,6 +9,7 @@#include <cstring>#include <filesystem>#include <gtk/gtk.h>+#include <string_view>#include <sys/socket.h>#include <sys/un.h>#include <sys/wait.h>@@ -87,13 +88,17 @@ namespace tether::ui {return FALSE;}if (line && length > 0) {- try {- if (g_on_event)- g_on_event(nlohmann::json::parse(std::string(line, length)));- } catch (const std::exception& e) {- // Silence here hides a dropped update as a view that- // simply did not refresh.- debug::log(WARN, "daemon: discarding an unreadable event ({})", e.what());+ std::string_view payload(line, length);+ while (!payload.empty() && (payload.back() == '\n' || payload.back() == '\r'))+ payload.remove_suffix(1);++ if (!payload.empty() && payload != "OK") {+ try {+ if (g_on_event)+ g_on_event(nlohmann::json::parse(payload));+ } catch (const std::exception& e) {+ debug::log(WARN, "daemon: discarding an unreadable event ({})", e.what());+ }}}if (line)diff --git a/src/gtk/main.cpp b/src/gtk/main.cppindex 1385f66..4c29648 100644--- a/src/gtk/main.cpp+++ b/src/gtk/main.cpp@@ -2,9 +2,12 @@#include "devices_view.hpp"#include "messages_view.hpp"#include "notifications_view.hpp"+#include "prefs.hpp"#include "tray.hpp"#include "ui_util.hpp"+#include <csignal>+#include <glib-unix.h>#include <gtk/gtk.h>#include <string>#include <tether/crypto.hpp>@@ -80,14 +83,90 @@ namespace {return button;}+ void store_geometry() {+ GtkWidget* window = main_window();+ if (!window)+ return;+ const gboolean maximized = gtk_window_is_maximized(GTK_WINDOW(window));+ prefs()["window_maximized"] = maximized == TRUE;+ if (!maximized) {+ int width = 0;+ int height = 0;+ gtk_window_get_size(GTK_WINDOW(window), &width, &height);+ if (width > 0 && height > 0) {+ prefs()["window_width"] = width;+ prefs()["window_height"] = height;+ }+ }+ messages_view_store_prefs();+ }++ void save_session_prefs() {+ store_geometry();+ prefs_save();+ }+// Hiding leaves the window alive but unmapped, and a second launch re-activates this instancegboolean on_window_delete(GtkWidget* window, GdkEvent*, gpointer) {+ save_session_prefs();if (!tray_close_to_tray())return FALSE;gtk_widget_hide(window);return TRUE;}+ void show_view(const char* name) {+ if (!g_stack)+ return;+ gtk_stack_set_visible_child_name(GTK_STACK(g_stack), name);+ }++ void install_actions(GtkApplication* app, GtkWidget* window) {+ struct Accel {+ const char* name;+ const char* key;+ void (*run)();+ };+ static const Accel accels[] = {+ {"new-message",+ "<Control>n",+ [] {+ show_view("messages");+ messages_view_new_message();+ }},+ {"search",+ "<Control>f",+ [] {+ show_view("messages");+ messages_view_focus_search();+ }},+ {"devices", "<Control>1", [] { show_view("devices"); }},+ {"messages", "<Control>2", [] { show_view("messages"); }},+ {"notifications", "<Control>3", [] { show_view("notifications"); }},+ {"close",+ "<Control>w",+ [] {+ if (GtkWidget* w = main_window())+ gtk_window_close(GTK_WINDOW(w));+ }},+ };++ for (const Accel& accel : accels) {+ GSimpleAction* action = g_simple_action_new(accel.name, nullptr);+ g_signal_connect(+ action,+ "activate",+ G_CALLBACK(+[](GSimpleAction*, GVariant*, gpointer data) { reinterpret_cast<void (*)()>(data)(); }),+ reinterpret_cast<gpointer>(accel.run));+ g_action_map_add_action(G_ACTION_MAP(window), G_ACTION(action));+ g_object_unref(action);++ const std::string detailed = std::string("win.") + accel.name;+ const char* keys[] = {accel.key, nullptr};+ gtk_application_set_accels_for_action(app, detailed.c_str(), keys);+ }+ }+void activate(GtkApplication* app, gpointer) {if (GtkWidget* existing = main_window()) {gtk_window_present(GTK_WINDOW(existing));@@ -99,9 +178,15 @@ namespace {GtkWidget* window = gtk_application_window_new(app);gtk_window_set_title(GTK_WINDOW(window), _("Tether"));- gtk_window_set_default_size(GTK_WINDOW(window), 820, 560);+ gtk_window_set_default_size(+ GTK_WINDOW(window), prefs().value("window_width", 820), prefs().value("window_height", 560));+ if (prefs().value("window_maximized", false))+ gtk_window_maximize(GTK_WINDOW(window));set_main_window(window);g_signal_connect(window, "delete-event", G_CALLBACK(on_window_delete), nullptr);+ g_signal_connect(+ window, "destroy", G_CALLBACK(+[](GtkWidget*, gpointer) { set_main_window(nullptr); }), nullptr);+ install_actions(app, window);tray_init();GtkWidget* header_bar = gtk_header_bar_new();@@ -207,6 +292,18 @@ int main(int argc, char** argv) {}),nullptr);g_signal_connect(app, "activate", G_CALLBACK(activate), nullptr);++ g_signal_connect(app, "shutdown", G_CALLBACK(+[](GApplication*, gpointer) { save_session_prefs(); }), nullptr);++ for (int signal_number : {SIGTERM, SIGINT, SIGHUP}) {+ g_unix_signal_add(+ signal_number,+ +[](gpointer data) -> gboolean {+ g_application_quit(G_APPLICATION(data));+ return G_SOURCE_REMOVE;+ },+ app);+ }int status = g_application_run(G_APPLICATION(app), argc, argv);tether::ui::daemon_client_stop();g_object_unref(app);diff --git a/src/gtk/message_format.cpp b/src/gtk/message_format.cppnew file mode 100644index 0000000..135be0d--- /dev/null+++ b/src/gtk/message_format.cpp@@ -0,0 +1,135 @@+#include "message_format.hpp"++#include <ctime>+#include <glib.h>+#include <regex>+#include <tether/i18n.hpp>++namespace tether::ui {++ namespace {++ std::string escape(const std::string& text) {+ gchar* escaped = g_markup_escape_text(text.c_str(), -1);+ std::string out = escaped ? escaped : "";+ g_free(escaped);+ return out;+ }++ size_t trim_trailing(const std::string& url) {+ size_t end = url.size();+ while (end > 0) {+ const char c = url[end - 1];+ if (c == '.' || c == ',' || c == '!' || c == '?' || c == ';' || c == ':')+ --end;+ else if (c == ')' && url.find('(', 0) >= end)+ --end;+ else+ break;+ }+ return end;+ }++ std::string localized_day(const std::tm& tm, const char* format) {+ char buffer[64];+ std::strftime(buffer, sizeof(buffer), format, &tm);+ return buffer;+ }++ // Whole days apart in local time, so "yesterday" means the calendar day+ // before rather than 24 hours ago.+ int days_between(const std::tm& then, const std::tm& now) {+ std::tm a = then;+ std::tm b = now;+ a.tm_hour = a.tm_min = a.tm_sec = 0;+ b.tm_hour = b.tm_min = b.tm_sec = 0;+ a.tm_isdst = b.tm_isdst = -1;+ const std::time_t start = std::mktime(&a);+ const std::time_t end = std::mktime(&b);+ if (start == static_cast<std::time_t>(-1) || end == static_cast<std::time_t>(-1))+ return 0;+ return static_cast<int>((end - start) / 86400);+ }++ } // namespace++ std::string linkify_markup(const std::string& body) {+ static const std::regex pattern(R"((https?://|www\.)[^\s<>"']+)", std::regex::icase);++ std::string out;+ auto begin = std::sregex_iterator(body.begin(), body.end(), pattern);+ auto end = std::sregex_iterator();+ size_t cursor = 0;++ for (auto it = begin; it != end; ++it) {+ const std::smatch& match = *it;+ std::string url = match.str();+ const size_t keep = trim_trailing(url);+ if (keep == 0)+ continue;+ url.resize(keep);++ const size_t at = static_cast<size_t>(match.position());+ out += escape(body.substr(cursor, at - cursor));+ // bare www. host is not a URI+ const std::string href = (url.compare(0, 4, "www.") == 0) ? "http://" + url : url;+ out += "<a href=\"" + escape(href) + "\">" + escape(url) + "</a>";+ cursor = at + keep;+ }+ out += escape(body.substr(cursor));+ return out;+ }++ std::string format_thread_time(int64_t epoch, int64_t now) {+ if (epoch <= 0)+ return "";++ std::time_t when = static_cast<std::time_t>(epoch);+ std::time_t today = static_cast<std::time_t>(now);+ std::tm when_tm{};+ std::tm today_tm{};+ localtime_r(&when, &when_tm);+ localtime_r(&today, &today_tm);++ const int days = days_between(when_tm, today_tm);+ if (days <= 0)+ return localized_day(when_tm, "%H:%M");+ if (days == 1)+ return _("Yesterday");+ if (days < 7)+ return localized_day(when_tm, "%a");+ return localized_day(when_tm, "%b %-d");+ }++ std::string format_day_heading(int64_t epoch, int64_t now) {+ if (epoch <= 0)+ return "";++ std::time_t when = static_cast<std::time_t>(epoch);+ std::time_t today = static_cast<std::time_t>(now);+ std::tm when_tm{};+ std::tm today_tm{};+ localtime_r(&when, &when_tm);+ localtime_r(&today, &today_tm);++ const int days = days_between(when_tm, today_tm);+ if (days <= 0)+ return _("Today");+ if (days == 1)+ return _("Yesterday");+ if (days < 7)+ return localized_day(when_tm, "%A");+ return localized_day(when_tm, "%A, %b %-d");+ }++ bool same_local_day(int64_t a, int64_t b) {+ std::time_t first = static_cast<std::time_t>(a);+ std::time_t second = static_cast<std::time_t>(b);+ std::tm first_tm{};+ std::tm second_tm{};+ localtime_r(&first, &first_tm);+ localtime_r(&second, &second_tm);+ return first_tm.tm_year == second_tm.tm_year && first_tm.tm_yday == second_tm.tm_yday;+ }++} // namespace tether::uidiff --git a/src/gtk/message_format.hpp b/src/gtk/message_format.hppnew file mode 100644index 0000000..7c2e2b0--- /dev/null+++ b/src/gtk/message_format.hpp@@ -0,0 +1,21 @@+#pragma once++#include <cstdint>+#include <string>++namespace tether::ui {++ // Pango markup for a message body, with any URLs turned into links. The+ // whole body is markup-escaped first, so the result is safe.+ std::string linkify_markup(const std::string& body);++ // How old a conversation's last message is.+ std::string format_thread_time(int64_t epoch, int64_t now);++ // Heading for a day's worth of messages: "Today", "Yesterday", or the date.+ std::string format_day_heading(int64_t epoch, int64_t now);++ // Whether two instants fall on the same local calendar day.+ bool same_local_day(int64_t a, int64_t b);++} // namespace tether::uidiff --git a/src/gtk/messages_view.cpp b/src/gtk/messages_view.cppindex d8973bd..70ff23e 100644--- a/src/gtk/messages_view.cpp+++ b/src/gtk/messages_view.cpp@@ -2,9 +2,12 @@#include <tether/i18n.hpp>#include "daemon_client.hpp"+#include "message_format.hpp"+#include "prefs.hpp"#include "tray.hpp"#include "ui_util.hpp"+#include <algorithm>#include <cstring>#include <ctime>#include <gdk/gdkkeysyms.h>@@ -30,6 +33,11 @@ namespace tether::ui {GtkWidget* composer = nullptr;GtkWidget* send_button = nullptr;GtkWidget* placeholder_stack = nullptr;+ GtkWidget* paned = nullptr;+ GtkWidget* thread_scroll = nullptr;+ GtkWidget* search_entry = nullptr;+ GtkWidget* send_error = nullptr;+ GtkWidget* send_error_label = nullptr;std::string selected_thread;std::string selected_name;@@ -47,9 +55,34 @@ namespace tether::ui {// Handles already asked about, so reopening a conversation does not// re-issue a blocking OBEX write per message every time.std::set<std::string> marked_read;- // Scrolling to the newest message has to wait for GTK to lay the new- // rows out, so it is deferred rather than done inline.+ // Scrolling has to wait for GTK to lay the new rows out, so it is+ // deferred rather than done inline. `scroll_pin` says whether that+ // means the newest message or the place the user was reading.guint scroll_idle_id = 0;+ bool scroll_pin = true;+ double scroll_from_bottom = 0.0;+ // The user's own message belongs on screen no matter where they had+ // scrolled to when they sent it.+ bool pin_next = false;++ // Composer text per conversation+ std::map<std::string, std::string> drafts;++ // Handles of the message rows currently on screen+ std::vector<std::string> rendered;++ // The last bubble rendered+ int64_t rendered_last_stamp = 0;+ bool rendered_last_outgoing = false;++ guint focus_idle_id = 0;++ // Sidebar scroll offset to put back after the rebuild that dropped it.+ double thread_scroll_value = -1.0;+ guint thread_scroll_idle_id = 0;++ // Folded needle from the search box; empty shows everything.+ std::string search_needle;// Whether the daemon says the selected thread can be replied to, and// why not when it cannot.bool selected_repliable = false;@@ -69,12 +102,17 @@ namespace tether::ui {MessagesState g_messages;constexpr int SEND_TIMEOUT_SECONDS = 60;+ constexpr int64_t GROUP_WINDOW_SECONDS = 300;+ constexpr double AT_BOTTOM_SLACK = 48.0;enum ComposeColumn { COMPOSE_COL_DISPLAY, COMPOSE_COL_ADDRESS, COMPOSE_COL_SEARCH, COMPOSE_COL_COUNT };void update_composer_sensitivity();void apply_row_selection(GtkWidget* row);void clear_selection();+ void switch_thread(const std::string& key);+ void hide_send_error();+ std::string fold(const std::string& text);// `offer_permissions` shows the button that re-solicits the iPhone's// Bluetooth toggles, which only helps when that is the actual problem.void set_banner(const std::string& text, bool offer_permissions = false);@@ -82,6 +120,54 @@ namespace tether::ui {void leave_compose();void on_recipient_changed(GtkEditable*, gpointer);+ gboolean focus_composer_idle(gpointer) {+ g_messages.focus_idle_id = 0;+ if (g_messages.composer && gtk_widget_is_sensitive(g_messages.composer))+ gtk_widget_grab_focus(g_messages.composer);+ return G_SOURCE_REMOVE;+ }++ void focus_composer_soon() {+ if (g_messages.focus_idle_id == 0)+ g_messages.focus_idle_id = g_idle_add(focus_composer_idle, nullptr);+ }++ void set_composer_text(const std::string& text) {+ if (!g_messages.composer)+ return;+ GtkTextBuffer* buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(g_messages.composer));+ gtk_text_buffer_set_text(buffer, text.c_str(), -1);+ GtkTextIter end;+ gtk_text_buffer_get_end_iter(buffer, &end);+ gtk_text_buffer_place_cursor(buffer, &end);+ }++ void stash_draft() {+ if (g_messages.selected_thread.empty() || !g_messages.composer)+ return;+ const std::string text = composer_text();+ if (text.empty())+ g_messages.drafts.erase(g_messages.selected_thread);+ else+ g_messages.drafts[g_messages.selected_thread] = text;+ }++ void switch_thread(const std::string& key) {+ if (key == g_messages.selected_thread)+ return;+ stash_draft();+ g_messages.selected_thread = key;+ g_messages.rendered.clear();+ g_messages.rendered_last_stamp = 0;+ g_messages.rendered_last_outgoing = false;+ if (g_messages.conversation)+ clear_list_box(g_messages.conversation);+ hide_send_error();++ const auto draft = g_messages.drafts.find(key);+ set_composer_text(draft == g_messages.drafts.end() ? "" : draft->second);+ }+std::string format_timestamp(int64_t epoch) {if (epoch <= 0)return "";@@ -89,16 +175,8 @@ namespace tether::ui {std::tm tm{};localtime_r(&t, &tm);- std::time_t now = std::time(nullptr);- std::tm now_tm{};- localtime_r(&now, &now_tm);-char buffer[64];- // Same day gets a time, anything older gets a date: a wall of- // identical timestamps is harder to scan than a mixed list.- const char* format =- (tm.tm_year == now_tm.tm_year && tm.tm_yday == now_tm.tm_yday) ? "%H:%M" : "%b %-d, %H:%M";- std::strftime(buffer, sizeof(buffer), format, &tm);+ std::strftime(buffer, sizeof(buffer), "%H:%M", &tm);return buffer;}@@ -123,10 +201,13 @@ namespace tether::ui {const std::string name = thread.value("name", address);const std::string preview = thread.value("preview", "");const int unread = thread.value("unread", 0);+ const int64_t stamp = thread.value("timestamp", static_cast<int64_t>(0));GtkWidget* row = gtk_list_box_row_new();g_object_set_data_full(G_OBJECT(row), "thread", g_strdup(key.c_str()), g_free);g_object_set_data_full(G_OBJECT(row), "name", g_strdup(name.c_str()), g_free);+ g_object_set_data_full(+ G_OBJECT(row), "search", g_strdup(fold(name + " " + address + " " + preview).c_str()), g_free);// The daemon owns the decision about whether a group can be replied// to; the UI must not re-derive it from the key shape.g_object_set_data(G_OBJECT(row), "repliable", GINT_TO_POINTER(thread.value("repliable", true) ? 1 : 0));@@ -152,34 +233,86 @@ namespace tether::ui {gtk_style_context_add_class(gtk_widget_get_style_context(subtitle), "muted");gtk_box_pack_start(GTK_BOX(labels), subtitle, FALSE, FALSE, 0);+ if (unread > 0)+ gtk_style_context_add_class(gtk_widget_get_style_context(subtitle), "tether-thread-unread");+gtk_box_pack_start(GTK_BOX(box), labels, TRUE, TRUE, 0);+ GtkWidget* meta = gtk_box_new(GTK_ORIENTATION_VERTICAL, 4);+ gtk_widget_set_valign(meta, GTK_ALIGN_START);++ const std::string when = format_thread_time(stamp, std::time(nullptr));+ if (!when.empty()) {+ GtkWidget* time_label = gtk_label_new(when.c_str());+ gtk_label_set_xalign(GTK_LABEL(time_label), 1.0);+ gtk_style_context_add_class(gtk_widget_get_style_context(time_label), "muted");+ gtk_box_pack_start(GTK_BOX(meta), time_label, FALSE, FALSE, 0);+ }+if (unread > 0) {GtkWidget* badge = gtk_label_new(nullptr);gtk_label_set_markup(GTK_LABEL(badge), ("<b>" + std::to_string(unread) + "</b>").c_str());- gtk_widget_set_valign(badge, GTK_ALIGN_CENTER);+ gtk_widget_set_halign(badge, GTK_ALIGN_END);gtk_style_context_add_class(gtk_widget_get_style_context(badge), "tether-badge");- gtk_box_pack_start(GTK_BOX(box), badge, FALSE, FALSE, 0);+ gtk_box_pack_start(GTK_BOX(meta), badge, FALSE, FALSE, 0);}+ gtk_box_pack_start(GTK_BOX(box), meta, FALSE, FALSE, 0);+gtk_container_add(GTK_CONTAINER(row), box);return row;}- GtkWidget* build_message_row(const nlohmann::json& message) {+ gboolean on_bubble_link(GtkWidget* label, gchar* uri, gpointer) {+ GtkWidget* toplevel = gtk_widget_get_toplevel(label);+ gtk_show_uri_on_window(+ GTK_IS_WINDOW(toplevel) ? GTK_WINDOW(toplevel) : nullptr, uri, GDK_CURRENT_TIME, nullptr);+ return TRUE;+ }++ GtkWidget* build_day_row(int64_t stamp) {+ GtkWidget* row = gtk_list_box_row_new();+ gtk_list_box_row_set_selectable(GTK_LIST_BOX_ROW(row), FALSE);+ gtk_list_box_row_set_activatable(GTK_LIST_BOX_ROW(row), FALSE);++ GtkWidget* label = gtk_label_new(format_day_heading(stamp, std::time(nullptr)).c_str());+ gtk_widget_set_halign(label, GTK_ALIGN_CENTER);+ gtk_widget_set_margin_top(label, 12);+ gtk_widget_set_margin_bottom(label, 4);+ gtk_style_context_add_class(gtk_widget_get_style_context(label), "muted");++ gtk_container_add(GTK_CONTAINER(row), label);+ return row;+ }++ GtkWidget* build_message_row(const nlohmann::json& message, bool show_stamp) {const bool outgoing = message.value("outgoing", false);const std::string body = message.value("body", "");- const std::string stamp = format_timestamp(message.value("timestamp", static_cast<int64_t>(0)));+ const std::string stamp =+ show_stamp ? format_timestamp(message.value("timestamp", static_cast<int64_t>(0))) : "";GtkWidget* row = gtk_list_box_row_new();gtk_list_box_row_set_selectable(GTK_LIST_BOX_ROW(row), FALSE);gtk_list_box_row_set_activatable(GTK_LIST_BOX_ROW(row), FALSE);GtkWidget* box = gtk_box_new(GTK_ORIENTATION_VERTICAL, 2);- gtk_container_set_border_width(GTK_CONTAINER(box), 8);+ gtk_widget_set_margin_start(box, 8);+ gtk_widget_set_margin_end(box, 8);+ gtk_widget_set_margin_top(box, show_stamp ? 8 : 1);+ gtk_widget_set_margin_bottom(box, 1);gtk_widget_set_halign(box, outgoing ? GTK_ALIGN_END : GTK_ALIGN_START);- GtkWidget* bubble = gtk_label_new(body.c_str());+ if (!stamp.empty()) {+ GtkWidget* time_label = gtk_label_new(stamp.c_str());+ gtk_label_set_xalign(GTK_LABEL(time_label), outgoing ? 1.0 : 0.0);+ gtk_style_context_add_class(gtk_widget_get_style_context(time_label), "muted");+ gtk_box_pack_start(GTK_BOX(box), time_label, FALSE, FALSE, 0);+ }++ GtkWidget* bubble = gtk_label_new(nullptr);+ gtk_label_set_markup(GTK_LABEL(bubble), linkify_markup(body).c_str());+ gtk_label_set_track_visited_links(GTK_LABEL(bubble), FALSE);+ g_signal_connect(bubble, "activate-link", G_CALLBACK(on_bubble_link), nullptr);gtk_label_set_line_wrap(GTK_LABEL(bubble), TRUE);gtk_label_set_line_wrap_mode(GTK_LABEL(bubble), PANGO_WRAP_WORD_CHAR);gtk_label_set_max_width_chars(GTK_LABEL(bubble), 48);@@ -193,40 +326,73 @@ namespace tether::ui {gtk_style_context_add_class(bubble_style, outgoing ? "tether-bubble-out" : "tether-bubble-in");gtk_box_pack_start(GTK_BOX(box), bubble, FALSE, FALSE, 0);- if (!stamp.empty()) {- GtkWidget* time_label = gtk_label_new(stamp.c_str());- gtk_label_set_xalign(GTK_LABEL(time_label), outgoing ? 1.0 : 0.0);- gtk_style_context_add_class(gtk_widget_get_style_context(time_label), "muted");- gtk_box_pack_start(GTK_BOX(box), time_label, FALSE, FALSE, 0);- }-gtk_container_add(GTK_CONTAINER(row), box);return row;}- gboolean scroll_to_end_idle(gpointer) {- g_messages.scroll_idle_id = 0;+ GtkAdjustment* conversation_adjustment() {if (!g_messages.conversation_scroll)+ return nullptr;+ return gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(g_messages.conversation_scroll));+ }++ // upper minus the visible page is the bottom edge+ double conversation_bottom(GtkAdjustment* adjustment) {+ return gtk_adjustment_get_upper(adjustment) - gtk_adjustment_get_page_size(adjustment);+ }++ bool conversation_at_bottom() {+ GtkAdjustment* adjustment = conversation_adjustment();+ if (!adjustment)+ return true;+ return gtk_adjustment_get_value(adjustment) >= conversation_bottom(adjustment) - AT_BOTTOM_SLACK;+ }++ gboolean scroll_conversation_idle(gpointer) {+ g_messages.scroll_idle_id = 0;+ GtkAdjustment* adjustment = conversation_adjustment();+ if (!adjustment)return G_SOURCE_REMOVE;- GtkAdjustment* adjustment =- gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(g_messages.conversation_scroll));- if (adjustment) {- // upper is the full content height; subtracting the visible page- // is what puts the last message at the bottom edge rather than- // one screen past it.- gtk_adjustment_set_value(- adjustment, gtk_adjustment_get_upper(adjustment) - gtk_adjustment_get_page_size(adjustment));- }+ const double bottom = conversation_bottom(adjustment);+ gtk_adjustment_set_value(adjustment,+ g_messages.scroll_pin ? bottom : bottom - g_messages.scroll_from_bottom);return G_SOURCE_REMOVE;}- void scroll_conversation_to_end() {- // The rows have only just been inserted, so GTK has not laid them out- // and the adjustment still reports the bounds of the old contents.- // Scrolling now lands somewhere short of the newest message.+ void restore_conversation_scroll(bool pin) {+ g_messages.scroll_pin = pin;if (g_messages.scroll_idle_id == 0)g_messages.scroll_idle_id =- g_idle_add_full(G_PRIORITY_DEFAULT_IDLE, scroll_to_end_idle, nullptr, nullptr);+ g_idle_add_full(G_PRIORITY_DEFAULT_IDLE, scroll_conversation_idle, nullptr, nullptr);+ }++ gboolean thread_scroll_idle(gpointer) {+ g_messages.thread_scroll_idle_id = 0;+ if (g_messages.thread_scroll_value < 0.0 || !g_messages.thread_scroll)+ return G_SOURCE_REMOVE;+ if (GtkAdjustment* adjustment =+ gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(g_messages.thread_scroll)))+ gtk_adjustment_set_value(adjustment, g_messages.thread_scroll_value);+ g_messages.thread_scroll_value = -1.0;+ return G_SOURCE_REMOVE;+ }++ void restore_thread_scroll() {+ if (g_messages.thread_scroll_value >= 0.0 && g_messages.thread_scroll_idle_id == 0)+ g_messages.thread_scroll_idle_id =+ g_idle_add_full(G_PRIORITY_DEFAULT_IDLE, thread_scroll_idle, nullptr, nullptr);+ }++ gboolean thread_visible(GtkListBoxRow* row, gpointer) {+ if (g_messages.search_needle.empty())+ return TRUE;+ const char* haystack = static_cast<const char*>(g_object_get_data(G_OBJECT(row), "search"));+ return haystack && std::strstr(haystack, g_messages.search_needle.c_str()) != nullptr;+ }++ void on_search_changed(GtkSearchEntry* entry, gpointer) {+ g_messages.search_needle = fold(gtk_entry_get_text(GTK_ENTRY(entry)));+ gtk_list_box_invalidate_filter(GTK_LIST_BOX(g_messages.thread_list));}void show_threads(const nlohmann::json& event) {@@ -241,6 +407,10 @@ namespace tether::ui {if (g_messages.thread_selected_handler)g_signal_handler_block(g_messages.thread_list, g_messages.thread_selected_handler);+ if (GtkAdjustment* adjustment =+ gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(g_messages.thread_scroll)))+ g_messages.thread_scroll_value = gtk_adjustment_get_value(adjustment);+clear_list_box(g_messages.thread_list);GtkWidget* reselect = nullptr;@@ -252,13 +422,6 @@ namespace tether::ui {}gtk_widget_show_all(g_messages.thread_list);- // Restoring the selection keeps the open conversation from closing- // every time a message arrives. The row is new, so the reply- // eligibility attached to it has to be re-read.- // While composing, the selection is driven by the To: field, and the- // thread being addressed usually has no row yet. Letting the refresh- // fall through to clear_selection() would wipe a half-typed message- // every time anything arrived.if (reselect) {gtk_list_box_select_row(GTK_LIST_BOX(g_messages.thread_list), GTK_LIST_BOX_ROW(reselect));if (!g_messages.composing)@@ -270,10 +433,54 @@ namespace tether::ui {if (g_messages.thread_selected_handler)g_signal_handler_unblock(g_messages.thread_list, g_messages.thread_selected_handler);+ restore_thread_scroll();+if (g_messages.focus_composer) {g_messages.focus_composer = false;- if (gtk_widget_is_sensitive(g_messages.composer))- gtk_widget_grab_focus(g_messages.composer);+ focus_composer_soon();+ }+ }++ // Opening a conversation marks it read here and on the phone, which is+ // what makes the unread badge agree with what the user has seen.+ void mark_conversation_read(const nlohmann::json& messages) {+ std::vector<std::string> pending;+ for (const auto& message : messages) {+ if (message.value("read", true) || message.value("outgoing", false))+ continue;+ const std::string handle = message.value("handle", "");+ if (!handle.empty() && !g_messages.marked_read.count(handle))+ pending.push_back(handle);+ }+ if (pending.empty())+ return;++ nlohmann::json j;+ j["command"] = "bt_mark_read";+ j["handles"] = pending;+ j["read"] = true;++ if (daemon_send(j))+ g_messages.marked_read.insert(pending.begin(), pending.end());+ }++ void append_message_rows(const nlohmann::json& messages, size_t from) {+ for (size_t i = from; i < messages.size(); ++i) {+ const auto& message = messages[i];+ const int64_t stamp = message.value("timestamp", static_cast<int64_t>(0));+ const bool outgoing = message.value("outgoing", false);+ const bool first = from == 0 && i == 0;++ if (stamp > 0 && (first || !same_local_day(g_messages.rendered_last_stamp, stamp)))+ gtk_list_box_insert(GTK_LIST_BOX(g_messages.conversation), build_day_row(stamp), -1);++ const bool grouped = !first && outgoing == g_messages.rendered_last_outgoing &&+ stamp - g_messages.rendered_last_stamp < GROUP_WINDOW_SECONDS &&+ same_local_day(g_messages.rendered_last_stamp, stamp);++ gtk_list_box_insert(GTK_LIST_BOX(g_messages.conversation), build_message_row(message, !grouped), -1);+ g_messages.rendered_last_stamp = stamp;+ g_messages.rendered_last_outgoing = outgoing;}}@@ -281,40 +488,44 @@ namespace tether::ui {if (event.value("thread", "") != g_messages.selected_thread)return;- clear_list_box(g_messages.conversation);- if (!event.contains("messages") || !event["messages"].is_array()) {- gtk_widget_show_all(g_messages.conversation);+ static const nlohmann::json none = nlohmann::json::array();+ const nlohmann::json& messages =+ (event.contains("messages") && event["messages"].is_array()) ? event["messages"] : none;++ mark_conversation_read(messages);++ std::vector<std::string> handles;+ handles.reserve(messages.size());+ for (const auto& message : messages)+ handles.push_back(message.value("handle", ""));++ if (handles == g_messages.rendered)return;++ const bool opening = g_messages.rendered.empty();+ const bool pinned = g_messages.pin_next || opening || conversation_at_bottom();+ g_messages.pin_next = false;++ const bool appended = handles.size() > g_messages.rendered.size() &&+ std::equal(g_messages.rendered.begin(), g_messages.rendered.end(), handles.begin());++ size_t from = g_messages.rendered.size();+ if (!appended) {+ if (GtkAdjustment* adjustment = conversation_adjustment())+ g_messages.scroll_from_bottom =+ conversation_bottom(adjustment) - gtk_adjustment_get_value(adjustment);+ clear_list_box(g_messages.conversation);+ g_messages.rendered_last_stamp = 0;+ g_messages.rendered_last_outgoing = false;+ from = 0;}- for (const auto& message : event["messages"])- gtk_list_box_insert(GTK_LIST_BOX(g_messages.conversation), build_message_row(message), -1);+ append_message_rows(messages, from);+ g_messages.rendered = handles;gtk_widget_show_all(g_messages.conversation);- scroll_conversation_to_end();- // Opening a conversation marks it read here and on the phone, which is- // what makes the unread badge agree with what the user has seen. One- // request for the whole batch, and never twice for the same message:- // each one costs the daemon a blocking OBEX write.- std::vector<std::string> pending;- for (const auto& message : event["messages"]) {- if (message.value("read", true) || message.value("outgoing", false))- continue;- const std::string handle = message.value("handle", "");- if (!handle.empty() && !g_messages.marked_read.count(handle))- pending.push_back(handle);- }- if (!pending.empty()) {- nlohmann::json j;- j["command"] = "bt_mark_read";- j["handles"] = pending;- j["read"] = true;- // Only remember them once the request is actually on its way, so a- // command lost to a dead socket is retried next time rather than- // leaving the conversation permanently stuck unread.- if (daemon_send(j))- g_messages.marked_read.insert(pending.begin(), pending.end());- }+ if (pinned || !appended)+ restore_conversation_scroll(pinned);}void set_banner(const std::string& text, bool offer_permissions) {@@ -419,6 +630,18 @@ namespace tether::ui {return out;}+ void hide_send_error() {+ if (g_messages.send_error)+ gtk_widget_hide(g_messages.send_error);+ }++ void show_send_error(const std::string& text) {+ if (!g_messages.send_error)+ return;+ set_text(g_messages.send_error_label, text);+ gtk_widget_show(g_messages.send_error);+ }+void clear_sending() {if (g_messages.send_watchdog_id != 0) {g_source_remove(g_messages.send_watchdog_id);@@ -446,8 +669,11 @@ namespace tether::ui {j["command"] = "bt_send_message";j["thread"] = g_messages.selected_thread;j["body"] = body;+ hide_send_error();if (!daemon_send(j)) {- set_status_main(_("Could not reach the Tether daemon; the message was not sent."));+ const char* reason = _("Could not reach the Tether daemon; the message was not sent.");+ set_status_main(reason);+ show_send_error(reason);return;}@@ -465,6 +691,10 @@ namespace tether::ui {// starts a new line. A multi-line box that only sends on a button click is// the single thing that makes a composer feel unfinished.gboolean on_composer_key(GtkWidget*, GdkEventKey* event, gpointer) {+ if (event->keyval == GDK_KEY_Escape) {+ gtk_widget_grab_focus(g_messages.thread_list);+ return TRUE;+ }if (event->keyval != GDK_KEY_Return && event->keyval != GDK_KEY_KP_Enter)return FALSE;if (event->state & (GDK_SHIFT_MASK | GDK_CONTROL_MASK))@@ -486,19 +716,23 @@ namespace tether::ui {if (event.value("success", false)) {// Only cleared once the phone accepted it, so a failed send// leaves the text where the user can retry or copy it out.- GtkTextBuffer* buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(g_messages.composer));- gtk_text_buffer_set_text(buffer, "", -1);+ g_messages.drafts.erase(g_messages.selected_thread);+ set_composer_text("");+ hide_send_error();+ g_messages.pin_next = true;// The conversation now exists under this key, so the thread list// refresh that follows will select it like any other.leave_compose();set_status_main(_("Sent"));return;}- set_status_main(event.value("message", _("The message was not sent.")));+ const std::string reason = event.value("message", _("The message was not sent."));+ set_status_main(reason);+ show_send_error(reason);}void clear_selection() {- g_messages.selected_thread.clear();+ switch_thread("");g_messages.selected_name.clear();g_messages.selected_repliable = false;g_messages.selected_block_reason.clear();@@ -512,7 +746,9 @@ 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");- g_messages.selected_thread = thread ? thread : "";++ switch_thread(thread ? thread : "");+g_messages.selected_name = name ? name : "";g_messages.selected_repliable = g_object_get_data(G_OBJECT(row), "repliable") != nullptr;g_messages.selected_block_reason = block_reason ? block_reason : "";@@ -658,6 +894,9 @@ namespace tether::ui {if (g_messages.selected_thread != g_messages.compose_requested_key) {g_messages.compose_requested_key = g_messages.selected_thread;clear_list_box(g_messages.conversation);+ g_messages.rendered.clear();+ g_messages.rendered_last_stamp = 0;+ g_messages.rendered_last_outgoing = false;gtk_widget_show_all(g_messages.conversation);request_messages(g_messages.selected_thread);}@@ -672,11 +911,18 @@ namespace tether::ui {if (g_messages.thread_selected_handler)g_signal_handler_unblock(g_messages.thread_list, g_messages.thread_selected_handler);+ stash_draft();+ set_composer_text("");+ hide_send_error();+g_messages.composing = true;g_messages.compose_requested_key.clear();rebuild_contact_completion();clear_list_box(g_messages.conversation);+ g_messages.rendered.clear();+ g_messages.rendered_last_stamp = 0;+ g_messages.rendered_last_outgoing = false;gtk_widget_show_all(g_messages.conversation);gtk_widget_show(g_messages.compose_bar);gtk_stack_set_visible_child_name(GTK_STACK(g_messages.placeholder_stack), "conversation");@@ -718,12 +964,10 @@ namespace tether::ui {apply_row_selection(GTK_WIDGET(row));gtk_stack_set_visible_child_name(GTK_STACK(g_messages.placeholder_stack), "conversation");request_messages(g_messages.selected_thread);- // Only on a real click: the handler is blocked while the list is- // rebuilt, so this cannot steal focus behind the user's back.- if (gtk_widget_is_sensitive(g_messages.composer))- gtk_widget_grab_focus(g_messages.composer);}+ void on_thread_activated(GtkListBox*, GtkListBoxRow*, gpointer) { focus_composer_soon(); }+} // namespacevoid messages_view_handle_disconnect() {@@ -740,7 +984,7 @@ namespace tether::ui {if (thread_key.empty())return;leave_compose();- g_messages.selected_thread = thread_key;+ switch_thread(thread_key);g_messages.selected_name.clear();g_messages.selected_repliable = false;g_messages.selected_block_reason.clear();@@ -751,6 +995,18 @@ namespace tether::ui {request_messages(thread_key);}+ void messages_view_new_message() { enter_compose(); }++ void messages_view_focus_search() {+ if (g_messages.search_entry)+ gtk_widget_grab_focus(g_messages.search_entry);+ }++ void messages_view_store_prefs() {+ if (g_messages.paned)+ prefs()["sidebar_width"] = gtk_paned_get_position(GTK_PANED(g_messages.paned));+ }+void messages_view_set_visible(bool visible) {g_messages.visible = visible;if (!visible)@@ -826,17 +1082,41 @@ namespace tether::ui {gtk_box_pack_start(GTK_BOX(root), g_messages.banner, FALSE, FALSE, 0);GtkWidget* paned = gtk_paned_new(GTK_ORIENTATION_HORIZONTAL);+ g_messages.paned = paned;+ gtk_paned_set_position(GTK_PANED(paned), prefs().value("sidebar_width", 260));gtk_box_pack_start(GTK_BOX(root), paned, TRUE, TRUE, 0);GtkWidget* thread_scroll = gtk_scrolled_window_new(nullptr, nullptr);+ g_messages.thread_scroll = thread_scroll;gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(thread_scroll), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);gtk_widget_set_size_request(thread_scroll, 240, -1);g_messages.thread_list = gtk_list_box_new();g_messages.thread_selected_handler =g_signal_connect(g_messages.thread_list, "row-selected", G_CALLBACK(on_thread_selected), nullptr);+ g_signal_connect(g_messages.thread_list, "row-activated", G_CALLBACK(on_thread_activated), nullptr);+ gtk_list_box_set_filter_func(GTK_LIST_BOX(g_messages.thread_list), thread_visible, nullptr, nullptr);gtk_container_add(GTK_CONTAINER(thread_scroll), g_messages.thread_list);GtkWidget* thread_side = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);++ g_messages.search_entry = gtk_search_entry_new();+ gtk_entry_set_placeholder_text(GTK_ENTRY(g_messages.search_entry), _("Search conversations"));+ gtk_entry_set_width_chars(GTK_ENTRY(g_messages.search_entry), 8);+ gtk_widget_set_margin_top(g_messages.search_entry, 8);+ gtk_widget_set_margin_start(g_messages.search_entry, 8);+ gtk_widget_set_margin_end(g_messages.search_entry, 8);+ g_signal_connect(g_messages.search_entry, "search-changed", G_CALLBACK(on_search_changed), nullptr);+ // GtkSearchEntry reports Escape but does not act on it outside a+ // GtkSearchBar, so an abandoned search would otherwise stay applied.+ g_signal_connect(g_messages.search_entry,+ "stop-search",+ G_CALLBACK(+[](GtkSearchEntry* entry, gpointer) {+ gtk_entry_set_text(GTK_ENTRY(entry), "");+ gtk_widget_grab_focus(g_messages.thread_list);+ }),+ nullptr);+ gtk_box_pack_start(GTK_BOX(thread_side), g_messages.search_entry, FALSE, FALSE, 0);+GtkWidget* new_message = gtk_button_new_with_label(_("New Message"));gtk_button_set_image(GTK_BUTTON(new_message),gtk_image_new_from_icon_name("list-add-symbolic", GTK_ICON_SIZE_BUTTON));@@ -898,10 +1178,7 @@ namespace tether::ui {// completion, so a popup selection consumes the key first.g_signal_connect(g_messages.compose_entry,"activate",- G_CALLBACK(+[](GtkEntry*, gpointer) {- if (gtk_widget_is_sensitive(g_messages.composer))- gtk_widget_grab_focus(g_messages.composer);- }),+ G_CALLBACK(+[](GtkEntry*, gpointer) { focus_composer_soon(); }),nullptr);g_signal_connect_after(g_messages.compose_entry, "key-press-event", G_CALLBACK(on_compose_entry_key), nullptr);@@ -956,14 +1233,39 @@ namespace tether::ui {g_signal_connect(g_messages.send_button, "clicked", G_CALLBACK(on_send_clicked), nullptr);g_signal_connect(g_messages.composer, "key-press-event", G_CALLBACK(on_composer_key), nullptr);// The button follows what is actually in the box, so "Send" is never- // offered for an empty message.+ // offered for an empty message. Editing also retires a failure notice+ // that no longer describes what is in the box.g_signal_connect(gtk_text_view_get_buffer(GTK_TEXT_VIEW(g_messages.composer)),"changed",- G_CALLBACK(+[](GtkTextBuffer*, gpointer) { update_composer_sensitivity(); }),+ G_CALLBACK(+[](GtkTextBuffer*, gpointer) {+ hide_send_error();+ update_composer_sensitivity();+ }),nullptr);// Enabled only once MAP is up and a conversation is open.update_composer_sensitivity();+ g_messages.send_error = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 8);+ gtk_container_set_border_width(GTK_CONTAINER(g_messages.send_error), 8);+ gtk_style_context_add_class(gtk_widget_get_style_context(g_messages.send_error), "tether-send-error");+ gtk_box_pack_start(GTK_BOX(g_messages.send_error),+ gtk_image_new_from_icon_name("dialog-warning-symbolic", GTK_ICON_SIZE_BUTTON),+ FALSE,+ FALSE,+ 0);+ g_messages.send_error_label = gtk_label_new(nullptr);+ gtk_label_set_xalign(GTK_LABEL(g_messages.send_error_label), 0.0);+ gtk_label_set_line_wrap(GTK_LABEL(g_messages.send_error_label), TRUE);+ gtk_box_pack_start(GTK_BOX(g_messages.send_error), g_messages.send_error_label, TRUE, TRUE, 0);+ GtkWidget* retry = gtk_button_new_with_label(_("Retry"));+ gtk_widget_set_valign(retry, GTK_ALIGN_CENTER);+ g_signal_connect(retry, "clicked", G_CALLBACK(on_send_clicked), nullptr);+ gtk_box_pack_start(GTK_BOX(g_messages.send_error), retry, FALSE, FALSE, 0);+ gtk_box_pack_start(GTK_BOX(conversation_box), g_messages.send_error, FALSE, FALSE, 0);+ gtk_widget_show_all(g_messages.send_error);+ gtk_widget_hide(g_messages.send_error);+ gtk_widget_set_no_show_all(g_messages.send_error, TRUE);+// A dead composer with the explanation hidden in the send button's tooltip// reads as the app being broken. The button is insensitive, so the tooltip// never appears at all.diff --git a/src/gtk/messages_view.hpp b/src/gtk/messages_view.hppindex 6a814bf..a47d098 100644--- a/src/gtk/messages_view.hpp+++ b/src/gtk/messages_view.hpp@@ -21,6 +21,13 @@ namespace tether::ui {// to be told when it comes and goes.void messages_view_set_visible(bool visible);+ // The window's ctrl+n and ctrl+f+ void messages_view_new_message();+ void messages_view_focus_search();++ // Records the sidebar width. The caller writes prefs out once at shutdown.+ void messages_view_store_prefs();+// Drops anything that was waiting on a daemon reply. Without this a send in// flight when the daemon goes away leaves the composer disabled for good.void messages_view_handle_disconnect();diff --git a/src/gtk/prefs.cpp b/src/gtk/prefs.cppnew file mode 100644index 0000000..78c5705--- /dev/null+++ b/src/gtk/prefs.cpp@@ -0,0 +1,55 @@+#include "prefs.hpp"++#include <filesystem>+#include <fstream>+#include <glib.h>+#include <tether/log.hpp>++namespace tether::ui {++ namespace {++ std::string prefs_path() {+ const char* home = g_get_home_dir();+ if (!home || !*home)+ return {};+ return (std::filesystem::path(home) / ".config" / "tether" / "gtk.json").string();+ }++ } // namespace++ nlohmann::json& prefs() {+ static nlohmann::json loaded = [] {+ const std::string path = prefs_path();+ if (!path.empty()) {+ try {+ std::ifstream in(path);+ if (in) {+ nlohmann::json parsed = nlohmann::json::parse(in);+ if (parsed.is_object())+ return parsed;+ }+ } catch (const std::exception& e) {+ debug::log(WARN, "prefs: ignoring {} ({})", path, e.what());+ }+ }+ return nlohmann::json::object();+ }();+ return loaded;+ }++ void prefs_save() {+ const std::string path = prefs_path();+ if (path.empty())+ return;+ try {+ std::error_code ec;+ std::filesystem::create_directories(std::filesystem::path(path).parent_path(), ec);+ std::ofstream out(path);+ out << prefs().dump(2) << "\n";+ } catch (const std::exception& e) {+ debug::log(ERR, "prefs: could not write {} ({})", path, e.what());+ }+ }++} // namespace tether::uidiff --git a/src/gtk/prefs.hpp b/src/gtk/prefs.hppnew file mode 100644index 0000000..d1dc901--- /dev/null+++ b/src/gtk/prefs.hpp@@ -0,0 +1,12 @@+#pragma once++#include <nlohmann/json.hpp>++namespace tether::ui {++ // ~/.config/tether/gtk.json, read once on first use. Unreadable or corrupt means defaults.+ nlohmann::json& prefs();++ void prefs_save();++} // namespace tether::uidiff --git a/src/gtk/tray.cpp b/src/gtk/tray.cppindex 43b59f1..cafbdca 100644--- a/src/gtk/tray.cpp+++ b/src/gtk/tray.cpp@@ -1,10 +1,9 @@#include "tray.hpp"#include "daemon_client.hpp"+#include "prefs.hpp"#include <tether/i18n.hpp>-#include <filesystem>-#include <fstream>#include <gio/gio.h>#include <gtk/gtk.h>#include <nlohmann/json.hpp>@@ -77,42 +76,9 @@ namespace tether::ui {RouteState& state(Route route) { return g_state[route == Route::WiFi ? 0 : 1]; }const char* route_name(Route route) { return route == Route::WiFi ? "Wi-Fi" : "Bluetooth"; }- std::string prefs_path() {- const char* home = g_get_home_dir();- if (!home || !*home)- return {};- return (std::filesystem::path(home) / ".config" / "tether" / "gtk.json").string();- }-void load_prefs() {- const std::string path = prefs_path();- if (path.empty())- return;- try {- std::ifstream in(path);- if (!in)- return;- const nlohmann::json prefs = nlohmann::json::parse(in);- g_close_to_tray = prefs.value("close_to_tray", false);- g_icon_style = prefs.value("tray_icon", std::string("symbolic"));- } catch (const std::exception& e) {- // unreadable file means defaults, not a dead tray.- debug::log(WARN, "tray: ignoring {} ({})", path, e.what());- }- }-- void save_prefs() {- const std::string path = prefs_path();- if (path.empty())- return;- try {- std::error_code ec;- std::filesystem::create_directories(std::filesystem::path(path).parent_path(), ec);- std::ofstream out(path);- out << nlohmann::json{{"close_to_tray", g_close_to_tray}, {"tray_icon", g_icon_style}}.dump(2) << "\n";- } catch (const std::exception& e) {- debug::log(ERR, "tray: could not write {} ({})", path, e.what());- }+ g_close_to_tray = prefs().value("close_to_tray", false);+ g_icon_style = prefs().value("tray_icon", std::string("symbolic"));}// Symbolic icons are drawn in the panel's foreground color, so the item matches the rest of@@ -312,7 +278,8 @@ namespace tether::ui {if (g_close_to_tray == enabled)return;g_close_to_tray = enabled;- save_prefs();+ prefs()["close_to_tray"] = enabled;+ prefs_save();}} // namespace tether::uidiff --git a/src/gtk/ui_util.cpp b/src/gtk/ui_util.cppindex f457497..83cd50d 100644--- a/src/gtk/ui_util.cpp+++ b/src/gtk/ui_util.cpp@@ -63,6 +63,16 @@ namespace tether::ui {font-size: 92%;}+.tether-thread-unread {+ opacity: 1;+ font-weight: bold;+}++.tether-send-error {+ background-color: alpha(#e5a50a, 0.20);+ border-top: 1px solid alpha(@theme_fg_color, 0.12);+}+.tether-badge {background-color: @theme_selected_bg_color;color: @theme_selected_fg_color;diff --git a/test/CMakeLists.txt b/test/CMakeLists.txtindex 3d5a207..bf0490e 100644--- a/test/CMakeLists.txt+++ b/test/CMakeLists.txt@@ -17,6 +17,8 @@ add_executable(tether_testtest_display_width.cpptest_file_transfer.cpptest_otp.cpp+ test_message_format.cpp+ ../src/gtk/message_format.cpp)target_include_directories(tether_test PRIVATEdiff --git a/test/test_message_format.cpp b/test/test_message_format.cppnew file mode 100644index 0000000..2424877--- /dev/null+++ b/test/test_message_format.cpp@@ -0,0 +1,136 @@+#include "../src/gtk/message_format.hpp"++#include <glib.h>+#include <gtest/gtest.h>++using tether::ui::format_day_heading;+using tether::ui::format_thread_time;+using tether::ui::linkify_markup;+using tether::ui::same_local_day;++namespace {++ // Fixed local time so the day boundaries are the ones under test rather than+ // whatever the build host happens to be set to.+ struct FixedZone : ::testing::Test {+ void SetUp() override {+ setenv("TZ", "UTC", 1);+ tzset();+ }+ };++ // 2026-08-25 12:00:00 UTC, a Tuesday.+ constexpr int64_t NOW = 1787659200;+ constexpr int64_t DAY = 86400;++} // namespace++TEST(LinkifyMarkup, PlainTextIsEscapedAndUnlinked) {+ EXPECT_EQ(linkify_markup("a < b & c"), "a < b & c");+}++TEST(LinkifyMarkup, BareUrlBecomesALink) {+ EXPECT_EQ(linkify_markup("see https://example.com now"),+ "see <a href=\"https://example.com\">https://example.com</a> now");+}++TEST(LinkifyMarkup, TrailingSentencePunctuationStaysOutsideTheLink) {+ EXPECT_EQ(linkify_markup("go to https://example.com/x."),+ "go to <a href=\"https://example.com/x\">https://example.com/x</a>.");+}++TEST(LinkifyMarkup, ClosingParenBelongingToTheUrlIsKept) {+ EXPECT_EQ(linkify_markup("https://example.com/a_(b)"),+ "<a href=\"https://example.com/a_(b)\">https://example.com/a_(b)</a>");+}++TEST(LinkifyMarkup, WwwHostGetsAScheme) {+ EXPECT_EQ(linkify_markup("www.example.com"), "<a href=\"http://www.example.com\">www.example.com</a>");+}++TEST(LinkifyMarkup, QueryStringIsEscapedInBothHrefAndText) {+ EXPECT_EQ(linkify_markup("https://example.com/?a=1&b=2"),+ "<a href=\"https://example.com/?a=1&b=2\">https://example.com/?a=1&b=2</a>");+}++TEST(LinkifyMarkup, MultipleUrlsInOneBody) {+ EXPECT_EQ(linkify_markup("http://a.test and http://b.test"),+ "<a href=\"http://a.test\">http://a.test</a> and <a href=\"http://b.test\">http://b.test</a>");+}++TEST_F(FixedZone, TodayIsAClockTime) { EXPECT_EQ(format_thread_time(NOW - 3600, NOW), "11:00"); }++TEST_F(FixedZone, EarlierTodayStaysAClockTime) {+ // 00:30 the same calendar day, which is more than 24h from nothing but is+ // still "today" and must not read as Yesterday.+ EXPECT_EQ(format_thread_time(NOW - (11 * 3600) - 1800, NOW), "00:30");+}++TEST_F(FixedZone, PreviousCalendarDayIsYesterday) { EXPECT_EQ(format_thread_time(NOW - DAY, NOW), "Yesterday"); }++TEST_F(FixedZone, WithinTheWeekIsAWeekday) {+ EXPECT_EQ(format_thread_time(NOW - (3 * DAY), NOW), "Sat");+ EXPECT_EQ(format_thread_time(NOW - (6 * DAY), NOW), "Wed");+}++TEST_F(FixedZone, BeyondAWeekIsADate) { EXPECT_EQ(format_thread_time(NOW - (7 * DAY), NOW), "Aug 18"); }++TEST_F(FixedZone, MissingTimestampIsEmpty) { EXPECT_EQ(format_thread_time(0, NOW), ""); }++TEST_F(FixedZone, DayHeadingNamesTodayAndYesterday) {+ EXPECT_EQ(format_day_heading(NOW, NOW), "Today");+ EXPECT_EQ(format_day_heading(NOW - DAY, NOW), "Yesterday");+}++TEST_F(FixedZone, DayHeadingWithinTheWeekIsTheWeekdayName) {+ EXPECT_EQ(format_day_heading(NOW - (3 * DAY), NOW), "Saturday");+}++TEST_F(FixedZone, DayHeadingBeyondAWeekCarriesTheDate) {+ EXPECT_EQ(format_day_heading(NOW - (7 * DAY), NOW), "Tuesday, Aug 18");+}++TEST_F(FixedZone, SameLocalDayIgnoresTimeOfDayButNotTheDateBoundary) {+ EXPECT_TRUE(same_local_day(NOW, NOW - (11 * 3600)));+ EXPECT_FALSE(same_local_day(NOW, NOW - (13 * 3600)));+}++// Whatever a sender types, the result has to be markup GTK will accept -+// invalid markup renders the bubble empty instead of showing the message.+TEST(LinkifyMarkup, AlwaysProducesParseableMarkup) {+ const char* bodies[] = {+ "",+ "plain text",+ "<b>not bold</b>",+ "5 < 6 && 7 > 3",+ "quote \" and apostrophe '",+ "<a href='http://evil'>click</a>",+ "https://example.com/<script>",+ "http://example.com/?q=<>&x=\"y\"",+ "& already escaped",+ "www.example.com</a><b>",+ "http://",+ "www.",+ "trailing )))",+ "https://example.com/a(b)c).",+ "ünïcödé https://exämple.com/ß",+ "\xf0\x9f\x98\x80 emoji https://example.com",+ "newline\nhttp://example.com\ttab",+ };++ for (const char* body : bodies) {+ const std::string markup = linkify_markup(body);+ // The same well-formedness gtk_label_set_markup requires, checked with+ // a root element the way Pango wraps it.+ const std::string document = "<markup>" + markup + "</markup>";+ GMarkupParser parser{};+ GMarkupParseContext* context = g_markup_parse_context_new(&parser, GMarkupParseFlags(0), nullptr, nullptr);+ GError* error = nullptr;+ const gboolean ok = g_markup_parse_context_parse(context, document.c_str(), -1, &error) &&+ g_markup_parse_context_end_parse(context, &error);+ EXPECT_TRUE(ok) << "body: " << body << "\nmarkup: " << markup+ << "\nerror: " << (error ? error->message : "?");+ g_clear_error(&error);+ g_markup_parse_context_free(context);+ }+}