Skip to content

fix: WhatsApp group conversations showing raw JID as name#4

Merged
chz160 merged 3 commits into
mainfrom
copilot/debug-whatsapp-group-name-format
May 11, 2026
Merged

fix: WhatsApp group conversations showing raw JID as name#4
chz160 merged 3 commits into
mainfrom
copilot/debug-whatsapp-group-name-format

Conversation

Copy link
Copy Markdown

Copilot AI commented May 11, 2026

WhatsApp group chats without a subject set show a raw internal JID (e.g. 16154856400-1585405251) as the conversation name in the web UI instead of something readable.

Changes

  • isRawGroupJIDName — replaces the previous regex approach; detects raw JID names by comparing the stored name directly against the known JID string or its local part (before @), avoiding false positives on real group subjects that happen to contain digits and hyphens (e.g. "2023-2024 Reunion")
  • deriveGroupName — builds a human-readable name from group participant records, preferring saved display names over bare phone numbers; output is deduplicated, sorted alphabetically for a stable result across SQLite row orderings, and capped at 5 names with a "+N more" suffix for large groups
  • joinGroupNames — helper that applies the N + "+N more" capping logic
  • isPhoneNumber — tightened to require 7–15 digits (ITU-T E.164 range), preventing short numeric strings from being misclassified as phone numbers
  • loadChats second pass — for groups whose name is empty or is a raw JID, derive from participants; fall back to the JID only when no participants exist
// Before: raw JID surfaced directly
if c.name == "" {
    c.name = c.jid  // e.g. "16154856400-1585405251@g.us"
}

// After: participant names tried first, safely
if c.name == "" || isRawGroupJIDName(c.name, c.jid) {
    if derived := deriveGroupName(c.participants); derived != "" {
        c.name = derived  // e.g. "Alice, Bob"
    } else {
        c.name = c.jid   // last resort
    }
}

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves WhatsApp Native imports so group conversations that have no subject (and therefore surface a raw group JID like 16154856400-1585405251) get a more human-readable name in the web UI by deriving a name from group members.

Changes:

  • Add a regex (rawGroupJIDRe) to detect “raw” WhatsApp group JID-style names.
  • Add deriveGroupName + isPhoneNumber to build readable group names from participant records.
  • Update loadChats to replace empty/raw group names with the derived participant-based name, with tests covering the new behavior.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
internal/importer/whatsapp_native.go Adds raw-JID detection and participant-derived naming logic for WhatsApp group chats.
internal/importer/whatsapp_native_test.go Adds unit/integration-style tests for raw-JID detection, name derivation, and loadChats fallback behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread internal/importer/whatsapp_native.go
Comment thread internal/importer/whatsapp_native.go Outdated
Comment thread internal/importer/whatsapp_native.go Outdated
@chz160 chz160 marked this pull request as ready for review May 11, 2026 02:08
@chz160
Copy link
Copy Markdown
Owner

chz160 commented May 11, 2026

@copilot apply changes based on the comments in this thread

Copy link
Copy Markdown
Author

Copilot AI commented May 11, 2026

@copilot apply changes based on the comments in this thread

Done in c8b7785. Three changes applied:

  1. rawGroupJIDRe false positives — replaced the regex with isRawGroupJIDName(name, jid) that only triggers when the stored name literally equals the JID or its local part. A real group subject like "2023-2024 Reunion" now passes through untouched (covered by TestLoadChatsRealSubjectNotOverwritten).

  2. deriveGroupName nondeterminism — names are now deduplicated, sorted alphabetically (stable across SQLite row orderings), and capped at 5 with a "+N more" suffix for large groups.

  3. isPhoneNumber too loose — now requires 7–15 digits (ITU-T E.164 range), so short numeric strings like "1" or "123" are no longer misclassified as phone numbers.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • instantmessaging-pa.googleapis.com
    • Triggering command: /tmp/TestBuiltBinaryAcceptsPairCommand3964019808/001/openmessage /tmp/TestBuiltBinaryAcceptsPairCommand3964019808/001/openmessage pair -stringintconv l/linux_amd64/vet /tmp/go-build274935996/b380/vet.cfg ux-amd64/src/os/-p ux-amd64/src/crygo.mau.fi/whatsmeow/types ux-amd64/pkg/tool/linux_amd64/compile user.name (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot finished work on behalf of chz160 May 11, 2026 02:15
Copilot AI requested a review from chz160 May 11, 2026 02:15
@chz160 chz160 requested a review from Copilot May 11, 2026 02:16
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

Comment thread internal/importer/whatsapp_native.go
@chz160 chz160 merged commit b6a59d8 into main May 11, 2026
4 checks passed
@chz160 chz160 deleted the copilot/debug-whatsapp-group-name-format branch May 11, 2026 02:18
@chz160
Copy link
Copy Markdown
Owner

chz160 commented May 11, 2026

@copilot apply changes based on the comments in this thread

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.

3 participants