docs: reflect write-once cell refactor from whatsapp-rust#1227 - #483
Conversation
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
|
Preview deployment for your docs. Learn more about Mintlify Previews.
💡 Tip: Enable Workflows to automatically generate PRs for you. |
📝 WalkthroughWalkthroughThe 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. ChangesSynchronous APIs and mutexes
Estimated code review effort: 2 (Simple) | ~10 minutes 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 |
|
| 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
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
There was a problem hiding this comment.
💡 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".
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
There was a problem hiding this comment.
💡 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".
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
There was a problem hiding this comment.
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
📒 Files selected for processing (5)
advanced/signal-protocol.mdxadvanced/websocket-handling.mdxapi/chatstate.mdxapi/client.mdxconcepts/architecture.mdx
There was a problem hiding this comment.
Review completed against the latest diff
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
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
Dismissed because a newer commit was pushed; Greptile will re-review the current head.
Summary
Updates the API reference to match whatsapp-rust#1227 ("perf(client): hoist write-once state out of async mutexes"), which moved several
Clientfields from async-lock primitives tostd::synclocks /OnceLockand droppedasyncfrom a couple of call surfaces.api/client.mdx—register_chatstate_handleris no longerasync. 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.awaitfrom theregister_chatstate_handlerexample.concepts/architecture.mdx— theClientstruct snippet'snoise_socketfield and thePendingDeviceSync.pendingfield both moved fromasync_lock/Mutextostd::sync::Mutex; updated both snippets and the surrounding paragraph that previously said the client usesasync-lockfor all internal synchronization (now mixed, with the rule for which lock type applies).advanced/signal-protocol.mdx—PendingDeviceSync::addis no longerasync(and already took&Jid, not an owned clone); updated thehandle_unknown_device_syncexample accordingly.The PR's public breaking changes were
register_chatstate_handlerand theClient::group_cachefield type.group_cache's field type was never documented directly in this repo (only the unrelatedCacheConfig::group_cache/CacheStores::group_cacheconfig keys are), so no change was needed there.No changelog entry included per standing instruction — those are added by a human.
Test plan
git diffreviewed — only the intended lines changed, no incidental reformatting.Generated by Claude Code
Summary by cubic
Updates docs to match
whatsapp-rust#1227.register_chatstate_handleris now sync,noise_socketexamples usestd::synclocks, and the synchronization overview is clearer.Migration
.awaitwhen callingclient.register_chatstate_handler(...).Refactors
register_chatstate_handlerto sync with a breaking-change note, active voice/second person, and a note on copy-on-write registration; removed.awaitin the chatstate example.PendingDeviceSync::add(&jid)to sync; alignednoise_socketusage with the source usingget_noise_socket()andstd::sync::Mutexlocking in connect, read loop, send, and cleanup.std::sync::Mutex,OnceLock), narrowed the compile-error caveat toSendfutures, and split the synchronization overview into short sentences.Written for commit 89ae08e. Summary will update on new commits.