Conversation
When importing an identity, the local room state starts with a default
ChatRoomStateV1 that has owner_member_id: FastHash(0) — a placeholder.
When the real state arrives from the network via GET, the merge fails
because apply_delta rejects owner_member_id changes ("Cannot change the
owner_member_id"). The imported room is stuck with a broken local state.
Fix: when `is_awaiting_initial_sync()` is true (empty members + empty
messages + non-owner), replace the local state wholesale with the
retrieved network state instead of merging. The default state has no
useful data to preserve, so replacement is correct and avoids the
owner_member_id mismatch entirely.
Closes #195
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.
Problem
When importing an identity (export → leave room → import), the local room state is initialized with
ChatRoomStateV1::default()which hasowner_member_id: MemberId(FastHash(0))— a placeholder value. When the real state arrives from the network via GET, the merge fails with "Cannot change the owner_member_id" becauseapply_deltarejects any change to the owner member ID.This leaves the imported room in a broken state: the user sees "Syncing room state" forever, members show as "Unknown", and messages never load. If they can get past the sync, they can never send messages because the local state's configuration is corrupted.
Previous PRs (#189, #190) fixed the export flow and added GET-first logic for imports, but the merge-vs-replace issue remained.
Root Cause
Configuration::default()setsowner_member_id: MemberId(FastHash(0)). When a GET response arrives with the real owner's member ID, the scaffoldmerge()→delta()→apply_delta()path rejects the change atconfiguration.rs:76-77becauseFastHash(0) != real_owner_member_id.Approach
For rooms where
is_awaiting_initial_sync()is true (empty members + empty messages + non-owner), replace the local state wholesale with the retrieved network state instead of merging. The default state has no useful data to preserve — it's a placeholder created during import. Normal rooms (already synced) continue to use the merge path.Testing
common/tests/import_merge_test.rs:test_default_state_has_placeholder_owner— verifies the root causetest_merge_fails_when_owner_member_id_differs— proves the merge failuretest_wholesale_replacement_works_for_imported_rooms— validates the fixui/code modified, no delegate migration neededCloses #195
[AI-assisted - Claude]