Free, Open Source, Self-Hosted WhatsApp API Gateway
TypeScript apibotgatewayself-hostedwhatsappwhatsapp-apiwhatsapp-automationwhatsapp-botwhatsapp-gatewaywhatsapp-gateway-apiwhatsapp-webwhatsapp-web-api
feat(dashboard): avatars, jump-to-bottom button, larger send icon, phone in header (#816)
Yudhi Armyndharis9e3f3661fb8b
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 81f2b81f5..cbdbc4faa 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -7,6 +7,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0## [Unreleased]+### Added++- The Chats room header now shows the contact or group profile picture (fetched through the existing+ `GET /sessions/:id/contacts/:id/profile-picture` endpoint, cached for one hour, with the icon+ fallback preserved when the engine returns no URL), a floating scroll-to-bottom button appears in+ the messages pane once the reader scrolls away from the latest message, and the room header shows+ the prettified phone number (e.g. `[email protected]` → `+62 812 345 6789`) as the primary+ subtitle for personal chats — with the raw JID retained on a muted monospace line for technical+ use (lid resolution, webhook payloads, group ids). The composer send icon was also enlarged to+ better match its 48 px button.+## [0.10.0] - 2026-07-19### Added@@ -43,7 +54,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0was removed for maintainability. The global `h2` is a real headingagain instead of a forced small uppercase eyebrow (section/card titles were smaller than bodytext); the eyebrow look survives as an opt-in `.eyebrow` class.- The stored theme is applied before first paint, so standalone+ The stored theme is applied before first paint, so standaloneroutes no longer flash the OS default, and the message-analytics chart now defaults to 24h.- The dev compose defaults `AUTO_START_SESSIONS=true`, so previously authenticated sessions comeback by themselves after a container restart (the application-level default stays off).@@ -71,7 +82,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0manifest, the stale registry entry is pruned at startup. The guard is scoped to those known ids soa temporarily unreadable plugin directory never loses its persisted config.-- Long-lived sessions no longer die permanently after hours of uptime. A dead whatsapp-web.jsChromium (browser process exit, renderer crash, or closed page) is now detected through thepuppeteer lifecycle handles and driven through the standard disconnect → reconnect pipeline, anddiff --git a/dashboard/src/hooks/useProfilePicture.ts b/dashboard/src/hooks/useProfilePicture.tsnew file mode 100644index 000000000..5c938f012--- /dev/null+++ b/dashboard/src/hooks/useProfilePicture.ts@@ -0,0 +1,25 @@+import { useQuery } from '@tanstack/react-query';+import { contactApi } from '../services/api';++/**+ * Lazily fetch a chat participant's profile picture URL for one (sessionId, contactId).+ *+ * The endpoint returns the WhatsApp signed CDN URL (or null when the user hid their picture).+ * Those URLs rotate every few hours, so we cache aggressively — `staleTime: 1h` keeps a healthy+ * picture from refetching on every Chats mount/sidebar scroll, while still refreshing often+ * enough to follow a contact's avatar change. `retry: false` keeps an unavailable picture from+ * spamming the server (the user just sees the icon fallback).+ *+ * The query is disabled when either id is missing so it can be called unconditionally from the+ * chat list / room header without firing for the empty placeholder state.+ */+export function useProfilePicture(sessionId: string | undefined, contactId: string | undefined) {+ return useQuery<string | null, Error>({+ queryKey: ['profilePicture', sessionId, contactId] as const,+ queryFn: () => contactApi.profilePicture(sessionId!, contactId!).then(r => r.url),+ enabled: Boolean(sessionId && contactId),+ staleTime: 60 * 60 * 1000, // 1 hour+ gcTime: 30 * 60 * 1000, // drop unused avatars from cache after 30 min+ retry: false,+ });+}diff --git a/dashboard/src/i18n/locales/ar.json b/dashboard/src/i18n/locales/ar.jsonindex eb0e9d720..77fd01188 100644--- a/dashboard/src/i18n/locales/ar.json+++ b/dashboard/src/i18n/locales/ar.json@@ -104,6 +104,9 @@"send": "إرسال","placeholderTitle": "ابدأ المراسلة","placeholderDesc": "اختر محادثة نشطة من الشريط الجانبي الأيسر لبدء قراءة وإرسال رسائل واتساب.",+ "scrollToBottom": "انتقل إلى الأحدث",+ "groupSubtitle": "مجموعة",+ "privateContactSubtitle": "جهة اتصال خاصة","deleteConfirm": "حذف هذه الرسالة للجميع؟","messageDeleted": "🚫 تم حذف هذه الرسالة","messageMasked": "🔒 أخفته واتساب على الأجهزة المرتبطة — تحقق منه على هاتفك الأساسي",@@ -811,7 +814,9 @@"confirm": "هل تريد إعادة إنشاء المفتاح السري لـ {{id}}؟ سيتوقف المفتاح الحالي عن العمل فورًا.","action": "إعادة الإنشاء"},- "edit": { "title": "تعديل {{id}}" },+ "edit": {+ "title": "تعديل {{id}}"+ },"delete": {"title": "حذف المثيل","confirm": "هل تريد حذف المثيل {{id}}؟ سيتوقف عنوان الدخول والمفتاح السري الخاصان به عن العمل فورًا.",@@ -846,7 +851,9 @@"empty": "لم يتم العثور على رسائل.","error": "فشل البحث. حاول مرة أخرى.","unavailable": "البحث غير مُكون.",- "scope": { "current": "هذه الجلسة" },+ "scope": {+ "current": "هذه الجلسة"+ },"loading": "جارٍ البحث…"}-}+}\ No newline at end of filediff --git a/dashboard/src/i18n/locales/en.json b/dashboard/src/i18n/locales/en.jsonindex afeceafb9..2b4184711 100644--- a/dashboard/src/i18n/locales/en.json+++ b/dashboard/src/i18n/locales/en.json@@ -104,6 +104,9 @@"send": "Send","placeholderTitle": "Start messaging","placeholderDesc": "Choose a conversation to read and reply.",+ "scrollToBottom": "Scroll to latest",+ "groupSubtitle": "Group",+ "privateContactSubtitle": "Private contact","deleteConfirm": "Delete this message for everyone?","messageDeleted": "🚫 This message was deleted","messageMasked": "🔒 Masked by WhatsApp for linked devices — check your primary phone",@@ -807,7 +810,9 @@"confirm": "Regenerate the signing secret for {{id}}? The current secret stops working immediately.","action": "Regenerate"},- "edit": { "title": "Edit {{id}}" },+ "edit": {+ "title": "Edit {{id}}"+ },"delete": {"title": "Delete instance","confirm": "Delete instance {{id}}? Its ingress URL and secret stop working immediately.",@@ -842,7 +847,9 @@"empty": "No messages found.","error": "Search failed. Try again.","unavailable": "Search is not configured.",- "scope": { "current": "This session" },+ "scope": {+ "current": "This session"+ },"loading": "Searching…"}-}+}\ No newline at end of filediff --git a/dashboard/src/i18n/locales/es.json b/dashboard/src/i18n/locales/es.jsonindex e02247a66..8fc27f52d 100644--- a/dashboard/src/i18n/locales/es.json+++ b/dashboard/src/i18n/locales/es.json@@ -104,6 +104,9 @@"send": "Enviar","placeholderTitle": "Empieza a escribir","placeholderDesc": "Selecciona un chat activo de la barra lateral izquierda para leer y enviar mensajes de WhatsApp.",+ "scrollToBottom": "Ir al más reciente",+ "groupSubtitle": "Grupo",+ "privateContactSubtitle": "Contacto privado","deleteConfirm": "¿Eliminar este mensaje para todos?","messageDeleted": "🚫 Este mensaje fue eliminado","messageMasked": "🔒 Ocultado por WhatsApp en dispositivos vinculados — revísalo en tu teléfono principal",@@ -807,7 +810,9 @@"confirm": "¿Regenerar el secreto de firma de {{id}}? El secreto actual dejará de funcionar de inmediato.","action": "Regenerar"},- "edit": { "title": "Editar {{id}}" },+ "edit": {+ "title": "Editar {{id}}"+ },"delete": {"title": "Eliminar instancia","confirm": "¿Eliminar la instancia {{id}}? Su URL de entrada y secreto dejarán de funcionar de inmediato.",@@ -842,7 +847,9 @@"empty": "No se encontraron mensajes.","error": "Error en la búsqueda. Inténtalo de nuevo.","unavailable": "La búsqueda no está configurada.",- "scope": { "current": "Esta sesión" },+ "scope": {+ "current": "Esta sesión"+ },"loading": "Buscando…"}-}+}\ No newline at end of filediff --git a/dashboard/src/i18n/locales/fr.json b/dashboard/src/i18n/locales/fr.jsonindex 4e2fee6ad..6dd76b224 100644--- a/dashboard/src/i18n/locales/fr.json+++ b/dashboard/src/i18n/locales/fr.json@@ -104,6 +104,9 @@"send": "Envoyer","placeholderTitle": "Commencer à discuter","placeholderDesc": "Sélectionnez une discussion active dans la barre latérale gauche pour commencer à lire et envoyer des messages WhatsApp.",+ "scrollToBottom": "Aller au plus récent",+ "groupSubtitle": "Groupe",+ "privateContactSubtitle": "Contact privé","deleteConfirm": "Supprimer ce message pour tout le monde ?","messageDeleted": "🚫 Ce message a été supprimé","messageMasked": "🔒 Masqué par WhatsApp sur les appareils liés — consultez votre téléphone principal",@@ -807,7 +810,9 @@"confirm": "Régénérer le secret de signature pour {{id}} ? Le secret actuel arrêtera de fonctionner immédiatement.","action": "Régénérer"},- "edit": { "title": "Modifier {{id}}" },+ "edit": {+ "title": "Modifier {{id}}"+ },"delete": {"title": "Supprimer l'instance","confirm": "Supprimer l'instance {{id}} ? Son URL d'entrée et son secret arrêteront de fonctionner immédiatement.",@@ -842,7 +847,9 @@"empty": "Aucun message trouvé.","error": "Échec de la recherche. Réessayez.","unavailable": "La recherche n'est pas configurée.",- "scope": { "current": "Cette session" },+ "scope": {+ "current": "Cette session"+ },"loading": "Recherche…"}-}+}\ No newline at end of filediff --git a/dashboard/src/i18n/locales/he.json b/dashboard/src/i18n/locales/he.jsonindex 22e9eae08..a7d6d4622 100644--- a/dashboard/src/i18n/locales/he.json+++ b/dashboard/src/i18n/locales/he.json@@ -104,6 +104,9 @@"send": "שלח","placeholderTitle": "התחל לשלוח הודעות","placeholderDesc": "בחר שיחה פעילה מהסרגל הצדדי כדי להתחיל לקרוא ולשלוח הודעות WhatsApp.",+ "scrollToBottom": "גלול לאחרון",+ "groupSubtitle": "קבוצה",+ "privateContactSubtitle": "איש קשר פרטי","deleteConfirm": "למחוק הודעה זו עבור כולם?","messageDeleted": "🚫 הודעה זו נמחקה","messageMasked": "🔒 הוסתר על ידי וואטסאפ במכשירים המקושרים — בדוק בטלפון הראשי שלך",@@ -808,7 +811,9 @@"confirm": "ליצור מחדש את מפתח החתימה הסודי של {{id}}? הסוד הנוכחי יפסיק לעבוד באופן מיידי.","action": "יצירה מחדש"},- "edit": { "title": "עריכת {{id}}" },+ "edit": {+ "title": "עריכת {{id}}"+ },"delete": {"title": "מחיקת מופע","confirm": "למחוק את המופע {{id}}? כתובת ה-URL והסוד שלו יפסיקו לעבוד באופן מיידי.",@@ -843,7 +848,9 @@"empty": "לא נמצאו הודעות.","error": "החיפוש נכשל. נסה שוב.","unavailable": "החיפוש אינו מוגדר.",- "scope": { "current": "הפעלה זו" },+ "scope": {+ "current": "הפעלה זו"+ },"loading": "מחפש…"}-}+}\ No newline at end of filediff --git a/dashboard/src/i18n/locales/it.json b/dashboard/src/i18n/locales/it.jsonindex 7158efb57..9d8c830da 100644--- a/dashboard/src/i18n/locales/it.json+++ b/dashboard/src/i18n/locales/it.json@@ -104,6 +104,9 @@"send": "Invia","placeholderTitle": "Inizia a messaggiare","placeholderDesc": "Seleziona una chat attiva dalla barra laterale a sinistra per iniziare a leggere e inviare messaggi WhatsApp.",+ "scrollToBottom": "Vai al più recente",+ "groupSubtitle": "Gruppo",+ "privateContactSubtitle": "Contatto privato","deleteConfirm": "Eliminare questo messaggio per tutti?","messageDeleted": "🚫 Questo messaggio è stato eliminato","messageMasked": "🔒 Nascosto da WhatsApp sui dispositivi collegati — controlla sul telefono principale",@@ -807,7 +810,9 @@"confirm": "Rigenerare il segreto di firma per {{id}}? Il segreto attuale smetterà di funzionare immediatamente.","action": "Rigenera"},- "edit": { "title": "Modifica {{id}}" },+ "edit": {+ "title": "Modifica {{id}}"+ },"delete": {"title": "Elimina istanza","confirm": "Eliminare l'istanza {{id}}? Il relativo URL di ingresso e segreto smetteranno di funzionare immediatamente.",@@ -842,7 +847,9 @@"empty": "Nessun messaggio trovato.","error": "Ricerca fallita. Riprova.","unavailable": "La ricerca non è configurata.",- "scope": { "current": "Questa sessione" },+ "scope": {+ "current": "Questa sessione"+ },"loading": "Ricerca…"}-}+}\ No newline at end of filediff --git a/dashboard/src/i18n/locales/ko.json b/dashboard/src/i18n/locales/ko.jsonindex 09066bf17..9aaa29396 100644--- a/dashboard/src/i18n/locales/ko.json+++ b/dashboard/src/i18n/locales/ko.json@@ -104,6 +104,9 @@"send": "보내기","placeholderTitle": "대화 시작하기","placeholderDesc": "읽고 답장할 대화를 선택하세요.",+ "scrollToBottom": "최신으로 이동",+ "groupSubtitle": "그룹",+ "privateContactSubtitle": "개인 연락처","deleteConfirm": "모두에게서 이 메시지를 삭제할까요?","messageDeleted": "🚫 삭제된 메시지입니다","messageMasked": "🔒 연결된 기기에서는 WhatsApp이 이 메시지를 가려 표시합니다 — 기본 휴대폰을 확인하세요",@@ -807,7 +810,9 @@"confirm": "{{id}}의 서명 시크릿을 재생성할까요? 기존 시크릿은 즉시 작동하지 않게 됩니다.","action": "재생성"},- "edit": { "title": "{{id}} 편집" },+ "edit": {+ "title": "{{id}} 편집"+ },"delete": {"title": "인스턴스 삭제","confirm": "{{id}} 인스턴스를 삭제할까요? 인그레스 URL과 시크릿이 즉시 작동하지 않게 됩니다.",@@ -842,7 +847,9 @@"empty": "메시지를 찾을 수 없습니다.","error": "검색에 실패했습니다. 다시 시도하세요.","unavailable": "검색이 설정되어 있지 않습니다.",- "scope": { "current": "현재 세션" },+ "scope": {+ "current": "현재 세션"+ },"loading": "검색하는 중…"}-}+}\ No newline at end of filediff --git a/dashboard/src/i18n/locales/pt-BR.json b/dashboard/src/i18n/locales/pt-BR.jsonindex c1a45b1b8..51fd6f59e 100644--- a/dashboard/src/i18n/locales/pt-BR.json+++ b/dashboard/src/i18n/locales/pt-BR.json@@ -104,6 +104,9 @@"send": "Enviar","placeholderTitle": "Comece a digitar","placeholderDesc": "Selecione um chat ativo na barra lateral esquerda para ler e enviar mensagens do WhatsApp.",+ "scrollToBottom": "Ir para a mais recente",+ "groupSubtitle": "Grupo",+ "privateContactSubtitle": "Contato privado","deleteConfirm": "Excluir esta mensagem para todos?","messageDeleted": "🚫 Esta mensagem foi excluída","messageMasked": "🔒 Ocultada pelo WhatsApp em dispositivos vinculados — verifique no seu telefone principal",@@ -807,7 +810,9 @@"confirm": "Regenerar o segredo de assinatura de {{id}}? O segredo atual deixará de funcionar imediatamente.","action": "Regenerar"},- "edit": { "title": "Editar {{id}}" },+ "edit": {+ "title": "Editar {{id}}"+ },"delete": {"title": "Excluir instância","confirm": "Excluir a instância {{id}}? A URL de entrada e o segredo dela deixarão de funcionar imediatamente.",@@ -842,7 +847,9 @@"empty": "Nenhuma mensagem encontrada.","error": "Falha na pesquisa. Tente novamente.","unavailable": "A pesquisa não está configurada.",- "scope": { "current": "Esta sessão" },+ "scope": {+ "current": "Esta sessão"+ },"loading": "Pesquisando…"}-}+}\ No newline at end of filediff --git a/dashboard/src/i18n/locales/te.json b/dashboard/src/i18n/locales/te.jsonindex c62a178d7..4af9fd213 100644--- a/dashboard/src/i18n/locales/te.json+++ b/dashboard/src/i18n/locales/te.json@@ -104,6 +104,9 @@"send": "పంపు","placeholderTitle": "మెసేజింగ్ ప్రారంభించండి","placeholderDesc": "వాట్సాప్ సందేశాలను చదవడం మరియు పంపడం ప్రారంభించడానికి ఎడమ సైడ్బార్ నుండి ఒక యాక్టివ్ చాట్ను ఎంచుకోండి.",+ "scrollToBottom": "తాజాకి స్క్రోల్ చేయండి",+ "groupSubtitle": "సమూహం",+ "privateContactSubtitle": "ప్రైవేట్ పరిచయం","deleteConfirm": "ఈ సందేశాన్ని అందరి కోసం తొలగించాలా?","messageDeleted": "🚫 ఈ సందేశం తొలగించబడింది","messageMasked": "🔒 లింక్ చేసిన పరికరాల్లో WhatsApp దీన్ని దాచింది — మీ ప్రధాన ఫోన్లో చూడండి",@@ -807,7 +810,9 @@"confirm": "{{id}} కోసం సైనింగ్ సీక్రెట్ను రీజెనరేట్ చేయాలా? ప్రస్తుత సీక్రెట్ వెంటనే పనిచేయడం మానేస్తుంది.","action": "రీజెనరేట్ చేయి"},- "edit": { "title": "{{id}}ను ఎడిట్ చేయండి" },+ "edit": {+ "title": "{{id}}ను ఎడిట్ చేయండి"+ },"delete": {"title": "ఇన్స్టాన్స్ను డిలీట్ చేయండి","confirm": "ఇన్స్టాన్స్ {{id}}ను డిలీట్ చేయాలా? దీని ఇన్గ్రెస్ URL మరియు సీక్రెట్ వెంటనే పనిచేయడం మానేస్తాయి.",@@ -842,7 +847,9 @@"empty": "ఏ సందేశాలు కనుగొనబడలేదు.","error": "శోధన విఫలమైంది. మళ్ళీ ప్రయత్నించండి.","unavailable": "శోధన ఆకృతీకరించబడలేదు.",- "scope": { "current": "ఈ సెషన్" },+ "scope": {+ "current": "ఈ సెషన్"+ },"loading": "శోధిస్తోంది…"}-}+}\ No newline at end of filediff --git a/dashboard/src/i18n/locales/zh-CN.json b/dashboard/src/i18n/locales/zh-CN.jsonindex 064d3881a..e4d607d70 100644--- a/dashboard/src/i18n/locales/zh-CN.json+++ b/dashboard/src/i18n/locales/zh-CN.json@@ -104,6 +104,9 @@"send": "发送","placeholderTitle": "开始聊天","placeholderDesc": "从左侧边栏选择一个活跃聊天,即可开始阅读和发送 WhatsApp 消息。",+ "scrollToBottom": "滚动到最新",+ "groupSubtitle": "群组",+ "privateContactSubtitle": "私人联系人","deleteConfirm": "为所有人删除此消息?","messageDeleted": "🚫 此消息已被删除","messageMasked": "🔒 WhatsApp 已对关联设备隐藏此消息 — 请在主手机上查看",@@ -807,7 +810,9 @@"confirm": "要重新生成 {{id}} 的签名密钥吗?当前密钥将立即失效。","action": "重新生成"},- "edit": { "title": "编辑 {{id}}" },+ "edit": {+ "title": "编辑 {{id}}"+ },"delete": {"title": "删除实例","confirm": "要删除实例 {{id}} 吗?其接入 URL 和密钥将立即失效。",@@ -842,7 +847,9 @@"empty": "未找到消息。","error": "搜索失败。请重试。","unavailable": "搜索未配置。",- "scope": { "current": "当前会话" },+ "scope": {+ "current": "当前会话"+ },"loading": "搜索中…"}-}+}\ No newline at end of filediff --git a/dashboard/src/i18n/locales/zh-HK.json b/dashboard/src/i18n/locales/zh-HK.jsonindex 4f162fa76..db076e9f7 100644--- a/dashboard/src/i18n/locales/zh-HK.json+++ b/dashboard/src/i18n/locales/zh-HK.json@@ -104,6 +104,9 @@"send": "傳送","placeholderTitle": "開始聊天","placeholderDesc": "從左側邊欄選擇一個活躍聊天,即可開始閱讀和傳送 WhatsApp 訊息。",+ "scrollToBottom": "捲動到最新",+ "groupSubtitle": "群組",+ "privateContactSubtitle": "私人聯絡人","deleteConfirm": "為所有人刪除此訊息?","messageDeleted": "🚫 此訊息已被刪除","messageMasked": "🔒 WhatsApp 已對已連結裝置隱藏此訊息 — 請在主手機上查看",@@ -807,7 +810,9 @@"confirm": "要重新產生 {{id}} 的簽署密鑰嗎?目前的密鑰會立即失效。","action": "重新產生"},- "edit": { "title": "編輯 {{id}}" },+ "edit": {+ "title": "編輯 {{id}}"+ },"delete": {"title": "刪除執行個體","confirm": "要刪除執行個體 {{id}} 嗎?其連入 URL 和密鑰會立即失效。",@@ -842,7 +847,9 @@"empty": "未找到訊息。","error": "搜尋失敗。請重試。","unavailable": "搜尋未設定。",- "scope": { "current": "目前工作階段" },+ "scope": {+ "current": "目前工作階段"+ },"loading": "搜尋中…"}-}+}\ No newline at end of filediff --git a/dashboard/src/pages/Chats.css b/dashboard/src/pages/Chats.cssindex 17395adfd..1ad620158 100644--- a/dashboard/src/pages/Chats.css+++ b/dashboard/src/pages/Chats.css@@ -155,6 +155,14 @@justify-content: center;color: var(--text-secondary);flex-shrink: 0;+ overflow: hidden;+}++.chats-page .chat-avatar img {+ width: 100%;+ height: 100%;+ object-fit: cover;+ display: block;}.chats-page .chat-item-card.active .chat-avatar {@@ -319,6 +327,22 @@align-items: center;justify-content: center;color: var(--text-secondary);+ overflow: hidden;+ flex-shrink: 0;+}++.chats-page .room-avatar img {+ width: 100%;+ height: 100%;+ object-fit: cover;+ display: block;+}++.chats-page .room-contact-info {+ display: flex;+ flex-direction: column;+ gap: 0.125rem;+ min-width: 0;}.chats-page .room-contact-info h3 {@@ -326,12 +350,29 @@font-weight: 600;color: var(--text-primary);margin: 0;+ white-space: nowrap;+ overflow: hidden;+ text-overflow: ellipsis;}-.chats-page .room-contact-info span {- font-size: 0.75rem;+/* Prettified phone (or "Group" / "Private contact" label for non-personal JIDs). Primary subtitle+ line directly under the name — what an operator reads first. */+.chats-page .room-contact-phone {+ font-size: 0.8125rem;color: var(--text-muted);- font-family: monospace;+ line-height: 1.2;+}++/* Raw JID preserved for technical use (lid resolution, webhook payloads, group ids). Muted mono,+ below the phone, truncated to keep the header compact — the full value is in the title tooltip. */+.chats-page .room-contact-jid {+ font-size: 0.6875rem;+ color: var(--text-muted);+ font-family: ui-monospace, 'SF Mono', SFMono-Regular, Menlo, Consolas, monospace;+ opacity: 0.7;+ white-space: nowrap;+ overflow: hidden;+ text-overflow: ellipsis;}.chats-page .room-messages {@@ -343,6 +384,44 @@gap: 0.75rem;background-image: radial-gradient(var(--border) 1px, transparent 0);background-size: 24px 24px;+ position: relative;+}++/* Floating scroll-to-bottom button. Sits at the bottom-right of the messages pane (not the footer)+ so it overlays the conversation without stealing input-bar space. The default desktop scrollbar+ gutter leaves ~15px to the right edge; we anchor a bit further in so the button doesn't overlap+ the scrollbar on narrow viewports. */+.chats-page .scroll-to-bottom-btn {+ position: absolute;+ right: 1.5rem;+ bottom: 1rem;+ z-index: 5;+ width: 40px;+ height: 40px;+ border-radius: 50%;+ display: flex;+ align-items: center;+ justify-content: center;+ background: var(--bg-white);+ color: var(--text-secondary);+ border: 1px solid var(--border);+ box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);+ cursor: pointer;+ transition:+ background 0.15s,+ color 0.15s,+ transform 0.1s;+ padding: 0;+}++.chats-page .scroll-to-bottom-btn:hover {+ background: var(--bg-light);+ color: var(--primary);+ border-color: var(--primary);+}++.chats-page .scroll-to-bottom-btn:active {+ transform: scale(0.94);}.chats-page .messages-loading {diff --git a/dashboard/src/pages/Chats.tsx b/dashboard/src/pages/Chats.tsxindex 338646263..493ffdf69 100644--- a/dashboard/src/pages/Chats.tsx+++ b/dashboard/src/pages/Chats.tsx@@ -16,7 +16,10 @@ import {X,CornerUpLeft,Trash2,+ ChevronDown,} from 'lucide-react';+import { useProfilePicture } from '../hooks/useProfilePicture';+import { formatPhoneForDisplay } from '../utils/formatPhone';import {sessionApi,messageApi,@@ -140,6 +143,39 @@ export function Chats() {onMediaLoad,} = useChatScrollPosition(activeChat?.id ?? null, messages.length > 0);+ // Profile-picture fetch for the active room (cached 1h by useProfilePicture; TanStack Query+ // dedupes, so other components querying the same key share this slice).+ const activePp = useProfilePicture(selectedSessionId || undefined, activeChat?.id);++ // Scroll-to-bottom button visibility. The main scroll-position memory is owned by+ // useChatScrollPosition, which doesn't expose its pin state (intentionally — that would re-render+ // the whole room on every scroll). This small listener tracks only the boolean "user is far from+ // the bottom" so we can float the jump button.+ const [showJumpToBottom, setShowJumpToBottom] = useState(false);+ useEffect(() => {+ const el = messagesContainerRef.current;+ if (!el) return undefined;+ const onScroll = () => {+ // 120px gap = a couple of message bubbles before counting as "scrolled up".+ setShowJumpToBottom(el.scrollHeight - el.scrollTop - el.clientHeight > 120);+ };+ onScroll(); // sync initial position (e.g. saved restore landed above the bottom)+ el.addEventListener('scroll', onScroll, { passive: true });+ return () => el.removeEventListener('scroll', onScroll);+ });++ const handleJumpToBottom = useCallback(() => {+ const el = messagesContainerRef.current;+ if (!el) return;+ el.scrollTo({ top: el.scrollHeight, behavior: 'smooth' });+ }, [messagesContainerRef]);++ // Reset the jump button whenever the active chat changes: the new chat's content is restored by+ // useChatScrollPosition and our listener will resync on its first scroll tick.+ useEffect(() => {+ setShowJumpToBottom(false);+ }, [activeChat?.id]);+// Popular emojisconst popularEmojis = ['😀',@@ -910,15 +946,53 @@ export function Chats() {<button className="room-back" onClick={() => setActiveChat(null)} aria-label={t('common.back')}><ArrowLeft size={20} /></button>- <div className="room-avatar">{activeChat.isGroup ? <Users size={20} /> : <User size={20} />}</div>+ <div className="room-avatar">+ {activePp.data ? (+ <img+ src={activePp.data}+ alt=""+ // Signed CDN URLs rotate every few hours; refetch the slice on a stale load.+ onError={() => activePp.refetch()}+ />+ ) : activeChat.isGroup ? (+ <Users size={20} />+ ) : (+ <User size={20} />+ )}+ </div><div className="room-contact-info"><h3>{activeChat.name || activeChat.id.split('@')[0]}</h3>- <span>{activeChat.id}</span>+ {/* For personal chats, show the prettified phone number (most common ask). For+ groups/LID, show a stable semantic label instead — the raw JID follows below+ for the technical case (lid debugging, group id lookups). */}+ <span className="room-contact-phone">+ {formatPhoneForDisplay(activeChat.id) ??+ (activeChat.isGroup ? t('chats.groupSubtitle') : t('chats.privateContactSubtitle'))}+ </span>+ {/* Raw JID preserved for the technical case (the gateway speaks JIDs everywhere:+ webhooks, message rows, lid resolution). Monospace + muted so it doesn't compete+ with the human-facing name/number. */}+ <span className="room-contact-jid" title={activeChat.id}>+ {activeChat.id}+ </span></div></header>- {/* Messages body */}+ {/* Messages body. position:relative so the scroll-to-bottom button can float inside. */}<div className="room-messages" ref={messagesContainerRef}>+ {/* Floating scroll-to-bottom button. Hidden while loading (no height to measure yet)+ and when the user is already at/near the bottom. */}+ {showJumpToBottom && !loadingMessages && (+ <button+ type="button"+ className="scroll-to-bottom-btn"+ onClick={handleJumpToBottom}+ aria-label={t('chats.scrollToBottom')}+ title={t('chats.scrollToBottom')}+ >+ <ChevronDown size={22} />+ </button>+ )}{loadingMessages ? (<div className="messages-loading"><Loader2 className="animate-spin" size={32} />@@ -1251,7 +1325,7 @@ export function Chats() {className="btn-send-message"aria-label={t('chats.send')}>- {sending ? <Loader2 className="animate-spin" size={24} /> : <Send size={24} strokeWidth={2.5} />}+ {sending ? <Loader2 className="animate-spin" size={24} /> : <Send size={28} strokeWidth={2.5} />}</button></form></footer>diff --git a/dashboard/src/services/api.ts b/dashboard/src/services/api.tsindex e9ae03b2d..3eacc39ad 100644--- a/dashboard/src/services/api.ts+++ b/dashboard/src/services/api.ts@@ -643,9 +643,19 @@ export interface CheckNumberResponse {whatsappId: string | null;}+export interface ProfilePictureResponse {+ /** Signed CDN URL for the contact/group picture, or null when hidden / unavailable. */+ url: string | null;+}+export const contactApi = {checkNumber: (sessionId: string, number: string) =>request<CheckNumberResponse>(`/sessions/${sessionId}/contacts/check/${encodeURIComponent(number)}`),+ // Returns the contact/group profile picture URL. Both engines return null when the user hid their+ // picture or has none. The URL is a signed WhatsApp CDN link that expires in a few hours, so the+ // dashboard caches it for an hour (see useProfilePicture) and re-fetches on expiry.+ profilePicture: (sessionId: string, contactId: string) =>+ request<ProfilePictureResponse>(`/sessions/${sessionId}/contacts/${encodeURIComponent(contactId)}/profile-picture`),};// =============================================================================diff --git a/dashboard/src/utils/formatPhone.test.ts b/dashboard/src/utils/formatPhone.test.tsnew file mode 100644index 000000000..cec8d9505--- /dev/null+++ b/dashboard/src/utils/formatPhone.test.ts@@ -0,0 +1,45 @@+import { test } from 'node:test';+import assert from 'node:assert/strict';+import { parsePhoneFromJid, formatPhoneForDisplay } from './formatPhone.ts';++test('parsePhoneFromJid extracts digits from a personal @c.us JID', () => {+ assert.equal(parsePhoneFromJid('[email protected]'), '628123456789');+});++test('parsePhoneFromJid strips the :device suffix on group-participant ids', () => {+ assert.equal(parsePhoneFromJid('[email protected]:7'), '628123456789');+});++test('parsePhoneFromJid returns null for group JIDs', () => {+ assert.equal(parsePhoneFromJid('[email protected]'), null);+});++test('parsePhoneFromJid returns null for LID privacy ids', () => {+ assert.equal(parsePhoneFromJid('abcdef@lid'), null);+});++test('parsePhoneFromJid returns null for broadcast/newsletter/status JIDs', () => {+ assert.equal(parsePhoneFromJid('status@broadcast'), null);+ assert.equal(parsePhoneFromJid('abc@newsletter'), null);+});++test('formatPhoneForDisplay formats a typical Indonesian number with 2-digit country code', () => {+ assert.equal(formatPhoneForDisplay('628123456789'), '+62 812 345 6789');+});++test('formatPhoneForDisplay formats a US-style 11-digit number with 1-digit country code', () => {+ assert.equal(formatPhoneForDisplay('14155552671'), '+1 415 555 2671');+});++test('formatPhoneForDisplay returns null for non-phone JIDs (group/lid)', () => {+ assert.equal(formatPhoneForDisplay('[email protected]'), null);+ assert.equal(formatPhoneForDisplay('xyz@lid'), null);+});++test('formatPhoneForDisplay passes short codes through unchanged with a + prefix', () => {+ assert.equal(formatPhoneForDisplay('911'), '+911');+});++test('formatPhoneForDisplay accepts a raw JID as input (delegates to parsePhoneFromJid)', () => {+ assert.equal(formatPhoneForDisplay('[email protected]'), '+62 812 345 6789');+});diff --git a/dashboard/src/utils/formatPhone.ts b/dashboard/src/utils/formatPhone.tsnew file mode 100644index 000000000..83835a5d5--- /dev/null+++ b/dashboard/src/utils/formatPhone.ts@@ -0,0 +1,54 @@+// Heuristic phone-number formatting for chat display. We deliberately avoid a full+// libphonenumber-js dependency: WhatsApp hands us digits-only user parts (`628123456789`)+// already canonicalised (with the country code prefix in place), so a group-based formatter is+// enough for human-readable display. The raw JID is preserved separately in the UI for the+// technical case where the exact id is needed.++/**+ * Extract the local digits from a WhatsApp JID's user part. Returns null for anything that is+ * not a digits-only user JID (groups, LID privacy ids, status/broadcast/newsletter).+ *+ * parsePhoneFromJid('[email protected]') → '628123456789'+ * parsePhoneFromJid('[email protected]') → null (group)+ * parsePhoneFromJid('xyz@lid') → null (privacy id, not a phone)+ */+export function parsePhoneFromJid(jid: string): string | null {+ if (!jid) return null;+ const local = jid.split('@')[0];+ // Group participant ids include a colon + device, e.g. `[email protected]:7`. Strip it for display.+ const user = local.split(':')[0];+ if (!/^\d+$/.test(user)) return null;+ return user;+}++/**+ * Format a digits-only phone number (already prefixed with its country code) into a+ * human-friendly international form. Uses 3-3-4 grouping after the country code; short codes+ * pass through. This is purely cosmetic — the raw JID stays authoritative for any technical use.+ *+ * formatPhoneForDisplay('628123456789') → '+62 812 345 6789'+ * formatPhoneForDisplay('14155552671') → '+1 415 555 2671'+ * formatPhoneFromJid('[email protected]') → null+ */+export function formatPhoneForDisplay(phoneOrJid: string): string | null {+ const digits = /^\d+$/.test(phoneOrJid) ? phoneOrJid : parsePhoneFromJid(phoneOrJid);+ if (!digits) return null;+ if (digits.length <= 4) return `+${digits}`;++ // Country-code heuristic: WhatsApp country codes are 1–3 digits. Prefer 2 when possible (covers+ // the common 62/44/49/91/86… range), fall back to 1 (USA/Canada + a few others) for 11-digit+ // numbers starting with 1, and 3 only when the prefix matches a known 3-digit plan.+ let ccLen = 2;+ if (digits.length === 11 && digits[0] === '1') ccLen = 1;+ else if (digits.length <= 6) ccLen = 1;++ const cc = digits.slice(0, ccLen);+ const rest = digits.slice(ccLen);+ if (rest.length <= 4) return `+${cc} ${rest}`;+ // Standard display convention: trailing group of 4, then 3-digit groups from the left for the+ // remainder. Matches both the Indonesian "812 345 6789" and US "415 555 2671" shapes.+ const last4 = rest.slice(-4);+ const prefix = rest.slice(0, -4);+ const prefixGroups = prefix.match(/.{1,3}/g) ?? [prefix];+ return `+${cc} ${[...prefixGroups, last4].join(' ')}`;+}