Skip to content

docs(events): document Event::SentFrame and the with_stats → with_observers rename - #502

Merged
jlucaso1 merged 4 commits into
mainfrom
claude/nifty-bohr-gmxoem
Aug 8, 2026
Merged

docs(events): document Event::SentFrame and the with_stats → with_observers rename#502
jlucaso1 merged 4 commits into
mainfrom
claude/nifty-bohr-gmxoem

Conversation

@jlucaso1

@jlucaso1 jlucaso1 commented Aug 8, 2026

Copy link
Copy Markdown
Collaborator

Summary

Documents whatsapp-rust#1260 ("observe what the client sends, not only what it receives"), which added a new opt-in Event::SentFrame — the outbound counterpart of Event::RawNode — and, as part of wiring it in, made a breaking rename to NoiseSocket's constructor and do_handshake's last parameter.

  • Event::SentFrame carries the marshaled plaintext of every frame the noise sender hands to the transport, gated by a new Client::acquire_sent_frame_forwarding() -> SentFrameLease. It covers every send path, including the ones that hand pre-marshaled bytes straight to the socket (acks, delivery receipts, direct-encoded IQs) that the existing wait_for_sent_node waiter never saw.
  • Breaking: NoiseSocket::with_stats(..., stats: Option<Arc<SessionStats>>) is now NoiseSocket::with_observers(..., observers: SendObservers), and do_handshake's last parameter changed the same way. SendObservers is one struct carrying both the existing SessionStats hook and the new SentFrame tap, so future observers plug in there instead of widening these constructors again.

Changes

  • concepts/events.mdx — added SentFrame to the Event enum listing and a new "Sent frame events" section, modeled on the existing DecryptedPayload section (same lease-gated pattern).
  • api/client.mdx — added ### acquire_sent_frame_forwarding, modeled on acquire_decrypted_payload_forwarding.
  • advanced/websocket-handling.mdx — documented the new SendObservers struct, updated the with_observers/sender_task code blocks and do_handshake signature, and called out the breaking rename with <Note> blocks in both spots.

