Skip to content

Architect unified state restoration across QR scans, deep links, and (future) push notifications #250

Description

@Lakes41

Difficulty: Expert
Type: refactor

Background
The app has three distinct entry-point mechanisms into specific screens with associated data: QR access-check scans (in-app, camera-driven), deep links (custom scheme and universal link, with explicit cold-start support), and, if the push-notifications roadmap item is implemented, notification taps that also deep-link into the app — each currently handled somewhat independently.

Problem
As more entry points are added (push notifications, and potentially wallet-connect callback deep links from the Native Wallet Integration work), the risk of inconsistent behavior grows: cold start vs. warm start, navigation state clobbering an in-progress flow (e.g., a deep link arriving while the user is mid-way through a QR scan or wallet-connect flow), and duplicate/competing validation logic across each entry point.

Expected outcome
A single, unified "external entry" handling layer normalizes QR scans, deep links, and notification taps into one internal event shape, applies consistent validation and error handling (reusing the existing QR/deep-link validators rather than duplicating logic), and defines explicit, tested precedence/interruption rules for what happens when a new external entry arrives while the user is mid-flow in another one (e.g., a deep link arriving during onboarding, or a notification tap arriving during an active QR scan).

Suggested implementation

  • Design a common ExternalEntryEvent type (source: qr | deep_link | notification, target screen, params) that all three entry mechanisms normalize into, reusing the existing per-source validation logic (QR payload validator, deep-link param validator) rather than rewriting it.
  • Implement a single navigation-arbitration function that decides, given the current app/navigation state and an incoming ExternalEntryEvent, whether to navigate immediately, queue the navigation until the current flow completes, or discard it with user notification (e.g., "switched away from QR scan due to an incoming link") — document and test the exact precedence rules chosen.
  • Cover cold-start and warm-start cases for all three sources through this same arbitration layer, eliminating any duplicated cold-start-specific logic.
  • Add unit tests for the arbitration logic covering realistic interruption scenarios (link during onboarding, notification during QR scan, QR scan result while a deep link navigation is still pending) and Maestro E2E coverage for at least one real interruption scenario end-to-end.
  • Document the full architecture, including the precedence rules and rationale, in docs/.

Acceptance criteria

  • All three entry mechanisms funnel through one normalized event type and shared validation logic
  • Explicit, tested precedence rules exist for competing/interrupting external entries
  • Cold-start behavior is handled identically across all three sources via the shared layer
  • Unit tests cover the arbitration logic's key interruption scenarios
  • At least one interruption scenario is covered end-to-end via Maestro
  • Architecture documented in docs/

Likely affected files/directories

  • src/ (new unified entry-handling module)
  • app/ (routing/layout integration)
  • docs/
  • .maestro/

Metadata

Metadata

Assignees

Labels

GrantFox OSSGrantFox Open Source Sponsorship program tagMaybe RewardedIssue may qualify for a reward upon successful completion per campaign rulesOfficial Campaign | FWC26Official FWC26 campaign issue — eligible for campaign scoring and rewardsexpertExpert difficulty tasks requiring deep expertise and architectural decision-makingrefactorCode restructuring without changing external behavior or API

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions