Skip to content

Pairing links that open Pulse or the store, and survive the install (#252) - #267

Merged
morepriyam merged 11 commits into
mainfrom
feat/universal-links
Oct 12, 2026
Merged

morepriyam merged 11 commits into
mainfrom
feat/universal-links

Conversation

@morepriyam

@morepriyam morepriyam commented Oct 9, 2026 •

Copy link
Copy Markdown
Collaborator

Part of #252.

This is the #252 branch: this first commit makes pairing links work as https links that open Pulse or the store. More commits for the rest of #252 land here (destination info on the link, the upload outcome and return to the host, watch links).

What changes

  • https pairing links. https://mieweb.github.io/pulse/open#v=1&artifactId=…&server=…&token=… is a Universal Link / App Link. app.config.ts declares mieweb.github.io (iOS associated domains; an Android autoVerify intent filter for /pulse/), fixed, with no env override. An Android debug build's key isn't in the host's assetlinks.json, so its links are switched on with adb shell pm set-app-links-user-selection (in the config comment). Parameters ride in the fragment, so the link host never receives them.
  • One parser, no navigation. pairingLinkParams reads both pulsecam://?… and the https form. +native-intent keeps the router on the current screen for both, so pairing opens over whatever is up (recorder, export, onboarding); pulsecam:// no longer collapses the stack to home. A bare pulsecam:// (Android's upload notification) is ignored instead of alerting.
  • Pairing sheet. Replaces the confirmation alert: the server, Connect / Cancel, and "Don't ask again for this server". Trusted servers pair without the sheet (an info toast says why); About lists them, with remove-one and Clear all, and Copy details includes them.
  • Pairing through a store install. Android reads the pairing link from the Play install referrer (expo-application) on first launch. iOS shows Apple's paste button for the link the /pulse/open page copied; it reads the pasteboard only on that tap, so iOS shows no paste prompt.
  • Log redaction also covers a #token= fragment.
  • The /pulse/open page (pages/open.html, served at https://mieweb.github.io/pulse/open with no trailing-slash redirect): Android goes to Play with the link as the install referrer, iOS copies the link on "Get Pulse" and opens the App Store, desktop shows a QR of the link, and "Already have Pulse? Open it" uses pulsecam://. It is the test host's page minus its debug log, and the QR script now loads with an integrity hash.

Testing

On an iPhone 17 Pro Max (iOS 26), on a build of the pulse-editor branch (#240) carrying these changes, with the link host pointed at morepriyam.github.io (a test host; the env override used for that has since been removed serving the association files and the /pulse/open page):

  • Pulse installed, app closed and app open: scanning the https QR with the Camera opened Pulse into the pairing sheet; Connect paired.
  • Pulse not installed: the page's "Get Pulse" opened the App Store; after installing (the dev build, standing in for the store), first launch showed the paste sheet; Paste paired, with no paste prompt, and it survived onboarding.
  • An old pulsecam:// QR (the demo server's page) opened Pulse over the current screen with the same sheet.
  • Apple's CDN served the test host's association file (app-site-association.cdn-apple.com/a/v1/morepriyam.github.io).
  • pages/open.html served locally, in Playwright (Chromium, desktop and iPhone emulation): desktop shows the QR (the integrity hash matches cdnjs's), iPhone shows "Get Pulse" and the pulsecam:// link, no console errors. Not opened on a phone from mieweb.github.io yet.
  • Typecheck: no errors in changed files; lint and Prettier clean; unit tests for the touched areas pass (upload, about, logs: 133).

Not confirmed on a device: a trusted server's next link pairing without the sheet (and its info toast).

Not run: Android (App Link verification, the store redirect, the install referrer and its size limit), the Play Store install path (needs an internal-track build), this branch's own build on main.

Before it goes live

  • iOS signing: the App ID now has the Associated Domains capability, which invalidates the existing provisioning profiles. Regenerate them (match with force) before the next iOS release build, or it fails to sign.
  • Link host: live. Serve the app-association files for Pulse links mieweb.github.io#1 is merged: both association files are served at the root with no redirect, Apple's CDN (app-site-association.cdn-apple.com/a/v1/mieweb.github.io) returns the Pulse entry, and Google's Digital Asset Links API returns both Play keys. The /pulse/open page goes live when this PR merges (the Pages workflow runs on pages/**).
  • Hosts: Https Pairing Links With Destination and Return Info, and Watch Links pulsevault#83 makes buildUploadLink produce the https form.

@morepriyam
morepriyam force-pushed the feat/sheets-and-cards branch from 96c462c to 853e5d0 Compare October 9, 2026 23:02
@morepriyam
morepriyam force-pushed the feat/universal-links branch 14 times, most recently from 903848f to 056215a Compare October 10, 2026 07:09
…survive the install

Part of #252.

- An https pairing link (`https://<link host>/pulse/open#<params>`) is a
  Universal Link / App Link: the app declares the host (associated
  domains, an autoVerify intent filter for /pulse/), defaulting to
  mieweb.github.io; PULSE_LINK_HOST points a local build at a test host.
  Parameters ride in the fragment, so the link host never receives them.
- Both link forms parse to the same link, and `+native-intent` keeps the
  router on the current screen for both, so pairing opens over whatever
  is up. A bare `pulsecam://` (Android's upload notification) is ignored.
- The pairing sheet replaces the confirmation alert: the server, with
  Connect / Cancel and "Don't ask again for this server". Trusted
  servers pair without the sheet; About lists them (remove one, or clear
  all) and Copy details includes them.
- After a store install: Android reads the pairing link from the Play
  install referrer (expo-application); iOS offers Apple's paste button on
  first launch for the link the /pulse/open page copied.
- Log redaction also covers a `#token=` fragment.
…th their text

The server glyph and the "Don't ask again" check on the pairing sheet, and the trusted-server
rows' check and the list's chevron on About, use Icon's scalesWithText (#266). The rows' trash
buttons keep their size.
@morepriyam
morepriyam force-pushed the feat/universal-links branch from 056215a to 2b700ab Compare October 10, 2026 07:18
@morepriyam
morepriyam changed the base branch from feat/sheets-and-cards to main October 12, 2026 15:34
…ulse

Served by this repo's Pages at https://mieweb.github.io/pulse/open (as
open.html, so there is no trailing-slash redirect). The page tested on the
test host, minus its debug log: Android goes to Play with the link as the
install referrer, iOS copies the link on the Get Pulse tap and opens the
App Store, desktop shows a QR of the link, and an installed Pulse opens via
pulsecam://. Parameters stay in the fragment. The QR script now loads with
an integrity hash.
The org host now serves the association files, so PULSE_LINK_HOST (a local
build pointed at a test host) has no use left. iOS dev builds match by team
and bundle ID and open the org host's links as they are; an Android debug
build's key isn't listed, so its links are switched on with adb, as the
comment says.
@morepriyam
morepriyam marked this pull request as ready for review October 12, 2026 16:20
Copilot AI balanced review requested due to automatic review settings October 12, 2026 16:20

Copilot AI 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.

🟡 Changes recommended

Cold-start and request-state races can select the wrong pairing flow, with additional accessibility and regression-test gaps.

7 open findings
What changed in this PR

Adds universal/app pairing links with store-install handoff, confirmation sheets, trusted-server management, and a static fallback page.

Changes:

  • Supports HTTPS and legacy pairing links, including deferred Android/iOS pairing.
  • Adds pairing confirmation and trusted-server controls.
  • Configures native app links and the web fallback page.
File Description
app.config.ts Configures iOS and Android app links.
package.json Adds Expo Application support.
package-lock.json Locks the new dependency.
pages/​open.html Implements store fallback and desktop QR flow.
src/​app/​+native-intent.tsx Prevents pairing links from navigating.
src/​app/​_layout.tsx Registers the pairing sheet.
src/​app/​about.tsx Adds trusted-server management.
src/​app/​pair.tsx Exposes the pairing route.
src/​features/​about/​details.ts Includes trusted servers in diagnostics.
src/​features/​logs/​log-buffer.ts Redacts fragment tokens.
src/​features/​upload/​deep-link.ts Parses both pairing-link formats.
src/​features/​upload/​deferred-pairing.ts Handles post-install pairing.
src/​features/​upload/​link-host.ts Reads the configured link host.
src/​features/​upload/​pairing-sheet.tsx Implements pairing confirmation UI.
src/​features/​upload/​trusted-servers.ts Persists trusted servers.
src/​features/​upload/​upload-deep-link-provider.tsx Coordinates pairing requests and persistence.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/app/_layout.tsx Resolved
Comment thread src/app/about.tsx Resolved
Comment thread src/features/upload/pairing-sheet.tsx Resolved
Comment thread pages/open.html Resolved
Comment thread src/features/logs/log-buffer.ts Resolved
Comment thread src/features/upload/deep-link.ts Resolved
…request, launch URL resolved, honest privacy line

- The pairing sheet opens full height and scrolls at large text or on a
  short screen, like About, so Connect is never cut off.
- "Don't ask again" belongs to the request it was ticked on: a link that
  replaces it in the open sheet starts unticked.
- The deferred-pairing check asks for the launch URL itself instead of the
  first render of useLinkingURL, which can be null on a cold start.
- About's trusted-servers list scrolls inside the full-height sheet on
  Android (nestedScrollEnabled).
- /pulse/open: "This website never receives" the link's details; on
  Android it adds that Google Play passes them to Pulse.
Copilot AI balanced review requested due to automatic review settings October 12, 2026 18:11

Copilot AI 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.

🔵 Needs a closer look

Deferred pairing can be permanently lost after transient failures, and trusted-server mutations can race.

0 open findings

7 resolved since last review
Previously missed (3)

In code that hasn't changed since last review

Medium severity Display full base URL for trusted-server identity

src/​app/​about.tsx:406

Trust is keyed by the full base URL, including its path prefix (trusted-servers.ts:24-27), but this row and its delete label reduce that identity to the host. Two servers such as https://vault.example.org/a and /b therefore appear identical, so the user cannot tell which trust they are removing. Display and announce the full stored base URL (or at least host plus path).

Medium severity Persist deferred-check flag only after a successful probe

src/​features/​upload/​deferred-pairing.ts:29

The one-shot flag is persisted before either platform probe succeeds. If the Play Install Referrer service is temporarily unavailable/disconnected (the Expo API rejects in those cases), or a clipboard/DB call fails, the outer catch swallows the error but every later launch sees deferredChecked=true; the pairing link is then permanently lost. Persist the flag only after a conclusive probe, and leave it unset when the probe fails so the next launch can retry.

Medium severity Serialize trusted-server mutations to prevent lost updates

src/​features/​upload/​trusted-servers.ts:46

This read-modify-write is not serialized. If two trusted rows are removed quickly, both calls can read the same original array and the last write restores the entry removed by the other call; trustServer and clearTrustedServers can race similarly. Serialize all trusted-server mutations (as src/db/destinations.ts:41-45 does) or update the value atomically.

🧠 Review effort: Balanced

- "Don't ask again" that fails to save still pairs, and the Connected
  toast says the next link will ask first (a toast of its own would be
  covered by it).
- Removing one trusted server that fails shows an error toast, like
  Remove all.
Copilot AI balanced review requested due to automatic review settings October 12, 2026 18:29
@morepriyam

morepriyam commented Oct 12, 2026 •

Copy link
Copy Markdown
Collaborator Author

Copilot's review of be0ea2b listed two previously missed findings with no thread. Both fixed in 5997948:

  • Individual trust removal lacks failure handling (about.tsx): the trash button's removal now shows an error toast when it fails, like Remove all.
  • Failed trust preference save is silently ignored (upload-deep-link-provider.tsx): pairing still goes ahead, and the "Connected to …" toast says Pulse couldn't save "Don't ask again", so its next link asks first. It's in that toast because a separate error toast would be replaced by it moments later. The second line the review cites (243 at be0ea2b) is the Cancel handler, which saves nothing; the only trust write is the one fixed here. A failed trust read (isTrustedServer) still falls back to asking, which is the safe side.

Not changed here: the review's summary also notes that opening the identical link again isn't processed. useLinkingURL only re-renders when the URL string changes, so (from reading the code, not tried on a device) re-opening the same link after Cancel does nothing until another link opens. That behaviour is on main too; it'll be its own fix.

Typecheck, lint and Prettier pass; the existing upload/about tests pass (125).

Copilot AI 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.

🔵 Needs a closer look

The iOS fallback opens the store even when copying fails, losing the pairing through installation.

0 open findings

Previously missed (1)

In code that hasn't changed since last review

Medium severity Avoid App Store redirect when pairing URL copy fails

pages/​open.html:228

Both fallback paths still open the App Store when the clipboard API is unavailable or writeText rejects. The install then succeeds without a pairing URL on the pasteboard, so first launch cannot offer the promised deferred pairing. Only navigate after a successful copy; on failure, keep the page open and provide a retry or manual-copy fallback.

🧠 Review effort: Balanced

On iOS the copied link is what carries the pairing through the install.
If the copy fails or there's no clipboard API, the page no longer goes to
the App Store: it says how to finish (install, come back, "Open it") and
the button becomes "Open the App Store" for the next tap.
@morepriyam

Copy link
Copy Markdown
Collaborator Author

Copilot's review of 5997948 listed one previously missed finding with no thread, fixed in 60409f2:

  • Avoid App Store redirect when pairing URL copy fails (pages/open.html): when writeText rejects or there's no clipboard API, the page stays: it shows "Pulse couldn’t copy your link. Install Pulse, then come back to this page and tap “Already have Pulse? Open it”." and the button becomes "Open the App Store", which the next tap follows. The tab keeps the link, so "Open it" (pulsecam://) pairs after the install, and re-scanning the QR works too.

Checked in Playwright (Chromium, iPhone emulation, page served locally): copy succeeds → the page URL is copied and it goes to the App Store; copy rejected, and no clipboard API → no navigation, message shown, button relabelled, second tap goes to the App Store. Not yet run in Safari on an iPhone.

Copilot AI balanced review requested due to automatic review settings October 12, 2026 18:37

Copilot AI 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.

🟡 Changes recommended

A replacement pairing request can become stranded when the current sheet closes.

1 open finding

🧠 Review effort: Balanced

…ets the sheet

closed() kept the newer request but left the sheet marked open after the
route had gone, so the push effect never showed it. The route's close now
always clears the mark, and a waiting newer request bumps the effect to
push the sheet again.
Copilot AI balanced review requested due to automatic review settings October 12, 2026 18:51

Copilot AI 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.

🔵 Needs a closer look

A dismissal race can still discard a newly arriving pairing request.

0 open findings

1 resolved since last review
Previously missed (1)

In code that hasn't changed since last review

Medium severity Replacement requests can be dropped during swipe dismissal

src/​features/​upload/​pairing-sheet.tsx:48

A replacement request can still be dropped during a swipe dismissal. The screen remains mounted during the closing transition, so if request B arrives after the swipe starts, this effect can change shown.current from A to B; the unmount cleanup then calls closed(B), and the provider sees B as the shown request and clears it instead of reopening it. If B arrives before these passive effects flush, the provider’s own requestRef can likewise still be stale. Snapshot the shown request when dismissal starts (or queue/version requests independently of passive effects) so arrivals after that point are preserved.

🧠 Review effort: Balanced

…as the dismissed one

The sheet stops tracking the current request once its closing transition
starts (native-stack transitionStart, closing: true; a swipe let go of
reopens with closing: false), so closed() reports the request it was
closed on and a newer one gets the sheet again. The provider keeps
requestRef in step at every set instead of in an effect, so closed() never
compares against a stale request.
@morepriyam

Copy link
Copy Markdown
Collaborator Author

Copilot's review of 0463a6b listed one previously missed finding with no thread, fixed in 29f8a40:

  • Replacement requests can be dropped during swipe dismissal (pairing-sheet.tsx): the sheet now listens for native-stack's transitionStart. From closing: true (the sheet's will-disappear) it stops updating shown, so its unmount reports the request it was closed on; a request that arrived during the closing animation is newer, so closed keeps it and the provider pushes the sheet again (0463a6b). A swipe that's let go of fires closing: false on will-appear and tracking resumes. The provider's requestRef is now set together with the state at every setRequest, not in an effect, so closed never compares against a stale value.

Typecheck, lint, Prettier and the existing upload tests pass. Checked by reading expo-router's native-stack view (will-disappear/will-appear emit transitionStart with closing true/false); the race itself hasn't been reproduced on a device.

Copilot AI balanced review requested due to automatic review settings October 12, 2026 19:00

Copilot AI 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.

🟡 Changes recommended

The iOS paste flow contacts the pasted server without confirming the actual host, bypassing the TOFU safeguard.

1 open finding

🧠 Review effort: Balanced

The pinned server now documents the https link form this branch accepts
(mieweb/pulsevault#86). protocol.gen.ts regenerated: only the deep-link
description and the protocol revision change.
Copilot AI balanced review requested due to automatic review settings October 12, 2026 19:12
@morepriyam
morepriyam merged commit 97a2afe into main Oct 12, 2026
8 checks passed

Copilot AI 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.

🔵 Needs a closer look

The cross-platform Universal Link, Play install-referrer, and device navigation flows still require the stated Android and release-build validation.

0 open findings

1 resolved since last review

🧠 Review effort: Balanced

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