Skip to content

Email for professionals and teams

Improve send toast actions, message navigation, and live updates

Antonio Ivanovskid0aebe7babe1
diff --git a/public/locales/ar.json b/public/locales/ar.json
index 0191993..6338b24 100644
--- a/public/locales/ar.json
+++ b/public/locales/ar.json
@@ -210,6 +210,11 @@
"compose.error.totalSize": "يجب ألا يتجاوز مجموع حجم المرفقات {max} ميغابايت",
"compose.scheduled": "تمت جدولة الرسالة",
"compose.sent": "تم إرسال الرسالة",
+ "compose.sendingIn": "جارٍ إرسال “{subject}” خلال {seconds} ثانية",
+ "compose.sendingSubject": "جارٍ إرسال “{subject}”...",
+ "compose.sentSubject": "تم إرسال “{subject}”",
+ "compose.undoSend": "تراجع",
+ "compose.sendNow": "إرسال الآن",
"compose.carriedOver": "منقول من الرسالة المُعاد توجيهها",
"compose.removeAttachment": "إزالة المرفق",
"compose.cloudWarning.will": "تحدّ Cloudflare الرسائل العامة بـ 5 MiB شاملةً الترميز. سيتم إرسال الملفات التي تزيد على 3 ميغابايت هنا كروابط تنزيل R2 صالحة لمدة 30 يومًا.",
diff --git a/public/locales/bn.json b/public/locales/bn.json
index ebdfa7b..6b34905 100644
--- a/public/locales/bn.json
+++ b/public/locales/bn.json
@@ -194,6 +194,11 @@
"compose.error.totalSize": "সংযুক্তির মোট আকার {max} MB বা তার কম হতে হবে",
"compose.scheduled": "বার্তা নির্ধারিত হয়েছে",
"compose.sent": "বার্তা পাঠানো হয়েছে",
+ "compose.sendingIn": "“{subject}” {seconds} সেকেন্ডে পাঠানো হচ্ছে",
+ "compose.sendingSubject": "“{subject}” পাঠানো হচ্ছে...",
+ "compose.sentSubject": "“{subject}” পাঠানো হয়েছে",
+ "compose.undoSend": "ফিরিয়ে নিন",
+ "compose.sendNow": "এখনই পাঠান",
"compose.carriedOver": "ফরোয়ার্ড করা বার্তা থেকে আনা হয়েছে",
"compose.removeAttachment": "সংযুক্তি সরান",
"compose.cloudWarning.will": "Cloudflare এনকোডিংসহ সাধারণ ইমেইল বার্তা ৫ MiB-এ সীমিত করে। এখানে ৩ MB-এর বেশি ফাইল ৩০ দিন মেয়াদি R2 ডাউনলোড লিঙ্ক হিসেবে পাঠানো হবে।",
diff --git a/public/locales/de.json b/public/locales/de.json
index 92ba2f2..7bda96c 100644
--- a/public/locales/de.json
+++ b/public/locales/de.json
@@ -194,6 +194,11 @@
"compose.error.totalSize": "Die Anhänge dürfen zusammen höchstens {max} MB groß sein",
"compose.scheduled": "Nachricht geplant",
"compose.sent": "Nachricht gesendet",
+ "compose.sendingIn": "„{subject}“ wird in {seconds} s gesendet",
+ "compose.sendingSubject": "„{subject}“ wird gesendet…",
+ "compose.sentSubject": "„{subject}“ wurde gesendet",
+ "compose.undoSend": "Rückgängig",
+ "compose.sendNow": "Jetzt senden",
"compose.carriedOver": "Aus der weitergeleiteten Nachricht übernommen",
"compose.removeAttachment": "Anhang entfernen",
"compose.cloudWarning.will": "Cloudflare begrenzt gewöhnliche E-Mails einschließlich Kodierung auf 5 MiB. Dateien über 3 MB werden hier als 30 Tage gültige R2-Download-Links gesendet.",
diff --git a/public/locales/es.json b/public/locales/es.json
index db8d1b9..b156ef5 100644
--- a/public/locales/es.json
+++ b/public/locales/es.json
@@ -198,6 +198,11 @@
"compose.error.totalSize": "Los archivos adjuntos deben sumar {max} MB o menos",
"compose.scheduled": "Mensaje programado",
"compose.sent": "Mensaje enviado",
+ "compose.sendingIn": "Enviando \"{subject}\" en {seconds} s",
+ "compose.sendingSubject": "Enviando \"{subject}\"…",
+ "compose.sentSubject": "Enviado \"{subject}\"",
+ "compose.undoSend": "Deshacer",
+ "compose.sendNow": "Enviar ahora",
"compose.carriedOver": "Procedente del mensaje reenviado",
"compose.removeAttachment": "Quitar archivo adjunto",
"compose.cloudWarning.will": "Cloudflare limita los correos generales a 5 MiB, incluida la codificación. Los archivos de más de 3 MB se enviarán aquí como enlaces de descarga R2 válidos durante 30 días.",
diff --git a/public/locales/fa.json b/public/locales/fa.json
index a845cfe..a81501d 100644
--- a/public/locales/fa.json
+++ b/public/locales/fa.json
@@ -194,6 +194,11 @@
"compose.error.totalSize": "مجموع پیوست‌ها باید {max} مگابایت یا کمتر باشد",
"compose.scheduled": "پیام زمان‌بندی شد",
"compose.sent": "پیام ارسال شد",
+ "compose.sendingIn": "ارسال “{subject}” تا {seconds} ثانیه دیگر",
+ "compose.sendingSubject": "در حال ارسال “{subject}”...",
+ "compose.sentSubject": "“{subject}” ارسال شد",
+ "compose.undoSend": "لغو",
+ "compose.sendNow": "ارسال اکنون",
"compose.carriedOver": "از پیام ارسال‌شده منتقل شد",
"compose.removeAttachment": "حذف پیوست",
"compose.cloudWarning.will": "Cloudflare ایمیل‌های عمومی را با احتساب کدگذاری به ۵ مبی‌بایت محدود می‌کند. فایل‌های بزرگ‌تر از ۳ مگابایت در اینجا به‌صورت پیوندهای دانلود R2 با اعتبار ۳۰ روز ارسال می‌شوند.",
diff --git a/public/locales/fr.json b/public/locales/fr.json
index 73901a4..0ef01c9 100644
--- a/public/locales/fr.json
+++ b/public/locales/fr.json
@@ -198,6 +198,11 @@
"compose.error.totalSize": "Les pièces jointes doivent totaliser {max} Mo ou moins",
"compose.scheduled": "Message programmé",
"compose.sent": "Message envoyé",
+ "compose.sendingIn": "Envoi de « {subject} » dans {seconds} s",
+ "compose.sendingSubject": "Envoi de « {subject} »…",
+ "compose.sentSubject": "« {subject} » envoyé",
+ "compose.undoSend": "Annuler l'envoi",
+ "compose.sendNow": "Envoyer maintenant",
"compose.carriedOver": "Repris du message transféré",
"compose.removeAttachment": "Retirer la pièce jointe",
"compose.cloudWarning.will": "Cloudflare limite les e-mails classiques à 5 Mio, encodage compris. Les fichiers de plus de 3 Mo seront ici envoyés sous forme de liens de téléchargement R2 valables 30 jours.",
diff --git a/public/locales/gu.json b/public/locales/gu.json
index 1ff9726..bc34119 100644
--- a/public/locales/gu.json
+++ b/public/locales/gu.json
@@ -194,6 +194,11 @@
"compose.error.totalSize": "જોડાણોનો કુલ કદ {max} MB અથવા ઓછું હોવું જોઈએ",
"compose.scheduled": "સંદેશો શેડ્યૂલ થયો",
"compose.sent": "સંદેશો મોકલાયો",
+ "compose.sendingIn": "“{subject}” {seconds} સેકન્ડમાં મોકલાઈ રહ્યું છે",
+ "compose.sendingSubject": "“{subject}” મોકલાઈ રહ્યું છે...",
+ "compose.sentSubject": "“{subject}” મોકલાયું",
+ "compose.undoSend": "પાછું ખેંચો",
+ "compose.sendNow": "હમણાં મોકલો",
"compose.carriedOver": "ફૉરવર્ડ કરેલા સંદેશામાંથી લાવ્યા",
"compose.removeAttachment": "જોડાણ દૂર કરો",
"compose.cloudWarning.will": "Cloudflare એન્કોડિંગ સહિત સામાન્ય ઇમેઇલ સંદેશાને 5 MiB સુધી મર્યાદિત કરે છે. અહીં 3 MB થી વધુની ફાઇલો 30 દિવસ માટે માન્ય R2 ડાઉનલોડ લિંક તરીકે મોકલવામાં આવશે.",
diff --git a/public/locales/ha.json b/public/locales/ha.json
index c6f3ac6..e9006f6 100644
--- a/public/locales/ha.json
+++ b/public/locales/ha.json
@@ -194,6 +194,11 @@
"compose.error.totalSize": "Jimillar haɗe-haɗe dole ta zama {max} MB ko ƙasa",
"compose.scheduled": "An tsara aikawar saƙo",
"compose.sent": "An aika saƙo",
+ "compose.sendingIn": "Ana aika “{subject}” cikin daƙiƙa {seconds}",
+ "compose.sendingSubject": "Ana aika “{subject}”...",
+ "compose.sentSubject": "An aika “{subject}”",
+ "compose.undoSend": "Soke",
+ "compose.sendNow": "Aika yanzu",
"compose.carriedOver": "An kawo daga saƙon da aka tura",
"compose.removeAttachment": "Cire haɗe-haɗe",
"compose.cloudWarning.will": "Cloudflare na iyakance saƙonnin imel na gama-gari zuwa 5 MiB har da lambobin ɓoyewa. Fayilolin da suka wuce 3 MB a nan za a aika su a matsayin hanyoyin sauke R2 masu aiki na kwana 30.",
diff --git a/public/locales/hi.json b/public/locales/hi.json
index 61d2c14..b5889dc 100644
--- a/public/locales/hi.json
+++ b/public/locales/hi.json
@@ -194,6 +194,11 @@
"compose.error.totalSize": "अटैचमेंट का कुल आकार {max} MB या उससे कम होना चाहिए",
"compose.scheduled": "संदेश शेड्यूल हो गया",
"compose.sent": "संदेश भेज दिया गया",
+ "compose.sendingIn": "“{subject}” {seconds} सेकंड में भेजा जा रहा है",
+ "compose.sendingSubject": "“{subject}” भेजा जा रहा है...",
+ "compose.sentSubject": "“{subject}” भेजा गया",
+ "compose.undoSend": "भेजना वापस लें",
+ "compose.sendNow": "अभी भेजें",
"compose.carriedOver": "अग्रेषित संदेश से लाया गया",
"compose.removeAttachment": "अटैचमेंट हटाएँ",
"compose.cloudWarning.will": "Cloudflare एन्कोडिंग सहित सामान्य ईमेल संदेशों को 5 MiB तक सीमित करता है। यहाँ 3 MB से बड़ी फ़ाइलें 30 दिन वाले R2 डाउनलोड लिंक के रूप में भेजी जाएँगी।",
diff --git a/public/locales/id.json b/public/locales/id.json
index b8906cc..8b68370 100644
--- a/public/locales/id.json
+++ b/public/locales/id.json
@@ -190,6 +190,11 @@
"compose.error.totalSize": "Total lampiran harus {max} MB atau kurang",
"compose.scheduled": "Pesan dijadwalkan",
"compose.sent": "Pesan terkirim",
+ "compose.sendingIn": "Mengirim “{subject}” dalam {seconds} detik",
+ "compose.sendingSubject": "Mengirim “{subject}”...",
+ "compose.sentSubject": "“{subject}” terkirim",
+ "compose.undoSend": "Urungkan",
+ "compose.sendNow": "Kirim sekarang",
"compose.carriedOver": "Dibawa dari pesan yang diteruskan",
"compose.removeAttachment": "Hapus lampiran",
"compose.cloudWarning.will": "Cloudflare membatasi pesan email umum hingga 5 MiB termasuk pengodean. File di atas 3 MB di sini akan dikirim sebagai tautan unduhan R2 yang berlaku 30 hari.",
diff --git a/public/locales/it.json b/public/locales/it.json
index 682da20..cbbec17 100644
--- a/public/locales/it.json
+++ b/public/locales/it.json
@@ -198,6 +198,11 @@
"compose.error.totalSize": "Il totale degli allegati non deve superare {max} MB",
"compose.scheduled": "Messaggio programmato",
"compose.sent": "Messaggio inviato",
+ "compose.sendingIn": "Invio di \"{subject}\" tra {seconds} s",
+ "compose.sendingSubject": "Invio di \"{subject}\"…",
+ "compose.sentSubject": "\"{subject}\" inviato",
+ "compose.undoSend": "Annulla invio",
+ "compose.sendNow": "Invia ora",
"compose.carriedOver": "Riportato dal messaggio inoltrato",
"compose.removeAttachment": "Rimuovi allegato",
"compose.cloudWarning.will": "Cloudflare limita le email generiche a 5 MiB, codifica inclusa. I file oltre 3 MB qui verranno inviati come link di download R2 validi 30 giorni.",
diff --git a/public/locales/ja.json b/public/locales/ja.json
index 8e7862b..3442b72 100644
--- a/public/locales/ja.json
+++ b/public/locales/ja.json
@@ -190,6 +190,11 @@
"compose.error.totalSize": "添付ファイルの合計は {max} MB 以下にしてください",
"compose.scheduled": "メールを予約しました",
"compose.sent": "メールを送信しました",
+ "compose.sendingIn": "“{subject}” を {seconds} 秒後に送信します",
+ "compose.sendingSubject": "“{subject}” を送信中...",
+ "compose.sentSubject": "“{subject}” を送信しました",
+ "compose.undoSend": "取り消す",
+ "compose.sendNow": "今すぐ送信",
"compose.carriedOver": "転送元のメールから引き継ぎました",
"compose.removeAttachment": "添付ファイルを削除",
"compose.cloudWarning.will": "Cloudflare は、エンコードを含めて通常のメールを 5 MiB に制限しています。ここでは 3 MB を超えるファイルは、30 日間有効な R2 ダウンロードリンクとして送信されます。",
diff --git a/public/locales/kn.json b/public/locales/kn.json
index b2f2095..1d19ebf 100644
--- a/public/locales/kn.json
+++ b/public/locales/kn.json
@@ -194,6 +194,11 @@
"compose.error.totalSize": "ಲಗತ್ತುಗಳ ಒಟ್ಟು ಗಾತ್ರ {max} MB ಅಥವಾ ಕಡಿಮೆ ಇರಬೇಕು",
"compose.scheduled": "ಸಂದೇಶವನ್ನು ನಿಗದಿಪಡಿಸಲಾಗಿದೆ",
"compose.sent": "ಸಂದೇಶವನ್ನು ಕಳುಹಿಸಲಾಗಿದೆ",
+ "compose.sendingIn": "“{subject}” ಅನ್ನು {seconds} ಸೆಕೆಂಡುಗಳಲ್ಲಿ ಕಳುಹಿಸಲಾಗುತ್ತಿದೆ",
+ "compose.sendingSubject": "“{subject}” ಅನ್ನು ಕಳುಹಿಸಲಾಗುತ್ತಿದೆ...",
+ "compose.sentSubject": "“{subject}” ಅನ್ನು ಕಳುಹಿಸಲಾಗಿದೆ",
+ "compose.undoSend": "ಹಿಂಪಡೆಯಿರಿ",
+ "compose.sendNow": "ಈಗಲೇ ಕಳುಹಿಸಿ",
"compose.carriedOver": "ಫಾರ್ವರ್ಡ್ ಮಾಡಿದ ಸಂದೇಶದಿಂದ ತರಲಾಗಿದೆ",
"compose.removeAttachment": "ಲಗತ್ತನ್ನು ತೆಗೆಯಿರಿ",
"compose.cloudWarning.will": "Cloudflare ಎನ್‌ಕೋಡಿಂಗ್ ಸೇರಿದಂತೆ ಸಾಮಾನ್ಯ ಇಮೇಲ್ ಸಂದೇಶಗಳನ್ನು 5 MiB ಗೆ ಸೀಮಿತಗೊಳಿಸುತ್ತದೆ. ಇಲ್ಲಿ 3 MB ಗಿಂತ ದೊಡ್ಡ ಫೈಲ್‌ಗಳನ್ನು 30 ದಿನಗಳ ಮಾನ್ಯತೆಯ R2 ಡೌನ್‌ಲೋಡ್ ಲಿಂಕ್‌ಗಳಾಗಿ ಕಳುಹಿಸಲಾಗುತ್ತದೆ.",
diff --git a/public/locales/ko.json b/public/locales/ko.json
index 62bc29a..2b8cd6f 100644
--- a/public/locales/ko.json
+++ b/public/locales/ko.json
@@ -194,6 +194,11 @@
"compose.error.totalSize": "첨부파일 총 용량은 {max}MB 이하여야 합니다",
"compose.scheduled": "메시지가 예약되었습니다",
"compose.sent": "메시지를 보냈습니다",
+ "compose.sendingIn": "“{subject}”을(를) {seconds}초 후에 보냅니다",
+ "compose.sendingSubject": "“{subject}”을(를) 보내는 중...",
+ "compose.sentSubject": "“{subject}”을(를) 보냈습니다",
+ "compose.undoSend": "취소",
+ "compose.sendNow": "지금 보내기",
"compose.carriedOver": "전달된 메시지에서 가져왔습니다",
"compose.removeAttachment": "첨부파일 제거",
"compose.cloudWarning.will": "Cloudflare는 인코딩을 포함해 일반 이메일을 5MiB로 제한합니다. 여기서 3MB를 초과하는 파일은 30일간 유효한 R2 다운로드 링크로 전송됩니다.",
diff --git a/public/locales/ml.json b/public/locales/ml.json
index 2ff880e..8f870ba 100644
--- a/public/locales/ml.json
+++ b/public/locales/ml.json
@@ -194,6 +194,11 @@
"compose.error.totalSize": "അറ്റാച്ച്‌മെന്റുകളുടെ ആകെ വലിപ്പം {max} MB അല്ലെങ്കിൽ കുറവായിരിക്കണം",
"compose.scheduled": "സന്ദേശം ഷെഡ്യൂൾ ചെയ്തു",
"compose.sent": "സന്ദേശം അയച്ചു",
+ "compose.sendingIn": "“{subject}” {seconds} സെക്കൻഡിൽ അയയ്ക്കുന്നു",
+ "compose.sendingSubject": "“{subject}” അയയ്ക്കുന്നു...",
+ "compose.sentSubject": "“{subject}” അയച്ചു",
+ "compose.undoSend": "അയയ്ക്കൽ പിൻവലിക്കുക",
+ "compose.sendNow": "ഇപ്പോൾ അയയ്ക്കുക",
"compose.carriedOver": "ഫോർവേഡ് ചെയ്ത സന്ദേശത്തിൽ നിന്ന് കൊണ്ടുവന്നത്",
"compose.removeAttachment": "അറ്റാച്ച്‌മെന്റ് നീക്കുക",
"compose.cloudWarning.will": "എൻകോഡിംഗ് ഉൾപ്പെടെ സാധാരണ ഇമെയിൽ സന്ദേശങ്ങളെ Cloudflare 5 MiB ആയി പരിമിതപ്പെടുത്തുന്നു. ഇവിടെ 3 MB ൽ കൂടുതലുള്ള ഫയലുകൾ 30 ദിവസം സാധുവായ R2 ഡൗൺലോഡ് ലിങ്കുകളായി അയയ്ക്കും.",
diff --git a/public/locales/mr.json b/public/locales/mr.json
index 3663eae..949097d 100644
--- a/public/locales/mr.json
+++ b/public/locales/mr.json
@@ -194,6 +194,11 @@
"compose.error.totalSize": "संलग्नकांचा एकूण आकार {max} MB किंवा त्यापेक्षा कमी असावा",
"compose.scheduled": "संदेश शेड्यूल केला",
"compose.sent": "संदेश पाठवला",
+ "compose.sendingIn": "“{subject}” {seconds} सेकंदात पाठवला जात आहे",
+ "compose.sendingSubject": "“{subject}” पाठवला जात आहे...",
+ "compose.sentSubject": "“{subject}” पाठवला",
+ "compose.undoSend": "पाठवणे मागे घ्या",
+ "compose.sendNow": "आता पाठवा",
"compose.carriedOver": "अग्रेषित संदेशातून आणले",
"compose.removeAttachment": "संलग्नक काढा",
"compose.cloudWarning.will": "Cloudflare एन्कोडिंगसह सामान्य ईमेल संदेश 5 MiB पर्यंत मर्यादित करते. येथे 3 MB पेक्षा मोठ्या फाइल्स 30 दिवसांच्या R2 डाउनलोड लिंक म्हणून पाठवल्या जातील.",
diff --git a/public/locales/ms.json b/public/locales/ms.json
index d09944a..8f5898e 100644
--- a/public/locales/ms.json
+++ b/public/locales/ms.json
@@ -194,6 +194,11 @@
"compose.error.totalSize": "Jumlah lampiran mestilah {max} MB atau kurang",
"compose.scheduled": "Mesej dijadualkan",
"compose.sent": "Mesej dihantar",
+ "compose.sendingIn": "Menghantar “{subject}” dalam {seconds} saat",
+ "compose.sendingSubject": "Menghantar “{subject}”...",
+ "compose.sentSubject": "“{subject}” dihantar",
+ "compose.undoSend": "Buat asal",
+ "compose.sendNow": "Hantar sekarang",
"compose.carriedOver": "Dibawa daripada mesej yang dimajukan",
"compose.removeAttachment": "Alih keluar lampiran",
"compose.cloudWarning.will": "Cloudflare mengehadkan mesej e-mel am kepada 5 MiB termasuk pengekodan. Fail melebihi 3 MB di sini akan dihantar sebagai pautan muat turun R2 yang sah selama 30 hari.",
diff --git a/public/locales/nl.json b/public/locales/nl.json
index 8ce2d2d..bfcedaf 100644
--- a/public/locales/nl.json
+++ b/public/locales/nl.json
@@ -194,6 +194,11 @@
"compose.error.totalSize": "Bijlagen mogen samen maximaal {max} MB zijn",
"compose.scheduled": "Bericht ingepland",
"compose.sent": "Bericht verzonden",
+ "compose.sendingIn": "“{subject}” wordt over {seconds} s verzonden",
+ "compose.sendingSubject": "“{subject}” wordt verzonden…",
+ "compose.sentSubject": "“{subject}” verzonden",
+ "compose.undoSend": "Ongedaan maken",
+ "compose.sendNow": "Nu verzenden",
"compose.carriedOver": "Overgenomen uit het doorgestuurde bericht",
"compose.removeAttachment": "Bijlage verwijderen",
"compose.cloudWarning.will": "Cloudflare beperkt gewone e-mailberichten tot 5 MiB, inclusief codering. Bestanden groter dan 3 MB worden hier verzonden als R2-downloadlinks die 30 dagen geldig zijn.",
diff --git a/public/locales/pa.json b/public/locales/pa.json
index 1131e0b..5f7a8f2 100644
--- a/public/locales/pa.json
+++ b/public/locales/pa.json
@@ -194,6 +194,11 @@
"compose.error.totalSize": "ਅਟੈਚਮੈਂਟਾਂ ਦਾ ਕੁੱਲ ਆਕਾਰ {max} MB ਜਾਂ ਘੱਟ ਹੋਣਾ ਚਾਹੀਦਾ ਹੈ",
"compose.scheduled": "ਸੁਨੇਹਾ ਨਿਯਤ ਕੀਤਾ ਗਿਆ",
"compose.sent": "ਸੁਨੇਹਾ ਭੇਜਿਆ ਗਿਆ",
+ "compose.sendingIn": "“{subject}” {seconds} ਸਕਿੰਟਾਂ ਵਿੱਚ ਭੇਜਿਆ ਜਾ ਰਿਹਾ ਹੈ",
+ "compose.sendingSubject": "“{subject}” ਭੇਜਿਆ ਜਾ ਰਿਹਾ ਹੈ...",
+ "compose.sentSubject": "“{subject}” ਭੇਜਿਆ ਗਿਆ",
+ "compose.undoSend": "ਭੇਜਣਾ ਵਾਪਸ ਲਵੋ",
+ "compose.sendNow": "ਹੁਣੇ ਭੇਜੋ",
"compose.carriedOver": "ਅੱਗੇ ਭੇਜੇ ਸੁਨੇਹੇ ਤੋਂ ਲਿਆਂਦਾ ਗਿਆ",
"compose.removeAttachment": "ਅਟੈਚਮੈਂਟ ਹਟਾਓ",
"compose.cloudWarning.will": "Cloudflare ਏਨਕੋਡਿੰਗ ਸਮੇਤ ਆਮ ਈਮੇਲ ਸੁਨੇਹਿਆਂ ਨੂੰ 5 MiB ਤੱਕ ਸੀਮਤ ਕਰਦਾ ਹੈ। ਇੱਥੇ 3 MB ਤੋਂ ਵੱਡੀਆਂ ਫਾਈਲਾਂ 30 ਦਿਨ ਵੈਧ R2 ਡਾਊਨਲੋਡ ਲਿੰਕਾਂ ਵਜੋਂ ਭੇਜੀਆਂ ਜਾਣਗੀਆਂ।",
diff --git a/public/locales/pl.json b/public/locales/pl.json
index 5cf0837..9b2b9c6 100644
--- a/public/locales/pl.json
+++ b/public/locales/pl.json
@@ -202,6 +202,11 @@
"compose.error.totalSize": "Łączny rozmiar załączników nie może przekraczać {max} MB",
"compose.scheduled": "Zaplanowano wiadomość",
"compose.sent": "Wiadomość wysłana",
+ "compose.sendingIn": "Wysyłanie „{subject}” za {seconds} s",
+ "compose.sendingSubject": "Wysyłanie „{subject}”…",
+ "compose.sentSubject": "Wysłano „{subject}”",
+ "compose.undoSend": "Cofnij",
+ "compose.sendNow": "Wyślij teraz",
"compose.carriedOver": "Przeniesiono z przekazanej wiadomości",
"compose.removeAttachment": "Usuń załącznik",
"compose.cloudWarning.will": "Cloudflare ogranicza zwykłe wiadomości e-mail do 5 MiB, wliczając kodowanie. Pliki powyżej 3 MB zostaną tu wysłane jako linki do pobrania z R2 ważne 30 dni.",
diff --git a/public/locales/pt-BR.json b/public/locales/pt-BR.json
index 7a71073..0d18e4f 100644
--- a/public/locales/pt-BR.json
+++ b/public/locales/pt-BR.json
@@ -198,6 +198,11 @@
"compose.error.totalSize": "Os anexos devem somar {max} MB ou menos",
"compose.scheduled": "Mensagem agendada",
"compose.sent": "Mensagem enviada",
+ "compose.sendingIn": "Enviando “{subject}” em {seconds} s",
+ "compose.sendingSubject": "Enviando “{subject}”…",
+ "compose.sentSubject": "“{subject}” enviado",
+ "compose.undoSend": "Desfazer",
+ "compose.sendNow": "Enviar agora",
"compose.carriedOver": "Trazido da mensagem encaminhada",
"compose.removeAttachment": "Remover anexo",
"compose.cloudWarning.will": "A Cloudflare limita e-mails comuns a 5 MiB, incluindo a codificação. Arquivos acima de 3 MB aqui serão enviados como links de download R2 válidos por 30 dias.",
diff --git a/public/locales/pt-PT.json b/public/locales/pt-PT.json
index 5094093..23ef2a1 100644
--- a/public/locales/pt-PT.json
+++ b/public/locales/pt-PT.json
@@ -198,6 +198,11 @@
"compose.error.totalSize": "Os anexos devem somar {max} MB ou menos",
"compose.scheduled": "Mensagem agendada",
"compose.sent": "Mensagem enviada",
+ "compose.sendingIn": "A enviar “{subject}” em {seconds} s",
+ "compose.sendingSubject": "A enviar “{subject}”…",
+ "compose.sentSubject": "“{subject}” enviado",
+ "compose.undoSend": "Anular",
+ "compose.sendNow": "Enviar agora",
"compose.carriedOver": "Trazido da mensagem encaminhada",
"compose.removeAttachment": "Remover anexo",
"compose.cloudWarning.will": "A Cloudflare limita emails comuns a 5 MiB, incluindo a codificação. Ficheiros acima de 3 MB aqui serão enviados como links de download R2 válidos por 30 dias.",
diff --git a/public/locales/ru.json b/public/locales/ru.json
index a795527..7fc447a 100644
--- a/public/locales/ru.json
+++ b/public/locales/ru.json
@@ -202,6 +202,11 @@
"compose.error.totalSize": "Общий размер вложений не должен превышать {max} МБ",
"compose.scheduled": "Сообщение запланировано",
"compose.sent": "Сообщение отправлено",
+ "compose.sendingIn": "Отправка «{subject}» через {seconds} с",
+ "compose.sendingSubject": "Отправка «{subject}»…",
+ "compose.sentSubject": "«{subject}» отправлено",
+ "compose.undoSend": "Отменить",
+ "compose.sendNow": "Отправить сейчас",
"compose.carriedOver": "Перенесено из пересылаемого сообщения",
"compose.removeAttachment": "Удалить вложение",
"compose.cloudWarning.will": "Cloudflare ограничивает обычные письма 5 МиБ с учётом кодирования. Файлы размером более 3 МБ здесь будут отправлены в виде ссылок для скачивания R2, действующих 30 дней.",
diff --git a/public/locales/si.json b/public/locales/si.json
index 890dfe9..e9f0493 100644
--- a/public/locales/si.json
+++ b/public/locales/si.json
@@ -194,6 +194,11 @@
"compose.error.totalSize": "ඇමුණුම්වල මුළු ප්‍රමාණය {max} MB හෝ ඊට අඩු විය යුතුය",
"compose.scheduled": "පණිවිඩය කාලසටහන්ගත කරන ලදී",
"compose.sent": "පණිවිඩය යවන ලදී",
+ "compose.sendingIn": "“{subject}” තත්පර {seconds}කින් යවනු ලැබේ",
+ "compose.sendingSubject": "“{subject}” යවමින් පවතී...",
+ "compose.sentSubject": "“{subject}” යවන ලදී",
+ "compose.undoSend": "යැවීම අවලංගු කරන්න",
+ "compose.sendNow": "දැන් යවන්න",
"compose.carriedOver": "යොමු කළ පණිවිඩයෙන් ගෙන එන ලදී",
"compose.removeAttachment": "ඇමුණුම ඉවත් කරන්න",
"compose.cloudWarning.will": "Cloudflare විසින් සාමාන්‍ය ඊමේල් පණිවිඩ කේතනය ඇතුළුව 5 MiB දක්වා සීමා කරයි. මෙහි ඇති 3 MB ට වැඩි ගොනු දින 30ක බාගැනීම් සබැඳි ලෙස යවනු ලැබේ.",
diff --git a/public/locales/sw.json b/public/locales/sw.json
index b2f15f8..23f83ff 100644
--- a/public/locales/sw.json
+++ b/public/locales/sw.json
@@ -194,6 +194,11 @@
"compose.error.totalSize": "Jumla ya viambatisho lazima iwe MB {max} au chini",
"compose.scheduled": "Ujumbe umepangwa kutumwa",
"compose.sent": "Ujumbe umetumwa",
+ "compose.sendingIn": "Inatuma “{subject}” baada ya sekunde {seconds}",
+ "compose.sendingSubject": "Inatuma “{subject}”...",
+ "compose.sentSubject": "“{subject}” imetumwa",
+ "compose.undoSend": "Tendua",
+ "compose.sendNow": "Tuma sasa",
"compose.carriedOver": "Imehamishwa kutoka kwenye ujumbe uliosambazwa",
"compose.removeAttachment": "Ondoa kiambatisho",
"compose.cloudWarning.will": "Cloudflare inapunguza jumbe za kawaida za barua pepe hadi MiB 5 ikijumuisha usimbaji. Faili zinazozidi MB 3 hapa zitatumwa kama viungo vya kupakua vya R2 vinavyodumu siku 30.",
diff --git a/public/locales/ta.json b/public/locales/ta.json
index 7a45057..f309935 100644
--- a/public/locales/ta.json
+++ b/public/locales/ta.json
@@ -194,6 +194,11 @@
"compose.error.totalSize": "இணைப்புகளின் மொத்த அளவு {max} MB அல்லது அதற்கும் குறைவாக இருக்க வேண்டும்",
"compose.scheduled": "செய்தி திட்டமிடப்பட்டது",
"compose.sent": "செய்தி அனுப்பப்பட்டது",
+ "compose.sendingIn": "“{subject}” {seconds} வினாடிகளில் அனுப்பப்படுகிறது",
+ "compose.sendingSubject": "“{subject}” அனுப்பப்படுகிறது...",
+ "compose.sentSubject": "“{subject}” அனுப்பப்பட்டது",
+ "compose.undoSend": "திரும்பப் பெறு",
+ "compose.sendNow": "இப்போதே அனுப்பு",
"compose.carriedOver": "முன்னனுப்பிய செய்தியிலிருந்து கொண்டுவரப்பட்டது",
"compose.removeAttachment": "இணைப்பை அகற்று",
"compose.cloudWarning.will": "குறியாக்கம் உட்பட, பொது மின்னஞ்சல் செய்திகளை Cloudflare 5 MiB ஆக வரையறுக்கிறது. இங்கு 3 MB க்கு மேற்பட்ட கோப்புகள் 30 நாட்கள் செல்லுபடியாகும் R2 பதிவிறக்க இணைப்புகளாக அனுப்பப்படும்.",
diff --git a/public/locales/te.json b/public/locales/te.json
index 2d86f76..bca90db 100644
--- a/public/locales/te.json
+++ b/public/locales/te.json
@@ -194,6 +194,11 @@
"compose.error.totalSize": "అటాచ్‌మెంట్‌ల మొత్తం {max} MB లేదా అంతకంటే తక్కువ ఉండాలి",
"compose.scheduled": "సందేశం షెడ్యూల్ చేయబడింది",
"compose.sent": "సందేశం పంపబడింది",
+ "compose.sendingIn": "“{subject}” {seconds} సెకన్లలో పంపబడుతోంది",
+ "compose.sendingSubject": "“{subject}” పంపబడుతోంది...",
+ "compose.sentSubject": "“{subject}” పంపబడింది",
+ "compose.undoSend": "వెనక్కి తీసుకోండి",
+ "compose.sendNow": "ఇప్పుడే పంపండి",
"compose.carriedOver": "ఫార్వర్డ్ చేసిన సందేశం నుండి తీసుకురాబడింది",
"compose.removeAttachment": "అటాచ్‌మెంట్‌ను తీసివేయండి",
"compose.cloudWarning.will": "Cloudflare ఎన్‌కోడింగ్‌తో సహా సాధారణ ఇమెయిల్ సందేశాలను 5 MiB కు పరిమితం చేస్తుంది. ఇక్కడ 3 MB కంటే పెద్ద ఫైళ్లు 30 రోజుల R2 డౌన్‌లోడ్ లింక్‌లుగా పంపబడతాయి.",
diff --git a/public/locales/th.json b/public/locales/th.json
index 4161471..3d6e087 100644
--- a/public/locales/th.json
+++ b/public/locales/th.json
@@ -194,6 +194,11 @@
"compose.error.totalSize": "ไฟล์แนบรวมกันต้องไม่เกิน {max} MB",
"compose.scheduled": "ตั้งเวลาส่งข้อความแล้ว",
"compose.sent": "ส่งข้อความแล้ว",
+ "compose.sendingIn": "กำลังส่ง “{subject}” ในอีก {seconds} วินาที",
+ "compose.sendingSubject": "กำลังส่ง “{subject}”...",
+ "compose.sentSubject": "ส่ง “{subject}” แล้ว",
+ "compose.undoSend": "เลิกทำ",
+ "compose.sendNow": "ส่งทันที",
"compose.carriedOver": "นำมาจากข้อความที่ส่งต่อ",
"compose.removeAttachment": "ลบไฟล์แนบ",
"compose.cloudWarning.will": "Cloudflare จำกัดอีเมลทั่วไปไว้ที่ 5 MiB รวมการเข้ารหัส ไฟล์ที่เกิน 3 MB ที่นี่จะถูกส่งเป็นลิงก์ดาวน์โหลด R2 ที่ใช้ได้ 30 วัน",
diff --git a/public/locales/tr.json b/public/locales/tr.json
index 87552c6..c1f1d5d 100644
--- a/public/locales/tr.json
+++ b/public/locales/tr.json
@@ -192,6 +192,11 @@
"compose.error.totalSize": "Eklerin toplamı {max} MB veya daha az olmalıdır",
"compose.scheduled": "İleti zamanlandı",
"compose.sent": "İleti gönderildi",
+ "compose.sendingIn": "\"{subject}\" {seconds} sn içinde gönderiliyor",
+ "compose.sendingSubject": "\"{subject}\" gönderiliyor…",
+ "compose.sentSubject": "\"{subject}\" gönderildi",
+ "compose.undoSend": "Geri al",
+ "compose.sendNow": "Şimdi gönder",
"compose.carriedOver": "İletilen iletiden aktarıldı",
"compose.removeAttachment": "Eki kaldır",
"compose.cloudWarning.will": "Cloudflare, kodlama dahil genel e-posta iletilerini 5 MiB ile sınırlar. Burada 3 MB'tan büyük dosyalar, 30 gün geçerli R2 indirme bağlantıları olarak gönderilir.",
diff --git a/public/locales/uk.json b/public/locales/uk.json
index 8e8dd01..0198855 100644
--- a/public/locales/uk.json
+++ b/public/locales/uk.json
@@ -202,6 +202,11 @@
"compose.error.totalSize": "Загальний розмір вкладень має бути не більше {max} МБ",
"compose.scheduled": "Повідомлення заплановано",
"compose.sent": "Повідомлення надіслано",
+ "compose.sendingIn": "Надсилання «{subject}» через {seconds} с",
+ "compose.sendingSubject": "Надсилання «{subject}»…",
+ "compose.sentSubject": "«{subject}» надіслано",
+ "compose.undoSend": "Скасувати",
+ "compose.sendNow": "Надіслати зараз",
"compose.carriedOver": "Перенесено з пересланого повідомлення",
"compose.removeAttachment": "Видалити вкладення",
"compose.cloudWarning.will": "Cloudflare обмежує звичайні листи до 5 МіБ разом із кодуванням. Файли понад 3 МБ тут буде надіслано як посилання для завантаження з R2, чинні 30 днів.",
diff --git a/public/locales/ur.json b/public/locales/ur.json
index 367ebe0..74190af 100644
--- a/public/locales/ur.json
+++ b/public/locales/ur.json
@@ -194,6 +194,11 @@
"compose.error.totalSize": "منسلکات کا کل سائز {max} MB یا اس سے کم ہونا چاہیے",
"compose.scheduled": "پیغام شیڈول ہو گیا",
"compose.sent": "پیغام بھیج دیا گیا",
+ "compose.sendingIn": "“{subject}” {seconds} سیکنڈ میں بھیجا جا رہا ہے",
+ "compose.sendingSubject": "“{subject}” بھیجا جا رہا ہے...",
+ "compose.sentSubject": "“{subject}” بھیج دیا گیا",
+ "compose.undoSend": "منسوخ کریں",
+ "compose.sendNow": "ابھی بھیجیں",
"compose.carriedOver": "آگے بھیجے گئے پیغام سے لایا گیا",
"compose.removeAttachment": "منسلکہ ہٹائیں",
"compose.cloudWarning.will": "Cloudflare انکوڈنگ سمیت عام ای میل پیغامات کو 5 MiB تک محدود کرتا ہے۔ یہاں 3 MB سے بڑی فائلیں 30 دن کی میعاد والے R2 ڈاؤن لوڈ لنکس کے طور پر بھیجی جائیں گی۔",
diff --git a/public/locales/vi.json b/public/locales/vi.json
index fcc8fd3..e012148 100644
--- a/public/locales/vi.json
+++ b/public/locales/vi.json
@@ -190,6 +190,11 @@
"compose.error.totalSize": "Tổng dung lượng tệp đính kèm phải từ {max} MB trở xuống",
"compose.scheduled": "Đã lên lịch gửi thư",
"compose.sent": "Đã gửi thư",
+ "compose.sendingIn": "Đang gửi “{subject}” sau {seconds} giây",
+ "compose.sendingSubject": "Đang gửi “{subject}”...",
+ "compose.sentSubject": "Đã gửi “{subject}”",
+ "compose.undoSend": "Hoàn tác",
+ "compose.sendNow": "Gửi ngay",
"compose.carriedOver": "Được mang theo từ thư chuyển tiếp",
"compose.removeAttachment": "Gỡ tệp đính kèm",
"compose.cloudWarning.will": "Cloudflare giới hạn thư email thông thường ở mức 5 MiB, bao gồm cả mã hóa. Các tệp trên 3 MB ở đây sẽ được gửi dưới dạng liên kết tải xuống R2 có hiệu lực 30 ngày.",
diff --git a/public/locales/zh-CN.json b/public/locales/zh-CN.json
index 95196a3..846bc2e 100644
--- a/public/locales/zh-CN.json
+++ b/public/locales/zh-CN.json
@@ -190,6 +190,11 @@
"compose.error.totalSize": "附件总大小不得超过 {max} MB",
"compose.scheduled": "邮件已定时发送",
"compose.sent": "邮件已发送",
+ "compose.sendingIn": "“{subject}”将在 {seconds} 秒后发送",
+ "compose.sendingSubject": "正在发送“{subject}”...",
+ "compose.sentSubject": "已发送“{subject}”",
+ "compose.undoSend": "撤销",
+ "compose.sendNow": "立即发送",
"compose.carriedOver": "已从转发的邮件中带入",
"compose.removeAttachment": "移除附件",
"compose.cloudWarning.will": "Cloudflare 将普通邮件(含编码)限制为 5 MiB。此处超过 3 MB 的文件将以 30 天有效的 R2 下载链接发送。",
diff --git a/src/app/(dashboard)/inbox/[messageId]/page.tsx b/src/app/(dashboard)/inbox/[messageId]/page.tsx
index a53fb0b..9a3eb14 100644
--- a/src/app/(dashboard)/inbox/[messageId]/page.tsx
+++ b/src/app/(dashboard)/inbox/[messageId]/page.tsx
@@ -45,12 +45,14 @@ import { useRemoteContent } from "@/components/messages/use-remote-content";
import clsx from "clsx";
import { useAssistantOpen } from "@/components/agent/assistant-open-state";
import { useMessageContentScroll } from "./use-message-content-scroll";
+import { useSendViewStatus } from "@/components/messages/use-send-view-status";
export default function MessageDetailPage() {
const { t } = useLanguage();
const params = useParams<{ messageId: string }>();
const { selectedMailbox, mailboxes } = useSelectedMailbox();
const messageId = params.messageId;
+ useSendViewStatus(messageId);
const [data, setData] = useState<MessageDetailResponse | null>(null);
const [loading, setLoading] = useState(true);
const [previewAttachment, setPreviewAttachment] =
@@ -88,7 +90,7 @@ export default function MessageDetailPage() {
return;
}
setLoading(true);
- const nextData = await fetchMessageDetail(messageId);
+ const nextData = await fetchMessageDetail(messageId).catch(() => fetchMessageDetail(messageId)).catch(() => ({ error: t("message.notFound") }));
if (!cancelled) {
setData(nextData);
setLoading(false);
@@ -387,4 +389,3 @@ export default function MessageDetailPage() {
</>
);
}
-
diff --git a/src/app/api/messages/[messageId]/send-now/route.ts b/src/app/api/messages/[messageId]/send-now/route.ts
new file mode 100644
index 0000000..d8b8dd3
--- /dev/null
+++ b/src/app/api/messages/[messageId]/send-now/route.ts
@@ -0,0 +1,49 @@
+import { eq } from "drizzle-orm";
+import { NextResponse } from "next/server";
+import { getDb } from "@/db";
+import { messages } from "@/db/schema";
+import { getCurrentUser } from "@/lib/auth/cookies";
+import { getEnv } from "@/lib/cloudflare";
+import { getMailboxAccessLevel } from "@/lib/mailboxes/access";
+import { sendScheduledMessageNow } from "@/lib/email/send";
+
+/**
+ * Sends a queued message now instead of waiting for its undo window or scheduled time.
+ * The job is claimed before delivery, so the queued send cannot also deliver it.
+ */
+export async function POST(
+ request: Request,
+ { params }: { params: Promise<{ messageId: string }> },
+) {
+ const { messageId } = await params;
+ const env = getEnv();
+ const user = await getCurrentUser(env, request);
+ if (!user) return NextResponse.json({ error: "Unauthorized" }, { status: 401 });
+
+ const db = getDb(env);
+ const [message] = await db
+ .select({ id: messages.id, mailboxId: messages.mailboxId, direction: messages.direction, status: messages.status })
+ .from(messages)
+ .where(eq(messages.id, messageId))
+ .limit(1);
+ if (!message?.mailboxId) return NextResponse.json({ error: "Message not found" }, { status: 404 });
+
+ const access = await getMailboxAccessLevel(db, user, message.mailboxId);
+ if (!access?.canRead) return NextResponse.json({ error: "Message not found" }, { status: 404 });
+ if (!access.canSendAs && !access.canSendOnBehalf) {
+ return NextResponse.json({ error: "You cannot send from this mailbox" }, { status: 403 });
+ }
+
+ if (message.direction !== "outbound" || message.status !== "queued") {
+ return NextResponse.json({ error: "This message is already on its way" }, { status: 409 });
+ }
+ try {
+ if (!(await sendScheduledMessageNow(env, message.id))) {
+ return NextResponse.json({ error: "This message is already on its way" }, { status: 409 });
+ }
+ } catch (error) {
+ const detail = error instanceof Error ? error.message : "Send failed";
+ return NextResponse.json({ error: detail }, { status: 500 });
+ }
+ return NextResponse.json({ ok: true });
+}
diff --git a/src/app/api/messages/[messageId]/send-status/route.ts b/src/app/api/messages/[messageId]/send-status/route.ts
new file mode 100644
index 0000000..d478c2f
--- /dev/null
+++ b/src/app/api/messages/[messageId]/send-status/route.ts
@@ -0,0 +1,34 @@
+import { eq } from "drizzle-orm";
+import { NextResponse } from "next/server";
+import { getDb } from "@/db";
+import { messages } from "@/db/schema";
+import { getCurrentUser } from "@/lib/auth/cookies";
+import { getEnv } from "@/lib/cloudflare";
+import { getMailboxAccessLevel } from "@/lib/mailboxes/access";
+
+/**
+ * Lightweight delivery status for the compose toast. It deliberately returns only
+ * the message status so polling does not load the body, attachments or thread.
+ */
+export async function GET(
+ request: Request,
+ { params }: { params: Promise<{ messageId: string }> },
+) {
+ const { messageId } = await params;
+ const env = getEnv();
+ const user = await getCurrentUser(env, request);
+ if (!user) return NextResponse.json({ error: "Unauthorized" }, { status: 401 });
+
+ const db = getDb(env);
+ const [message] = await db
+ .select({ mailboxId: messages.mailboxId, status: messages.status })
+ .from(messages)
+ .where(eq(messages.id, messageId))
+ .limit(1);
+ if (!message?.mailboxId) return NextResponse.json({ error: "Message not found" }, { status: 404 });
+
+ const access = await getMailboxAccessLevel(db, user, message.mailboxId);
+ if (!access?.canRead) return NextResponse.json({ error: "Message not found" }, { status: 404 });
+
+ return NextResponse.json({ status: message.status }, { headers: { "Cache-Control": "no-store" } });
+}
diff --git a/src/components/compose/compose-context.tsx b/src/components/compose/compose-context.tsx
index 4ba2e90..5655fea 100644
--- a/src/components/compose/compose-context.tsx
+++ b/src/components/compose/compose-context.tsx
@@ -2,6 +2,27 @@
import { createContext, useContext, useEffect, useRef, useState } from "react";
import type { ReactNode } from "react";
+import type { SendNoticeParts } from "./send-notice-utils";
+
+export type ComposeNoticeAction = { label: string; onClick: () => void | Promise<void> };
+
+export type ComposeNoticePoll = {
+ messageId: string;
+ /** Called once the message is sent, failed or returned to Drafts. */
+ onStatus: (status: "sent" | "failed" | "cancelled") => void;
+};
+
+export type ComposeNoticeOptions = {
+ actions?: ComposeNoticeAction[];
+ parts?: SendNoticeParts;
+ tone?: "success" | "error";
+ durationMs?: number;
+ countdown?: { endAt: number };
+ /** Called once when the countdown reaches zero; the callback decides what replaces the toast. */
+ onCountdownEnd?: () => void;
+ /** Polls the message's delivery status while the toast is visible. */
+ poll?: ComposeNoticePoll;
+};
type ComposeContextValue = {
open: boolean;
@@ -10,14 +31,22 @@ type ComposeContextValue = {
openDraftComposer: (draftId: string) => void;
closeComposer: () => void;
notice: ComposeNotice | null;
- /** Shows a toast; `action` adds a button, `durationMs` overrides the default 3.2s. */
- showNotice: (message: string | null, options?: { action?: { label: string; onClick: () => void }; durationMs?: number }) => void;
+ /** Shows a toast and returns its id; `actions` adds buttons, `durationMs` overrides the default 3.2s. */
+ showNotice: (message: string | null, options?: ComposeNoticeOptions) => number | null;
+ /** Whether a notice id is still the latest one; async actions use it to avoid replacing a newer toast. */
+ isCurrentNotice: (id: number) => boolean;
};
export type ComposeNotice = {
+ id: number;
message: string;
- action?: { label: string; onClick: () => void };
+ parts?: SendNoticeParts;
+ actions: ComposeNoticeAction[];
+ tone: "success" | "error";
durationMs: number;
+ countdown?: { endAt: number };
+ onCountdownEnd?: () => void;
+ poll?: ComposeNoticePoll;
};
const ComposeContext = createContext<ComposeContextValue | null>(null);
@@ -37,10 +66,15 @@ export function ComposeProvider({ children }: { children: ReactNode }) {
opener.current = document.activeElement instanceof HTMLElement ? document.activeElement : null;
}
const [notice, setNotice] = useState<ComposeNotice | null>(null);
+ const noticeId = useRef(0);
useEffect(() => {
if (!notice) return;
- const timer = setTimeout(() => setNotice(null), notice.durationMs);
+ // A countdown notice normally replaces itself when it reaches zero. The extra
+ // grace keeps that transition ahead of dismissal and still clears the notice if
+ // the layout has no toast mounted.
+ const timeout = Math.max(0, notice.durationMs) + (notice.onCountdownEnd ? 2000 : 0);
+ const timer = setTimeout(() => setNotice(null), timeout);
return () => clearTimeout(timer);
}, [notice]);
@@ -67,7 +101,22 @@ export function ComposeProvider({ children }: { children: ReactNode }) {
if (previous) requestAnimationFrame(() => { if (previous.isConnected) previous.focus(); });
},
notice,
- showNotice: (message, options) => setNotice(message ? { message, action: options?.action, durationMs: options?.durationMs ?? 3200 } : null),
+ showNotice: (message, options) => {
+ const id = ++noticeId.current;
+ setNotice(message ? {
+ id,
+ message,
+ parts: options?.parts,
+ actions: options?.actions ?? [],
+ tone: options?.tone ?? "success",
+ durationMs: options?.durationMs ?? 3200,
+ countdown: options?.countdown,
+ onCountdownEnd: options?.onCountdownEnd,
+ poll: options?.poll,
+ } : null);
+ return message ? id : null;
+ },
+ isCurrentNotice: (id) => noticeId.current === id,
}}
>
{children}
diff --git a/src/components/compose/compose-form.tsx b/src/components/compose/compose-form.tsx
index fd211fa..61600a5 100644
--- a/src/components/compose/compose-form.tsx
+++ b/src/components/compose/compose-form.tsx
@@ -13,6 +13,7 @@ import { Tooltip } from "@/components/ui/tooltip";
import { useSelectedMailbox } from "@/components/mailbox-provider";
import { authFetch } from "@/lib/auth/client";
import { formatEmailAddress, getEmailAddress } from "@/lib/email/address";
+import { clearMessageDetailCache } from "@/lib/messages/detail-cache";
import { useCompose } from "@/components/compose/compose-context";
import { cn } from "@/lib/utils";
import { SendReview } from "@/components/agent/send-review";
@@ -22,11 +23,14 @@ import { useSheetViewport } from "./use-sheet-viewport";
import { useTrackOpens } from "./use-track-opens";
import { FollowUpMenu } from "@/components/follow-ups/follow-up-menu";
import { followUpOptionKey } from "@/components/follow-ups/follow-up-client-utils";
+import { formatScheduledSendTime } from "@/components/messages/scheduled-send-utils";
import { buildSendFormData, fetchDraft, formatAttachmentSize } from "./utils";
import { RecipientInput } from "./recipient-input";
import { RichTextEditor } from "./rich-text-editor";
import { ScheduleSendMenu } from "./schedule-send-menu";
import { isPastSchedule } from "./schedule-send-utils";
+import { DELIVERY_WAIT_MS, SCHEDULED_NOTICE_MS, SENT_NOTICE_MS, resolveSendNotice, splitSendTemplate } from "./send-notice-utils";
+import type { SendNoticeParts, SendResult } from "./send-notice-utils";
import {
applyMailboxSignatureHtml,
hasMeaningfulHtml,
@@ -52,7 +56,7 @@ export function ComposeForm({
}) {
const { t } = useLanguage();
const router = useRouter();
- const { showNotice, openDraftComposer } = useCompose();
+ const { showNotice, openDraftComposer, isCurrentNotice } = useCompose();
const { selectedMailbox, setSelectedMailbox, mailboxes } = useSelectedMailbox();
const [draftId, setDraftId] = useState<string | null>(null);
const [agentRevision, setAgentRevision] = useState<number | null>(null);
@@ -91,6 +95,7 @@ export function ComposeForm({
const [closing, setClosing] = useState(false);
const dragStart = useRef<number | null>(null);
const [dragY, setDragY] = useState(0);
+ const noticeActionInFlight = useRef(false);
// Phones: slide the sheet away and let the page behind grow back before unmounting.
function dismiss() {
@@ -381,7 +386,7 @@ export function ComposeForm({
return;
}
let res: Response;
- let data: { messageId?: string; scheduled?: boolean; undoSeconds?: number; error?: string };
+ let data: SendResult & { error?: string };
try {
res = await authFetch("/api/send", {
method: "POST",
@@ -403,7 +408,7 @@ export function ComposeForm({
followUpDays,
}),
});
- data = (await res.json()) as { messageId?: string; scheduled?: boolean; undoSeconds?: number; error?: string };
+ data = (await res.json()) as SendResult & { error?: string };
} catch {
setLoading(false);
setToast({ type: "error", message: t("compose.error.sendFailed") });
@@ -434,17 +439,39 @@ export function ComposeForm({
setQuotedHtml(null);
setAttachments([]);
setScheduledAt(null);
- const sentMessageId = data.messageId;
- if (data.undoSeconds && sentMessageId) {
- // The send is queued for the undo window; Cancel puts the message back in Drafts and reopens it.
- showNotice(t("compose.sent"), {
- durationMs: data.undoSeconds * 1000,
- action: { label: t("compose.cancelSend"), onClick: () => void cancelSend(sentMessageId) },
- });
- // Refresh the lists once the queue has had time to deliver it.
- setTimeout(() => window.dispatchEvent(new Event("mailflare:messages-changed")), (data.undoSeconds + 3) * 1000);
+ const notice = resolveSendNotice(data);
+ const subjectLabel = subject.trim() || t("list.noSubject");
+ if (notice.kind === "undo") {
+ const content = buildSubjectNotice("compose.sendingIn", subjectLabel, notice.messageId, true);
+ let undoNoticeId = 0;
+ // The send is queued for the undo window; Undo returns it to Drafts and Send now skips the wait.
+ undoNoticeId = showNotice(content.message, {
+ parts: content.parts,
+ durationMs: notice.durationMs,
+ countdown: { endAt: notice.endAt },
+ // Delivery starts after the window; keep watching until the queue reports a result.
+ onCountdownEnd: () => {
+ if (!isCurrentNotice(undoNoticeId) || noticeActionInFlight.current) return;
+ showSendingNotice(notice.messageId, subjectLabel);
+ },
+ actions: [
+ { label: t("compose.undoSend"), onClick: () => cancelSend(notice.messageId, "undo", undoNoticeId) },
+ { label: t("compose.sendNow"), onClick: () => sendNow(notice.messageId, subjectLabel, undoNoticeId) },
+ ],
+ }) ?? 0;
+ } else if (notice.kind === "sending") {
+ showSendingNotice(notice.messageId, subjectLabel);
+ } else if (notice.kind === "scheduled") {
+ const message = notice.scheduledAt
+ ? t("schedule.sendScheduledFor", { when: formatScheduledSendTime(notice.scheduledAt, t) })
+ : t("compose.scheduled");
+ let scheduledNoticeId = 0;
+ scheduledNoticeId = showNotice(message, {
+ durationMs: SCHEDULED_NOTICE_MS,
+ actions: [{ label: t("schedule.cancelSend"), onClick: () => cancelSend(notice.messageId, "scheduled", scheduledNoticeId) }],
+ }) ?? 0;
} else {
- showNotice(data.scheduled ? t("compose.scheduled") : t("compose.sent"));
+ showNotice(t("compose.sent"));
}
if (!currentDraftId) refreshLists();
@@ -455,18 +482,120 @@ export function ComposeForm({
router.push("/sent");
}
- async function cancelSend(messageId: string) {
+ /**
+ * Splits a translated template around {subject} so the subject can link to the
+ * message, and around {seconds} so only the ticking suffix changes. Passing the
+ * placeholders back as values leaves them intact for the split.
+ *
+ * A message that is still queued is listed under Scheduled; only a delivered one
+ * lives in Sent, so the link follows the message's state.
+ */
+ function buildSubjectNotice(
+ key: "compose.sendingIn" | "compose.sendingSubject" | "compose.sentSubject",
+ subjectLabel: string,
+ messageId: string,
+ countdown: boolean,
+ ): { message: string; parts: SendNoticeParts } {
+ const template = t(key, { subject: "{subject}", seconds: "{seconds}" });
+ const href = key === "compose.sentSubject" ? `/sent/${messageId}` : `/scheduled/${messageId}`;
+ const parts: SendNoticeParts = {
+ ...splitSendTemplate(template, countdown),
+ link: { label: subjectLabel, href },
+ };
+ return { message: t(key, { subject: subjectLabel, seconds: 1 }), parts };
+ }
+
+ /** Shows the message while the queue delivers it and watches for the final status. */
+ function showSendingNotice(messageId: string, subjectLabel: string): number {
+ const content = buildSubjectNotice("compose.sendingSubject", subjectLabel, messageId, false);
+ let noticeId = 0;
+ noticeId = showNotice(content.message, {
+ parts: content.parts,
+ durationMs: DELIVERY_WAIT_MS,
+ poll: {
+ messageId,
+ onStatus: (status) => {
+ if (status === "sent") {
+ // Delivered: refresh the lists even if a newer toast has taken over.
+ showSentNotice(messageId, subjectLabel, noticeId);
+ return;
+ }
+ if (!isCurrentNotice(noticeId)) return;
+ if (status === "failed") showNotice(t("compose.error.sendFailed"), { tone: "error" });
+ else showNotice(null);
+ },
+ },
+ }) ?? 0;
+ return noticeId;
+ }
+
+ function showSentNotice(messageId: string, subjectLabel: string, sourceNoticeId: number) {
+ // The message is delivered, so the lists and the cached detail are stale
+ // whichever toast is on screen; refresh them before the notice check.
+ clearMessageDetailCache();
+ window.dispatchEvent(new Event("mailflare:messages-changed"));
+ if (!isCurrentNotice(sourceNoticeId)) return;
+ const content = buildSubjectNotice("compose.sentSubject", subjectLabel, messageId, false);
+ showNotice(content.message, { parts: content.parts, durationMs: SENT_NOTICE_MS });
+ }
+
+ async function sendNow(messageId: string, subjectLabel: string, sourceNoticeId: number) {
+ if (noticeActionInFlight.current) return;
+ noticeActionInFlight.current = true;
+ try {
+ const response = await authFetch(`/api/messages/${messageId}/send-now`, { method: "POST" });
+ if (response.ok) {
+ // The message is on its way: refresh the lists even if a newer toast has taken over.
+ showSentNotice(messageId, subjectLabel, sourceNoticeId);
+ return;
+ }
+ if (!isCurrentNotice(sourceNoticeId)) return;
+ if (response.status === 409) {
+ // The queued delivery claimed the message first; watch it instead of failing.
+ showSendingNotice(messageId, subjectLabel);
+ return;
+ }
+ if (response.status >= 500) {
+ // The request may have failed before claiming the job; the scheduled send can
+ // still deliver later, so let the status poll decide instead of reporting failure.
+ showSendingNotice(messageId, subjectLabel);
+ return;
+ }
+ const result = await response.json().catch(() => ({})) as { error?: string };
+ if (!isCurrentNotice(sourceNoticeId)) return;
+ showNotice(result.error ?? t("compose.error.sendFailed"), { tone: "error" });
+ } catch {
+ // A dropped response is ambiguous: the message may still be on its way.
+ if (isCurrentNotice(sourceNoticeId)) showSendingNotice(messageId, subjectLabel);
+ } finally {
+ noticeActionInFlight.current = false;
+ }
+ }
+
+ async function cancelSend(messageId: string, source: "undo" | "scheduled", sourceNoticeId: number) {
+ if (noticeActionInFlight.current) return;
+ noticeActionInFlight.current = true;
try {
const res = await authFetch(`/api/messages/${messageId}/cancel-schedule`, { method: "POST" });
if (!res.ok) {
- showNotice(t("compose.cancelTooLate"));
+ if (!isCurrentNotice(sourceNoticeId)) return;
+ // A 409 on the undo toast means the queue claimed it; a scheduled send can also fail for other reasons.
+ showNotice(source === "undo" && res.status === 409 ? t("compose.cancelTooLate") : t("schedule.cancelFailed"), {
+ tone: "error",
+ });
return;
}
- showNotice(t("compose.sendCancelled"));
+ // The message is back in Drafts, so the lists and the cached detail are
+ // stale whichever toast is on screen; refresh them before the notice check.
+ clearMessageDetailCache();
window.dispatchEvent(new Event("mailflare:messages-changed"));
+ if (!isCurrentNotice(sourceNoticeId)) return;
+ showNotice(t("compose.sendCancelled"));
openDraftComposer(messageId);
} catch {
- showNotice(t("compose.cancelTooLate"));
+ if (isCurrentNotice(sourceNoticeId)) showNotice(t("schedule.cancelFailed"), { tone: "error" });
+ } finally {
+ noticeActionInFlight.current = false;
}
}
diff --git a/src/components/compose/floating-composer.tsx b/src/components/compose/floating-composer.tsx
index fac82f7..fe5aea8 100644
--- a/src/components/compose/floating-composer.tsx
+++ b/src/components/compose/floating-composer.tsx
@@ -1,11 +1,121 @@
"use client";
+import { useEffect, useRef, useState } from "react";
+import Link from "next/link";
import { MailPlus } from "@/components/icons";
import { usePathname, useRouter } from "next/navigation";
import { ComposeForm } from "@/components/compose/compose-form";
import { useCompose } from "@/components/compose/compose-context";
+import type { ComposeNotice, ComposeNoticeAction } from "@/components/compose/compose-context";
import { useSidebar } from "@/components/sidebar-state";
import { useLanguage } from "@/components/language-provider";
+import { authFetch } from "@/lib/auth/client";
+import { cn } from "@/lib/utils";
+
+const STATUS_POLL_MS = 1000;
+
+function ComposeNoticeToast({ notice }: { notice: ComposeNotice }) {
+ const [now, setNow] = useState(() => Date.now());
+ const [pendingAction, setPendingAction] = useState<string | null>(null);
+ const countdownEnded = useRef(false);
+ const countdown = notice.countdown;
+ const parts = notice.parts;
+ useEffect(() => {
+ if (!countdown) return;
+ const timer = window.setInterval(() => setNow(Date.now()), 250);
+ return () => window.clearInterval(timer);
+ }, [countdown]);
+ useEffect(() => {
+ if (!countdown || !notice.onCountdownEnd || countdownEnded.current) return;
+ if (now < countdown.endAt) return;
+ countdownEnded.current = true;
+ notice.onCountdownEnd();
+ }, [countdown, notice, now]);
+
+ // Delivery is asynchronous after the countdown; watch the persisted status instead of guessing.
+ useEffect(() => {
+ const poll = notice.poll;
+ if (!poll) return;
+ let cancelled = false;
+ let timer: number | undefined;
+ const check = async () => {
+ if (cancelled) return;
+ try {
+ const response = await authFetch(`/api/messages/${poll.messageId}/send-status`);
+ if (cancelled) return;
+ if (response.ok) {
+ const data = await response.json() as { status?: string };
+ if (data.status === "sent") { poll.onStatus("sent"); return; }
+ if (data.status === "failed") { poll.onStatus("failed"); return; }
+ if (data.status === "draft") { poll.onStatus("cancelled"); return; }
+ }
+ } catch {
+ // A transient poll failure keeps the toast waiting until the next attempt.
+ }
+ if (!cancelled) timer = window.setTimeout(() => void check(), STATUS_POLL_MS);
+ };
+ void check();
+ return () => {
+ cancelled = true;
+ if (timer) window.clearTimeout(timer);
+ };
+ }, [notice.poll]);
+
+ const secondsLeft = countdown ? Math.max(0, Math.ceil((countdown.endAt - now) / 1000)) : null;
+ const ticker = parts?.ticker && secondsLeft !== null ? parts.ticker(secondsLeft) : null;
+
+ async function runAction(action: ComposeNoticeAction) {
+ if (pendingAction) return;
+ const result = action.onClick();
+ if (!(result instanceof Promise)) return;
+ setPendingAction(action.label);
+ try {
+ await result;
+ } finally {
+ setPendingAction(null);
+ }
+ }
+
+ return (
+ <div
+ role="status"
+ aria-atomic="false"
+ className={cn(
+ "fixed right-6 top-6 z-[60] flex max-w-[calc(100vw-3rem)] items-center gap-4 rounded-lg px-4 py-3 text-sm font-medium text-white shadow-lg",
+ notice.tone === "error" ? "bg-red-600" : "bg-green-600",
+ )}
+ >
+ <span className="min-w-0 break-words">
+ {parts ? (
+ <>
+ {parts.before}
+ {parts.link && (
+ // The underline follows the text colour so it stays legible on
+ // both the success and the error toast, hover included.
+ <Link href={parts.link.href} className="underline decoration-current underline-offset-2 hover:decoration-current">
+ {parts.link.label}
+ </Link>
+ )}
+ {parts.after}
+ {/* The countdown changes every second; keep it out of the live region. */}
+ {ticker !== null && <span aria-live="off">{ticker}</span>}
+ </>
+ ) : notice.message}
+ </span>
+ {notice.actions.map((action) => (
+ <button
+ key={action.label}
+ type="button"
+ onClick={() => void runAction(action)}
+ disabled={pendingAction !== null}
+ className="shrink-0 rounded-md bg-white/20 px-2.5 py-1 font-semibold hover:bg-white/30 disabled:cursor-wait disabled:opacity-60"
+ >
+ {action.label}
+ </button>
+ ))}
+ </div>
+ );
+}
/** `showButton` adds the phone Compose button; only the dashboard pages (mail) pass it. */
export function FloatingComposer({ showButton = false }: { showButton?: boolean }) {
@@ -27,16 +137,7 @@ export function FloatingComposer({ showButton = false }: { showButton?: boolean
{t("navigation.compose")}
</button>
)}
- {notice && (
- <div role="status" className="fixed right-6 top-6 z-[60] flex items-center gap-4 rounded-lg bg-green-600 px-4 py-3 text-sm font-medium text-white shadow-lg">
- {notice.message}
- {notice.action && (
- <button type="button" onClick={notice.action.onClick} className="rounded-md bg-white/20 px-2.5 py-1 font-semibold hover:bg-white/30">
- {notice.action.label}
- </button>
- )}
- </div>
- )}
+ {notice && <ComposeNoticeToast key={notice.id} notice={notice} />}
{open && <ComposeForm key={draftId ?? "new"} mode="popup" draftIdToLoad={draftId} onClose={() => {
closeComposer();
if (/^\/drafts\/[^/]+\/?$/.test(pathname)) router.replace("/drafts");
diff --git a/src/components/compose/send-notice-utils.ts b/src/components/compose/send-notice-utils.ts
new file mode 100644
index 0000000..5bd80b0
--- /dev/null
+++ b/src/components/compose/send-notice-utils.ts
@@ -0,0 +1,79 @@
+export type SendResult = {
+ messageId?: string;
+ scheduled?: boolean;
+ undoSeconds?: number;
+ undoRemainingMs?: number;
+ scheduledAt?: string;
+};
+
+export type SendNoticePlan =
+ | { kind: "undo"; messageId: string; endAt: number; durationMs: number }
+ | { kind: "sending"; messageId: string }
+ | { kind: "scheduled"; messageId: string; scheduledAt: string | null }
+ | { kind: "sent" };
+
+/** A scheduled-send toast carries a cancel action, so give it longer than the 3.2s default. */
+export const SCHEDULED_NOTICE_MS = 8000;
+/** Confirmation toasts carry a link, so leave enough time to notice and click it. */
+export const SENT_NOTICE_MS = 8000;
+/** How long the toast waits for the queue to report a delivered or failed message. */
+export const DELIVERY_WAIT_MS = 30_000;
+
+const SUBJECT_TOKEN = "{subject}";
+const SECONDS_TOKEN = "{seconds}";
+
+export type SendNoticeParts = {
+ /** Text before the subject, including its opening punctuation. */
+ before: string;
+ /** Text after the subject and any countdown, including closing punctuation. */
+ after: string;
+ /** The linked subject label and destination. */
+ link?: { label: string; href: string };
+ /** Renders the ticking seconds and whatever follows them. */
+ ticker?: (secondsLeft: number) => string;
+};
+
+/**
+ * Splits a message template around `{subject}` so the subject can be a link, and
+ * around `{seconds}` so only the ticking suffix changes while the toast is live.
+ *
+ * Pass the catalog entry with its placeholders intact, for example
+ * `t("compose.sendingIn", { subject: "{subject}", seconds: "{seconds}" })`.
+ */
+export function splitSendTemplate(template: string, countdown: boolean): SendNoticeParts {
+ const subjectAt = template.indexOf(SUBJECT_TOKEN);
+ const before = subjectAt >= 0 ? template.slice(0, subjectAt) : template;
+ const rest = subjectAt >= 0 ? template.slice(subjectAt + SUBJECT_TOKEN.length) : "";
+ if (!countdown) return { before, after: rest };
+
+ const secondsAt = rest.indexOf(SECONDS_TOKEN);
+ if (secondsAt < 0) return { before, after: rest };
+ return {
+ before,
+ after: rest.slice(0, secondsAt),
+ ticker: (secondsLeft) => `${secondsLeft}${rest.slice(secondsAt + SECONDS_TOKEN.length)}`,
+ };
+}
+
+/**
+ * Decides which toast a send response deserves. The server reports the undo
+ * window as a duration so a clock difference between server and browser cannot
+ * shorten or stretch the countdown.
+ */
+export function resolveSendNotice(result: SendResult, now = Date.now()): SendNoticePlan {
+ if (!result.messageId) return { kind: "sent" };
+ if (result.undoSeconds) {
+ const remaining = typeof result.undoRemainingMs === "number" && Number.isFinite(result.undoRemainingMs)
+ ? result.undoRemainingMs
+ : result.undoSeconds * 1000;
+ const durationMs = Math.max(0, remaining);
+ // No time left means the queue may already be sending; watch for the result instead of guessing.
+ return durationMs > 0
+ ? { kind: "undo", messageId: result.messageId, endAt: now + durationMs, durationMs }
+ : { kind: "sending", messageId: result.messageId };
+ }
+ if (result.scheduled) {
+ return { kind: "scheduled", messageId: result.messageId, scheduledAt: result.scheduledAt ?? null };
+ }
+ return { kind: "sent" };
+}
diff --git a/src/components/messages/send-view-utils.ts b/src/components/messages/send-view-utils.ts
new file mode 100644
index 0000000..0684f91
--- /dev/null
+++ b/src/components/messages/send-view-utils.ts
@@ -0,0 +1,7 @@
+/** Only move the reader for the message whose delivery state changed. */
+export function resolveSendViewRoute(pathname: string, messageId: string, status: string): string | null {
+ if (pathname !== `/scheduled/${messageId}` && pathname !== `/sent/${messageId}`) return null;
+ if (status === "draft") return pathname.startsWith("/scheduled/") ? "/scheduled" : "/sent";
+ if (status === "sent" && pathname === `/scheduled/${messageId}`) return `/sent/${messageId}`;
+ return null;
+}
diff --git a/src/components/messages/use-send-view-status.ts b/src/components/messages/use-send-view-status.ts
new file mode 100644
index 0000000..d24b4da
--- /dev/null
+++ b/src/components/messages/use-send-view-status.ts
@@ -0,0 +1,52 @@
+"use client";
+
+import { useEffect } from "react";
+import { usePathname, useRouter } from "next/navigation";
+import { authFetch } from "@/lib/auth/client";
+import { clearMessageDetailCache } from "@/lib/messages/detail-cache";
+import { resolveSendViewRoute } from "./send-view-utils";
+
+/** Keep a scheduled reader on the delivered message, or close it after Undo. */
+export function useSendViewStatus(messageId: string) {
+ const pathname = usePathname();
+ const router = useRouter();
+ useEffect(() => {
+ const scheduled = pathname === `/scheduled/${messageId}`;
+ if (!scheduled && pathname !== `/sent/${messageId}`) return;
+ let disposed = false;
+ let checking = false;
+ let checkAgain = false;
+ let moved = false;
+ async function check() {
+ if (disposed || moved) return;
+ if (checking) { checkAgain = true; return; }
+ checking = true;
+ try {
+ const response = await authFetch(`/api/messages/${messageId}/send-status`, { cache: "no-store" });
+ if (!response.ok) return;
+ const { status } = await response.json() as { status?: string };
+ if (disposed || !status) return;
+ const destination = resolveSendViewRoute(pathname, messageId, status);
+ if (!destination) return;
+ moved = true;
+ clearMessageDetailCache();
+ window.dispatchEvent(new Event("mailflare:messages-changed"));
+ router.replace(destination);
+ } catch {
+ // Transient failures are retried by the timer or the next change event.
+ } finally {
+ checking = false;
+ if (checkAgain && !disposed) { checkAgain = false; void check(); }
+ }
+ }
+ const onChange = () => void check();
+ void check();
+ const timer = scheduled ? window.setInterval(onChange, 1000) : undefined;
+ window.addEventListener("mailflare:messages-changed", onChange);
+ return () => {
+ disposed = true;
+ if (timer !== undefined) window.clearInterval(timer);
+ window.removeEventListener("mailflare:messages-changed", onChange);
+ };
+ }, [messageId, pathname, router]);
+}
diff --git a/src/lib/email/send.ts b/src/lib/email/send.ts
index 32ea870..eaf2efd 100644
--- a/src/lib/email/send.ts
+++ b/src/lib/email/send.ts
@@ -1,4 +1,4 @@
-import { and, eq } from "drizzle-orm";
+import { and, eq, isNotNull } from "drizzle-orm";
import { getDb } from "@/db";
import { messages, outboundJobs } from "@/db/schema";
import { newId } from "@/lib/ids";
@@ -82,7 +82,7 @@ function toRecipientList(value: string | string[] | undefined): string[] {
export async function sendEmail(
env: CloudflareEnv,
input: SendEmailInput,
-): Promise<{ messageId: string; scheduled?: boolean; undoSeconds?: number }> {
+): Promise<{ messageId: string; scheduled?: boolean; undoSeconds?: number; undoRemainingMs?: number; scheduledAt?: string }> {
const db = getDb(env);
const sender = await getAuthorizedSenderAddress(env, input);
const attachments = input.attachments ?? [];
@@ -187,7 +187,16 @@ export async function sendEmail(
};
if (scheduledAt) {
await enqueueScheduledDelivery(env, delivery, scheduledAt);
- return userScheduledAt ? { messageId, scheduled: true } : { messageId, scheduled: true, undoSeconds };
+ if (userScheduledAt) {
+ return { messageId, scheduled: true, scheduledAt: scheduledAt.toISOString() };
+ }
+ // Send the window as a duration: client and server clocks need not agree.
+ return {
+ messageId,
+ scheduled: true,
+ undoSeconds,
+ undoRemainingMs: Math.max(0, scheduledAt.getTime() - Date.now()),
+ };
}
await deliverEmail(env, delivery);
@@ -323,19 +332,8 @@ async function enqueueScheduledDelivery(
);
}
-export async function processOutboundQueue(
- env: CloudflareEnv,
- payload: OutboundQueueMessage,
-): Promise<void> {
- const db = getDb(env);
- const [job] = await db
- .select({ status: outboundJobs.status, payload: outboundJobs.payload })
- .from(outboundJobs)
- .where(eq(outboundJobs.id, payload.jobId))
- .limit(1);
- if (!job || job.status !== "queued") return;
- const scheduledAt = new Date(payload.scheduledAt);
- const input = JSON.parse(job.payload) as SendEmailInput;
+function deliveryFromJob(jobId: string, messageId: string, payload: string): PreparedDelivery {
+ const input = JSON.parse(payload) as SendEmailInput;
const to = toRecipientList(input.to);
const cc = toRecipientList(input.cc);
const bcc = toRecipientList(input.bcc);
@@ -346,10 +344,10 @@ export async function processOutboundQueue(
const headers: Record<string, string> = { ...input.headers };
if (inReplyTo) headers["In-Reply-To"] = `<${inReplyTo}>`;
if (references.length > 0) headers.References = formatMessageIdHeader(references);
- const delivery: PreparedDelivery = {
+ return {
input,
- messageId: payload.messageId,
- jobId: payload.jobId,
+ messageId,
+ jobId,
from: input.from,
mailboxId: input.mailboxId,
to,
@@ -358,17 +356,58 @@ export async function processOutboundQueue(
headers,
attachments: [],
};
+}
+
+function claimJob(db: ReturnType<typeof getDb>, jobId: string) {
+ return db
+ .update(outboundJobs)
+ .set({ status: "sending", updatedAt: new Date() })
+ .where(and(eq(outboundJobs.id, jobId), eq(outboundJobs.status, "queued")))
+ .returning({ id: outboundJobs.id });
+}
+
+/**
+ * Sends a scheduled message before its due time. The job is claimed the same way
+ * the queue consumer claims it, so send-now and the queued delivery cannot both send.
+ * Returns false when the message has already left the queue.
+ */
+export async function sendScheduledMessageNow(env: CloudflareEnv, messageId: string): Promise<boolean> {
+ const db = getDb(env);
+ const [job] = await db
+ .select({ id: outboundJobs.id, payload: outboundJobs.payload })
+ .from(outboundJobs)
+ .where(and(eq(outboundJobs.messageId, messageId), eq(outboundJobs.status, "queued"), isNotNull(outboundJobs.scheduledAt)))
+ .limit(1);
+ if (!job) return false;
+ const delivery = deliveryFromJob(job.id, messageId, job.payload);
+ // Load first: a failure here must leave the job queued so the scheduled send can retry.
+ delivery.attachments = await loadMessageAttachmentContents(env, messageId);
+ const claimed = await claimJob(db, job.id);
+ if (!claimed.length) return false;
+ await deliverEmail(env, delivery);
+ return true;
+}
+
+export async function processOutboundQueue(
+ env: CloudflareEnv,
+ payload: OutboundQueueMessage,
+): Promise<void> {
+ const db = getDb(env);
+ const [job] = await db
+ .select({ status: outboundJobs.status, payload: outboundJobs.payload })
+ .from(outboundJobs)
+ .where(eq(outboundJobs.id, payload.jobId))
+ .limit(1);
+ if (!job || job.status !== "queued") return;
+ const scheduledAt = new Date(payload.scheduledAt);
+ const delivery = deliveryFromJob(payload.jobId, payload.messageId, job.payload);
if (scheduledAt.getTime() > Date.now()) {
await enqueueScheduledDelivery(env, delivery, scheduledAt);
return;
}
// Claim the job before delivering. Cancelling deletes only a job that is still
// "queued", so exactly one of cancel and delivery wins.
- const claimed = await db
- .update(outboundJobs)
- .set({ status: "sending", updatedAt: new Date() })
- .where(and(eq(outboundJobs.id, payload.jobId), eq(outboundJobs.status, "queued")))
- .returning({ id: outboundJobs.id });
+ const claimed = await claimJob(db, payload.jobId);
if (!claimed.length) return;
delivery.attachments = await loadMessageAttachmentContents(env, payload.messageId);
await deliverEmail(env, delivery);
diff --git a/src/lib/i18n/en.json b/src/lib/i18n/en.json
index 4e5a68f..9ea781f 100644
--- a/src/lib/i18n/en.json
+++ b/src/lib/i18n/en.json
@@ -194,6 +194,11 @@
"compose.error.totalSize": "Attachments must total {max} MB or less",
"compose.scheduled": "Message scheduled",
"compose.sent": "Message sent",
+ "compose.sentSubject": "Sent “{subject}”",
+ "compose.sendingIn": "Sending “{subject}” in {seconds}s",
+ "compose.sendingSubject": "Sending “{subject}”...",
+ "compose.sendNow": "Send now",
+ "compose.undoSend": "Undo",
"compose.carriedOver": "Carried over from the forwarded message",
"compose.removeAttachment": "Remove attachment",
"compose.cloudWarning.will": "Cloudflare limits general email messages to 5 MiB including encoding. Files over 3 MB here will be sent as 30-day download links.",
diff --git a/tests/compose-ai-review-behavior.test.mjs b/tests/compose-ai-review-behavior.test.mjs
index c5a7472..40062c9 100644
--- a/tests/compose-ai-review-behavior.test.mjs
+++ b/tests/compose-ai-review-behavior.test.mjs
@@ -31,6 +31,9 @@ export function useCompose() { return { showNotice() {}, openComposer() {} }; }
`],
["@/lib/auth/client", `
export function authFetch(...args) { return globalThis.__reviewTestFetch(...args); }
+`],
+ ["@/lib/messages/detail-cache", `
+export function clearMessageDetailCache() {}
`],
["@/components/compose/utils", `
export async function fetchDraft() { return globalThis.__reviewTestDraft(); }
diff --git a/tests/send-notice.test.mjs b/tests/send-notice.test.mjs
new file mode 100644
index 0000000..34124e1
--- /dev/null
+++ b/tests/send-notice.test.mjs
@@ -0,0 +1,125 @@
+import assert from "node:assert/strict";
+import { mkdtempSync, readFileSync, readdirSync, rmSync } from "node:fs";
+import { dirname, join } from "node:path";
+import test from "node:test";
+import { fileURLToPath, pathToFileURL } from "node:url";
+import { build } from "esbuild";
+
+const root = join(dirname(fileURLToPath(import.meta.url)), "..");
+const bundleDirectory = mkdtempSync(join(root, "node_modules", "mailflare-send-notice-bundle-"));
+await build({
+ stdin: {
+ contents: `export { resolveSendNotice, splitSendTemplate } from "./src/components/compose/send-notice-utils.ts";
+ export { resolveSendViewRoute } from "./src/components/messages/send-view-utils.ts";`,
+ resolveDir: root,
+ sourcefile: "send-notice-test-entry.ts",
+ },
+ outfile: join(bundleDirectory, "entry.mjs"),
+ bundle: true,
+ platform: "node",
+ format: "esm",
+ target: "node24",
+ tsconfig: join(root, "tsconfig.json"),
+ logLevel: "silent",
+});
+const { resolveSendNotice, splitSendTemplate, resolveSendViewRoute } = await import(pathToFileURL(join(bundleDirectory, "entry.mjs")).href);
+rmSync(bundleDirectory, { recursive: true, force: true });
+
+const now = Date.parse("2026-10-28T12:00:00.000Z");
+const at = (offsetMs) => new Date(now + offsetMs).toISOString();
+
+test("a delivered scheduled reader follows the message to Sent", () => {
+ assert.equal(resolveSendViewRoute("/scheduled/msg_1", "msg_1", "sent"), "/sent/msg_1");
+ for (const status of ["queued", "sending", "failed"]) {
+ assert.equal(resolveSendViewRoute("/scheduled/msg_1", "msg_1", status), null);
+ }
+});
+
+test("Undo closes only the cancelled message reader, preserving its folder", () => {
+ assert.equal(resolveSendViewRoute("/scheduled/msg_1", "msg_1", "draft"), "/scheduled");
+ assert.equal(resolveSendViewRoute("/sent/msg_1", "msg_1", "draft"), "/sent");
+ for (const path of ["/scheduled", "/sent", "/scheduled/msg_2", "/sent/msg_2", "/inbox/msg_1"]) {
+ assert.equal(resolveSendViewRoute(path, "msg_1", "draft"), null);
+ assert.equal(resolveSendViewRoute(path, "msg_1", "sent"), null);
+ }
+ assert.equal(resolveSendViewRoute("/sent/msg_1", "msg_1", "sent"), null);
+});
+
+test("an undo window counts down from the duration the server reports", () => {
+ assert.deepEqual(
+ resolveSendNotice({ messageId: "msg_1", scheduled: true, undoSeconds: 15, undoRemainingMs: 14_200 }, now),
+ { kind: "undo", messageId: "msg_1", endAt: now + 14_200, durationMs: 14_200 },
+ );
+});
+
+test("a missing remaining duration falls back to the configured undo window", () => {
+ assert.deepEqual(
+ resolveSendNotice({ messageId: "msg_1", scheduled: true, undoSeconds: 10 }, now),
+ { kind: "undo", messageId: "msg_1", endAt: now + 10_000, durationMs: 10_000 },
+ );
+});
+
+test("a window with no time left waits for the queue's result", () => {
+ for (const undoRemainingMs of [0, -1]) {
+ assert.deepEqual(
+ resolveSendNotice({ messageId: "msg_1", scheduled: true, undoSeconds: 5, undoRemainingMs }, now),
+ { kind: "sending", messageId: "msg_1" },
+ );
+ }
+});
+
+test("an explicit schedule carries its time for the cancel toast", () => {
+ assert.deepEqual(
+ resolveSendNotice({ messageId: "msg_2", scheduled: true, scheduledAt: at(86_400_000) }, now),
+ { kind: "scheduled", messageId: "msg_2", scheduledAt: at(86_400_000) },
+ );
+});
+
+test("a schedule without a timestamp is still cancellable", () => {
+ assert.deepEqual(
+ resolveSendNotice({ messageId: "msg_2", scheduled: true }, now),
+ { kind: "scheduled", messageId: "msg_2", scheduledAt: null },
+ );
+});
+
+test("an immediate send and a response without a message id have no action", () => {
+ assert.deepEqual(resolveSendNotice({ messageId: "msg_3" }, now), { kind: "sent" });
+ assert.deepEqual(resolveSendNotice({}, now), { kind: "sent" });
+});
+
+test("the countdown template splits the subject from the ticking seconds", () => {
+ const parts = splitSendTemplate("Sending “{subject}” in {seconds}s", true);
+ assert.equal(parts.before, "Sending “");
+ assert.equal(parts.after, "” in ");
+ assert.equal(parts.ticker?.(9), "9s");
+ assert.equal(parts.ticker?.(0), "0s");
+});
+
+test("a template without seconds keeps the whole suffix after the subject", () => {
+ assert.deepEqual(splitSendTemplate("Sending “{subject}”...", false), {
+ before: "Sending “",
+ after: "”...",
+ });
+ assert.deepEqual(splitSendTemplate("Sent “{subject}”", false), {
+ before: "Sent “",
+ after: "”",
+ });
+});
+
+test("every locale preserves the linked subject and countdown placeholders", () => {
+ const keys = ["compose.sendingIn", "compose.sendingSubject", "compose.sentSubject", "compose.undoSend", "compose.sendNow"];
+ const en = JSON.parse(readFileSync(join(root, "src/lib/i18n/en.json"), "utf8"));
+ const placeholders = (value) => [...value.matchAll(/\{\w+\}/g)].map(([token]) => token).sort();
+ for (const file of readdirSync(join(root, "public/locales"))) {
+ if (!file.endsWith(".json")) continue;
+ const catalog = JSON.parse(readFileSync(join(root, "public/locales", file), "utf8"));
+ for (const key of keys) {
+ assert.ok(catalog[key]?.trim(), `${file}: ${key}`);
+ assert.deepEqual(placeholders(catalog[key]), placeholders(en[key]), `${file}: ${key}`);
+ }
+ const template = catalog["compose.sendingIn"];
+ assert.ok(template.indexOf("{subject}") < template.indexOf("{seconds}"), file);
+ const parts = splitSendTemplate(template, true);
+ assert.equal(parts.before + "SUBJECT" + parts.after + parts.ticker(7), template.replace("{subject}", "SUBJECT").replace("{seconds}", "7"), file);
+ }
+});
diff --git a/tests/send-view-status.test.mjs b/tests/send-view-status.test.mjs
new file mode 100644
index 0000000..685be5c
--- /dev/null
+++ b/tests/send-view-status.test.mjs
@@ -0,0 +1,215 @@
+import assert from "node:assert/strict";
+import { mkdtempSync, rmSync } from "node:fs";
+import { dirname, join } from "node:path";
+import test, { after } from "node:test";
+import { fileURLToPath, pathToFileURL } from "node:url";
+import { build } from "esbuild";
+import { JSDOM } from "jsdom";
+
+const root = join(dirname(fileURLToPath(import.meta.url)), "..");
+const outDir = mkdtempSync(join(root, "tests", ".tmp-send-view-status-"));
+const outfile = join(outDir, "hook.mjs");
+after(() => rmSync(outDir, { recursive: true, force: true }));
+
+const dom = new JSDOM("<!doctype html><html><body></body></html>", { url: "https://mail.example/" });
+for (const key of ["window", "document", "HTMLElement", "Element", "Node", "Event"]) {
+ globalThis[key] = key === "window" ? dom.window : dom.window[key];
+}
+globalThis.IS_REACT_ACT_ENVIRONMENT = true;
+
+const mocks = new Map([
+ ["next/navigation", `
+ const router = {
+ replace(destination) { globalThis.__sendViewReplace(destination); },
+ push() {},
+ refresh() {},
+ back() {},
+ forward() {},
+ prefetch() {},
+ };
+ export function usePathname() { return globalThis.__sendViewPathname; }
+ export function useRouter() { return router; }
+ `],
+ ["@/lib/auth/client", `
+ export function authFetch(...args) { return globalThis.__sendViewFetch(...args); }
+ `],
+ ["@/lib/messages/detail-cache", `
+ export function clearMessageDetailCache() { globalThis.__sendViewClearCache(); }
+ `],
+]);
+
+await build({
+ stdin: {
+ contents: `
+ import { createElement } from "react";
+ import { createRoot } from "react-dom/client";
+ import { act } from "react";
+ import { useSendViewStatus } from "@/components/messages/use-send-view-status";
+
+ async function flushTurns() {
+ for (let turn = 0; turn < 3; turn++) {
+ await new Promise(resolve => setImmediate(resolve));
+ }
+ }
+ async function settle() {
+ await act(async () => { await flushTurns(); });
+ }
+
+ export async function mountReader(messageId) {
+ document.body.replaceChildren();
+ const container = document.createElement("div");
+ document.body.appendChild(container);
+ const root = createRoot(container);
+ function Reader() {
+ useSendViewStatus(messageId);
+ return null;
+ }
+ await act(async () => { root.render(createElement(Reader)); });
+ await settle();
+ return {
+ async unmount() { await act(async () => { root.unmount(); }); },
+ };
+ }
+
+ export async function messagesChanged() {
+ await act(async () => {
+ window.dispatchEvent(new window.Event("mailflare:messages-changed"));
+ });
+ await settle();
+ }
+ `,
+ resolveDir: root,
+ loader: "tsx",
+ },
+ outfile,
+ bundle: true,
+ platform: "browser",
+ format: "esm",
+ target: "es2022",
+ tsconfig: join(root, "tsconfig.json"),
+ external: ["react", "react-dom", "react-dom/client", "jsdom"],
+ alias: { "@": join(root, "src") },
+ banner: { js: 'import { createRequire } from "node:module"; const require = createRequire(import.meta.url);' },
+ plugins: [{
+ name: "send-view-status-mocks",
+ setup(builder) {
+ builder.onResolve({ filter: /.*/ }, args => {
+ if (mocks.has(args.path)) return { path: args.path, namespace: "send-view-status-mock" };
+ return undefined;
+ });
+ builder.onLoad({ filter: /.*/, namespace: "send-view-status-mock" }, args => ({ contents: mocks.get(args.path), loader: "js" }));
+ },
+ }],
+ logLevel: "silent",
+});
+
+const { mountReader, messagesChanged } = await import(pathToFileURL(outfile).href);
+
+function statusResponse(status, ok = true) {
+ return { ok, status: ok ? 200 : 500, json: async () => ({ status }) };
+}
+
+/** Installs mutable pathname, stable-router replace spy, controlled fetch and cache-clear spy. */
+function prepare({ pathname, responses = [] }) {
+ const calls = [];
+ const replacements = [];
+ const cleared = [];
+ const queue = [...responses];
+ globalThis.__sendViewPathname = pathname;
+ globalThis.__sendViewReplace = destination => { replacements.push(destination); };
+ globalThis.__sendViewFetch = async (url, init) => {
+ calls.push({ url: String(url), cache: init?.cache });
+ if (queue.length === 0) throw new Error(`unexpected status request for ${url}`);
+ const next = queue.shift();
+ return typeof next === "function" ? next() : next;
+ };
+ globalThis.__sendViewClearCache = () => { cleared.push(true); };
+ return { calls, replacements, cleared, queue };
+}
+
+function trackMessagesChanged(t) {
+ const seen = [];
+ const listener = () => { seen.push("changed"); };
+ window.addEventListener("mailflare:messages-changed", listener);
+ t.after(() => window.removeEventListener("mailflare:messages-changed", listener));
+ return seen;
+}
+
+test("a scheduled reader navigates to the sent reader after confirmed delivery and clears its cache", async t => {
+ const view = prepare({ pathname: "/scheduled/msg-1", responses: [statusResponse("sent")] });
+ const changes = trackMessagesChanged(t);
+ const reader = await mountReader("msg-1");
+ t.after(() => reader.unmount());
+
+ assert.deepEqual(view.calls, [{ url: "/api/messages/msg-1/send-status", cache: "no-store" }]);
+ assert.deepEqual(view.replacements, ["/sent/msg-1"]);
+ assert.equal(view.cleared.length, 1, "the reader's detail cache is cleared before the move");
+ assert.deepEqual(changes, ["changed"], "listeners learn the message list needs to refresh");
+ assert.equal(view.calls.length, 1, "the emitted change event does not fetch again after moving");
+});
+
+test("a messages-changed event re-checks a scheduled reader until delivery is confirmed", async t => {
+ const view = prepare({
+ pathname: "/scheduled/msg-2",
+ responses: [statusResponse("queued"), statusResponse("sent")],
+ });
+ const reader = await mountReader("msg-2");
+ t.after(() => reader.unmount());
+
+ assert.equal(view.calls.length, 1);
+ assert.deepEqual(view.replacements, [], "a queued message stays in the scheduled reader");
+
+ await messagesChanged();
+
+ assert.equal(view.calls.length, 2);
+ assert.deepEqual(view.replacements, ["/sent/msg-2"]);
+ assert.equal(view.cleared.length, 1);
+});
+
+for (const [pathname, destination] of [
+ ["/scheduled/msg-draft", "/scheduled"],
+ ["/sent/msg-draft", "/sent"],
+]) {
+ test(`a draft status closes the ${pathname.startsWith("/scheduled/") ? "scheduled" : "sent"} reader`, async t => {
+ const view = prepare({ pathname, responses: [statusResponse("draft")] });
+ const changes = trackMessagesChanged(t);
+ const reader = await mountReader("msg-draft");
+ t.after(() => reader.unmount());
+
+ assert.deepEqual(view.replacements, [destination]);
+ assert.equal(view.cleared.length, 1);
+ assert.deepEqual(changes, ["changed"]);
+ });
+}
+
+test("folder lists and unrelated message routes never request status or navigate", async () => {
+ for (const pathname of ["/scheduled", "/sent", "/inbox", "/scheduled/other-id", "/sent/other-id", "/inbox/msg-3"]) {
+ const view = prepare({ pathname, responses: [] });
+ const reader = await mountReader("msg-3");
+ await reader.unmount();
+
+ assert.equal(view.calls.length, 0, `${pathname} does not poll`);
+ assert.deepEqual(view.replacements, [], `${pathname} does not navigate`);
+ assert.equal(view.cleared.length, 0, `${pathname} does not clear a cache`);
+ }
+});
+
+test("a status response resolved after unmount cannot navigate or clear the cache", async t => {
+ let resolveFetch;
+ const view = prepare({
+ pathname: "/scheduled/msg-inflight",
+ responses: [() => new Promise(resolve => { resolveFetch = resolve; })],
+ });
+ const changes = trackMessagesChanged(t);
+ const reader = await mountReader("msg-inflight");
+ assert.equal(view.calls.length, 1);
+
+ await reader.unmount();
+ resolveFetch(statusResponse("sent"));
+ await new Promise(resolve => setImmediate(resolve));
+ await new Promise(resolve => setImmediate(resolve));
+
+ assert.deepEqual(view.replacements, []);
+ assert.equal(view.cleared.length, 0);
+ assert.deepEqual(changes, []);
+});