Skip to content

docs: add USync typed query engine reference - #420

Merged
jlucaso1 merged 14 commits into
mainfrom
claude/nifty-bohr-6205s0
Jul 22, 2026
Merged

docs: add USync typed query engine reference#420
jlucaso1 merged 14 commits into
mainfrom
claude/nifty-bohr-6205s0

Conversation

@jlucaso1

@jlucaso1 jlucaso1 commented Jul 21, 2026

Copy link
Copy Markdown
Collaborator

Summary

Documents the typed USync query engine added in oxidezap/whatsapp-rust#1063 ("feat(core): add typed USync query engine").

  • New page api/usync.mdx — full reference for Client::query_usync, the UsyncQuery/UsyncUser/UsyncProtocol builders, the UsyncResponse/UsyncOutcome<T>/UsyncProtocolResult response model (including bot profile, username, text status, disappearing mode, and feature-flag subprotocols), the phone-number canonicalization behavior, the UsyncValidationError variants, and hosted PN/LID addressing via Jid::with_device_hosting.
  • api/client.mdx — added a query_usync entry under Feature APIs, alongside the existing signal()/contacts() accessors, pointing to the new page.
  • api/store.mdx — documented the new is_hosted field and DeviceInfo::new/with_hosting constructors, and called out the breaking change (struct-literal DeviceInfo construction no longer compiles; persisted JSON is unaffected).
  • api/wacore.mdx — expanded the usync module bullet to mention the typed model and link to the new page.
  • docs.json — added api/usync to the API Reference → Features navigation group.

Breaking changes covered

  • DeviceInfo (wacore::store::traits) and UsyncDevice (wacore::usync) both gained an is_hosted: bool field — struct-literal construction no longer compiles; use the new ::new()/with_hosting() constructors. Persisted JSON deserializes unaffected (is_hosted defaults to false).
  • UsyncMode::Delta and UsyncContext::Voip are new enum variants on non-#[non_exhaustive] enums — an exhaustive match over either will fail to compile until the new arms are handled.

Out of scope

No changelog/ entries were added or modified per standing instructions (changelog is human-maintained).


Generated by Claude Code


Summary by cubic

Adds a USync typed query engine reference and links it across the docs so developers can call Client::query_usync directly. Also documents hosted device addressing, clarifies DeviceInfo destructuring impact and new enum variants, and fixes a mistaken SignalManager reference to Signal on the USync page.

  • New Features

    • New page api/usync.mdx: reference for Client::query_usync, UsyncQuery/UsyncUser/UsyncProtocol, response types, subprotocols (bot profile, username, text status, disappearing mode, features), phone canonicalization, validation errors, and hosted PN/LID addressing via Jid::with_device_hosting.
    • Linked from api/client.mdx (adds query_usync), api/wacore.mdx (typed model blurb + link), and docs.json (navigation).
    • api/store.mdx and concepts/storage.mdx: document DeviceInfo::new/with_hosting, the new is_hosted field, and the destructuring/pattern-matching impact.
  • Migration

    • Update DeviceInfo and UsyncDevice construction: use ::new(...).with_hosting(...) instead of struct literals; persisted JSON remains compatible (is_hosted defaults to false).
    • Fix exhaustive patterns for DeviceInfo: include .. or match is_hosted as well.
    • Handle new enum variants in exhaustive matches: UsyncMode::Delta and UsyncContext::Voip.

Written for commit 0962dab. Summary will update on new commits.

Summary by CodeRabbit

  • New Features

    • Added typed USync queries for retrieving registration, device, profile, business, and bot information.
    • Added support for hosted device addressing and expanded USync modes and contexts.
    • Added comprehensive USync API reference documentation and navigation.
  • Documentation

    • Documented query construction, validation, response handling, and error behavior.
    • Added constructors and hosting configuration guidance for device records.
    • Documented compatibility considerations for existing device record integrations.

@coderabbitai

coderabbitai Bot commented Jul 21, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The documentation adds the typed Client::query_usync API, describes USync query and response models, documents hosted-device addressing and validation behavior, records related breaking changes, and adds the new page to API navigation.

Changes

