Skip to content

Free, Open Source, Self-Hosted WhatsApp API Gateway

Merge branch 'main' into fix/dashboard-mention-names

Tanmay Chachra32a00774e6bc
diff --cc CHANGELOG.md
index 54ccc625f,ffe5edb41..f7d0f1557
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@@ -30,7 -37,7 +37,8 @@@ and this project adheres to [Semantic V
### Fixed
+- The dashboard Chats thread renders an `@<digits>` mention as `@FirstName` when that participant has posted in the loaded thread and their id matches the digits in the body. This covers whatsapp-web.js, where the author id and the mention carry the same digits. On Baileys the author is normalized to the phone number when the lid mapping is known while the body keeps the lid digits, so those mentions stay as WhatsApp sent them, as does any mention of someone who has not posted. The resolved name renders inside its own `<bdi>` element, outside Linkify's `ignoreTags`-respected walk, so a push name can never become a clickable link, however it's spelled. Thanks @TanmayChachra.
+ - The dashboard Chats page drops a staged reply when another chat or session is opened, so a text send there no longer fails with `404` and a media send no longer quotes the previous chat's message.
- whatsapp-web.js chat history resolves each message's sender through `getContact()`, as the live `message` handler already does, so a group participant outside the account's contacts gets a sender label in history too. Thanks @TanmayChachra.
- A WebSocket client that emits without an ack callback now receives command replies at all. The gateway answered by returning a frame, which Socket.IO delivers through the ack callback and nowhere else, so a client written to the documented `message` event saw no subscribe confirmation, no pong, and none of the refusals, including the session-scope denial. Replies now go out on `message` as well as through the ack.
- A Baileys message the account sent from its phone is no longer lost when the message store cannot be read. The repeat-delivery check threw on a locked database or an unparseable row and the message was dropped with it, and WhatsApp does not re-deliver one it has already acked; the check now fails open, so at worst such a message is reported twice rather than never.
diff --cc dashboard/src/components/chats/ChatThread.tsx
index 15321916e,fa00b527a..5995cfa64
--- a/dashboard/src/components/chats/ChatThread.tsx
+++ b/dashboard/src/components/chats/ChatThread.tsx
@@@ -1,14 -1,9 +1,15 @@@
-import { useCallback, useEffect, useState, type RefObject } from 'react';
+import { useCallback, useEffect, useMemo, useState, type RefObject } from 'react';
import { useTranslation } from 'react-i18next';
import { AlertCircle, ChevronDown, CornerUpLeft, Loader2, MessageSquare, Smile, Trash2 } from 'lucide-react';
+ import { useRole } from '../../hooks/useRole';
import { sessionApi, type Chat } from '../../services/api';
-import { getMediaSrc, senderKey, type ChatMessageView } from '../../utils/chatMessages';
+import {
+ buildMentionNameMap,
+ getMediaSrc,
+ resolveMentions,
+ senderKey,
+ type ChatMessageView,
+} from '../../utils/chatMessages';
import { shouldFetchOlderMessages } from '../../utils/scrollDecision';
import MessageBody from './MessageBody';
@@@ -68,12 -63,10 +69,15 @@@ function ChatThread(
onClickButton,
}: ChatThreadProps) {
const { t } = useTranslation();
+ // Reply, react, delete and prompt taps all need an operator key, like the composer; a viewer
+ // would only reach a 403.
+ const { canWrite } = useRole();
+ // "@<digits>" in a message body only ever means something once resolved against a participant
+ // this thread has already seen post (see buildMentionNameMap) — recomputed only when the message
+ // list itself changes, not per-render.
+ const mentionNames = useMemo(() => buildMentionNameMap(messages), [messages]);
+
// Media the message list did not inline. The route serves the bytes as an attachment
// (Content-Disposition), and the list only carries payloads up to
// MESSAGE_LIST_INLINE_MEDIA_BUDGET_BYTES — past that a row arrives as `{ omitted: true }`. Without