Skip to content

add doc-aware embed routing + sticky verification request - #2194

Draft
transphorm wants to merge 11 commits into
devfrom
justin/wia-demo-rd1
Draft

add doc-aware embed routing + sticky verification request#2194
transphorm wants to merge 11 commits into
devfrom
justin/wia-demo-rd1

Conversation

@transphorm

@transphorm transphorm commented Jun 30, 2026

Copy link
Copy Markdown
Member

Summary

  • Embed launches are now document-aware. The SDK launches the WebView at …/tunnel/tour/1?disclosures=…, which hits the catch-all route. It used to force-jump every such launch straight to /disclose/request regardless of document state, so a first-time user with no registered document landed on the proof screen and failed (passport_data_not_found). The catch-all now checks the selected document first: registered → /disclose/request (unchanged), unregistered/unknown/error → onboarding (/tour/1).
  • The verification request survives onboarding. VerificationRequestProvider now sticky-captures the request, so in-session onboarding navigation (which wipes the URL query) no longer loses disclosures/userId/scope before the user reaches the proof request after registration.
  • Shared decision helper. The registered-document branch already living in embed/TourScreen is extracted into resolveEmbedEntry and reused by the catch-all, so the two boot paths can't drift.
  • Adds the Embed Mode workstream specs (contract + EM-01/EM-02 plans). This is EM-02 Part A (the demo unblock); it is independent of EM-01 and stays at the catch-all, which is the boot path that runs without getConfig.

Changes

WebView app

  • src/utils/resolveEmbedEntry.ts (new) — doc-aware entry decision: registered document → /disclose/request, otherwise the caller's onboarding fallback. Any failure to read document state falls toward onboarding (never into an unsatisfiable proof request).
  • src/components/InitialRouteRedirect.tsx — catch-all is now doc-aware and async behind a loading state; on a disclosures/proofItems param it defers to resolveEmbedEntry(client, '/tour/1') instead of an unconditional jump. Entries without a request param still redirect to /.
  • src/screens/embed/TourScreen.tsx — inline end-of-tour branch replaced with the shared helper (/capture/kyc fallback, dev mockParam preserved).
  • src/providers/VerificationRequestProvider.tsx — sticky-capture the last parse that carried a request so in-session navigation can't drop it.

Tests

  • resolveEmbedEntry unit tests (registered / unregistered / none / error / fallback pass-through).
  • InitialRouteRedirect doc-aware routing tests (registered → disclose w/ preserved query, unregistered → onboarding, proofItems keying, no-param → home with no doc check).
  • VerificationRequestProvider sticky-capture test (request survives query-wiping navigation) + empty baseline.