USync API

Layer / File(s) Summary
Query API and protocol model
api/usync.mdx, api/client.mdx
Documents query construction, user targets, device hints, protocol selection, and the Client::query_usync signature.
Response decoding and addressing
api/usync.mdx
Documents typed protocol outcomes, payload variants, validation errors, usage examples, hosted-device addressing, and related breaking changes.
Store compatibility and documentation wiring
api/store.mdx, api/wacore.mdx, docs.json
Documents DeviceInfo constructors and persistence behavior, expands the USync module description, and adds the USync page to navigation.

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

Poem

A rabbit hops through queries bright,
With typed replies decoded right.
Hosted devices find their way,
New docs bloom in menus today.
“USync!” I cheer, and twitch my nose.

🚥 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 matches the main change: adding documentation for the USync typed query engine reference.
✨ 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.

@mintlify

mintlify Bot commented Jul 21, 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 21, 2026, 10:59 PM

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

@greptile-apps

greptile-apps Bot commented Jul 21, 2026

Copy link
Copy Markdown

Greptile Summary

This PR adds documentation for the typed USync query engine. The main changes are:

  • A new USync reference covering queries, responses, validation, and hosted addressing.
  • Client, storage, and wacore documentation linked to the new reference.
  • Migration guidance for hosted device fields and new enum variants.
  • The USync page added to the API navigation.

Confidence Score: 5/5

This looks safe to merge.

  • The latest documentation correction resolves the reported API naming mismatch.
  • No blocking issue remains in the updated documentation.

Important Files Changed

Filename Overview
api/usync.mdx Adds the typed USync reference and corrects the specialized device lookup reference.
api/client.mdx Documents the direct Client::query_usync feature API.
api/store.mdx Documents hosted device metadata, constructors, and migration effects.
concepts/storage.mdx Updates the storage model and persistence guidance for hosted devices.
api/wacore.mdx Expands the USync module description and links its reference.
docs.json Adds the USync reference to API navigation.

Reviews (6): Last reviewed commit: "docs: fix incorrect SignalManager refere..." | Re-trigger Greptile

greptile-apps[bot]
greptile-apps Bot previously approved these changes Jul 21, 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: 1

🤖 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/usync.mdx`:
- Around line 35-44: Format Rust API identifiers as inline code in both
documentation sites: in api/usync.mdx lines 35-44, wrap UsyncMode and
UsyncContext in backticks and apply the same treatment to analogous headings on
that page; in api/client.mdx line 881, change the heading to use inline code for
query_usync.
🪄 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: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 1e37e154-7b6d-441c-a478-9c1d74939020

📥 Commits

Reviewing files that changed from the base of the PR and between 59e0f29 and 0c482ef.

📒 Files selected for processing (5)
  • api/client.mdx
  • api/store.mdx
  • api/usync.mdx
  • api/wacore.mdx
  • docs.json

Comment thread api/usync.mdx Outdated
@mintlify

mintlify Bot commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

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

Project Status Preview Updated (UTC)
whatsapp-rust 🟡 Building Jul 21, 2026, 10:59 PM

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

@greptile-apps
greptile-apps Bot dismissed their stale review July 21, 2026 23:05

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

greptile-apps[bot]
greptile-apps Bot previously approved these changes Jul 21, 2026
Addresses CodeRabbit nitpick on #420
@greptile-apps
greptile-apps Bot dismissed their stale review July 21, 2026 23:12

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

greptile-apps[bot]
greptile-apps Bot previously approved these changes Jul 21, 2026
Previous commit dropped the file's final newline during transcription.
@greptile-apps
greptile-apps Bot dismissed their stale review July 21, 2026 23:17

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

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

ℹ️ 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/store.mdx Outdated
The `raw_id` field stores the ADV (Account Device Verification) key index list `raw_id` from device notifications. When this value changes for a user, it indicates an identity change (e.g., the user reinstalled WhatsApp). The client uses this to detect identity changes and clear Signal sessions for that user's non-primary devices. Per-device sender key tracking is **not** wiped globally on identity change — that would empty the tracker too aggressively and feed the no-distribution path on the next group send. SKDM redistribution is instead driven per-group/per-device by retry receipts (matching WhatsApp Web's `WAWebUpdateLocalSignalSession`/`markForgetSenderKey` behavior).

<Note>
**Breaking change:** `DeviceInfo` gained the `is_hosted` field (marks whether the device belongs to WhatsApp's hosted PN/LID address space, populated from usync device-list results). Struct-literal construction (`DeviceInfo { device_id, key_index }`) no longer compiles — use `DeviceInfo::new(device_id, key_index).with_hosting(is_hosted)` instead. Persisted JSON without `is_hosted` still deserializes correctly (it defaults to `false`); only Rust struct-literal call sites are affected. See [USync](/api/usync#hosted-addressing) for how `is_hosted` is used with `Jid::with_device_hosting`.

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 Update the second DeviceInfo reference

This breaking-change documentation leaves concepts/storage.mdx:550-554 showing the obsolete two-field DeviceInfo definition. Readers implementing the documented device registry from that page can copy a struct literal that no longer compiles because is_hosted is required. Update that reference with the new field and constructor guidance as well.

Useful? React with 👍 / 👎.

Comment thread api/usync.mdx Outdated
DeviceInfo::new(device_id, key_index).with_hosting(is_hosted)
UsyncDevice::new(device, key_index).with_hosting(is_hosted)
```
Persisted `DeviceInfo` JSON without `is_hosted` still deserializes correctly (`is_hosted` defaults to `false`) — this only affects Rust struct-literal call sites, not on-disk data.

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 Include destructuring in the migration warning

