Profile: editing name and summary
The profile package: loading an identity's public name and summary, publishing a signed change to its home document, and confirming it.

The profile package (pkg:profile) is one modal screen at /me/id/:uid/edit that edits the public display name and summary of an identity whose key is on the device. A profile is metadata on the account's home document, so saving means signing a Change and a Ref and publishing them. "Profile editing is separate from the local key name and preserves other home metadata" (profile.contract L1).

Files

File

Role

src/profile/load.ts

loadProfile, publishProfile, previousProfile

src/profile/sources.ts

Sources profileLoad and profilePublish

profile.contract

Shapes ProfilePage, ProfileReply; components ProfileScreen, ProfileForm

app.contract pkg:profile blocks

Route, resource, mutation, actions, view

src/profile/__tests__/profile.test.ts

9 test declarations, one run twice (fresh and existing home)

profile.test.contract

2 Contract tests

Loading

loadProfile(store, server, account) returns a ProfilePage (account, server, name, summary, version, fresh, error):

    No key for the account in the identity store: This identity is no longer on this device.

    GET /api/Account?id={account} through read's client.

    account-not-found: a fresh profile, prefilled with the local key name, fresh: true.

    account: the server's metadata.name and metadata.summary.

    Anything else is an error (The server returned an unreadable profile.): "without treating server failures as a fresh profile".

Publishing

publishProfile(store, server, account, name, summary, nowMs) returns {ok, error, account, server} and never throws.

flowchart TD A["trim name and summary, refuse an empty name"] --> B["signerFor(store, account)"] B --> C["GET /api/Resource?id=hm://account"] C -- "not-found" --> E["no previous: genesis will be created"] C -- "document" --> D["GET /api/ListChanges, then previousProfile"] C -- "anything else" --> X["refuse: never bootstrap a new home"] D --> F["yieldCryptoTurn"] E --> F F --> G["createProfilePublishBlobs: Change and Ref, signed"] G --> H["POST /api/PublishBlobs as CBOR"] H --> I["GET /api/Account and compare name and summary"] I --> J["ok only when the server shows the new values"]

Details:

    The home document must be the account's own root (document.account == account and path == ""). Otherwise: This home points to another document. Edit it from Seed desktop.

    previousProfile(document, history) derives {genesis, version, depth, generation}. It requires history.latestVersion == document.version (else The profile changed while loading. Try saving again.), a genesis with no dependencies, complete dependency lists, and all heads present. Depth is the maximum DAG depth over the heads, computed with a queue: "Linear traversal accepts newest-first histories without recursion or quadratic work on Hermes."

    yieldCryptoTurn() starts a fresh CPU turn before signing, see The 100 ms turn budget.

    createProfilePublishBlobs emits one SetAttributes operation per metadata key (name, summary), so other metadata such as the icon is untouched. A fresh home yields three blobs (genesis, change, ref); an existing one two. Clearing the summary sends an empty string.

    The timestamp is Math.round(nowMs), where nowMs comes from the action.

    The upload uses exactTimeout: 15000. A non-2xx status gives The server refused the profile ({status}). Try again.

    Confirmation is a real read: "Confirm using the public Account API rather than optimistically claiming the write is visible." A mismatch gives The profile was sent, but the server has not confirmed it. Reload before saving again.

Root contract wiring

    Route: profile-edit "/me/id/:uid/edit" (L59-L61), linked from the identity screen in Me.

    profileUid: the route's uid while the route is on top, else "".

    resource profileData = profileLoad(server, profileUid, top(nav).id) as shape ProfilePage else empty(). The third argument is the navigation entry id, so every visit loads again. The source ignores it.

    mutation profileSaved as shape ProfileReply refreshes meProfiles, authors, docs then profileAfterSave. A save refreshes the names shown in Me and in Read.

    profileReady and profileError accept data only when account, server and (for the reply) visit match the current route. sources.ts copies the visit argument into the reply for this purpose. This is the stale-reply pattern from State, refresh and stale-reply patterns.

    Actions (L670-L686): profileClose (back, then go to Me), profileRetry (refresh profileData), profileSave(uid, name, summary) (only when ready, error-free, name not blank and nothing pending; sends profilePublish(server, uid, name, summary, time.epochAtZero + performanceNow(), top(nav).id)), profileAfterSave (on a matching ok, refresh profileData and haptic("success")).

Screens

ProfileScreen props: eid, page, ready, loading, saving, saved, error, save, cancel, retry, hasKey, openImport. A modal with a Cancel button that reads Done after a save (profile-cancel). It shows profile-loading, or the load error (profile-load-error) with profile-import when the key is missing or profile-retry otherwise, plus a Change server link (profile-server), or the form.

ProfileForm keeps name, summary and touched as local component state seeded from the page. TestIds: profile-form, profile-name, profile-summary, profile-success (Profile updated), profile-name-error (Enter a display name., only after the field was edited), profile-save-error, profile-save. Save is disabled while saving, with a blank name, or when nothing changed on a profile that is not fresh. The footer names the server and says the profile is visible to everyone.

Tests

    Bun: history resolution (all heads, maximum depth, existing generation; a long newest-first history; refusal of concurrent changes and missing or cyclic dependencies), prefill rules, refusals before any request, signed blobs for a fresh and an existing home, no bootstrap on failures or redirects, unconfirmed uploads, and a refused publish.

    Contract: "All writes use dev.hyper.media and the public BIP39 vector identity. Never a production write." One test prefills, validates, publishes twice (with a fail fetch on PublishBlobs in between) and rereads; the other checks that a missing key cannot edit.

Known limits

    Only name and summary. The avatar cannot be changed (the builder's comment says to "upload icons separately").

    A home document that redirects or belongs to another account must be edited on desktop.

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

Unsubscribe anytime