Skip to content

feat(notifications): add deterministic notification preference handling (#885) - #940

Draft
s6pa1rta3n-lab wants to merge 1 commit into
Predictify-org:mainfrom
s6pa1rta3n-lab:fix-issue-885
Draft

feat(notifications): add deterministic notification preference handling (#885)#940
s6pa1rta3n-lab wants to merge 1 commit into
Predictify-org:mainfrom
s6pa1rta3n-lab:fix-issue-885

Conversation

@s6pa1rta3n-lab

Copy link
Copy Markdown

Closes #885

Summary & Motivation

Users need predictable, robust, and deterministic control over settlement, market, wallet, and dispute notifications. This PR introduces an account-scoped notification preferences subsystem with explicit defaults, conflict resolution, offline reconciliation, and UI controls.


Acceptance Criteria Checklist

  • Preferences are isolated by account: Stored in useNotificationPreferencesStore keyed by normalized account ID (e.g. Stellar address or normalized anonymous). Switching accounts immediately rebinds preferences and isolates custom settings without cross-contamination (app/state/notificationPreferences.ts, hooks/useNotificationPreferences.ts).
  • Defaults are explicit: DEFAULT_NOTIFICATION_PREFERENCES provides explicit immutable defaults (intensity: important, default channels: inApp: true, categories: all high-signal enabled, quiet hours configured) with isDefault status checking (lib/notification-preferences.ts, types/notification-preferences.ts).
  • Offline changes reconcile without duplication: applyOfflineMutation and reconcilePreferences provide deterministic Last-Write-Wins (LWW) resolution and monotonic versioning with mutation deduplication tracking (lib/notification-preferences.ts, app/state/notificationPreferences.ts).
  • Tests cover account switch, conflict, and reset: Unit and integration test suites comprehensively verify account switching, LWW conflict reconciliation, offline queues, default reset, and filtering logic (lib/__tests__/notification-preferences.test.ts, app/state/__tests__/notificationPreferences.test.ts, hooks/__tests__/useNotificationPreferences.test.tsx).

Implementation Details

  • Schema & Types (types/notification-preferences.ts): Typed definitions for notification categories (settlement, market, wallet, dispute, payout, system, account), delivery channels (inApp, email, push), intensity profiles (important, balanced, everything), quiet hours, and mutation records.
  • Core Engine & Reconciliation (lib/notification-preferences.ts): Deterministic pure functions for normalization, cloning, validation, offline mutations, LWW reconciliation, and notification filtering (shouldDeliverNotification).
  • Store & Cross-Tab Sync (app/state/notificationPreferences.ts): Account-scoped Zustand store using persist middleware, offline network listeners, and cross-tab storage synchronization.
  • React Hook (hooks/useNotificationPreferences.ts): React hook binding active wallet address to scoped notification preferences with ergonomic setters and reset capabilities.
  • Settings UI (app/(dashboard)/settings/page.tsx): Dedicated Notifications tab with granular category and channel switches, intensity presets, active account indicators, and default reset actions.

Security & Failure-Mode Considerations

  1. Account Isolation: Account keys are defensively normalized (lowercased/trimmed) to prevent casing mismatches and leakage across sessions.
  2. Offline Resilience: Offline mutations record unique IDs and timestamps so network drops or reconnects reconcile without dropping user intent or causing race conditions.
  3. Safe Defaults: High-signal alerts (settlement, dispute, wallet) are enabled by default while noisy market updates are throttled under the important preset.

Payout Routing

  • EVM (Base/Arbitrum/Polygon/ETH): 0xF46C9F6d70C50BF81ef3588AB523a90a594a2F89
  • Stellar: GCL6OXAMLD75BMTINA6EMRUDWK5THQUSHMYNLSNBCJAPZJHNYJTUNIBC

@vercel

vercel Bot commented Sep 1, 2026

Copy link
Copy Markdown

@s6pa1rta3n-lab is attempting to deploy a commit to the Jagadeesh B's projects Team on Vercel.

A member of the Team first needs to authorize it.

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.

[GrantFox][Medium] Add deterministic notification preference handling

1 participant