Open site lets a person type a Seed site address or an hm:// link and read it in the native reader. "Opening a URL is navigation, not a change to the account or the configured server" (read.contract L440). It was added in PR 1484. The workflow-level write-up and review evidence are in Open site: implementation and evidence.
Pieces
Piece | Where |
|---|---|
Validator | |
Source | |
Sheet | |
State, mutation and actions | |
Route | |
Reading from the typed server |
Validation
openSite(input) returns {url, error}. It runs only on explicit submission: "typing never starts a request". It makes no network request itself.
Accepted:
https:, http: and hm: addresses. A host with no scheme gets https:// ("Never guess a different scheme").
For hm: and gateway /hm/… URLs: the first segment must match z6Mk plus 44 base58 characters, and no segment may start with : (view terms such as :directory).
For site URLs: the hostname must contain a dot and siteUrlParts must accept the path.
Rejected with one message, Enter a valid Seed site URL, like https://hyper.media, or an hm:// document link.: empty input, white space or backslashes, other schemes, credentials in the URL, malformed percent escapes, file-like paths and gateway pages that are not documents. On success url is the normalised URL.href.
The flow
sequenceDiagram
participant P as Person
participant S as OpenSiteScreen
participant R as Root contract
participant D as Data module
P->>S: tap open-site in a document header
S->>R: readShowOpenSite
R->>R: revision + 1, clear draft and error, push open-site
P->>S: type, then Enter or Open
S->>R: readSubmitSite
R->>D: send readSiteOpened = readOpenSite(draft)
D-->>R: url or error
R->>R: readSiteAfterOpen, only if the reply is current
R->>R: on success, back then push doc with the URL as refThe stale-reply guard
One submission may be pending, and its reply must not apply to a form the person has since changed (app.contract L82-L86):
readSiteRevision increases on every edit (readEditSite) and every new visit (readShowOpenSite).
readSubmitSite copies it to readSiteSubmittedRevision and sends, only when nothing is pending and the draft is not blank.
readSiteReplyCurrent is true when the top route is open-site and the two revisions are equal. readSiteAfterOpen does nothing otherwise.
On a current reply: an error is shown under the field; success replaces the sheet with doc whose ref is the URL (back then push). A mutation that produced no reply sets Could not open this link. Try again. This is one instance of the pattern in State, refresh and stale-reply patterns.
Reading from the typed server
The doc route's ref is now a URL, so loadDoc reads it from that URL's origin and returns a DocPage whose server is that origin. readContextServer follows the visible reader, so the directory, authors, discussions and further links opened from it use the same server, while the persisted server setting and the account stay untouched. If the site cannot be reached the page shows the error and Retry, with the title Document, never the default home.
Screen
OpenSiteScreen props: eid, active, draft, error, busy, edit, submit, close. It is a modal with a url input (placeholder https://hyper.media, submits on Enter), an alert line and an Open button that reads Opening… while busy and is disabled for a blank draft. TestIds: open-site-cancel, site-url, site-url-error, site-url-open. The header button that opens it is open-site on DocScreen.
Tests
open-site.test.ts: 2 Bun tests (trimming, bare hosts and preserved targets; invalid addresses, credentials, files and non-document routes).
open-site.test.contract: 4 Contract tests against live hyper.media: open a typed URL and return; invalid input stays editable and Cancel returns; an unreachable site (https://unreachable-typed.test) shows Retry and never the default home; a submitted revision cannot apply to an edited or reopened form with identical text (asserts readSiteReplyCurrent).
open-site-activity.test.contract: 1 test that an Activity thread opened over a typed-site document fetches and replies on the configured server, then Back restores the typed site's context. It uses the thread scenario of the mock notify service.
Do you like what you are reading? Subscribe to receive updates.
Unsubscribe anytime