Open an hm:// link from outside the app
A reader taps an hm:// link in another app and Seed opens on that document in the Read tab.

As a reader, I want to tap an hm:// link anywhere on my phone and have Seed open that document, so that links people send me lead straight to the page.

Situation

Someone sent me a Hypermedia link, or I saved one in a note. It starts with "hm://". Seed is installed on my iPhone. It may be closed or already open on something else.

What I do

    Tap the hm:// link in the other app.

    Let the phone switch to Seed.

    Read the document that opens.

    Tap Back to return to what Seed was showing before.

What I should see

    My phone offers Seed for hm:// links and opens it.

    The linked document opens in Seed's reader with its title, body and discussion, like any other page.

    If Seed was closed, it starts directly on the linked document.

    If Seed was already open on Read, the document opens on top of what I was reading, and Back returns there.

    A link to an account with no page after it opens that account's home document.

    A link that carries a version or points at one paragraph still opens the document.

    The document is read from the server I chose in Me.

    From the opened document, links, the directory, the authors and the discussion all work as usual.

    While the document loads, the title reads "Document" and a spinner shows.

When something goes wrong

    A link that is not a Hypermedia document shows "This link is not a Hypermedia document." with "Retry". Back returns to what I was reading.

    A document my server does not have shows "This document doesn't exist on this server." I can go Back, or choose another server in Me and open the link again.

    With no connection I see "Couldn't reach the server." and "Retry", which loads the page once I am online.

Not included

    Ordinary web links to a Seed site (https://) do not open the app from outside. I paste them into Open site instead (Deep links and URL handling).

    The link's version is ignored: I see the latest version.

    A link to one paragraph does not scroll to that paragraph.

    What happens when a link arrives while I am on the Activity, Agents or Me tab has not been confirmed (Moving between tabs and into the app).

Trace

Story US-READ-05, status Shipped. These links are kept in step with the traceability matrix and with the "User stories" section of every page listed here.

Design

Page

Part it plays

Moving between tabs and into the app

Links into the app: the hm scheme, what the tests cover, what is not verified

Document and site home

The screen a deep link lands on, pushed over what Read showed

Stacks, pushes and sheets

The linked document is pushed; Back returns

Every screen

The doc route "/d/:ref" that every link resolves to

Reading another site in place

An hm link is read from the configured server

The four tabs

Read is the tab that shows documents

link

Deep links arrive through the same handler as in-app links

StatusLine

The failure line for a link that is not a document

Loading, failure and empty states

Loading and failure of the landed document

Share, copy and open

What enters and leaves the app

Honest state: loading, failure and empty

A link that is not a document says so

Implementation

Page

Part it plays

Deep links and URL handling

The hm protocol handler, the URL-as-ref form, resolveLink and what is not handled

Navigation and routes

The doc route, follow as the warm-link handler, go

The root contract (app.contract)

main navigate=follow

Read: ids, refs and link targets

linkOfRef, refFromUrl, parseRef: a ref that is a whole URL

Read: loading pages, caches and embeds

buildPage resolves the link, then loads the document

Read: sources and the refresh epoch

readDocs receives the URL ref

Read: root contract wiring

readRefs takes the doc route parameter as is

Read: screens and components

DocScreen for the landed document

Seed site read API

/api/Resource for the document, /hm/api/config for site URLs

The Exact framework

The framework whose iOS host registers the hm scheme declared in app.json

Contract UI tests

type "app" "<location>" delivers a deep link in tests

Bun unit tests

deep-links.test.ts

Current limits and known gaps

Platform limits around links

Code

File

What

app.json L38-43

protocolhandlers: hm → /d/%s

app.contract L28-28

route doc "/d/:ref"

app.contract L277-278

follow: the handler a warm link fires

app.contract L744-744

main navigate=follow

app.contract L19-20

readScopedHref leaves a ref that is already a URL untouched

src/read/ids.ts L52-61

linkOfRef: a route parameter that is a whole URL, decoded once

src/read/ids.ts L17-35

refFromUrl: version and block fragment dropped

src/read/load.ts L279-292

resolveLink

src/read/load.ts L302-314

buildPage: link resolution and "This link is not a Hypermedia document."

src/read/load.ts L385-406

failedPage for a link that cannot be read

Tests

File

What it checks

read.test.contract

an hm deep link opens its document in Read, over the home

read.test.contract

a site URL deep link resolves through the site's home account

read.test.contract

a deep link that is not a document says so

src/read/__tests__/deep-links.test.ts

a doc route parameter that is a whole URL is a link, decoded once when encoded

src/read/__tests__/deep-links.test.ts

deep links resolve: hm and gateway URLs directly, site pages through the site home

src/read/__tests__/deep-links.test.ts

a deep-linked document page keeps the URL as its ref and shows the resolved document

src/read/__tests__/markdown.test.ts

hm and gateway URLs become refs; others are not documents

Delivery

Delivered by #1470.

Do you like what you are reading? Subscribe to receive updates.

Unsubscribe anytime