Skip to content

feat(history_sync): expose peer_data_request_session_id on LazyHistorySync - #614

Merged
jlucaso1 merged 1 commit into
mainfrom
feat/history-sync-peer-data-request-session-id
May 5, 2026
Merged

jlucaso1 merged 1 commit into
mainfrom
feat/history-sync-peer-data-request-session-id

Conversation

@jlucaso1

@jlucaso1 jlucaso1 commented May 5, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Adds an optional peer_data_request_session_id: Option<String> field to LazyHistorySync, populated from the originating HistorySyncNotification.
  • Exposes a builder (with_peer_data_request_session_id) and accessor; Clone, Debug, and Serialize impls all updated.
  • Lets consumers correlate ON_DEMAND history sync answers with their outstanding fetchMessageHistory / requestPlaceholderResend requests, matching WA Web's HistorySyncNotification handler (docs/captured-js/WAWeb/Handle/HistorySyncNotification.js:98, :195-234).

Test plan

  • cargo build
  • cargo clippy --all --tests
  • cargo test -p wacore --lib lazy_history_sync (8/8 pass, including the new lazy_history_sync_peer_data_request_session_id round-trip test)

…ySync

Propagate the PDO session id from `HistorySyncNotification` onto the
dispatched event so consumers can correlate ON_DEMAND history sync
answers with their outstanding `fetchMessageHistory` /
`requestPlaceholderResend` requests, matching WA Web's
`HistorySyncNotification` handler.
@coderabbitai

coderabbitai Bot commented May 5, 2026

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: c1becba2-9124-4b91-9974-0f9eb2fd2ab5

📥 Commits

Reviewing files that changed from the base of the PR and between ceb62b8 and 5eb6465.

📒 Files selected for processing (2)
  • src/history_sync.rs
  • wacore/src/types/events.rs

📝 Walkthrough

Summary by CodeRabbit

  • New Features
    • History synchronization now includes session identifiers to better track and correlate sync requests with their responses.

Walkthrough

A new optional peer_data_request_session_id field is added to LazyHistorySync to correlate on-demand history-sync responses with outstanding requests. The field includes a builder method, accessor, serialization support, tests, and is threaded through the event dispatch site.

Changes

Session ID Metadata for History Sync

Layer / File(s) Summary
Data Shape
wacore/src/types/events.rs (lines 30–67)
LazyHistorySync gains optional peer_data_request_session_id: Option<String> field, preserved in Clone and initialized to None in constructor.
Builder & Accessor
wacore/src/types/events.rs (lines 69–94)
with_peer_data_request_session_id(...) builder method and peer_data_request_session_id(&self) -> Option<&str> accessor expose the field fluently.
Serialization & Debug
wacore/src/types/events.rs (lines 124–150)
Debug and Serialize implementations updated to include peer_data_request_session_id in output.
Event Dispatch
src/history_sync.rs (lines 222–228)
Event::HistorySync dispatch chains .with_peer_data_request_session_id(notification.peer_data_request_session_id.take()) to carry session ID.
Tests
wacore/src/types/events.rs (lines 968–983)
Unit test lazy_history_sync_peer_data_request_session_id validates unset, set, and clone behavior.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

  • oxidezap/whatsapp-rust#533: Extends LazyHistorySync with the same peer_data_request_session_id metadata field and builder pattern for correlating on-demand sync responses.

Suggested labels

api-design


Look, this is solid work. The pattern is clean and consistent—you're adding metadata to track session correlation on history syncs, which is exactly what you need to match responses to requests. The field threads through correctly: it's optional by default, there's a builder to set it when needed, and it's carried all the way through serialization and dispatch. Tests cover it. No surprises, no edge cases getting missed. This is how you do incremental API expansion right. Ship it.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: exposing a peer_data_request_session_id field on LazyHistorySync, which aligns with the code modifications across both files.
Description check ✅ Passed The description clearly explains the feature addition, implementation details, and includes a comprehensive test plan with passing results, directly addressing the changeset.
Docstring Coverage ✅ Passed Docstring coverage is 83.33% which is sufficient. The required threshold is 80.00%.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/history-sync-peer-data-request-session-id

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 and usage tips.

@jlucaso1
jlucaso1 merged commit 7bd875a into main May 5, 2026
11 checks passed
@jlucaso1
jlucaso1 deleted the feat/history-sync-peer-data-request-session-id branch May 5, 2026 17:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant