Skip to content

Free, Open Source, Self-Hosted WhatsApp API Gateway

fix(dashboard): name an unnamed chat by its number everywhere

Yudhi Armyndharisa28422fcc9ff
diff --git a/CHANGELOG.md b/CHANGELOG.md
index e17b753b9..a6704d935 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -43,6 +43,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Keep the reply, react and delete actions of dashboard chat messages visible beside each bubble on touch screens, which have no hover to reveal them.
- Fit the dashboard chat room's menu to the room's height, scrolling its entries, so a short window no longer cuts off the last ones.
- Keep a member's name and number at the start edge of the dashboard group dialog in right-to-left languages, where a Latin name and every number sat at the left.
+- Name an unnamed dashboard chat by its formatted number on its list row, in its menu, dialogs and toasts and on the reply banner, instead of the bare digits of its id.
## [0.26.0] - 2026-10-28
diff --git a/dashboard/src/components/chats/ChatComposer.tsx b/dashboard/src/components/chats/ChatComposer.tsx
index d813051f5..d8e10f1fb 100644
--- a/dashboard/src/components/chats/ChatComposer.tsx
+++ b/dashboard/src/components/chats/ChatComposer.tsx
@@ -4,6 +4,7 @@ import { useTranslation } from 'react-i18next';
import { Loader2, Plus, Send, Smile, X } from 'lucide-react';
import { messageApi, type Chat, type MessageType } from '../../services/api';
import { type ChatMessageView } from '../../utils/chatMessages';
+import { chatTitle } from '../../utils/formatPhone';
import { buildMediaSendPayload, buildOptimisticMetadata, quotedIdOf } from '../../utils/composerSend';
import { messagesQueryKey, useChatMessagesActions, upsertCachedMessage } from '../../hooks/useChatMessages';
import { useRole } from '../../hooks/useRole';
@@ -347,8 +348,7 @@ function ChatComposer({
<div className="replying-preview-content">
<div className="replying-to-title">
{t('chats.replyingTo', {
- name:
- replyingTo.direction === 'outgoing' ? t('chats.you') : activeChat.name || activeChat.id.split('@')[0],
+ name: replyingTo.direction === 'outgoing' ? t('chats.you') : chatTitle(activeChat),
})}
</div>
<div className="replying-to-body">
diff --git a/dashboard/src/components/chats/ChatDialogs.tsx b/dashboard/src/components/chats/ChatDialogs.tsx
index 962f94620..e03332fb0 100644
--- a/dashboard/src/components/chats/ChatDialogs.tsx
+++ b/dashboard/src/components/chats/ChatDialogs.tsx
@@ -3,6 +3,7 @@ import { useTranslation } from 'react-i18next';
import { Loader2 } from 'lucide-react';
import { Modal } from '../Modal';
import type { Chat } from '../../services/api';
+import { chatTitle } from '../../utils/formatPhone';
export type MuteDuration = '8h' | '1w' | 'always';
@@ -26,7 +27,7 @@ export function MuteChatDialog({
<Modal
open
onClose={onClose}
- title={t('chats.rowActions.muteTitle', { name: chat.name || chat.id.split('@')[0] })}
+ title={t('chats.rowActions.muteTitle', { name: chatTitle(chat) })}
className="confirm-modal"
closeLabel={t('common.close')}
footer={
diff --git a/dashboard/src/components/chats/ChatRowMenu.tsx b/dashboard/src/components/chats/ChatRowMenu.tsx
index 0726850b9..d12767f53 100644
--- a/dashboard/src/components/chats/ChatRowMenu.tsx
+++ b/dashboard/src/components/chats/ChatRowMenu.tsx
@@ -2,6 +2,7 @@ import { useEffect, useLayoutEffect, useRef, useState } from 'react';
import { useTranslation } from 'react-i18next';
import { ChevronDown } from 'lucide-react';
import type { Chat } from '../../services/api';
+import { chatTitle } from '../../utils/formatPhone';
import { chatActionItems, type ChatActionItem, type ChatRowActions } from './chatActionItems';
/**
@@ -143,7 +144,7 @@ function ChatRowMenu({ chat, actions }: { chat: Chat; actions: ChatRowActions })
setOpen(value => !value);
}}
aria-expanded={open}
- aria-label={t('chats.rowActions.actionsFor', { name: chat.name || chat.id.split('@')[0] })}
+ aria-label={t('chats.rowActions.actionsFor', { name: chatTitle(chat) })}
title={t('chats.moreActions')}
>
<ChevronDown size={18} />
diff --git a/dashboard/src/components/chats/ChatSidebar.tsx b/dashboard/src/components/chats/ChatSidebar.tsx
index 35c6a2f24..be83f7bc3 100644
--- a/dashboard/src/components/chats/ChatSidebar.tsx
+++ b/dashboard/src/components/chats/ChatSidebar.tsx
@@ -19,6 +19,7 @@ import type { UseQueryResult } from '@tanstack/react-query';
import type { Channel, Chat, ContactStatusGroup, Session } from '../../services/api';
import { useRole } from '../../hooks/useRole';
import { CHAT_LIST_FILTERS, type ChatListFilter } from '../../utils/chatFilters';
+import { chatTitle } from '../../utils/formatPhone';
import ChatAvatar from './ChatAvatar';
import SessionPicker from './SessionPicker';
import ChatRowMenu from './ChatRowMenu';
@@ -131,7 +132,7 @@ function ChatSidebar({
<div className="chat-item-info">
<div className="chat-item-top">
<span className="chat-item-name" title={chat.name || chat.id}>
- {chat.name || chat.id.split('@')[0]}
+ {chatTitle(chat)}
</span>
{chat.kind !== 'individual' && chat.kind !== 'unknown' && (
<span className={`chat-kind-badge kind-${chat.kind}`}>{t(`chats.kind.${chat.kind}`)}</span>
diff --git a/dashboard/src/pages/Chats.features.test.ts b/dashboard/src/pages/Chats.features.test.ts
index 838024aa6..66141d6c1 100644
--- a/dashboard/src/pages/Chats.features.test.ts
+++ b/dashboard/src/pages/Chats.features.test.ts
@@ -702,11 +702,44 @@ test('the chat list search clear button returns focus to the field it cleared',
assert.equal(document.activeElement === field, true, `focus is on "${focusedName()}", not on the field`);
});
+// A number in a title is isolated left to right, so a right-to-left page keeps its digit groups in order.
+const isolated = (number: string) => `${String.fromCodePoint(0x2066)}${number}${String.fromCodePoint(0x2069)}`;
+
+test('an unnamed chat is titled by its number on its row, in its menu, its dialogs and its reply banner', async () => {
+ const { screen, fireEvent, waitFor } = rtl;
+ aliceNow.name = '';
+ aliceThread = [threadRow(1)];
+ const { container } = renderPage();
+ const number = isolated('+1 555 000 1111');
+ await screen.findByText(number);
+ assert.equal(container.querySelector('.chat-item-name')?.textContent, number, 'the row shows the bare digits');
+
+ fireEvent.click(screen.getByRole('button', { name: `Actions for ${number}` }));
+ fireEvent.click(screen.getByRole('button', { name: 'Mute notifications' }));
+ await waitFor(() => assert.ok(screen.getByRole('dialog', { name: `Mute "${number}"` })));
+ fireEvent.click(screen.getByRole('button', { name: 'Cancel' }));
+
+ fireEvent.click(screen.getByText(number));
+ await screen.findByText('message 1');
+ fireEvent.click(screen.getByRole('button', { name: 'Reply' }));
+ await waitFor(() =>
+ assert.equal(container.querySelector('.replying-to-title')?.textContent, `Replying to ${number}`),
+ );
+});
+
+test('an unnamed privacy-id chat keeps the digits of its id on its row and in its menu, never formatted', async () => {
+ const { screen } = rtl;
+ Object.assign(aliceNow, { id: '262813461250073@lid', name: '' });
+ renderPage();
+ await screen.findByText('262813461250073');
+ assert.ok(screen.getByRole('button', { name: 'Actions for 262813461250073' }));
+});
+
test('an unnamed chat is titled by its number, formatted and isolated left to right, in the header and the panel', async () => {
const { screen, fireEvent, waitFor, within } = rtl;
aliceNow.name = '';
const { container } = renderPage();
- fireEvent.click(await screen.findByText('15550001111'));
+ fireEvent.click(await screen.findByText(isolated('+1 555 000 1111')));
const title = await waitFor(() => {
const name = container.querySelector('.room-header .room-contact-name') as HTMLElement;
assert.equal(name?.textContent, '+1 555 000 1111');
diff --git a/dashboard/src/pages/Chats.tsx b/dashboard/src/pages/Chats.tsx
index 6b88109b8..60144b9dc 100644
--- a/dashboard/src/pages/Chats.tsx
+++ b/dashboard/src/pages/Chats.tsx
@@ -28,7 +28,7 @@ import {
import { useProfilePicture } from '../hooks/useProfilePicture';
import { useProfilePictures } from '../hooks/useProfilePictures';
import { useResolvedPhone, resolvedPhoneQuery, isResolvedPhoneHeld } from '../hooks/useResolvedPhone';
-import { formatPhoneForDisplay } from '../utils/formatPhone';
+import { chatTitle, formatPhoneForDisplay } from '../utils/formatPhone';
import {
sessionApi,
messageApi,
@@ -1648,7 +1648,7 @@ export function Chats() {
.unblock(sessionId, chat.id)
.then(expectSuccess)
.then(() => {
- showSuccessToast(t('chats.rowActions.unblocked', { name: chat.name || chat.id.split('@')[0] }));
+ showSuccessToast(t('chats.rowActions.unblocked', { name: chatTitle(chat) }));
return queryClient.invalidateQueries({ queryKey: ['contacts-blocked', sessionId] });
})
.catch(failWith('chats.rowActions.blockFailed'));
@@ -1689,7 +1689,7 @@ export function Chats() {
const started = confirmAction;
const { kind, chat } = started;
const sessionId = selectedSessionId;
- const name = chat.name || chat.id.split('@')[0];
+ const name = chatTitle(chat);
setConfirmRunning(started);
try {
if (kind === 'leave') {
@@ -2307,11 +2307,7 @@ export function Chats() {
</>
}
>
- <p>
- {t(CONFIRM_TEXT[confirmAction.kind].question, {
- name: confirmAction.chat.name || confirmAction.chat.id.split('@')[0],
- })}
- </p>
+ <p>{t(CONFIRM_TEXT[confirmAction.kind].question, { name: chatTitle(confirmAction.chat) })}</p>
<p className="text-muted">{t(CONFIRM_TEXT[confirmAction.kind].warning)}</p>
</Modal>
)}
diff --git a/dashboard/src/utils/formatPhone.test.ts b/dashboard/src/utils/formatPhone.test.ts
index cffa1f10b..c14b10e7c 100644
--- a/dashboard/src/utils/formatPhone.test.ts
+++ b/dashboard/src/utils/formatPhone.test.ts
@@ -1,6 +1,6 @@
import { test } from 'node:test';
import assert from 'node:assert/strict';
-import { parsePhoneFromJid, formatPhoneForDisplay, isolateNumber } from './formatPhone.ts';
+import { parsePhoneFromJid, formatPhoneForDisplay, isolateNumber, chatTitle } from './formatPhone.ts';
test('parsePhoneFromJid extracts digits from a personal @c.us JID', () => {
assert.equal(parsePhoneFromJid('[email protected]'), '628123456789');
@@ -92,3 +92,12 @@ test('isolateNumber keeps a number one left-to-right run inside a right-to-left
const pdi = String.fromCodePoint(0x2069);
assert.equal(isolateNumber('+49 170 123 4 5678'), `${lri}+49 170 123 4 5678${pdi}`);
});
+
+test('chatTitle is the name, else the isolated number of a phone id, else the digits of any other id', () => {
+ assert.equal(chatTitle({ id: '[email protected]', name: 'Alice' }), 'Alice');
+ assert.equal(chatTitle({ id: '[email protected]', name: '' }), isolateNumber('+1 555 000 1111'));
+ assert.equal(chatTitle({ id: '[email protected]' }), isolateNumber('+62 812 345 6789'));
+ // A privacy id and a group id are digits too, and no phone number.
+ assert.equal(chatTitle({ id: '262813461250071@lid', name: '' }), '262813461250071');
+ assert.equal(chatTitle({ id: '[email protected]', name: '' }), '120363000000000001');
+});
diff --git a/dashboard/src/utils/formatPhone.ts b/dashboard/src/utils/formatPhone.ts
index 6957eea10..ba578e4fe 100644
--- a/dashboard/src/utils/formatPhone.ts
+++ b/dashboard/src/utils/formatPhone.ts
@@ -73,3 +73,14 @@ export function formatPhoneForDisplay(phoneOrJid: string): string | null {
export function isolateNumber(number: string): string {
return `${String.fromCodePoint(0x2066)}${number}${String.fromCodePoint(0x2069)}`;
}
+
+/**
+ * What a chat is called on its row, in its menu and in a sentence: its name, else the formatted number of a phone id,
+ * isolated left to right, else the digits of its id. A privacy id (@lid) is no phone number, so its digits are never
+ * formatted as one.
+ */
+export function chatTitle(chat: { id: string; name?: string }): string {
+ if (chat.name) return chat.name;
+ const phone = formatPhoneForDisplay(chat.id);
+ return phone ? isolateNumber(phone) : chat.id.split('@')[0];
+}