Skip to content

docs: update event examples for the event-payload API freeze (whatsapp-rust#1004) - #399

Merged
jlucaso1 merged 3 commits into
mainfrom
claude/nifty-bohr-3j2k01
Jul 8, 2026
Merged

docs: update event examples for the event-payload API freeze (whatsapp-rust#1004)#399
jlucaso1 merged 3 commits into
mainfrom
claude/nifty-bohr-3j2k01

Conversation

@jlucaso1

@jlucaso1 jlucaso1 commented Jul 8, 2026

Copy link
Copy Markdown
Collaborator

What

Updates the docs to reflect oxidezap/whatsapp-rust#1004 — "refactor(events): complete the event-payload API freeze" — which:

  • Sealed the last ~25 event payload structs (Receipt, InboundMessage, MessageBatch, UndecryptableMessage, LoggedOut, Disconnected, PairSuccess, PairError, the three PairPasskey* structs, DeviceListUpdate/DeviceNotificationInfo, IdentityChange, BusinessStatusUpdate, DisappearingModeChanged, MexNotification, NewsletterLiveUpdate(+Message/+Reaction), TemporaryBan, ConnectFailure, StreamError, OfflineSyncPreview, OfflineSyncCompleted) with #[non_exhaustive] + a generated bon builder.
  • Converted 3 inline Event enum-variant fields to sealed newtype structs: Event::PairingQrCode { code, timeout }Event::PairingQrCode(PairingQrCode) (and likewise for PairingCode, PairingCodeRefresh).
  • Converted 4 unit-marker events (Connected, ClientOutdated, QrScannedWithoutMultidevice, StreamReplaced) to empty sealed structs built via X::builder().build().
  • Widened EventInterest from u64 to u128 (EventKind::CAPACITY 64 → 128).
  • Changed ConnectFailure.message from String (empty-string sentinel) to Option<String>.

All of these are breaking changes for consumers who pattern-match on the old shapes or construct these payloads directly.

Doc changes

  • concepts/events.mdx — the primary reference: updated the Event enum listing, the payload-stability note (freeze is now complete, not "rolling out"), every affected struct definition (added #[non_exhaustive] + bon::Builder), the three pairing-event sections (rewritten for the newtype shape), the EventKind/EventInterest capacity note (64→128), and every InboundMessage { .. } / Disconnected { .. } destructuring example to add the now-required .. rest.
  • concepts/authentication.mdx — QR/pair-code/pair-code-refresh sections rewritten for the newtype shape (struct defs, construction via .builder()…build(), match patterns); PairSuccess/PairError/LoggedOut construction examples updated to builder syntax; added breaking-change notes.
  • api/bot.mdx, api/receipt.mdx — updated matching examples and struct sealing notes.
  • guides/receiving-messages.mdx, guides/communities.mdx, guides/sending-messages.mdx, guides/media-handling.mdx, api/client.mdx, advanced/inbound-durability.mdx, pt/quickstart.mdx — mechanical fix: added the .. rest to InboundMessage { .. } destructuring patterns (now required since the struct is #[non_exhaustive]).

No changes to changelog/ (per project convention, that's maintained by a human).

Test plan

  • Doc site build (Mintlify) passes
  • Spot-check rendered concepts/events.mdx and concepts/authentication.mdx for formatting

Generated by Claude Code


Summary by cubic

Updates docs to reflect oxidezap/whatsapp-rust#1004 event-payload API freeze. Examples now use sealed #[non_exhaustive] payloads with bon builders, newtype-wrapped pairing events, widened EventInterest (u128), ConnectFailure.message: Option<String>, and add the missing bon::Builder derive to the InboundMessage snippet in advanced/inbound-durability.mdx.

  • Migration
    • Update patterns: Event::PairingQrCode(PairingQrCode { code, timeout, .. }), Event::PairingCode(PairingCode { .. }), Event::PairingCodeRefresh(PairingCodeRefresh { .. }).
    • Add .. when destructuring sealed structs, e.g. InboundMessage { message, info, .. }, Disconnected { reason, .. }, Receipt { source, r#type, .. }.
    • Construct payloads via builders: Type::builder()…build(); unit markers are empty sealed structs (e.g., Connected::builder().build()).
    • Handle ConnectFailure.message as Option<String> (not an empty-string sentinel).
    • EventInterest is now a u128 mask (capacity 128); public helpers are unchanged.

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

Summary by CodeRabbit

  • Documentation
    • Updated code examples across the docs to match the latest event and message-handling patterns.
    • Examples now show safer destructuring with .., helping readers avoid breakage when payloads gain new fields.
    • Pairing, receipt, logout, and other event snippets were refreshed to use the newer builder-based construction style.
    • Several authentication and event-handling guides were aligned with the latest payload shapes and matching patterns.

Reflects PR #1004 in oxidezap/whatsapp-rust, "refactor(events): complete
the event-payload API freeze": event payload structs are now
#[non_exhaustive] with bon::Builder construction, and PairingQrCode,
PairingCode, and PairingCodeRefresh moved from inline enum-variant
fields to newtype-wrapped structs.
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

@mintlify

mintlify Bot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Preview deployment for your docs. Learn more about Mintlify Previews.

Project Status Preview Updated (UTC)
whatsapp-rust 🟢 Ready View Preview Jul 8, 2026, 8:41 AM

💡 Tip: Enable Workflows to automatically generate PRs for you.

@coderabbitai

coderabbitai Bot commented Jul 8, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Documentation across the site is updated to reflect that event payload structs (Connected, Disconnected, InboundMessage, Receipt, PairingQrCode, PairingCode, and others) are now #[non_exhaustive] bon-builder types. Examples update destructuring patterns to add .. rest bindings and convert pairing event matches to tuple-struct form.

Changes

Event payload non-exhaustive documentation

Layer / File(s) Summary
Core events reference updates
concepts/events.mdx
Documents completed payload-stability policy, widened EventKind capacity, tuple-style pairing variants, bon::Builder/#[non_exhaustive] markers across all payload structs, breaking-change notes, and updated .. destructuring in examples.
Receipt and InboundMessage struct docs
api/receipt.mdx, advanced/inbound-durability.mdx
Adds #[non_exhaustive] attribute and notes requiring .. rest patterns for Receipt and InboundMessage.
Authentication pairing examples
concepts/authentication.mdx
Updates QR pairing, pair-code, passkey, success/logout examples to tuple-struct destructuring with .. and bon builder construction, with breaking-change notes.
API reference examples
api/bot.mdx, api/client.mdx
Updates InboundMessage destructuring to add .. and rewrites Event::PairingCode/PairingQrCode match arms to tuple-struct form.
Guides message handling
guides/communities.mdx, guides/media-handling.mdx, guides/sending-messages.mdx
Updates InboundMessage destructuring examples to include ...
Portuguese quickstart
pt/quickstart.mdx
Updates imports and examples for tuple-struct PairingQrCode/PairingCode matching and InboundMessage .. destructuring.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Possibly related PRs

Suggested reviewers: greptile-apps, cubic-dev-ai

Poem

With ears perked up, I hop through docs,
Adding .. to catch the odd non-blocks,
Builders bloom where fields once lay bare,
#[non_exhaustive] structs now everywhere,
A rabbit's cheer for stable ground! 🐇📚

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the docs updates for the event-payload API freeze and the related event example changes.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

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.

@greptile-apps

greptile-apps Bot commented Jul 8, 2026

Copy link
Copy Markdown

Greptile Summary

This PR updates eleven documentation files to reflect the completed event-payload API freeze in whatsapp-rust#1004, where ~25 payload structs were sealed with #[non_exhaustive] + bon::Builder, three inline Event enum-variant fields were converted to newtype structs, four unit-marker events became empty sealed structs, EventInterest widened to u128, and ConnectFailure.message changed to Option<String>.

  • Pattern updates: All InboundMessage { message, info } destructuring patterns across every guide and API reference gain the required .. rest, and Event::PairingQrCode { code, timeout } / PairingCode / PairingCodeRefresh inline-field patterns are rewritten to destructure through their new newtype wrappers.
  • Struct definitions: Every affected struct gains the #[derive(Debug, Clone, Serialize, bon::Builder)] + #[non_exhaustive] header in docs, plus breaking-change <Note> callouts where consumer code must change.
  • Breaking-change callouts: New <Note> blocks call out every shape change with migration guidance, including the ConnectFailure.message: String → Option<String> conversion and the EventInterest u64→u128 widening.

Confidence Score: 5/5

Documentation-only PR with no runtime code changes; all patterns are mechanically consistent with the described API freeze.

Every structural change is applied consistently across all eleven files. The one minor doc inconsistency — Receipt's struct definition in api/receipt.mdx missing the derive line present everywhere else — does not affect correctness of the library or any consumer code.

api/receipt.mdx — Receipt struct definition is missing #[derive(Debug, Clone, Serialize, bon::Builder)] relative to the same struct in concepts/events.mdx.

Important Files Changed

Filename Overview
concepts/events.mdx Primary event reference updated comprehensively: enum listing rewritten for newtype pairing variants, all affected struct definitions gain derive + non_exhaustive, capacity/interest widening noted, and all InboundMessage destructuring patterns updated with .. rest.
concepts/authentication.mdx QR/pair-code/pair-code-refresh sections fully rewritten for newtype shapes; PairSuccess/PairError/LoggedOut construction examples updated to builder syntax; PairPasskey structs noted as non_exhaustive; Best Practices event-handling snippet updated consistently.
api/receipt.mdx Receipt struct shown as #[non_exhaustive] only — the #[derive(Debug, Clone, Serialize, bon::Builder)] line present in concepts/events.mdx for the same struct was not added here, leaving the definition inconsistent between the two pages.
api/bot.mdx Three pattern sites updated: InboundMessage .. rest (two locations) and PairingCode/PairingQrCode newtype destructuring; imports extended to include the new struct types.
guides/receiving-messages.mdx Five InboundMessage destructuring sites updated; PairingQrCode enum-variant updated in the illustrative Event enum listing; all changes accurate.
advanced/inbound-durability.mdx InboundMessage struct definition gains derive + non_exhaustive annotation; single mechanical change, correct.
pt/quickstart.mdx Portuguese quickstart updated: PairingQrCode/PairingCode newtype patterns and InboundMessage .. rest applied consistently across all four code snippets; PairingCode import correctly added to the pair-code section.
api/client.mdx Single InboundMessage destructuring pattern updated with .. rest; change is minimal and correct.
guides/communities.mdx Single InboundMessage destructuring updated with .. rest; mechanical and correct.
guides/media-handling.mdx Single InboundMessage destructuring updated with .. rest; mechanical and correct.
guides/sending-messages.mdx Single InboundMessage destructuring updated with .. rest; mechanical and correct.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[Event dispatched] --> B{Event variant}
    B --> C["Event::Messages(MessageBatch)"]
    B --> D["Event::PairingQrCode(PairingQrCode)"]
    B --> E["Event::PairingCode(PairingCode)"]
    B --> F["Event::PairingCodeRefresh(PairingCodeRefresh)"]
    B --> G["Event::Connected(Connected {})"]
    B --> H["Event::Disconnected(Disconnected)"]
    B --> I["Event::Receipt(Receipt)"]
    B --> J[Other sealed structs ...]
    C --> C1["for InboundMessage { message, info, .. } in batch.iter()"]
    D --> D1["PairingQrCode { code, timeout, .. }"]
    E --> E1["PairingCode { code, timeout, .. }"]
    F --> F1["PairingCodeRefresh { force_manual, .. }"]
    G --> G1["Connected::builder().build()"]
    H --> H1["Disconnected::builder().reason(r).build()"]
    I --> I1["Receipt { source, r#type, .. } — needs .."]
Loading
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
flowchart TD
    A[Event dispatched] --> B{Event variant}
    B --> C["Event::Messages(MessageBatch)"]
    B --> D["Event::PairingQrCode(PairingQrCode)"]
    B --> E["Event::PairingCode(PairingCode)"]
    B --> F["Event::PairingCodeRefresh(PairingCodeRefresh)"]
    B --> G["Event::Connected(Connected {})"]
    B --> H["Event::Disconnected(Disconnected)"]
    B --> I["Event::Receipt(Receipt)"]
    B --> J[Other sealed structs ...]
    C --> C1["for InboundMessage { message, info, .. } in batch.iter()"]
    D --> D1["PairingQrCode { code, timeout, .. }"]
    E --> E1["PairingCode { code, timeout, .. }"]
    F --> F1["PairingCodeRefresh { force_manual, .. }"]
    G --> G1["Connected::builder().build()"]
    H --> H1["Disconnected::builder().reason(r).build()"]
    I --> I1["Receipt { source, r#type, .. } — needs .."]
Loading

Reviews (2): Last reviewed commit: "docs: add bon::Builder derive to Inbound..." | Re-trigger Greptile

@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.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
advanced/inbound-durability.mdx (1)

107-112: 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Also show the bon::Builder derive for InboundMessage.

#[non_exhaustive] is added without the derive line. concepts/events.mdx documents InboundMessage as #[derive(Debug, Clone, Serialize, bon::Builder)] with #[non_exhaustive], so include the derive here for consistency and to signal that external construction goes through the builder.

📝 Proposed alignment
+#[derive(Debug, Clone, Serialize, bon::Builder)]
 #[non_exhaustive]
 pub struct InboundMessage {
     pub message: Arc<wa::Message>,
     pub info: Arc<MessageInfo>,
 }
🤖 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 `@advanced/inbound-durability.mdx` around lines 107 - 112, The InboundMessage
definition is missing the bon::Builder derive, so update the struct declaration
to match the documented shape used elsewhere. In the InboundMessage block, add
the derive list alongside the existing non_exhaustive attribute so it includes
bon::Builder (and the other documented traits if present), matching the
InboundMessage symbol referenced in concepts/events.mdx. This keeps external
construction aligned with the builder pattern and consistent across the docs.
🤖 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.

Outside diff comments:
In `@advanced/inbound-durability.mdx`:
- Around line 107-112: The InboundMessage definition is missing the bon::Builder
derive, so update the struct declaration to match the documented shape used
elsewhere. In the InboundMessage block, add the derive list alongside the
existing non_exhaustive attribute so it includes bon::Builder (and the other
documented traits if present), matching the InboundMessage symbol referenced in
concepts/events.mdx. This keeps external construction aligned with the builder
pattern and consistent across the docs.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 4dc84024-7dce-46d1-b051-cc552b0e1288

📥 Commits

Reviewing files that changed from the base of the PR and between 76d12e9 and 0f2500a.

📒 Files selected for processing (10)
  • advanced/inbound-durability.mdx
  • api/bot.mdx
  • api/client.mdx
  • api/receipt.mdx
  • concepts/authentication.mdx
  • concepts/events.mdx
  • guides/communities.mdx
  • guides/media-handling.mdx
  • guides/sending-messages.mdx
  • pt/quickstart.mdx

@cubic-dev-ai cubic-dev-ai 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.

1 issue found and verified against the latest diff

Confidence score: 4/5

  • In concepts/authentication.mdx, the updated event-handling snippet uses unqualified PairingQrCode, PairingCode, and PairingCodeRefresh types, which can fail to compile (or mislead readers) if those names are not already in scope; merging as-is risks a broken docs example and avoidable developer confusion — qualify or import the payload types in the snippet before merging.
Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="concepts/authentication.mdx">

<violation number="1" location="concepts/authentication.mdx:100">
P2: The updated best-practices event-handling snippet introduces three unqualified payload type names (`PairingQrCode`, `PairingCode`, `PairingCodeRefresh`) that now must be in scope for the pattern to compile. Before the API freeze, matching on inline enum-variant fields only required `Event` to be imported. Consider adding an `use` line (e.g., `use wacore::types::events::{Event, PairingQrCode, PairingCode, PairingCodeRefresh};`) above the snippet or qualifying the types, so the example remains copy-pasteable for readers.</violation>
</file>

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

.on_event(|event, _client| async move {
match &*event {
Event::PairingQrCode { code, timeout } => {
Event::PairingQrCode(PairingQrCode { code, timeout, .. }) => {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2: The updated best-practices event-handling snippet introduces three unqualified payload type names (PairingQrCode, PairingCode, PairingCodeRefresh) that now must be in scope for the pattern to compile. Before the API freeze, matching on inline enum-variant fields only required Event to be imported. Consider adding an use line (e.g., use wacore::types::events::{Event, PairingQrCode, PairingCode, PairingCodeRefresh};) above the snippet or qualifying the types, so the example remains copy-pasteable for readers.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At concepts/authentication.mdx, line 100:

<comment>The updated best-practices event-handling snippet introduces three unqualified payload type names (`PairingQrCode`, `PairingCode`, `PairingCodeRefresh`) that now must be in scope for the pattern to compile. Before the API freeze, matching on inline enum-variant fields only required `Event` to be imported. Consider adding an `use` line (e.g., `use wacore::types::events::{Event, PairingQrCode, PairingCode, PairingCodeRefresh};`) above the snippet or qualifying the types, so the example remains copy-pasteable for readers.</comment>

<file context>
@@ -97,7 +97,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
         .on_event(|event, _client| async move {
             match &*event {
-                Event::PairingQrCode { code, timeout } => {
+                Event::PairingQrCode(PairingQrCode { code, timeout, .. }) => {
                     println!("Scan this QR code (valid for {}s):", timeout.as_secs());
                     println!("{}", code);
</file context>

….mdx

Addresses CodeRabbit review comment on #399 — the struct shown was
missing the derive line shown elsewhere for the same (now-sealed)
InboundMessage struct.

@cubic-dev-ai cubic-dev-ai 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.

0 issues found across 1 file (changes from recent commits).

Requires human review: Auto-approval blocked by 1 unresolved issue from previous reviews.

Re-trigger cubic

@jlucaso1
jlucaso1 merged commit 94c4131 into main Jul 8, 2026
4 checks passed
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.

2 participants