Skip to content

docs: reflect write-once cell refactor from whatsapp-rust#1227 - #483

Merged
jlucaso1 merged 5 commits into
mainfrom
claude/nifty-bohr-ms0pxg
Aug 7, 2026
Merged

docs: reflect write-once cell refactor from whatsapp-rust#1227#483
jlucaso1 merged 5 commits into
mainfrom
claude/nifty-bohr-ms0pxg

Conversation

@jlucaso1

@jlucaso1 jlucaso1 commented Aug 7, 2026

Copy link
Copy Markdown
Collaborator

Summary

Updates the API reference to match whatsapp-rust#1227 ("perf(client): hoist write-once state out of async mutexes"), which moved several Client fields from async-lock primitives to std::sync locks / OnceLock and dropped async from a couple of call surfaces.

  • api/client.mdxregister_chatstate_handler is no longer async. Updated the signature and added a <Warning> breaking-change note (matching the convention already used elsewhere in this doc, e.g. download.mdx), plus a short mention of the new copy-on-write registration behavior.
  • api/chatstate.mdx — dropped the stale .await from the register_chatstate_handler example.
  • concepts/architecture.mdx — the Client struct snippet's noise_socket field and the PendingDeviceSync.pending field both moved from async_lock/Mutex to std::sync::Mutex; updated both snippets and the surrounding paragraph that previously said the client uses async-lock for all internal synchronization (now mixed, with the rule for which lock type applies).
  • advanced/signal-protocol.mdxPendingDeviceSync::add is no longer async (and already took &Jid, not an owned clone); updated the handle_unknown_device_sync example accordingly.

The PR's public breaking changes were register_chatstate_handler and the Client::group_cache field type. group_cache's field type was never documented directly in this repo (only the unrelated CacheConfig::group_cache / CacheStores::group_cache config keys are), so no change was needed there.

No changelog entry included per standing instruction — those are added by a human.

Test plan

  • Verified every touched code snippet against the PR's actual diff (field types, method signatures, call sites) rather than the PR description alone.
  • git diff reviewed — only the intended lines changed, no incidental reformatting.

Generated by Claude Code


Summary by cubic

Updates docs to match whatsapp-rust #1227. register_chatstate_handler is now sync, noise_socket examples use std::sync locks, and the synchronization overview is clearer.

  • Migration

    • Drop .await when calling client.register_chatstate_handler(...).
  • Refactors

    • API docs: updated register_chatstate_handler to sync with a breaking-change note, active voice/second person, and a note on copy-on-write registration; removed .await in the chatstate example.
    • Advanced guides: switched PendingDeviceSync::add(&jid) to sync; aligned noise_socket usage with the source using get_noise_socket() and std::sync::Mutex locking in connect, read loop, send, and cleanup.
    • Architecture: refreshed lock types (std::sync::Mutex, OnceLock), narrowed the compile-error caveat to Send futures, and split the synchronization overview into short sentences.

Written for commit 89ae08e. Summary will update on new commits.

register_chatstate_handler is no longer async (breaking); update its
reference signature and the chatstate example call site. Also refresh
the internal noise_socket / PendingDeviceSync lock types shown in the
architecture doc and the pending_device_sync.add() call in the Signal
Protocol doc, which the same PR moved from async-lock to std::sync.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AHB1c3sSbAvVhju9PsQCWP
@mintlify

mintlify Bot commented Aug 7, 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 7, 2026, 4:16 PM

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

@coderabbitai

coderabbitai Bot commented Aug 7, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The documentation updates describe synchronous mutex access for noise sockets and pending device synchronization. They also document synchronous chat-state handler registration and update related examples and callsites.

Changes

Synchronous APIs and mutexes

Layer / File(s) Summary
Synchronization contracts
concepts/architecture.mdx
The architecture documentation distinguishes async-lock usage from synchronous locks and documents synchronous mutexes for Client.noise_socket and PendingDeviceSync.pending.
Noise socket access
advanced/websocket-handling.mdx
Connection setup, message sending, socket retrieval, and cleanup use synchronous mutex access.
Synchronous registration callsites
api/client.mdx, api/chatstate.mdx, advanced/signal-protocol.mdx
The documentation describes synchronous register_chatstate_handler registration, removes .await from its example, normalizes a code fence, and updates pending device synchronization to call add synchronously.

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

