Skip to content

fix(baileys): show saved/contact names in the Chats list (#369)#370

Merged
rmyndharis merged 1 commit into
mainfrom
fix/baileys-chat-contact-names
Jun 20, 2026
Merged

fix(baileys): show saved/contact names in the Chats list (#369)#370
rmyndharis merged 1 commit into
mainfrom
fix/baileys-chat-contact-names

Conversation

@rmyndharis

Copy link
Copy Markdown
Owner

Closes #369.

Problem

On the Baileys engine, the dashboard Chats list showed a raw number — or a privacy-id for @lid contacts — instead of the saved/contact name. The dashboard already renders chat.name || chat.id.split('@')[0], so the gap was server-side: BaileysSessionStore.toNeutralChat() returned name: c.name ?? userPart(c.id) and never consulted the synced contacts map, even though the name data (name / verifiedName / notify), the lidToPn map, and resolvePhone() all already live in that same store.

Fix

Add a resolveContactName(id) priority chain used only when Baileys gives the chat no title:

  1. Chat title (Chat.name) — unchanged, still wins.
  2. Saved contact nameverifiedNamepushName (notify).
  3. For a @lid chat: resolve to the phone via lidToPn / contact.phoneNumber, then look up that phone-JID contact's name.
  4. Raw user-part — last resort (previous behavior), so a number/lid is never shown as a JID.

Engine-neutral: no interface change — ChatSummary.name is simply better populated. whatsapp-web.js is unaffected.

Tests

Added 5 cases to baileys-session-store.spec.ts (TDD, watched them fail first): chat-title-wins, contact-name fallthrough, @lid via lidToPn, pushName fallback, raw-user-part last resort.

  • npx jest933/933 pass (86 suites)
  • npm run build clean, eslint clean

Notes

When Baileys gave a chat no title, the Chats list fell back to the raw JID
user-part (a bare number, or a privacy-id for @lid contacts). Resolve a
best-known display name from the synced contacts (saved name -> verifiedName
-> pushName), and for a @lid chat look up the contact behind the resolved
phone, keeping the raw user-part only as a last resort.

No API shape change; ChatSummary.name is simply better populated.
@rmyndharis rmyndharis merged commit ce27d45 into main Jun 20, 2026
5 checks passed
@rmyndharis rmyndharis deleted the fix/baileys-chat-contact-names branch June 20, 2026 01:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: Show saved contact / push names in the dashboard Chats list (Baileys returns raw JID/@lid instead of the name)

1 participant