Skip to content

Free, Open Source, Self-Hosted WhatsApp API Gateway

feat(dashboard): show the sender's name on group messages

Yudhi Armyndharisc01ab986057c
diff --git a/CHANGELOG.md b/CHANGELOG.md
index f99619b63..d9596cd41 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -23,6 +23,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
read-only viewer for a contact's updates (image and video), and can post a text or image status,
with a recipient picker on the Baileys engine.
+- **Group chats now show who sent each message.** In a group conversation the dashboard labels each
+ incoming message with the sender's name — coloured per participant and shown once per consecutive
+ run — so a thread is no longer an anonymous wall of text. One-to-one chats are unchanged.
+
### Fixed
- **Outbound `withSafeFetch` no longer crashes the process on unread webhook response bodies.**
diff --git a/dashboard/src/pages/Chats.css b/dashboard/src/pages/Chats.css
index 3440aec30..67bb64c21 100644
--- a/dashboard/src/pages/Chats.css
+++ b/dashboard/src/pages/Chats.css
@@ -546,6 +546,15 @@
white-space: pre-wrap;
}
+/* Group sender label: the poster's name atop an incoming group bubble (colour set inline per sender). */
+.chats-page .message-sender {
+ font-size: 0.78rem;
+ font-weight: 600;
+ line-height: 1.2;
+ margin-bottom: 0.15rem;
+ word-break: break-word;
+}
+
.chats-page .message-meta {
display: flex;
align-items: center;
diff --git a/dashboard/src/pages/Chats.tsx b/dashboard/src/pages/Chats.tsx
index cf1ea4571..51838eb94 100644
--- a/dashboard/src/pages/Chats.tsx
+++ b/dashboard/src/pages/Chats.tsx
@@ -82,8 +82,21 @@ interface IncomingWsMessage {
call?: { video: boolean; missed: boolean };
metadata?: ChatMessageView['metadata'];
kind?: ChatKind;
+ /** Group poster: `from` is the group JID, so `contact`/`author` identify who actually sent it. */
+ contact?: { id?: string; name?: string; pushName?: string };
+ author?: string;
}
+// Stable per-sender colour for group message labels, like WhatsApp gives each participant a colour.
+// Hashed from the sender's name so the same person keeps the same colour across a session. The palette
+// is tuned to stay legible on both the light and dark incoming-bubble backgrounds.
+const SENDER_COLORS = ['#d1416f', '#7c5cff', '#0a86c4', '#1a8f5c', '#c26a00', '#c0392b', '#0e7c86', '#8e44ad'];
+const senderColor = (name: string): string => {
+ let hash = 0;
+ for (let i = 0; i < name.length; i++) hash = (hash * 31 + name.charCodeAt(i)) | 0;
+ return SENDER_COLORS[Math.abs(hash) % SENDER_COLORS.length];
+};
+
// Map an attachment MIME type to the neutral MessageType for the optimistic outgoing bubble, so the
// placeholder matches what the backend will persist (e.g. a PDF is `document`, not `application`).
const messageTypeFromMime = (mimetype: string): MessageType => {
@@ -533,6 +546,9 @@ export function Chats() {
id: newMsg.id,
waMessageId: newMsg.id,
chatId: newMsg.chatId,
+ // For a group post `from` is the group JID, so the sender's name is carried on `contact`.
+ // Persisted rows keep the same value in `chatName`; normalize both to one field for the thread.
+ chatName: newMsg.contact?.pushName ?? newMsg.contact?.name,
from: newMsg.from,
to: newMsg.to,
body: newMsg.body,
@@ -1468,12 +1484,23 @@ export function Chats() {
<span>{t('chats.noMessagesInChat')}</span>
</div>
) : (
- messages.map(msg => {
+ messages.map((msg, index) => {
const isMe = msg.direction === 'outgoing';
const formattedTime = formatTime(
msg.timestamp || Math.floor(new Date(msg.createdAt).getTime() / 1000),
);
+ // Label who posted, WhatsApp-style: only in groups, only on incoming messages,
+ // and only on the first of a consecutive run from the same sender (so a burst
+ // from one person isn't repeated on every bubble).
+ const prev = messages[index - 1];
+ const showSender = Boolean(
+ activeChat?.isGroup &&
+ !isMe &&
+ msg.chatName &&
+ (!prev || prev.direction === 'outgoing' || prev.chatName !== msg.chatName),
+ );
+
const isMediaMessage = msg.type !== 'text';
const mediaInfo = msg.metadata?.media;
@@ -1588,6 +1615,13 @@ export function Chats() {
isMediaMessage ? 'media-type' : ''
} ${isRevoked ? 'revoked-type' : ''}`}
>
+ {/* Group sender label (WhatsApp-style: coloured name atop the bubble) */}
+ {showSender && (
+ <div className="message-sender" style={{ color: senderColor(msg.chatName!) }}>
+ {msg.chatName}
+ </div>
+ )}
+
{/* Quoted message display */}
{msg.metadata?.quotedMessage && (
<div className="message-quote-box">
diff --git a/dashboard/src/services/api.ts b/dashboard/src/services/api.ts
index d8403fce6..f27e12d9f 100644
--- a/dashboard/src/services/api.ts
+++ b/dashboard/src/services/api.ts
@@ -178,6 +178,12 @@ export interface ChatMessage {
chatId: string;
/** Chat kind of the source conversation (present on live engine/WS payloads). */
kind?: ChatKind;
+ /**
+ * Human-readable name of the message's sender. For a group this is the participant who posted
+ * (their pushName/contact name); the chat view uses it to label who said what, like WhatsApp. Null
+ * on legacy rows or when the engine could not resolve a name.
+ */
+ chatName?: string;
from: string;
to: string;
body: string;
@@ -206,6 +212,10 @@ export interface EngineHistoryMessage {
timestamp: number;
fromMe?: boolean;
media?: { mimetype: string; filename?: string; data?: string };
+ /** Sender in a group: `from` is the group JID, so this participant WID is the real poster. */
+ author?: string;
+ /** Best-effort sender contact (sync cache); its name labels the poster in a group thread. */
+ contact?: { id?: string; name?: string; pushName?: string };
}
// Mirrors the backend engine Channel / ChannelMessage (GET /sessions/:id/channels[/:id/messages]).
diff --git a/dashboard/src/utils/chatMessages.ts b/dashboard/src/utils/chatMessages.ts
index 88ea1d7a7..24b01788b 100644
--- a/dashboard/src/utils/chatMessages.ts
+++ b/dashboard/src/utils/chatMessages.ts
@@ -15,6 +15,7 @@ export function mapEngineHistoryMessage(h: EngineHistoryMessage): ChatMessage {
id: h.id,
waMessageId: h.id,
chatId: h.chatId,
+ chatName: h.contact?.pushName ?? h.contact?.name,
from: h.from,
to: h.to,
body: h.body ?? '',