Suggested reviewers: greptile-apps

Poem

A rabbit checks the mutex tight,
No await hops through the night.
Handlers register, queues align,
Socket locks now follow the line.
Docs grow crisp beneath moonlight.

🚥 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 clearly identifies a documentation update that reflects the referenced write-once cell refactor.

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

Copy link
Copy Markdown

Greptile Summary

The PR updates the API and architecture documentation for the upstream write-once state refactor.

  • Removes obsolete .await usage from synchronous chat-state and pending-device-sync calls.
  • Documents the new synchronous chat-state registration behavior.
  • Updates the Noise socket and pending-device synchronization examples to use std::sync::Mutex.
  • Aligns WebSocket lifecycle snippets with the synchronous Noise socket accessor and locking model.

Confidence Score: 5/5

The PR appears safe to merge.

The previously reported Noise socket synchronization inconsistency has been fixed, and no blocking failure remains.

Important Files Changed

Filename Overview
advanced/signal-protocol.mdx Updates deferred device-sync registration to use the synchronous borrowed-JID API.
advanced/websocket-handling.mdx Correctly replaces the obsolete Noise socket APIs with synchronous mutex locking and accessor calls, resolving the previous synchronization inconsistency.
api/chatstate.mdx Removes the obsolete await from the chat-state handler registration example.
api/client.mdx Documents the synchronous chat-state handler signature, copy-on-write behavior, and migration requirement.
concepts/architecture.mdx Updates the documented synchronization model and affected field types consistently with the refactor.

Reviews (3): Last reviewed commit: "docs: use active voice and second person..." | Re-trigger Greptile

Comment thread concepts/architecture.mdx
The connect/read-loop/send/cleanup examples mixed ArcSwap-style
.store()/.load() calls with .lock().await, none of which matched the
real Client::noise_socket field (a std::sync::Mutex, accessed via
get_noise_socket() / lock().unwrap_or_else(...)). Align all four
snippets with the actual source.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AHB1c3sSbAvVhju9PsQCWP

@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: 7e0219fc47

ℹ️ 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 concepts/architecture.mdx Outdated
Comment thread concepts/architecture.mdx
std::sync::MutexGuard is only rejected across an .await when the
enclosing future must be Send (e.g. a spawned task) — a !Send future
still compiles holding one. The prior wording overstated this as a
blanket guarantee and lumped in OnceLock, which has no guard to hold
across an .await in the first place.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AHB1c3sSbAvVhju9PsQCWP

@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: 11eedfc4cd

ℹ️ 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 concepts/architecture.mdx Outdated
Per the style guide (AGENTS.md), each primitive's selection rule and
the Send-future caveat now get their own sentence instead of one long
compound one.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AHB1c3sSbAvVhju9PsQCWP
greptile-apps[bot]
greptile-apps Bot previously approved these changes Aug 7, 2026

@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: 2

🤖 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 `@api/client.mdx`:
- Around line 1816-1818: Add release-note coverage for the breaking change
documented in the register_chatstate_handler warning: add a migration note
identifying the first affected release and instructing users to remove .await at
call sites, or explicitly confirm that the release process excludes this change.
- Line 1814: Rewrite the handler description near the registration signature to
address the reader directly and use active voice. State that the caller supplies
an Arc-wrapped handler, then describe copy-on-write registration and the
zero-handler no-lock behavior in separate concise sentences.
🪄 Autofix

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: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 6ba56bf9-feaf-49e0-8798-67c088e392ce

📥 Commits

Reviewing files that changed from the base of the PR and between 489300a and 2a5b546.

📒 Files selected for processing (5)
  • advanced/signal-protocol.mdx
  • advanced/websocket-handling.mdx
  • api/chatstate.mdx
  • api/client.mdx
  • concepts/architecture.mdx

Comment thread api/client.mdx Outdated
Comment thread api/client.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.

Review completed against the latest diff

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

Re-trigger cubic

Comment thread concepts/architecture.mdx
Per the style guide (AGENTS.md), address the reader directly and keep
one idea per sentence.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AHB1c3sSbAvVhju9PsQCWP
@greptile-apps
greptile-apps Bot dismissed their stale review August 7, 2026 16:28

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

@jlucaso1
jlucaso1 merged commit 663a83d into main Aug 7, 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