Skip to content

Free, Open Source, Self-Hosted WhatsApp API Gateway

fix(dashboard): render call/location correctly + UX polish across pages (#548)

Yudhi Armyndharisfdca029ca9c8
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 9edf6bb4a..798084b45 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -9,6 +9,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed
+- **Incoming call messages show their real detail in the dashboard.** Call detail (`video` / `missed`) is now attached on the live whatsapp-web.js inbound path — as it already was on history — so an incoming call renders a specific labeled bubble instead of a generic "Call". (#548)
+- **Location messages no longer dump a base64 thumbnail in the chat list.** Both the live dashboard handler and the engine's chat summary now show a "📍 Location" label as the last-message preview instead of the multi-KB base64 map thumbnail. (#548)
+- **Logs pagination can reach every page.** The numbered pager was frozen at pages 1–5 (pages 6+ were only reachable by repeated "Next" clicks and the active highlight was lost); it now slides a centered, clamped window around the current page. (#548)
+- **Message Tester clears the group selection when the session changes.** A stale group id from the previous session could otherwise be sent to; it is reset and re-seeded from the new session's groups. (#548)
+- **The media lightbox caption shows a formatted time** instead of a raw ISO timestamp. (#548)
+- **The "Create API key" button is disabled while the request is in flight** (and shows a spinner), preventing a double-submit. (#548)
+- **QR polling no longer churns its own interval.** The poll callback reads the latest sessions via a ref, so it keeps a stable identity instead of being torn down and restarted on every sessions update. (#548)
+- **Editing a webhook clears its message-filters when no message events remain selected**, matching the create path and the (hidden) filter UI. (#548)
+- **A session-status toast fires once per real transition.** A double-signalled WS `session.status` event no longer produces a duplicate toast (and redundant refresh); the handler compares against the current status before reacting. (#548)
- **Dashboard chat media labels are localized.** The omitted-media placeholder and the chat image `alt` text were hardcoded English; both now use the `chats.media.*` translation keys, added across all 10 locales. (#547)
- **Spanish template-test hint interpolates correctly again.** The `templates.noPlaceholders` string had its `{{name}}` interpolation token localized to `{{nombre}}`, which broke substitution; the token is restored while the surrounding prose stays Spanish. (#547)
- **Arabic and Hebrew filter-count badges use the correct plural form.** The `webhooks.filters.badge` count was missing the required CLDR plural categories for Arabic (zero/two/few/many) and Hebrew (two), so i18next fell back to the singular noun; the missing forms are now provided. (#547)
diff --git a/dashboard/src/pages/ApiKeys.tsx b/dashboard/src/pages/ApiKeys.tsx
index b8f740b66..d50f6f1a5 100644
--- a/dashboard/src/pages/ApiKeys.tsx
+++ b/dashboard/src/pages/ApiKeys.tsx
@@ -302,8 +302,12 @@ export function ApiKeys() {
<button className="btn-secondary" onClick={() => setShowModal(false)}>
{t('common.cancel')}
</button>
- <button className="btn-primary" onClick={handleCreate}>
- {t('common.create')}
+ <button
+ className="btn-primary"
+ onClick={handleCreate}
+ disabled={createMutation.isPending || !newKey.name}
+ >
+ {createMutation.isPending ? <Loader2 className="animate-spin" size={16} /> : t('common.create')}
</button>
</div>
)}
diff --git a/dashboard/src/pages/Chats.tsx b/dashboard/src/pages/Chats.tsx
index 0fac45e96..e9538beb4 100644
--- a/dashboard/src/pages/Chats.tsx
+++ b/dashboard/src/pages/Chats.tsx
@@ -56,6 +56,9 @@ interface IncomingWsMessage {
fromMe?: boolean;
media?: MessageMedia;
quotedMessage?: { id: string; body: string };
+ // The backend emits `call` as a top-level field on the live `message.received` event (it's only
+ // folded into `metadata` on the persisted/history path), so declare it here to carry it through.
+ call?: { video: boolean; missed: boolean };
metadata?: ChatMessageView['metadata'];
}
@@ -220,6 +223,7 @@ export function Chats() {
metadata: newMsg.metadata || {
media: newMsg.media,
quotedMessage: newMsg.quotedMessage,
+ call: newMsg.call,
},
};
@@ -243,7 +247,8 @@ export function Chats() {
const updatedChats = [...prevChats];
const targetChat = { ...updatedChats[chatIndex] };
- targetChat.lastMessage = newMsg.body;
+ // A location message's body is the (multi-KB) base64 map thumbnail; show a label instead.
+ targetChat.lastMessage = newMsg.type === 'location' ? `📍 ${t('chats.media.location')}` : newMsg.body;
targetChat.timestamp = newMsg.timestamp;
if (!newMsg.fromMe && (!activeChat || activeChat.id !== targetChat.id)) {
@@ -255,7 +260,7 @@ export function Chats() {
return updatedChats;
});
},
- [selectedSessionId, activeChat, loadChats, markChatRead, appendMessage, onMessageAppended],
+ [selectedSessionId, activeChat, loadChats, markChatRead, appendMessage, onMessageAppended, t],
);
const handleIncomingMessageAck = useCallback(
@@ -601,20 +606,23 @@ export function Chats() {
const formatLastMessageSnippet = (chat: Chat) => chat.lastMessage || '';
- const formatChatTime = (timestamp?: number) => {
- if (!timestamp) return '';
- const date = new Date(timestamp * 1000);
- const today = new Date();
- if (date.toDateString() === today.toDateString()) {
- return date.toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' });
- }
- const yesterday = new Date(today);
- yesterday.setDate(yesterday.getDate() - 1);
- if (date.toDateString() === yesterday.toDateString()) {
- return t('chats.yesterday');
- }
- return date.toLocaleDateString([], { month: 'short', day: 'numeric' });
- };
+ const formatChatTime = useCallback(
+ (timestamp?: number) => {
+ if (!timestamp) return '';
+ const date = new Date(timestamp * 1000);
+ const today = new Date();
+ if (date.toDateString() === today.toDateString()) {
+ return date.toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' });
+ }
+ const yesterday = new Date(today);
+ yesterday.setDate(yesterday.getDate() - 1);
+ if (date.toDateString() === yesterday.toDateString()) {
+ return t('chats.yesterday');
+ }
+ return date.toLocaleDateString([], { month: 'short', day: 'numeric' });
+ },
+ [t],
+ );
const filteredChats = chats.filter(
c =>
@@ -633,9 +641,9 @@ export function Chats() {
url: getMediaSrc(m.metadata?.media),
alt: m.body || m.metadata?.media?.filename || '',
senderName: undefined,
- timestamp: m.createdAt,
+ timestamp: formatChatTime(m.timestamp || Math.floor(new Date(m.createdAt).getTime() / 1000)),
})),
- [messages],
+ [messages, formatChatTime],
);
return (
diff --git a/dashboard/src/pages/Logs.tsx b/dashboard/src/pages/Logs.tsx
index 5a6e0cedc..e51a99b2e 100644
--- a/dashboard/src/pages/Logs.tsx
+++ b/dashboard/src/pages/Logs.tsx
@@ -6,6 +6,7 @@ import { auditApi } from '../services/api';
import { useDocumentTitle } from '../hooks/useDocumentTitle';
import { useLogsQuery } from '../hooks/queries';
import { PageHeader } from '../components/PageHeader';
+import { pageWindow } from '../utils/pageWindow';
import './Logs.css';
export function Logs() {
@@ -206,7 +207,7 @@ export function Logs() {
{t('common.previous')}
</button>
<span className="page-numbers">
- {Array.from({ length: Math.min(totalPages, 5) }, (_, i) => i + 1).map(p => (
+ {pageWindow(page, totalPages).map(p => (
<button key={p} className={p === page ? 'active' : ''} onClick={() => setPage(p)}>
{p}
</button>
diff --git a/dashboard/src/pages/MessageTester.tsx b/dashboard/src/pages/MessageTester.tsx
index c7c79e716..b8c0e5840 100644
--- a/dashboard/src/pages/MessageTester.tsx
+++ b/dashboard/src/pages/MessageTester.tsx
@@ -44,6 +44,12 @@ export function MessageTester() {
}
}, [sessions, session]);
+ // Clear the group selection when the session changes so a stale group id from the previous session
+ // can't be sent to; the effect below then re-seeds groups[0].id once the new session's groups load.
+ useEffect(() => {
+ setSelectedGroup('');
+ }, [session]);
+
useEffect(() => {
if (groups.length > 0 && !selectedGroup) {
setSelectedGroup(groups[0].id);
diff --git a/dashboard/src/pages/Sessions.tsx b/dashboard/src/pages/Sessions.tsx
index 09d4613d0..17e89c21e 100644
--- a/dashboard/src/pages/Sessions.tsx
+++ b/dashboard/src/pages/Sessions.tsx
@@ -52,12 +52,26 @@ export function Sessions() {
}
}, [t, queryClient]);
+ // Mirror the latest sessions in a ref so the WS handler can compare against the current status without
+ // depending on `sessions` (which would churn the callback identity and re-subscribe the socket). Kept
+ // in sync with every state update (fetch / create / delete / WS) via the effect below.
+ const sessionsRef = useRef<Session[]>([]);
+ useEffect(() => {
+ sessionsRef.current = sessions;
+ }, [sessions]);
+
const { isConnected, subscribe } = useWebSocket({
onSessionStatus: useCallback(
(event: { sessionId: string; status: string }) => {
- setSessions(prev =>
- prev.map(s => (s.id === event.sessionId ? { ...s, status: event.status as Session['status'] } : s)),
+ const prev = sessionsRef.current.find(s => s.id === event.sessionId);
+ // Some engines double-signal one transition; only react to an ACTUAL status change so the toast
+ // and the failed-refresh don't fire on every redundant envelope. Update the ref synchronously so
+ // a duplicate arriving in the same tick (before the sync effect runs) is also caught.
+ if (prev && prev.status === event.status) return;
+ sessionsRef.current = sessionsRef.current.map(s =>
+ s.id === event.sessionId ? { ...s, status: event.status as Session['status'] } : s,
);
+ setSessions(sessionsRef.current);
if (event.status === 'ready') {
toast.success(t('sessions.toasts.readyTitle'), t('sessions.toasts.readyDesc'));
} else if (event.status === 'disconnected') {
@@ -89,8 +103,10 @@ export function Sessions() {
const currentSessionName = useRef<string>('');
const fetchQR = useCallback(async (sessionId: string) => {
- // Guard: if session is already connected, stop polling immediately.
- const currentSession = sessions.find(s => s.id === sessionId);
+ // Guard: if session is already connected, stop polling immediately. Read the ref (not `sessions`)
+ // so fetchQR keeps a stable identity — otherwise the polling interval is torn down and restarted on
+ // every sessions update.
+ const currentSession = sessionsRef.current.find(s => s.id === sessionId);
if (currentSession?.status === 'ready') {
setQrData(null);
currentSessionName.current = '';
@@ -116,7 +132,7 @@ export function Sessions() {
fetchSessions();
}
}
- }, [sessions]);
+ }, [fetchSessions]);
useEffect(() => {
if (qrData) {
diff --git a/dashboard/src/pages/Webhooks.tsx b/dashboard/src/pages/Webhooks.tsx
index 65b4726ff..9ea0f7291 100644
--- a/dashboard/src/pages/Webhooks.tsx
+++ b/dashboard/src/pages/Webhooks.tsx
@@ -152,7 +152,8 @@ export function Webhooks() {
sessionId: newWebhook.sessionId,
url: newWebhook.url,
events: newWebhook.events,
- filters: newWebhook.filters,
+ // Don't persist message-filters when no message events are selected (the filter UI is hidden).
+ filters: supportsFilters(newWebhook.events) ? newWebhook.filters : null,
});
setShowCreateModal(false);
setNewWebhook({ url: '', events: ['message.received'], sessionId: '', filters: null });
@@ -228,7 +229,8 @@ export function Webhooks() {
url: editWebhook.url,
events: editWebhook.events,
active: editWebhook.active,
- filters: editWebhook.filters ?? null,
+ // Clear message-filters if the edit removed all message events (the filter UI is hidden then).
+ filters: supportsFilters(editWebhook.events) ? (editWebhook.filters ?? null) : null,
},
});
setShowEditModal(false);
diff --git a/dashboard/src/utils/pageWindow.test.ts b/dashboard/src/utils/pageWindow.test.ts
new file mode 100644
index 000000000..8ce3c6feb
--- /dev/null
+++ b/dashboard/src/utils/pageWindow.test.ts
@@ -0,0 +1,35 @@
+import { test } from 'node:test';
+import assert from 'node:assert/strict';
+import { pageWindow } from './pageWindow.ts';
+
+test('returns empty for no pages', () => {
+ assert.deepEqual(pageWindow(1, 0), []);
+});
+
+test('small tables show every page (identity)', () => {
+ assert.deepEqual(pageWindow(1, 1), [1]);
+ assert.deepEqual(pageWindow(3, 5), [1, 2, 3, 4, 5]);
+});
+
+test('window stays anchored at the start near the first pages', () => {
+ assert.deepEqual(pageWindow(1, 10), [1, 2, 3, 4, 5]);
+ assert.deepEqual(pageWindow(2, 10), [1, 2, 3, 4, 5]);
+});
+
+test('window centers on the current page in the middle', () => {
+ assert.deepEqual(pageWindow(6, 10), [4, 5, 6, 7, 8]);
+});
+
+test('window stays anchored at the end near the last pages (pages 6+ reachable)', () => {
+ assert.deepEqual(pageWindow(10, 10), [6, 7, 8, 9, 10]);
+ assert.deepEqual(pageWindow(9, 10), [6, 7, 8, 9, 10]);
+});
+
+test('clamps an out-of-range current page', () => {
+ assert.deepEqual(pageWindow(0, 10), [1, 2, 3, 4, 5]);
+ assert.deepEqual(pageWindow(99, 10), [6, 7, 8, 9, 10]);
+});
+
+test('honors a custom window size', () => {
+ assert.deepEqual(pageWindow(5, 10, 3), [4, 5, 6]);
+});
diff --git a/dashboard/src/utils/pageWindow.ts b/dashboard/src/utils/pageWindow.ts
new file mode 100644
index 000000000..4cb9f79a5
--- /dev/null
+++ b/dashboard/src/utils/pageWindow.ts
@@ -0,0 +1,18 @@
+/**
+ * Compute the contiguous block of page numbers to show in a numbered paginator, centered on the
+ * current page and clamped to the valid range. Replaces a frozen `[1..5]` window that left pages
+ * beyond 5 unreachable by number and lost the active highlight.
+ *
+ * @param current 1-based current page (clamped into range).
+ * @param totalPages total number of pages.
+ * @param size max page buttons to show (default 5).
+ */
+export function pageWindow(current: number, totalPages: number, size = 5): number[] {
+ if (totalPages <= 0) return [];
+ const clamped = Math.min(Math.max(current, 1), totalPages);
+ const count = Math.min(size, totalPages);
+ // Center the window on the current page, then slide it back inside [1, totalPages].
+ let start = clamped - Math.floor(count / 2);
+ start = Math.max(1, Math.min(start, totalPages - count + 1));
+ return Array.from({ length: count }, (_, i) => start + i);
+}
diff --git a/src/engine/adapters/whatsapp-web-js.adapter.spec.ts b/src/engine/adapters/whatsapp-web-js.adapter.spec.ts
index 81fdb0678..c84ff9a50 100644
--- a/src/engine/adapters/whatsapp-web-js.adapter.spec.ts
+++ b/src/engine/adapters/whatsapp-web-js.adapter.spec.ts
@@ -927,6 +927,45 @@ describe('WhatsAppWebJsAdapter inbound media (MEDIA_DOWNLOAD_ENABLED=false)', ()
expect(msg.media?.mimetype).toBe('image/png');
expect(msg.media?.sizeBytes).toBe(5000);
});
+
+ it('surfaces call detail on a live incoming call_log message (#494)', async () => {
+ const adapter = new WhatsAppWebJsAdapter({
+ sessionId: 'sess-call-test',
+ sessionDataPath: './data/sessions',
+ puppeteer: {},
+ });
+ const client = Object.assign(new EventEmitter(), {
+ info: { wid: { user: '628123' }, pushname: 'Tester' },
+ getState: jest.fn().mockResolvedValue(WAState.CONNECTED),
+ pupPage: { evaluate: jest.fn().mockResolvedValue(true) },
+ });
+ (adapter as unknown as { client: unknown }).client = client;
+ const onMessage = jest.fn();
+ (adapter as unknown as { callbacks: unknown }).callbacks = { onMessage };
+ (adapter as unknown as { setupEventHandlers: () => void }).setupEventHandlers();
+
+ const mockMsg = {
+ id: { _serialized: 'CALL_1' },
+ body: '',
+ type: 'call_log',
+ timestamp: 1700000060,
+ fromMe: false,
+ hasMedia: false,
+ _data: { isVideoCall: true }, // no callDuration on an incoming call => missed
+ getContact: jest.fn().mockResolvedValue(null),
+ hasQuotedMsg: false,
+ };
+
+ client.emit('message', mockMsg);
+ await new Promise(r => setImmediate(r));
+
+ expect(onMessage).toHaveBeenCalledTimes(1);
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
+ const msg = onMessage.mock.calls[0][0] as { call?: { video: boolean; missed: boolean } };
+ expect(msg.call).toEqual({ video: true, missed: true });
+ });
});
describe('outbound mentions (#530)', () => {
diff --git a/src/engine/adapters/whatsapp-web-js.adapter.ts b/src/engine/adapters/whatsapp-web-js.adapter.ts
index d1b7a1eb1..a08a4997a 100644
--- a/src/engine/adapters/whatsapp-web-js.adapter.ts
+++ b/src/engine/adapters/whatsapp-web-js.adapter.ts
@@ -458,6 +458,11 @@ export class WhatsAppWebJsAdapter extends EventEmitter implements IWhatsAppEngin
}
}
+ // Surface call-log detail on the live path too (getChatHistory already does this), so a missed/
+ // video incoming call renders a labeled bubble instead of a generic "Call".
+ const call = extractWwebjsCall(msg);
+ if (call) incomingMessage.call = call;
+
this.callbacks.onMessage?.(incomingMessage);
} catch (error) {
this.logger.error('Error processing incoming message', String(error));
@@ -1540,7 +1545,8 @@ export class WhatsAppWebJsAdapter extends EventEmitter implements IWhatsAppEngin
isGroup: Boolean(chat.isGroup),
unreadCount: chat.unreadCount || 0,
timestamp: chat.timestamp || 0,
- lastMessage: chat.lastMessage?.body || undefined,
+ // A location message's body is the base64 map thumbnail; don't surface it as the chat preview.
+ lastMessage: chat.lastMessage?.type === MessageTypes.LOCATION ? '📍' : chat.lastMessage?.body || undefined,
});
}