fix: use current desktop web subplatforms#2693
Conversation
|
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 worksIf you’ve tested this PR, please comment below with: This helps us speed up the review and merge process. 📦 To test this PR locally:If you encounter any issues or have feedback, feel free to comment as well. |
📝 WalkthroughWalkthroughRefactors connection validation to derive ChangesDesktop Platform Detection Fix
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
Possibly related PRs
Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
src/Utils/validate-connection.ts (1)
16-37: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAdd a comment explaining the WhatsApp-side quirk behind this platform selection.
The
MACOSbranch here exists specifically to work around WhatsApp's status-428 rejection forWindows/DesktopandMac OS/Desktopfull-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
📒 Files selected for processing (2)
src/Utils/validate-connection.tssrc/__tests__/Utils/validate-connection.test.ts
|
Tested and working ✅ |
Summary
Windows/Desktopfull-history payloads toWebSubPlatform.WIN_HYBRID.Mac OS/Desktopfull-history payloads toUserAgent.Platform.MACOSwithWebSubPlatform.DARWIN.WEB_BROWSER.Protocol / behavior context
The WhatsApp-side trigger is the registration/login
ClientPayloadsent before QR/open. Recent server behavior rejects the old full-history Desktop payloads before QR with 428:Windows/Desktop+syncFullHistory: truepreviously emittedWEB + WIN32.Mac OS/Desktop+syncFullHistory: truepreviously emittedWEB + 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.jsWAWeb/Wam/Platform.jsWAWeb/Protobufs/Wa6.pb.jsRelevant excerpt:
WAWeb/Client/Payload.jsmaps the runtime web platform towebInfo.webSubPlatform, and the protobuf bundle includesWIN_HYBRIDas a validClientPayload.WebInfo.WebSubPlatform.Validation
yarn test --runTestsByPath src/__tests__/Utils/validate-connection.test.ts --runInBandyarn lint— 0 errors, 103 pre-existingno-explicit-anywarningsyarn test— 29 suites / 412 tests passing2.3000.1042632189:Browsers.windows('Desktop')+syncFullHistory: true-> QR emittedBrowsers.macOS('Desktop')+syncFullHistory: true-> QR emittedBrowsers.ubuntu('Chrome')+syncFullHistory: true-> QR emittedBrowsers.windows('Desktop')+syncFullHistory: false-> QR emittedFixes #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.
Written for commit dab9e86. Summary will update on new commits.
Summary by CodeRabbit
Bug Fixes
Tests