feat(hive): scope notification history to the current device id#17
Merged
feat(hive): scope notification history to the current device id#17
Conversation
Hive notification history is now bound to a single backend device id, so unpairing or repairing with a different device never leaks old messages. IndexedDB is bumped to v2 with a by-device index. On first boot after the upgrade a lazy migration stamps legacy records with the current device id, normalises any snake_case fields, and removes records that belong to another device. The localStorage cache uses the same scoping, with garbage collection of stale keys and a one-shot cleanup of the old unscoped legacy keys. To enforce the correct order the app shell now bootstraps through a single orchestration function: register the worker, check paired state, read credentials, activate the store for the current device, attach listeners, run the migration, and only then drain IndexedDB. The store guards every mutating operation with the active device id, and the service worker includes the device id in every push message so the app shell can silently ignore messages meant for a previous device. All new tests run against a real in-memory IndexedDB via fake-indexeddb instead of mocks, covering the migration, key cleanup, and bootstrap ordering.
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.
Hive notification history is now bound to a single backend device id, so unpairing or repairing with a different device never leaks old messages.
IndexedDB is bumped to v2 with a by-device index. On first boot after the upgrade a lazy migration stamps legacy records with the current device id, normalises any snake_case fields, and removes records that belong to another device. The localStorage cache uses the same scoping, with garbage collection of stale keys and a one-shot cleanup of the old unscoped legacy keys.
To enforce the correct order the app shell now bootstraps through a single orchestration function: register the worker, check paired state, read credentials, activate the store for the current device, attach listeners, run the migration, and only then drain IndexedDB. The store guards every mutating operation with the active device id, and the service worker includes the device id in every push message so the app shell can silently ignore messages meant for a previous device.
All new tests run against a real in-memory IndexedDB via fake-indexeddb instead of mocks, covering the migration, key cleanup, and bootstrap ordering.