#1724·OpenWA

[Bug]: Pinned Chat

Author: gLeW7Created Sep 26, 2026Updated Sep 27, 2026
Labelsbugengine:baileys

Pre-flight

  • I searched existing issues and this isn't a duplicate
  • I'm on the latest released version (or noted my version below)

OpenWA version

0.23.7

Deployment

Docker Compose

Database

SQLite (default)

WhatsApp engine

Bailys

What happened?

When linking a WhatsApp account using the Baileys engine, pinned individual (1:1) chats are not returned as pinned in GET /api/sessions/{sessionId}/chats (all individual chats return "pinned": false), even when they are pinned in WhatsApp Web and WhatsApp Mobile.

In the underlying SQLite database (chat_states table), the records with pinned = 1 do exist, but their chatId is saved using the contact's WhatsApp LID (<numeric_lid>@lid) rather than their phone number JID (@c.us), as WhatsApp Multi-Device protocol sends state syncs under LIDs.

When BaileysSessionStore.toNeutralChat(c) builds the chat list, it attempts to look up this.chatStateStore?.get(this.sessionId, id) using c.id (which is @c.us). Because of the LID vs phone JID mismatch, st is undefined and pinned resolves to false.

Steps to reproduce

  1. Pin one or two individual (1:1) chats in WhatsApp on your phone or WhatsApp Web.
  2. Connect an OpenWA session using ENGINE_TYPE=baileys.
  3. Check the internal SQLite database (openwa.sqlite): SELECT * FROM chat_states WHERE pinned = 1; (Rows with pinned = 1 are present, but chatId is formatted as <numeric_lid>@lid).
  4. Call GET /api/sessions/{sessionId}/chats: Notice all returned individual chats have "pinned": false.

Expected behavior

GET /api/sessions/{sessionId}/chats should report "pinned": true for chats that are pinned in WhatsApp.

BaileysSessionStore.toNeutralChat(c) should resolve the contact's LID (via lidStore / lidToPn) before querying this.chatStateStore.get(this.sessionId, ...), so that states saved under @lid are matched to their phone chat.

Relevant logs

bash
SQLite database:
sqlite> SELECT sessionId, chatId, pinned, updatedAt FROM chat_states WHERE pinned = 1;
00000000-0000-0000-0000-000000000001|12345678901234@lid|1|2026-09-25 18:28:35.747
00000000-0000-0000-0000-000000000001|98765432109876@lid|1|2026-09-25 18:28:35.746

sqlite> SELECT * FROM lid_mappings WHERE lid = '12345678901234';
12345678901234|15551234567|00000000-0000-0000-0000-000000000001|2026-09-25 17:17:54.723

API Output:
GET /api/sessions/00000000-0000-0000-0000-000000000001/chats
[
  {
    "id": "[email protected]",
    "name": "Alice Contact",
    "pinned": false
  }
]

Code reference (/app/src/engine/adapters/baileys-session-store.ts ~line 347):
toNeutralChat(c: BaileysChatSummary): NeutralChat {
    const id = c.id; // "[email protected]"
    const st = this.sessionId ? this.chatStateStore?.get(this.sessionId, id) : undefined;
    ...
    pinned: st ? st.pinned : Boolean(c.pinned),
}

Environment / additional context

  • OpenWA version: 0.23.6
  • Engine: Baileys (ENGINE_TYPE=baileys)
  • Node version: v22.23.2
  • OS: Linux (Docker, x86_64)
  • Database: SQLite (default /app/data/openwa.sqlite)