Docs/specs

  • specs/.../webview-in-app/embed-mode/SPEC.mdgetConfig bridge contract + embed-mode backlog (EM-01/02a/02b/03).
  • embed-mode/plans/EM-01-getconfig-handler.md — SDK getConfig handler plan (code lands in the self-webview-sdk repo, PR Updated circuit #26).
  • embed-mode/plans/EM-02-web-doc-aware-routing.md — this work (Part A) + Part B (post-EM-01 getConfig consumption).
  • SPEC-MODES.html — minor contract note.

Linear Issues

  • Closes SELF-3396 — EM-02a: Web — doc-aware embed routing + sticky request (demo unblock)

Related embed-mode backlog: SELF-3395 (EM-01, self-webview-sdk PR #26) · SELF-3397 (EM-02b) · SELF-3398 (EM-03)

Scope notes

  • EM-02 Part B is intentionally not here — it consumes EM-01's getConfig (separate repo, still in PR Updated circuit #26), so per the spec it follows the demo. Part B will refactor parseVerificationRequestContext to a structured input and switch embed screens to read from context.
  • No native/KMP changes in this PR. EM-01's KMP getConfig handler lives in self-webview-sdk.

Test Plan

  • pnpm --filter @selfxyz/webview-app types passes
  • pnpm --filter @selfxyz/webview-app test passes (237 tests)
  • pnpm --filter @selfxyz/webview-app build succeeds
  • pnpm --filter @selfxyz/webview-app lint passes (--max-warnings=0)
  • On-device via the demo host (self-webview-sdk PR Updated circuit #26 tooling): "Reset Documents (force scan flow)" → next launch with a verification request starts onboarding, then resumes /disclose/request with the request intact; with a registered document, launch goes straight to /disclose/request.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features
    • Document-aware boot/tour routing in embed mode, with query-string preservation and improved redirects for disclosures/proofItems.
    • Added live MRZ scan status overlays to supported camera scanning flows.
  • Bug Fixes
    • Verification request context now persists reliably across in-session navigation.
    • Improved StrictMode-safe MRZ/NFC scan cancellation and stabilized route state handling.
    • Tour “next” navigation now resolves destinations consistently via the embed resolver.
    • Bridge reuse is more consistent across rerenders.
  • Documentation
    • Updated embed-mode specs, including the lifecycle.getConfig contract and routing requirements.
  • Tests
    • Added/expanded unit and flow coverage for routing, sticky capture, overlays, and StrictMode behavior.

@vercel

vercel Bot commented Jun 30, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
self-webview-app Ready Ready Preview, Comment Jul 24, 2026 5:02am

Request Review

@coderabbitai

coderabbitai Bot commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: df157e34-9424-49a3-829b-7fbc4a345343

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Webview boot routing now resolves document-aware destinations asynchronously, preserves request context across navigation, and shows MRZ scan status overlays during native camera scanning. The embed-mode spec and plans were expanded to define the getConfig contract and related workstream items.

Changes

Doc-aware embed routing (EM-02 Part A)

Layer / File(s) Summary
resolveEmbedEntry utility
packages/webview-app/src/utils/resolveEmbedEntry.ts, packages/webview-app/tests/utils/resolveEmbedEntry.test.ts
New async helper exports DISCLOSE_ROUTE and resolveEmbedEntry; it returns the disclose route for registered documents and falls back to the caller’s route on unregistered, missing, or failed document loads.
InitialRouteRedirect async routing
packages/webview-app/src/components/InitialRouteRedirect.tsx, packages/webview-app/tests/components/initialRouteRedirect.test.tsx
The redirect now waits for resolveEmbedEntry, renders null while resolving, and redirects to the resolved target with location.search preserved. Tests cover disclosures, proofItems, and no-request paths.
TourScreen next-navigation
packages/webview-app/src/screens/embed/TourScreen.tsx
Replaces manual selected-document loading and conditional fallback routing with a single resolveEmbedEntry-based navigation target.
VerificationRequestProvider sticky capture
packages/webview-app/src/providers/VerificationRequestProvider.tsx, packages/webview-app/tests/providers/verificationRequestProvider.test.tsx
The provider now preserves a disclosed request context in a ref when later renders lose the launch query string, and tests verify persistence plus empty-request behavior.

Bridge and onboarding scan overlays

Layer / File(s) Summary
Shared bridge singleton
packages/webview-app/src/providers/BridgeProvider.tsx, packages/webview-app/tests/providers/bridgeProvider.test.tsx
BridgeProvider now reuses a shared bridge instance and exposes a reset helper for tests; the provider tests reset the singleton and verify reuse across StrictMode renders.
MRZ scan overlay and routes
packages/webview-app/src/screens/onboarding/components/MrzScanStatusOverlay.tsx, packages/webview-app/src/screens/onboarding/eu-id/ViewfinderRoute.tsx, packages/webview-app/src/screens/onboarding/passport/CodeScanViewfinderRoute.tsx
MrzScanStatusOverlay subscribes to scan-progress events and renders status text during native camera scanning, and the passport and EU-ID viewfinder routes overlay it while tightening StrictMode-safe cancellation handling.
Onboarding test support and flows
packages/webview-app/tests/utils/renderWithBridge.tsx, packages/webview-app/tests/screens/onboarding/mrzScanStatusOverlay.test.tsx, packages/webview-app/tests/flows/onboarding.euid-aadhaar.test.tsx, packages/webview-app/tests/flows/onboarding.passport.test.tsx
renderWithBridge adds rerender and StrictMode support, and the onboarding flow tests and overlay tests cover scan progress text, rerender continuity, and StrictMode completion and error paths.

Embed-mode specs and plans

Layer / File(s) Summary
SPEC-MODES.html update
specs/projects/sdk/workstreams/webview-in-app/SPEC-MODES.html
The embed-mode coordination note now names EM-01 and EM-02 and marks the SPEC-MODES contract as canonical.
Embed Mode SPEC
specs/projects/sdk/workstreams/webview-in-app/embed-mode/SPEC.md
The spec now defines embed-versus-self-app mode selection, the lifecycle.getConfig response contract, invariants, dependencies, backlog items, active plans, a mode-signal design decision, and an open routing question.
EM-01 and EM-02 plans
specs/projects/sdk/workstreams/webview-in-app/embed-mode/plans/EM-01-getconfig-handler.md, specs/projects/sdk/workstreams/webview-in-app/embed-mode/plans/EM-02-web-doc-aware-routing.md
The EM-01 plan documents SDK-side getConfig parity and implementation steps. The EM-02 plan defines Part A document-aware boot routing, sticky request capture, Part B context-based request consumption, and validation criteria.

Estimated code review effort: 4 (Complex) | ~60 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 75.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main changes: document-aware embed routing and sticky verification request handling.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch justin/wia-demo-rd1

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@transphorm transphorm changed the title Justin/wia demo rd1 add doc-aware embed routing + sticky verification request Jun 30, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2


ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 3e4a6046-7eea-4ab9-bd25-2bfcf9df2c59

📥 Commits

Reviewing files that changed from the base of the PR and between 305599e and 5c0ecf6.

📒 Files selected for processing (11)
  • packages/webview-app/src/components/InitialRouteRedirect.tsx
  • packages/webview-app/src/providers/VerificationRequestProvider.tsx
  • packages/webview-app/src/screens/embed/TourScreen.tsx
  • packages/webview-app/src/utils/resolveEmbedEntry.ts
  • packages/webview-app/tests/components/initialRouteRedirect.test.tsx
  • packages/webview-app/tests/providers/verificationRequestProvider.test.tsx
  • packages/webview-app/tests/utils/resolveEmbedEntry.test.ts
  • specs/projects/sdk/workstreams/webview-in-app/SPEC-MODES.html
  • specs/projects/sdk/workstreams/webview-in-app/embed-mode/SPEC.md
  • specs/projects/sdk/workstreams/webview-in-app/embed-mode/plans/EM-01-getconfig-handler.md
  • specs/projects/sdk/workstreams/webview-in-app/embed-mode/plans/EM-02-web-doc-aware-routing.md

Comment thread packages/webview-app/src/screens/embed/TourScreen.tsx Outdated
Comment thread specs/projects/sdk/workstreams/webview-in-app/embed-mode/SPEC.md Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5c0ecf6189

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/webview-app/src/components/InitialRouteRedirect.tsx

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2


ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 9a15c44c-f0d3-4808-9b61-58fd2a0fbef6

📥 Commits

Reviewing files that changed from the base of the PR and between 68ad026 and 8e98e4d.

📒 Files selected for processing (8)
  • packages/webview-app/src/providers/BridgeProvider.tsx
  • packages/webview-app/src/screens/onboarding/eu-id/ViewfinderRoute.tsx
  • packages/webview-app/src/screens/onboarding/passport/CodeScanViewfinderRoute.tsx
  • packages/webview-app/tests/flows/onboarding.euid-aadhaar.test.tsx
  • packages/webview-app/tests/flows/onboarding.passport.test.tsx
  • packages/webview-app/tests/providers/bridgeProvider.test.tsx
  • packages/webview-app/tests/screens/onboarding/mrzScanStatusOverlay.test.tsx
  • packages/webview-app/tests/utils/renderWithBridge.tsx

Comment thread packages/webview-app/src/screens/onboarding/eu-id/ViewfinderRoute.tsx Outdated
Comment thread packages/webview-app/src/screens/onboarding/passport/CodeScanViewfinderRoute.tsx Outdated
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.

2 participants