Skip to content

docs: Disconnected event now carries a DisconnectReason - #365

Merged
jlucaso1 merged 4 commits into
mainfrom
claude/nifty-bohr-a0i9aq
Jul 3, 2026
Merged

docs: Disconnected event now carries a DisconnectReason#365
jlucaso1 merged 4 commits into
mainfrom
claude/nifty-bohr-a0i9aq

Conversation

@jlucaso1

@jlucaso1 jlucaso1 commented Jul 3, 2026

Copy link
Copy Markdown
Collaborator

Summary

Reflects whatsapp-rust#956 ("typed read-loop exit — routine server recycles are not errors; Disconnected carries the reason"), which merged a breaking change: events::Disconnected is no longer a unit struct — it now carries reason: DisconnectReason so consumers can tell a routine server-initiated stream recycle apart from a genuine transport failure without parsing logs.

Changes

  • concepts/events.mdx — updated the Disconnected event section: new struct shape with the reason field, an explanation of reason.is_clean_shutdown(), a link to the existing DisconnectReason reference in api/transport.mdx, and a breaking-change <Note> for consumers with existing Event::Disconnected(Disconnected) match patterns.
  • advanced/observability.mdx — the same PR also tags the wa.conn.connect and wa.conn.read_loop spans with lid/pn (previously only wa.conn.run, wa.iq, wa.send.message were tagged), and changes wa.conn.connect's failure level from ERROR to WARN (its caller already classifies real failures). Updated the span taxonomy's "Levels" and "Account identity in spans" sections accordingly.

