feat: implement offline-first typed data layer for mailbox (#69)#90
Open
strngecloud wants to merge 6 commits into
Open
feat: implement offline-first typed data layer for mailbox (#69)#90strngecloud wants to merge 6 commits into
strngecloud wants to merge 6 commits into
Conversation
…ail#69) - Add typed repository interface for messages, threads, contacts, policies, proofs, and sync cursors - Implement memory adapter for deterministic testing - Implement storage adapter for persistent offline-first state - Add React hook (useMailbox) for managing mailbox state with loading states - Support idle, loading, stale, and error states for reliable synchronization - Ensure all mutations are idempotent - Create seed data for development - Update mail route to use new data layer - Replace hard-coded component data with repository pattern - Enable versioning for future schema migrations
Author
|
@kryputh |
Collaborator
|
@strngecloud fix all |
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.
Offline-First Typed Data Layer for Mailbox
Summary
Replaces hard-coded component data with a typed, offline-first repository pattern that enables reliable synchronization, testing, and recovery.
Changes
IMailboxRepository) with CRUD operations for messages, threads, contacts, policies, proofs, and sync cursorsuseMailbox()hook providing state management with loading states (idle, loading, stale, error)Acceptance Criteria Met
✅ Components depend on interfaces, not seed data
✅ Loading, stale, offline, and error states modeled
✅ Mutations are idempotent
✅ Migration strategy exists for local schema changes
✅ Same logic works against both memory and storage adapters
Files Added
src/features/mailbox/types.ts- Core domain typessrc/features/mailbox/repository.ts- Repository interfacesrc/features/mailbox/adapters/memory-adapter.ts- Testing adaptersrc/features/mailbox/adapters/storage-adapter.ts- Production adaptersrc/features/mailbox/useMailbox.ts- React hooksrc/features/mailbox/seed.ts- Seed datasrc/features/mailbox/README.md- Architecture documentationFiles Modified
src/components/mail/data.ts- Removed hardcoded emails, added helper functionssrc/routes/index.tsx- Integrated useMailbox hook, replaced local stateTesting
Run existing tests to verify no regressions:
npm run testComponents automatically work offline via localStorage and continue functioning if network fails.
Closes #69