Skip to content

fix: use current desktop web subplatforms#2693

Open
frndchagas wants to merge 2 commits into
WhiskeySockets:masterfrom
frndchagas:fix/desktop-websubplatform-win-hybrid
Open

fix: use current desktop web subplatforms#2693
frndchagas wants to merge 2 commits into
WhiskeySockets:masterfrom
frndchagas:fix/desktop-websubplatform-win-hybrid

Conversation

@frndchagas

@frndchagas frndchagas commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Updates Desktop full-history client payloads so fresh pairing/reconnect no longer advertises the legacy rejected Desktop sub-platform combination.
  • Maps Windows/Desktop full-history payloads to WebSubPlatform.WIN_HYBRID.
  • Maps Mac OS/Desktop full-history payloads to UserAgent.Platform.MACOS with WebSubPlatform.DARWIN.
  • Adds regression coverage for both registration and existing-creds login payloads, while keeping browser clients and Desktop without full-history on WEB_BROWSER.

Protocol / behavior context

The WhatsApp-side trigger is the registration/login ClientPayload sent before QR/open. Recent server behavior rejects the old full-history Desktop payloads before QR with 428:

  • Windows/Desktop + syncFullHistory: true previously emitted WEB + WIN32.
  • Mac OS/Desktop + syncFullHistory: true previously emitted WEB + DARWIN.

With this change, the previously failing Desktop full-history cases now reach QR in a throwaway-auth live check. No real pairing or auth-state inspection was needed.

WA Web captured JS sanity

Ran:

./tools/wa-web-sanity.sh 'WIN_HYBRID|WebSubPlatform|webSubPlatform|WAWebWamPlatform|CompanionRegClientUtils'

Relevant matches from the captured WA Web bundle:

  • WAWeb/Client/Payload.js
  • WAWeb/Wam/Platform.js
  • WAWeb/Protobufs/Wa6.pb.js

Relevant excerpt:

if (e === "WIN_HYBRID") return ...WIN_HYBRID

WAWeb/Client/Payload.js maps the runtime web platform to webInfo.webSubPlatform, and the protobuf bundle includes WIN_HYBRID as a valid ClientPayload.WebInfo.WebSubPlatform.

Validation

  • Focused unit test: yarn test --runTestsByPath src/__tests__/Utils/validate-connection.test.ts --runInBand
  • Full lint: yarn lint — 0 errors, 103 pre-existing no-explicit-any warnings
  • Full unit test suite: yarn test — 29 suites / 412 tests passing
  • Live no-pairing repro with throwaway auth dirs and WA Web 2.3000.1042632189:
    • Browsers.windows('Desktop') + syncFullHistory: true -> QR emitted
    • Browsers.macOS('Desktop') + syncFullHistory: true -> QR emitted
    • Browsers.ubuntu('Chrome') + syncFullHistory: true -> QR emitted
    • Browsers.windows('Desktop') + syncFullHistory: false -> QR emitted

Fixes #2677

Drafted with Codex, reviewed and tested by me.


Summary by cubic

Switch Desktop full-history client payloads to the current web subplatforms so registration/login are no longer rejected before QR. Windows now uses WIN_HYBRID; macOS uses MACOS platform with DARWIN subplatform.

  • Bug Fixes
    • Align Desktop full-history mapping: Windows -> WIN_HYBRID, macOS -> MACOS + DARWIN.
    • Keep WEB_BROWSER for browsers and Desktop without full history.
    • Add regression tests for registration and login payloads, including Desktop login user-agent.

Written for commit dab9e86. Summary will update on new commits.

Review in cubic

Summary by CodeRabbit

  • Bug Fixes

    • Improved connection setup device/platform detection, including refined desktop handling.
    • Windows desktop now reports the correct hybrid web sub-platform mapping.
    • macOS desktop clients correctly use the full-history desktop platform when enabled; non–full-history and other clients keep web behavior.
    • Android detection behavior remains consistent.
  • Tests

    • Added coverage for registration and login connection payloads across Windows, macOS, Ubuntu, and desktop clients with and without full-history syncing.

@whiskeysockets-bot

Copy link
Copy Markdown
Contributor

Thanks for opening this pull request and contributing to the project!

The next step is for the maintainers to review your changes. If everything looks good, it will be approved and merged into the main branch.

In the meantime, anyone in the community is encouraged to test this pull request and provide feedback.

✅ How to confirm it works

If you’ve tested this PR, please comment below with:

Tested and working ✅

This helps us speed up the review and merge process.

📦 To test this PR locally:

# NPM
npm install @whiskeysockets/baileys@frndchagas/Baileys#fix/desktop-websubplatform-win-hybrid

# Yarn (v2+)
yarn add @whiskeysockets/baileys@frndchagas/Baileys#fix/desktop-websubplatform-win-hybrid

# PNPM
pnpm add @whiskeysockets/baileys@frndchagas/Baileys#fix/desktop-websubplatform-win-hybrid

If you encounter any issues or have feedback, feel free to comment as well.

@coderabbitai

coderabbitai Bot commented Jul 4, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Refactors connection validation to derive userAgent.platform and webInfo.webSubPlatform through shared desktop-detection logic, changes Windows desktop web sub-platform mapping to WIN_HYBRID, and adds tests covering registration and login payload generation across browser and desktop combinations.

Changes

Desktop Platform Detection Fix

