fix: send room deltas instead of full state to Freenet API#201
Open
fix: send room deltas instead of full state to Freenet API#201
Conversation
iduartgomez
approved these changes
Mar 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
UpdateData::Deltainstead of serializing the entireChatRoomStateV1on every changeUpdateData::State(full state) only on first sync when no baseline existsNone, updatinglast_synced_stateto prevent re-queuingcompute_update_data()function with 4 unit testsCloses #17
What changed
ui/src/components/app/sync_info.rsneeds_to_send_update()now returns(ChatRoomStateV1, Option<ChatRoomStateV1>)per room — the current state paired with the last synced baselineui/src/components/app/freenet_api/room_synchronizer.rscompute_update_data(state, baseline, params) -> Option<UpdateData>— pure function that computes a delta viaComposableState::summarize()+ComposableState::delta(), or falls back to full state when no baseline existsprocess_rooms()callscompute_update_data()and sends the resultNone, updateslast_synced_stateso the room isn't re-queuedWhy this is safe
UpdateData::Deltainupdate_state()— deserializesChatRoomStateV1Deltaand callsapply_delta()#[composable]macro enforces field application order (config -> bans -> members -> member_info -> secrets -> messages)get_state_delta()+ summaries — this change only affects the client-to-node pathensure_members_for_message_authors()in the contract injects missing member entries into deltas, preventing rejection of messages from pruned membersTests
4 unit tests on
compute_update_data():no_baseline_returns_full_state— first sync sendsUpdateData::Stateidentical_states_returns_none— no changes producesNonechanged_state_returns_delta— new message producesUpdateData::Deltadelta_is_smaller_than_full_state— delta bytes < full state bytes