Skip to content

feat(hive): scope notification history to the current device id#17

Merged
lucor merged 1 commit intomainfrom
feat/device-scoped-notifications
May 5, 2026
Merged

feat(hive): scope notification history to the current device id#17
lucor merged 1 commit intomainfrom
feat/device-scoped-notifications

Conversation

@lucor
Copy link
Copy Markdown
Owner

@lucor lucor commented May 5, 2026

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.

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.
@lucor lucor merged commit 40d1b3d into main May 5, 2026
3 checks passed
@lucor lucor deleted the feat/device-scoped-notifications branch May 5, 2026 18:30
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.

1 participant