When downstream code exhaustively destructures DeviceInfo, such as let DeviceInfo { device_id, key_index } = info, adding is_hosted also causes a compile error. The claim that this “only affects Rust struct-literal call sites” therefore understates the breaking change and leaves those users without applicable migration guidance; describe construction and exhaustive pattern matching as affected.

Useful? React with 👍 / 👎.

Comment thread api/usync.mdx Outdated
) -> Result<Self, UsyncValidationError>
```

`UsyncQuery::new` validates the whole query before it reaches the network — non-empty protocols/users, no duplicate protocol kinds, and per-user field consistency (e.g. a `tc_token` requires the `Status` protocol to be selected; `device_sync` requires `DevicesV2`). Deserializing a `UsyncQuery` from an external source runs the same validation, so a serialized input can't bypass it.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Split the validation paragraph into single-idea sentences

This paragraph combines the constructor's validation categories, two protocol-dependency examples, and the deserialization guarantee into two dense sentences. Split these ideas into concise sentences so readers can distinguish the checks and the separate serde behavior, as required by the project's documentation style.

AGENTS.md reference: AGENTS.md:L24-L25

Useful? React with 👍 / 👎.

greptile-apps[bot]
greptile-apps Bot previously approved these changes Jul 21, 2026
@greptile-apps
greptile-apps Bot dismissed their stale review July 21, 2026 23:20

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

greptile-apps[bot]
greptile-apps Bot previously approved these changes Jul 21, 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: 5035103d5b

ℹ️ 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/usync.mdx Outdated
`Client::query_usync` exposes the same typed query engine directly, for protocol combinations the specialized helpers don't cover — for example fetching a bot's profile, resolving a username, or reading `disappearing_mode`/`text_status` in the same request as a device-list lookup.

<Note>
Prefer the specialized helpers ([`Contacts`](/api/contacts), [`SignalManager::get_user_devices`](/api/signal#get_user_devices)) for common lookups — they also handle cache population and persistence. `query_usync` is a neutral operation: it only returns decoded wire data.

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 Name the public Signal accessor correctly

The linked API exposes get_user_devices on the Signal struct returned by client.signal(), not on a SignalManager type. Readers searching for or importing SignalManager will find no such public API, so refer to Signal::get_user_devices or client.signal().get_user_devices(...) here.

Useful? React with 👍 / 👎.

@greptile-apps
greptile-apps Bot dismissed their stale review July 21, 2026 23:29

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

@jlucaso1
jlucaso1 merged commit cea3a00 into main Jul 22, 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.

1 participant