Refresh a page and recover from a failed load
A reader pulls down to get the latest version of a page, always sees whether it is loading or has failed, and can retry a failed load without losing their place.

As a reader, I want to refresh a page and be told plainly when it cannot be loaded, so that I always know whether I am looking at the latest content and can try again.

Situation

I am in the Read tab. A page is open and may have changed, or I have just opened one on a poor connection.

What I do

    Pull down on a document to refresh it.

    If a page fails to load, read the message and tap "Retry".

    If it still fails, tap Back to return to the page before.

What I should see

    Pulling down shows the refresh spinner at the top while the page I was reading stays in place, then the new content replaces it.

    A refresh reloads the document, its lists and child documents, its authors and its discussion together.

    A page that has not arrived yet shows a spinner in the middle. Its title reads "Document", or "Seed" on the home.

    A page that cannot be loaded shows the reason and a "Retry" button, with "Check your connection, then try again." beneath.

    The reason is specific: "Couldn't reach the server.", "The server answered 503.", "The server sent something unreadable.", "This document doesn't exist on this server.", "This link is not a Hypermedia document." or "This document has a redirect loop or too many redirects."

    "Retry" always asks the server again. A failure is never remembered in place of a page.

    A failed page never shows another document, such as my home, in its place.

    Back works from a failed page and returns to the page I came from, intact.

    A document that has moved opens at its new place, and its child list, discussion and shared link are those of the new place.

    A request that gets no answer gives up after about 15 seconds and shows the failure.

    The directory and an author's profile each show their own spinner, and their own reason with "Retry" when they fail.

When something goes wrong

    I open a document with no signal and read "Couldn't reach the server." I move to where I have signal and tap "Retry": the message disappears and the document shows.

    A refresh that fails replaces the page with the reason and "Retry".

Not included

    Nothing can be read offline. Pages are kept only while the app is running (Read: loading pages, caches and embeds).

    "Check your connection, then try again." appears under every failure, including a document that does not exist, where it does not help (Loading, failure and empty states).

    The author profile and the directory sheet cannot be pulled to refresh.

    I am not told that a document was moved. I simply see it at its new place.

Trace

Story US-READ-10, 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

Loading, failure and empty states

Loading, failure with Retry and empty for every screen

States for every screen

The exact strings of the document, directory and author states

Refresh, haptics and progress

Pull to refresh and progress indicators

Document and site home

The States table: loading, failure, refreshing; failure never substitutes another document

Directory sheet

The sheet's own loading and failure states

Author profile

The profile's loading and failure states

StatusLine

The message and Retry button

progress

The spinner labelled "Loading"

list and section

The refreshable list behind pull to refresh

scroll

Scrolling and the pull gesture

Honest state: loading, failure and empty

Every piece of data has a loading, a failure and an empty presentation

Reading another site in place

Failure never falls back to home

Stacks, pushes and sheets

Back from a failed page

Voice and wording

How errors are worded

Representative strings

The failure and loading strings

Implementation

Page

Part it plays

State, refresh and stale-reply patterns

The readEpoch counter for pull to refresh and refresh <resource> for Retry

Read: sources and the refresh epoch

epochSeen: a new epoch drops that server's caches

Read: loading pages, caches and embeds

Caches and generations, failures never cached, redirects, the failed page

Read: API client and superjson decoder

The 15 second timeout and the three transport error messages

Read: screens and components

The not-loaded branch of DocScreen, the refresh and refreshing attributes

Read: root contract wiring

readRetry, readRefresh, readDirRetry, readAuthorRetry

Read: rows, directory and author pages

Directory and author failures returned as pages with an error

Discuss: root contract wiring

discussEpoch + readEpoch: refreshing a document also refreshes its discussion

Shared components and visual design

StatusLine

Root declarations: Read and Discuss

readEpoch and the resources it feeds

Seed site read API

The redirect, not-found and document answers of /api/Resource

Contract views and built-in calls

The list refresh and refreshing attributes and the progress element

The data module runtime (Hermes)

fetch with exactTimeout on the device runtime

Contract UI tests

fail fetch and pass fetch; the failure and recovery tests

Bun unit tests

load.test.ts and client.test.ts

Current limits and known gaps

No offline reading

Code

File

What

read.contract L312-319

The refreshable list and the not-loaded branch: StatusLine, the connection hint, the spinner

read.contract L287-289

page, loaded and the title fallback "Seed" or "Document"

ui.contract L23-31

StatusLine with Retry

app.contract L308-315

readRetry, readRefresh, readDirRetry, readAuthorRetry

app.contract L87-87

state readEpoch

app.contract L103-105

docs, directory and authors take readEpoch

src/read/sources.ts L7-13

epochSeen

src/read/client.ts L10-25

The timeout and "Couldn't reach the server.", "The server answered N.", "The server sent something unreadable."

src/read/load.ts L89-104

The caches, generations and forget

src/read/load.ts L198-224

fetchDocument: redirects, the loop guard, not found and unavailable messages

src/read/load.ts L385-429

failedPage and loadDoc: a failure comes back with its error and is never cached

src/read/load.ts L542-546

forgetAll

Tests

File

What it checks

read.test.contract

a failed load shows Retry and recovers

read.test.contract

a deep link that is not a document says so

open-site.test.contract

failed site loading exposes retry and never substitutes the default home

src/read/__tests__/load.test.ts

refresh starts a new document request and late old responses cannot replace it

src/read/__tests__/load.test.ts

refresh epochs are tracked independently for each server

src/read/__tests__/load.test.ts

redirected documents use the destination for children, discussion and sharing

src/read/__tests__/load.test.ts

redirect cycles terminate with an actionable document error

src/read/__tests__/load.test.ts

a failed child listing is a retryable error rather than a cached empty document

src/read/__tests__/client.test.ts

an invalid SuperJSON annotation is an unreadable response, not silently accepted data

Delivery

Delivered by #1470, #1484.

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

Unsubscribe anytime

Attributes
Epic
Reading
name
Refresh a page and recover from a failed load
Story
US-READ-10
Status
Shipped
summary
A reader pulls down to get the latest version of a page, always sees whether it is loading or has failed, and can retry a failed load without losing their place.