Not changed

  • changelog/*.mdx — left untouched per standing instructions (changelog entries are human-authored only).
  • advanced/observability.mdx — checked; it only covers the tracing feature and has no NoiseSocket/SessionStats content to update.
  • api/transport.mdx — checked; it documents the Transport trait, not NoiseSocket, so nothing there references with_stats.

Note for a maintainer

While researching this, I noticed concepts/events.mdx and api/client.mdx currently describe RawNode as toggle-gated (client.set_raw_node_forwarding(bool)), but the current whatsapp-rust source (src/client/accessors.rs) only exposes a lease-based acquire_raw_node_forwarding() -> RawNodeLease — there's no set_raw_node_forwarding in the source anymore. That's a pre-existing staleness unrelated to PR #1260, so I left it out of this PR's scope, but it's worth a follow-up doc fix.


Generated by Claude Code


Summary by cubic

Documents the new outbound event Event::SentFrame and the breaking rename from with_stats to with_observers. Clarifies that .with_sent_frames(...) is crate-internal and that consumers should use Client::acquire_sent_frame_forwarding().

  • New Features

    • Added Event::SentFrame docs and examples in concepts/events.mdx (opt-in via lease; covers all send paths).
    • Added Client::acquire_sent_frame_forwarding() to api/client.mdx with usage notes; example registers the handler before acquiring the lease.
    • Documented SendObservers in advanced/websocket-handling.mdx, including how it publishes sent frames and the public vs crate-internal wiring.
    • Fixed the Connect walkthrough do_handshake(...) call signature and the SessionStats cross-link.
  • Migration

    • Breaking: NoiseSocket::with_stats(..., Option<Arc<SessionStats>>)NoiseSocket::with_observers(..., SendObservers).
    • do_handshake last parameter now observers: SendObservers (was stats: Option<Arc<SessionStats>>).
    • To keep prior behavior: pass SendObservers::with_stats(stats); for none, SendObservers::default().
    • Sent-frame forwarding for consumers: use Client::acquire_sent_frame_forwarding(). .with_sent_frames(...) and sent_frame_tap are pub(crate) and used internally.

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

…servers rename

whatsapp-rust#1260 added Event::SentFrame / Client::acquire_sent_frame_forwarding()
as the outbound counterpart of RawNode, and renamed NoiseSocket::with_stats to
with_observers (now taking a SendObservers struct instead of
Option<Arc<SessionStats>>), with the same change threading through
do_handshake's last parameter.

- concepts/events.mdx: add SentFrame to the Event enum listing and a new
  "Sent frame events" section modeled on DecryptedPayload's.
- api/client.mdx: add acquire_sent_frame_forwarding, modeled on
  acquire_decrypted_payload_forwarding.
- advanced/websocket-handling.mdx: document SendObservers, update the
  with_observers/sender_task signatures, and note the breaking rename.
@mintlify

mintlify Bot commented Aug 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 Aug 8, 2026, 12:52 PM

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

@coderabbitai

coderabbitai Bot commented Aug 8, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@jlucaso1, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 14 minutes

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 9a87d027-5a78-4f39-8f25-f10a1ea1a912

📥 Commits

Reviewing files that changed from the base of the PR and between 05e1d22 and f803956.

📒 Files selected for processing (3)
  • advanced/websocket-handling.mdx
  • api/client.mdx
  • concepts/events.mdx

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 Aug 8, 2026

Copy link
Copy Markdown

Greptile Summary

The PR documents outbound SentFrame events and migration from with_stats to the extensible SendObservers API.

  • Adds lease-gated sent-frame forwarding documentation and examples.
  • Updates Noise socket and handshake signatures, observer wiring, and migration guidance.
  • Corrects the connection walkthrough and the SessionStats cross-reference.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Important Files Changed

Filename Overview
advanced/websocket-handling.mdx Documents SendObservers, the renamed socket and handshake APIs, and a corrected six-argument connection walkthrough.
api/client.mdx Adds the public sent-frame forwarding lease contract and a correctly ordered registration example.
concepts/events.mdx Adds Event::SentFrame, its payload semantics, exclusions, decoding guidance, and corrected observer-accounting cross-reference.

Sequence Diagram

sequenceDiagram
    participant Consumer
    participant Client
    participant NoiseSender
    participant Transport
    participant EventBus
    Consumer->>Client: acquire_sent_frame_forwarding()
    Client->>NoiseSender: enable SentFrame tap
    NoiseSender->>Transport: send encrypted frame
    Transport-->>NoiseSender: write accepted
    NoiseSender->>EventBus: publish Event::SentFrame(plaintext)
    EventBus-->>Consumer: dispatch event
Loading

Reviews (4): Last reviewed commit: "docs(websocket): clarify with_sent_frame..." | Re-trigger Greptile

Comment thread concepts/events.mdx Outdated
…reference

Per Greptile review on PR #502:
- The Connect walkthrough's do_handshake call still showed the pre-SendObservers
  argument list; updated it to match the real call site in
  src/client/lifecycle.rs.
- SentFrame's SessionStats reference pointed at advanced/observability.mdx,
  which doesn't document SessionStats; point it at the websocket-handling page
  that actually covers it.
greptile-apps[bot]
greptile-apps Bot previously approved these changes Aug 8, 2026

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c2a3d0935d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread api/client.mdx Outdated
```rust
use wacore::types::events::{ChannelEventHandler, Event};

let _lease = client.acquire_sent_frame_forwarding();

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 Badge Register the handler before acquiring the frame lease

When the connected client can send concurrently—for example, from a keepalive, acknowledgement worker, or another task—acquiring the lease here activates publication before the handler is registered. Any frame sent between these statements is dispatched without this consumer and is lost, which undermines the documented session-recording use case. Register the handler first, then acquire the lease so every frame produced after activation has a receiver.

Useful? React with 👍 / 👎.

Per Codex review on PR #502: acquiring the lease first activates
forwarding immediately, so a frame sent between the lease call and
register_handler would dispatch to no one. Swap the order in the example.
@greptile-apps
greptile-apps Bot dismissed their stale review August 8, 2026 12:59

Dismissed because a newer commit was pushed; Greptile will re-review the current head.

greptile-apps[bot]
greptile-apps Bot previously approved these changes Aug 8, 2026

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

All reported issues were addressed

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

Re-trigger cubic

Comment thread advanced/websocket-handling.mdx
Per cubic review on PR #502: the breaking-change note described chaining
.with_sent_frames(...) without flagging that it (and sent_frame_tap) are
pub(crate), so a reader outside the crate could try to call it and hit a
privacy error. Spell out the pub/pub(crate) split and point at
Client::acquire_sent_frame_forwarding() as the actual public entry point.
@greptile-apps
greptile-apps Bot dismissed their stale review August 8, 2026 13:03

Dismissed because a newer commit was pushed; Greptile will re-review the current head.

@jlucaso1
jlucaso1 merged commit 61b8338 into main Aug 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