Free, Open Source, Self-Hosted WhatsApp API Gateway
TypeScript apibotgatewayself-hostedwhatsappwhatsapp-apiwhatsapp-automationwhatsapp-botwhatsapp-gatewaywhatsapp-gateway-apiwhatsapp-webwhatsapp-web-api
fix(dashboard): give group sender names a palette per theme
Yudhi Armyndharis923335ada081
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 4c24e2ec5..48110ba6b 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -35,6 +35,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0- Make the deleted-message and omitted-media labels in outgoing dashboard chat bubbles readable in dark mode.- Match the dashboard New chat search against contact numbers only when the query reads as a phone number, so a name with a digit no longer lists every contact whose number holds that digit.- Read the dashboard Chats page's session list again when the page is shown, so a session deleted elsewhere no longer stays open.+- Draw group sender names in dashboard chat threads in colours that clear 4.5:1 on the incoming bubble in light and dark themes.## [0.26.0] - 2026-10-28diff --git a/dashboard/src/components/chats/ChatThread.tsx b/dashboard/src/components/chats/ChatThread.tsxindex 5b3f3ee70..d8aee5078 100644--- a/dashboard/src/components/chats/ChatThread.tsx+++ b/dashboard/src/components/chats/ChatThread.tsx@@ -39,13 +39,14 @@ import ArchivedMediaPreview, { type ArchivedMediaKind } from './ArchivedMediaPreimport MessageBody from './MessageBody';// 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'];+// Hashed from the sender's name so the same person keeps the same colour across a session. The colours+// are the chat palette's --chat-sender-1 to -8 (Chats.css), which each theme sets to clear 4.5:1 on its+// incoming bubble: no one hex does that on both the light and the dark bubble.+const SENDER_COLORS = 8;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];+ return `var(--chat-sender-${(Math.abs(hash) % SENDER_COLORS) + 1})`;};/** A message's time in epoch seconds: the WhatsApp timestamp, else when the gateway stored it. */diff --git a/dashboard/src/pages/Chats.css b/dashboard/src/pages/Chats.cssindex f2934c3b6..5af84886a 100644--- a/dashboard/src/pages/Chats.css+++ b/dashboard/src/pages/Chats.css@@ -29,6 +29,16 @@--chat-tick-read: #1f8fc4;--chat-icon: #54656f;--chat-shadow-bubble: 0 1px 0.5px rgba(11, 20, 26, 0.13);+ /* A group sender's name on the incoming bubble (ChatThread picks one per sender): each hue clears 4.5:1 there, so+ the dark set below lightens every one of them. */+ --chat-sender-1: #d03c6b;+ --chat-sender-2: #7756ff;+ --chat-sender-3: #097cb5;+ --chat-sender-4: #188556;+ --chat-sender-5: #b06000;+ --chat-sender-6: #c0392b;+ --chat-sender-7: #0e7c86;+ --chat-sender-8: #8e44ad;width: 100%;height: 100vh;@@ -59,6 +69,14 @@--chat-tick-read: #53bdeb;--chat-icon: #aebac1;--chat-shadow-bubble: 0 1px 0.5px rgba(11, 20, 26, 0.4);+ --chat-sender-1: #dc7093;+ --chat-sender-2: #987eff;+ --chat-sender-3: #0c9be2;+ --chat-sender-4: #1ea76b;+ --chat-sender-5: #dd7900;+ --chat-sender-6: #dd7469;+ --chat-sender-7: #12a2b0;+ --chat-sender-8: #b57dcc;}/* System-dark twin: the default 'system' theme removes data-theme entirely, so the explicit rule above@@ -86,6 +104,14 @@--chat-tick-read: #53bdeb;--chat-icon: #aebac1;--chat-shadow-bubble: 0 1px 0.5px rgba(11, 20, 26, 0.4);+ --chat-sender-1: #dc7093;+ --chat-sender-2: #987eff;+ --chat-sender-3: #0c9be2;+ --chat-sender-4: #1ea76b;+ --chat-sender-5: #dd7900;+ --chat-sender-6: #dd7469;+ --chat-sender-7: #12a2b0;+ --chat-sender-8: #b57dcc;}}diff --git a/dashboard/src/theme-contrast.test.ts b/dashboard/src/theme-contrast.test.tsindex 59581dd64..9d09d5d7f 100644--- a/dashboard/src/theme-contrast.test.ts+++ b/dashboard/src/theme-contrast.test.ts@@ -71,6 +71,9 @@ const CHAT_TEXT_ON: Array<[string, string[]]> = [// bubble has its own.['--chat-link', ['--chat-bubble-in']],['--chat-link-out', ['--chat-bubble-out']],+ // A group sender's name heads an incoming bubble in one of eight colours. One hex for both themes measured 3.92:1 at+ // worst on the light bubble and 2.44:1 on the dark one.+ ...Array.from({ length: 8 }, (_, i): [string, string[]] => [`--chat-sender-${i + 1}`, ['--chat-bubble-in']]),];const CHAT_ANCHORS = ['.chats-page {',@@ -90,6 +93,13 @@ for (const anchor of CHAT_ANCHORS) {});}+test('a group sender is named in the eight palette colours measured above, not in a hex of its own', () => {+ const thread = readFileSync(join(dirname(fileURLToPath(import.meta.url)), 'components/chats/ChatThread.tsx'), 'utf8');+ assert.match(thread, /const SENDER_COLORS = 8;/);+ assert.match(thread, /return `var\(--chat-sender-\$\{\(Math\.abs\(hash\) % SENDER_COLORS\) \+ 1\}\)`;/);+ assert.match(thread, /<div className="message-sender" style=\{\{ color: senderColor\(/);+});+const chatRule = (selector: string): string => {const css = CHATS_CSS.replace(/\/\*[\s\S]*?\*\//g, '');for (const m of css.matchAll(/([^{}]+)\{([^{}]*)\}/g)) {