Layer / File(s) Summary
Platform selection helper and webInfo mapping
src/Utils/validate-connection.ts
Adds isDesktop and getUserAgentPlatform helpers, updates PLATFORM_MAP.Windows to WIN_HYBRID, and changes getWebInfo to use isDesktop(config) while selecting desktop sub-platform values.
Registration and login payload tests
src/__tests__/Utils/validate-connection.test.ts
Adds helpers for building registration and login payloads and assertions covering Windows/macOS desktop, Ubuntu browser, and syncFullHistory cases for both registration and login flows.

Estimated code review effort: 2 (Simple) | ~12 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Client
  participant generateRegistrationNode
  participant getUserAgent
  participant getWebInfo
  participant WhatsAppServer

  Client->>generateRegistrationNode: build payload with browser and syncFullHistory
  generateRegistrationNode->>getUserAgent: compute userAgent.platform
  getUserAgent->>getUserAgentPlatform: resolve WEB or MACOS
  getUserAgentPlatform-->>getUserAgent: platform value
  generateRegistrationNode->>getWebInfo: compute webInfo.webSubPlatform
  getWebInfo-->>generateRegistrationNode: WEB_BROWSER, WIN_HYBRID, or DARWIN
  generateRegistrationNode->>WhatsAppServer: submit connection node
Loading

Possibly related PRs

Suggested reviewers: canove, souravkl11, purpshell

Poem

A rabbit hopped through config trails,
To tune the platform code and scales.
WIN_HYBRID now, MACOS too,
Web sub-platforms hop straight through.
With tests in place, the path is bright,
And QR pairings feel just right.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The code and tests implement the reported fix by switching Desktop full-history payloads to WIN_HYBRID/DARWIN and preserving WEB_BROWSER otherwise.
Out of Scope Changes check ✅ Passed The refactor and new tests stay focused on the connection payload fix and support the linked issue.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: updating desktop web subplatform selection for current payloads.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
src/Utils/validate-connection.ts (1)

16-37: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add a comment explaining the WhatsApp-side quirk behind this platform selection.

The MACOS branch here exists specifically to work around WhatsApp's status-428 rejection for Windows/Desktop and Mac OS/Desktop full-history payloads (issue #2677). This non-obvious protocol workaround should be documented inline so future contributors don't "simplify" it away.

As per coding guidelines, "Write comments explaining the why — protocol quirks, WhatsApp-side behavior, non-obvious workarounds. Do not write comments that restate the code."

📝 Proposed comment addition
+// WhatsApp rejects Desktop full-history payloads (status 428, closed before QR)
+// unless macOS Desktop advertises userAgent.platform = MACOS alongside
+// webInfo.webSubPlatform = DARWIN. See issue `#2677`.
 const getUserAgentPlatform = (config: SocketConfig): proto.ClientPayload.UserAgent.Platform => {
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/Utils/validate-connection.ts` around lines 16 - 37, Add an inline comment
in getUserAgentPlatform explaining that the MACOS return for syncFullHistory on
Desktop with Mac OS is a WhatsApp protocol workaround for status-428 rejections
on Windows/Desktop and Mac OS/Desktop full-history payloads (issue `#2677`). Keep
the comment focused on the WhatsApp-side quirk and why this branch must remain,
so future changes to validate-connection.ts and getUserAgentPlatform do not
remove it as “simplification.”

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/__tests__/Utils/validate-connection.test.ts`:
- Around line 72-79: The Desktop login payload regression test is missing the
Windows-side user agent assertion, so the coverage is incomplete. In the `uses
the fixed Desktop web sub-platforms when logging in with existing creds` test,
add an expectation for `windowsPayload.userAgent?.platform` alongside the
existing `windowsPayload.webInfo?.webSubPlatform` check, using the same
`loginPayload` and `Browsers.windows('Desktop')` setup to verify it resolves to
the WEB platform and stays symmetric with the macOS assertions.

---

Nitpick comments:
In `@src/Utils/validate-connection.ts`:
- Around line 16-37: Add an inline comment in getUserAgentPlatform explaining
that the MACOS return for syncFullHistory on Desktop with Mac OS is a WhatsApp
protocol workaround for status-428 rejections on Windows/Desktop and Mac
OS/Desktop full-history payloads (issue `#2677`). Keep the comment focused on the
WhatsApp-side quirk and why this branch must remain, so future changes to
validate-connection.ts and getUserAgentPlatform do not remove it as
“simplification.”
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 5fa69046-4227-498f-8d9b-0459525cb52f

📥 Commits

Reviewing files that changed from the base of the PR and between 731cd6b and 0c76dee.

📒 Files selected for processing (2)
  • src/Utils/validate-connection.ts
  • src/__tests__/Utils/validate-connection.test.ts

Comment thread src/__tests__/Utils/validate-connection.test.ts

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

No issues found across 2 files

Re-trigger cubic

@luiscabus

luiscabus commented Jul 8, 2026

Copy link
Copy Markdown

Tested and working ✅
p.s.: It doesn't sync full history, but browser: Browsers.macOS('Desktop'), generated qr_code and synced 1 year

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Backlog

Development

Successfully merging this pull request may close these issues.

[BUG] WebSubPlatform WIN32/DARWIN (Desktop) → 428 "Connection Terminated" before QR is emitted; WEB_BROWSER works (7.0.0-rc13)

3 participants