Skip to content

docs: history sync compressed streaming API (PR #853) - #323

Merged
jlucaso1 merged 6 commits into
mainfrom
claude/eager-cerf-gburuj
Jun 11, 2026
Merged

jlucaso1 merged 6 commits into
mainfrom
claude/eager-cerf-gburuj

Conversation

@jlucaso1

@jlucaso1 jlucaso1 commented Jun 11, 2026

Copy link
Copy Markdown
Collaborator

Updates documentation for the breaking API changes introduced in oxidezap/whatsapp-rust#853.

Changes

concepts/events.mdx

LazyHistorySync section rewritten:

  • Description updated: events now hold the compressed zlib payload (~10× smaller than decompressed)
  • Struct definition updated: raw_bytes: Bytescompressed: Bytes + decompressed_size: usize
  • raw_bytes() method removed; replaced with compressed_bytes(), decompressed_size(), decompress(), stream()
  • get() semantics updated: compressed payload is no longer consumed — all accessors remain available after calling get()
  • Clone semantics updated: refcount bump only, no decode cache carried over
  • Old <Warning> about ~2× memory removed; replaced with <Tip> recommending spawn_blocking for large blobs
  • Examples updated: added streaming and decompress() examples, removed raw_bytes() example

New HistorySyncStream section added (after LazyHistorySync):

  • Documents next_conversation_bytes(), next_conversation(), skipped_conversations(), remainder()
  • Documents MAX_DECOMPRESSED constant
  • Documents HistorySyncError::UnreadConversations error variant

changelog/2026-06-11-history-sync-compressed-streaming.mdx (new)

New changelog entry covering:

  • Compressed payload storage and memory model change
  • Single-copy inflate optimization
  • Boxed large proto submessages (HistorySyncMsg.message, WebMessageInfo.message)
  • Latent panic fix in small-cap decompress
  • Truncated zlib stream fix
  • Full breaking changes table and migration guide

References


Generated by Claude Code


Summary by cubic

Docs updated for compressed history sync storage with a new streaming reader, plus a changelog and concise migration notes for the breaking API. Also fixes a shadowed match guard in the event-filtering example. Aligns with oxidezap/whatsapp-rust#853.

  • New Features

    • Rewrote LazyHistorySync docs for zlib-compressed storage; added compressed_bytes(), decompressed_size(), decompress(), stream(); get() is non-consuming; cloning is a refcount bump.
    • Added HistorySyncStream docs with next_conversation_bytes(), next_conversation(), remainder(), skipped_conversations(), and MAX_DECOMPRESSED; documents HistorySyncError::UnreadConversations.
    • Updated api/bot and architecture docs: events retain compressed bytes (O(compressed) queue cost); recommend .stream() for incremental, memory-bounded processing.
    • Clarified RawNode usage: require client.set_raw_node_forwarding(true) and include EventKind::RawNode in handler interest(); dispatch is skipped when disabled.
    • New changelog entry: memory model change, single-copy inflate, boxed large protobuf fields, and fixes for small-cap panic and truncated zlib streams.
  • Bug Fixes

    • Reordered match guards in the event-filtering example so the is_group branch runs before !is_from_me.

Written for commit 5ca8705. Summary will update on new commits.

Review in cubic

Summary by CodeRabbit

  • New Features

    • History sync now uses compressed storage with on-demand decompression and introduces a streaming reader for memory-efficient processing of large payloads.
  • Documentation

    • Updated event structure documentation for call events and disappearing-messages mode notifications.
    • Added detailed streaming API documentation with usage examples and decompression guidelines.

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

@coderabbitai

coderabbitai Bot commented Jun 11, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

This PR updates documentation for the WhatsApp Rust SDK to reflect history sync event compression with streaming support and introduces revised APIs for multiple event types. The changelog documents the shift to compressed payloads with on-demand decompression, while concepts/events.mdx expands API documentation for lazy-loaded history sync and updates event structures for calls, disappearing messages, and raw node forwarding.

Changes

Event API Documentation

Layer / File(s) Summary
LazyHistorySync compression and metadata API
changelog/2026-06-11-history-sync-compressed-streaming.mdx, concepts/events.mdx
Changelog entry and LazyHistorySync struct documentation introduce compressed-payload storage with explicit decompressed_size, replace raw-bytes access with compressed_bytes(), and add get() for cached full-proto decode and decompress() for one-shot decompression.
HistorySyncStream iteration and usage examples
concepts/events.mdx
New HistorySyncStream<'a> interface with conversation iteration, remainder decoding, and skipped-conversation tracking, plus usage examples for memory-bounded streaming and custom parsing of large compressed payloads.
Other event type documentation updates
concepts/events.mdx
GroupParticipantInfo masking format corrected; IncomingCall struct simplified; DisappearingModeChanged fields updated to expiration and initiator; RawNode event documentation rewritten for opt-in forwarding via Client::set_raw_node_forwarding(true).

Sequence Diagram

sequenceDiagram
  participant Client
  participant LazyHistorySync
  participant HistorySyncStream
  participant HistorySync as HistorySync Proto
  Client->>LazyHistorySync: compressed_bytes()
  LazyHistorySync-->>Client: Bytes (compressed)
  Client->>LazyHistorySync: get()
  LazyHistorySync-->>Client: Option ~HistorySync~ (cached)
  Client->>LazyHistorySync: stream()
  LazyHistorySync-->>Client: HistorySyncStream
  loop Process Conversations
    Client->>HistorySyncStream: next_conversation()?
    HistorySyncStream-->>Client: Proto (decoded)
  end
  Client->>HistorySyncStream: remainder()?
  HistorySyncStream-->>Client: Bytes (final chunk)
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

🐰 Compressed histories now stream with grace,
No full decode to slow the race,
Lazy loading saves the day,
While HistorySyncStream clears the way,
Events refined in every place! 📚✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: documentation updates for history sync compressed streaming API, which matches the primary focus of the changeset.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/eager-cerf-gburuj

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 and usage tips.

@mintlify

mintlify Bot commented Jun 11, 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 Jun 11, 2026, 9:44 PM

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

@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

Caution

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

⚠️ Outside diff range comments (1)
concepts/events.mdx (1)

1519-1553: ⚠️ Potential issue | 🟠 Major

Align docs with compressed_bytes()/decompress() and remove .raw_bytes() guidance.

  • concepts/architecture.mdx:498 and api/bot.mdx:487 still describe LazyHistorySync as wrapping a “decompressed blob” and tell consumers to use .raw_bytes() for custom partial decoding; update these to the new compressed_bytes()/decompress() contract (and adjust wording accordingly).
  • concepts/events.mdx uses ## RawNode; format it per docs heading/code-reference conventions (e.g., ## \RawNode`` or sentence-case form).
🤖 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 `@concepts/events.mdx` around lines 1519 - 1553, Update the docs to reflect
that LazyHistorySync exposes compressed bytes and a decompression API rather
than a “decompressed blob”: replace any guidance to use `.raw_bytes()` with
instructions to call `compressed_bytes()` for zero-copy access and
`decompress()` to get an inflated `Bytes` buffer; update text in
concepts/architecture.mdx and api/bot.mdx where `LazyHistorySync` is described
(search for mentions of `LazyHistorySync`, `.raw_bytes()`, “decompressed blob”)
to use the new `compressed_bytes()`/`decompress()` contract and adjust wording
about partial decoding accordingly. Also reformat the heading `RawNode` in
concepts/events.mdx to follow docs conventions (e.g., use a code reference like
`RawNode` or sentence-case) so it renders consistently with other code
references.
🧹 Nitpick comments (1)
changelog/2026-06-11-history-sync-compressed-streaming.mdx (1)

10-10: ⚡ Quick win

Rewrite this paragraph in second person and split it into shorter sentences.

This sentence packs multiple ideas and uses third-person narration. Please rewrite it so you address the reader directly and keep one idea per sentence.

As per coding guidelines, "Use active voice and second person ('you') in documentation" and "Keep sentences concise — one idea per sentence in documentation".

🤖 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 `@changelog/2026-06-11-history-sync-compressed-streaming.mdx` at line 10,
Rewrite the paragraph to address the reader in second person and split it into
short, single-idea sentences using active voice: explain that Event::HistorySync
used to carry a fully decoded Box<wa::HistorySync> (the whole conversation
history as a heap-allocated Rust struct), note that large InitialBootstrap
chunks could reach 5–20 MB after decoding, then state that the event is now
Box<LazyHistorySync>, and finish by saying LazyHistorySync keeps the original
zlib-compressed bytes (about 10× smaller) and decodes on demand; ensure each
sentence contains only one idea and reference the symbols Event::HistorySync,
Box<wa::HistorySync>, InitialBootstrap, Box<LazyHistorySync>, and
LazyHistorySync.

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 `@concepts/events.mdx`:
- Line 1966: The heading "## RawNode" should format the identifier as inline
code; update the heading to use code formatting for the symbol RawNode (i.e.,
change the heading to use backticks around RawNode) so it reads as a code
reference and follows the documentation guideline for code identifiers.

---

Outside diff comments:
In `@concepts/events.mdx`:
- Around line 1519-1553: Update the docs to reflect that LazyHistorySync exposes
compressed bytes and a decompression API rather than a “decompressed blob”:
replace any guidance to use `.raw_bytes()` with instructions to call
`compressed_bytes()` for zero-copy access and `decompress()` to get an inflated
`Bytes` buffer; update text in concepts/architecture.mdx and api/bot.mdx where
`LazyHistorySync` is described (search for mentions of `LazyHistorySync`,
`.raw_bytes()`, “decompressed blob”) to use the new
`compressed_bytes()`/`decompress()` contract and adjust wording about partial
decoding accordingly. Also reformat the heading `RawNode` in concepts/events.mdx
to follow docs conventions (e.g., use a code reference like `RawNode` or
sentence-case) so it renders consistently with other code references.

---

Nitpick comments:
In `@changelog/2026-06-11-history-sync-compressed-streaming.mdx`:
- Line 10: Rewrite the paragraph to address the reader in second person and
split it into short, single-idea sentences using active voice: explain that
Event::HistorySync used to carry a fully decoded Box<wa::HistorySync> (the whole
conversation history as a heap-allocated Rust struct), note that large
InitialBootstrap chunks could reach 5–20 MB after decoding, then state that the
event is now Box<LazyHistorySync>, and finish by saying LazyHistorySync keeps
the original zlib-compressed bytes (about 10× smaller) and decodes on demand;
ensure each sentence contains only one idea and reference the symbols
Event::HistorySync, Box<wa::HistorySync>, InitialBootstrap,
Box<LazyHistorySync>, and LazyHistorySync.
🪄 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: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 1994c6c0-1a45-4b0f-998d-25edbfde4e05

📥 Commits

Reviewing files that changed from the base of the PR and between ab41023 and 2e0aff1.

📒 Files selected for processing (2)
  • changelog/2026-06-11-history-sync-compressed-streaming.mdx
  • concepts/events.mdx

Comment thread concepts/events.mdx Outdated

@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 across 2 files

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

Fix all with cubic | Re-trigger cubic

Comment thread concepts/events.mdx Outdated

@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 across 1 file (changes from recent commits).

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

Fix all with cubic | Re-trigger cubic

Comment thread concepts/events.mdx
claude and others added 2 commits June 11, 2026 22:45
The `!is_from_me` arm came first and matched group messages from others
before the `is_group` arm could fire. Reorder so the more specific
`is_group` branch runs first.

https://claude.ai/code/session_01KwjzmWFn9LCCeHdY5DYkvA
@jlucaso1
jlucaso1 merged commit 669ec1e into main Jun 11, 2026
2 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