Other PRs merged in the same batch (#949–#957) were internal performance/refactor/CI work with no user-facing API surface, so no further doc changes were needed for those.

Test plan

  • Verified against the merged PR diff for whatsapp-rust#956
  • Cross-checked all existing references to Disconnected across the docs repo to confirm concepts/events.mdx and advanced/observability.mdx were the only files describing the changed shape/behavior (other Disconnected mentions are unrelated types: TransportEvent::Disconnected(DisconnectReason), IqError::Disconnected, HandshakeError::Disconnected)

Generated by Claude Code


Summary by cubic

Docs updated for the breaking change: events::Disconnected now includes reason: DisconnectReason so clients can tell routine server recycles from transport failures. Added DisconnectReason::is_clean_shutdown() docs, clarified the Disconnected “Emitted” wording to include routine server recycles, and updated observability to tag wa.conn.connect/wa.conn.read_loop with lid/pn and note the WARN vs ERROR split.

  • Migration
    • Update match patterns from Event::Disconnected(Disconnected) to Event::Disconnected(Disconnected { reason }) or Event::Disconnected(_).

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

…t#956)

Reflects the breaking change where events::Disconnected gained a
reason field distinguishing routine server-initiated stream recycles
from genuine transport failures, and documents the two additional
spans (wa.conn.connect, wa.conn.read_loop) that now tag lid/pn and
the err-level split between them.

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

coderabbitai Bot commented Jul 3, 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: 59 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

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: 05857ac4-4706-486f-b54c-e82971031ce1

📥 Commits

Reviewing files that changed from the base of the PR and between a8914b4 and fd64032.

📒 Files selected for processing (3)
  • advanced/observability.mdx
  • api/transport.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.

@mintlify

mintlify Bot commented Jul 3, 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 3, 2026, 1:42 AM

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

cubic-dev-ai[bot]
cubic-dev-ai Bot previously approved these changes Jul 3, 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.

No issues found across 2 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Auto-approved: Documentation-only updates reflecting a breaking change in the underlying library: updating the Disconnected event struct shape and observability span taxonomy. No production code, logic, or infrastructure changes.

Re-trigger cubic

@greptile-apps

greptile-apps Bot commented Jul 3, 2026

Copy link
Copy Markdown

Greptile Summary

This PR updates docs to reflect the breaking change in whatsapp-rust#956: events::Disconnected is no longer a unit struct — it now carries reason: DisconnectReason. The previous thread's concern about is_clean_shutdown() not being documented has been fully addressed here.

  • concepts/events.mdx: Updates the struct shape, adds a reason field description with a link to DisconnectReason, and adds a <Note> with migration guidance for broken match patterns.
  • api/transport.mdx: Adds an is_clean_shutdown() API section with an impl stub and a table clarifying which variants return true vs false.
  • advanced/observability.mdx: Adds wa.conn.connect and wa.conn.read_loop to the spans tagged with lid/pn, and documents the WARN (not ERROR) failure level on wa.conn.connect.

Confidence Score: 5/5

Safe to merge — documentation-only change that accurately reflects the upstream breaking change.

All three files contain correct, consistent descriptions of the new struct shape and method behavior. The previously flagged gap (is_clean_shutdown() undocumented in api/transport.mdx) is now fully addressed with an impl stub and a complete variant table. The observability section changes are internally consistent. No links are broken, no variant entries are missing from the table, and the migration note in concepts/events.mdx covers both the destructured and wildcard pattern alternatives.

No files require special attention.

Important Files Changed

Filename Overview
api/transport.mdx Adds is_clean_shutdown() documentation (impl stub + variant table) directly after the DisconnectReason enum — addresses the gap called out in the previous review thread; the table entries and their true/false values are internally consistent with the described behavior.
concepts/events.mdx Updates Disconnected struct shape, field docs, and adds a migration ; the link to /api/transport#disconnected now resolves to the section that includes is_clean_shutdown() docs.
advanced/observability.mdx Extends span identity coverage to wa.conn.connect and wa.conn.read_loop, and clarifies WARN vs ERROR failure levels; changes are coherent with the referenced upstream PR behavior.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    D["Transport closes"] --> E["events::Disconnected { reason }"]
    E --> F{"reason.is_clean_shutdown()"}
    F -->|true| G["Routine server-initiated\nstream recycle\nClient reconnects silently"]
    F -->|false| H["Genuine transport failure\nLog / alert if needed"]

    subgraph "DisconnectReason → is_clean_shutdown()"
        R1["StreamEnded"] -->|true| G
        R2["ServerClose { code: None }"] -->|true| G
        R3["ServerClose { code: Some(1000 or 1001) }"] -->|true| G
        R4["ServerClose { code: other }"] -->|false| H
        R5["ReadError(_)"] -->|false| H
        R6["Unknown"] -->|false| H
    end
Loading
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
flowchart TD
    D["Transport closes"] --> E["events::Disconnected { reason }"]
    E --> F{"reason.is_clean_shutdown()"}
    F -->|true| G["Routine server-initiated\nstream recycle\nClient reconnects silently"]
    F -->|false| H["Genuine transport failure\nLog / alert if needed"]

    subgraph "DisconnectReason → is_clean_shutdown()"
        R1["StreamEnded"] -->|true| G
        R2["ServerClose { code: None }"] -->|true| G
        R3["ServerClose { code: Some(1000 or 1001) }"] -->|true| G
        R4["ServerClose { code: other }"] -->|false| H
        R5["ReadError(_)"] -->|false| H
        R6["Unknown"] -->|false| H
    end
Loading

Reviews (4): Last reviewed commit: "docs: clarify Disconnected's Emitted wor..." | Re-trigger Greptile

Comment thread concepts/events.mdx
```

**Fields:**
- `reason: DisconnectReason` — why the transport ended. Check `reason.is_clean_shutdown()` to tell a routine server-initiated stream recycle (WhatsApp's normal reconnect path) apart from a genuine transport failure, without parsing logs. See [`DisconnectReason`](/api/transport#disconnected) for the variants.

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 is_clean_shutdown() not documented in the linked DisconnectReason reference

The text directs users to call reason.is_clean_shutdown(), then links them to /api/transport#disconnected for the variants. However, api/transport.mdx only documents the four enum variants (ServerClose, StreamEnded, ReadError, Unknown) — there is no helper-methods section and no mention of is_clean_shutdown() anywhere in the file. A developer following the link will find the variants but no explanation of which variant(s) the method considers a clean shutdown, or that the method exists at all. The helper should be documented in api/transport.mdx alongside the enum definition.

Prompt To Fix With AI
This is a comment left during a code review.
Path: concepts/events.mdx
Line: 242

Comment:
`is_clean_shutdown()` not documented in the linked `DisconnectReason` reference

The text directs users to call `reason.is_clean_shutdown()`, then links them to `/api/transport#disconnected` for the variants. However, `api/transport.mdx` only documents the four enum variants (`ServerClose`, `StreamEnded`, `ReadError`, `Unknown`) — there is no helper-methods section and no mention of `is_clean_shutdown()` anywhere in the file. A developer following the link will find the variants but no explanation of which variant(s) the method considers a clean shutdown, or that the method exists at all. The helper should be documented in `api/transport.mdx` alongside the enum definition.

How can I resolve this? If you propose a fix, please make it concise.

Fix in Claude Code

concepts/events.mdx sends readers to /api/transport#disconnected for
DisconnectReason details but the method it tells them to call wasn't
documented there (caught by Greptile review on #365).

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

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

Re-trigger cubic

Comment thread api/transport.mdx
@cubic-dev-ai
cubic-dev-ai Bot dismissed their stale review July 3, 2026 01:47

Dismissed because Cubic found issues in a newer review.

Give is_clean_shutdown() a real function body (a bare semicolon is
invalid Rust in an inherent impl, only valid in traits/externs), and
drop the escaped pipes inside table-cell code spans in favor of prose
(caught by cubic and Greptile review on #365).

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

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

0 issues found across 1 file (changes from recent commits).

Auto-approved: Updates documentation for Disconnected event and observability spans. Pure docs changes, no code modifications.

Re-trigger cubic

"unexpectedly" read as abnormal/error-only, but the event also fires
for a routine clean server recycle — reword to say what actually
distinguishes it (not client-initiated) instead.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0116e1C7aqCk2AdecsCpf6E6
@jlucaso1
jlucaso1 merged commit 1908b3d into main Jul 3, 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