Discuss: screens and components
discuss.contract: shapes, helper functions, components, the testIds tests rely on, and the Contract tests that drive them.

discuss.contract draws comments in four places: the section under a document, the list of all threads, a thread, and the compose sheet. Its data comes from two resources and one mutation declared in the root contract. As in read, plain testIds sit only on the visible screen (active).

Shapes and helpers

DiscussComment, Discussion, DiscussThread, DiscussReply (L7-L40) mirror CommentRow, Discussion, ThreadPage and PostReply in logic.ts and load.ts.

    dtid(active, name): the testId only when active.

    repliesText(n), commentsText(n): 1 reply, 3 replies, 1 comment, 3 comments.

    whenText(at, now, utc): now, 5 min. ago, 3 hr. ago, 2 days ago within a week, then the medium date. now is the root's minute clock; 0 or a future instant reads absolute.

Components

Component

Props

Renders

DiscussBubble

c, now, utc, big, testId

Avatar, name, time ({testId}-when), Replying to {parentName}, and the Markdown body in a rounded bubble (testId). Indent is (depth - 1) * 16. An empty body shows (empty comment).

DiscussThreadRow

c, now, utc, testId

A link to the thread: the bubble and the reply count.

DiscussSection

uid, path, active, discussions, now, utc

Under a document, through read's DocDiscussionSlot. Finds its Discussion by uid and path.

DiscussAllScreen

eid, target, active, discussions, now, utc, loading, refresh

Every thread of a document, with pull to refresh. Finds its Discussion by key == target.

DiscussComposer

active, signedIn, draft, placeholder, replyName, posting, error, edit, send, cancelReply, openCreate

The reply bar of the thread screen.

DiscussThreadScreen

eid, id, active, threads, loading, now, utc, signedIn, draft, replyTo, posting, error, edit, post, setReply, openCreate, retry, refresh

A thread and its composer.

DiscussComposeScreen

eid, target, active, signedIn, accountName, draft, posting, error, edit, post, cancel, openCreate

The modal sheet for a new top-level comment.

TestIds tests rely on

    Section: discussion, discussion-count, discussion-loading, discussion-error, discussion-empty, thread-{i} (first three), discussion-all (more than three threads), discussion-add.

    All threads: all-title, all-loading, all-error, all-thread-{i}.

    Thread: comment-thread, thread-title, thread-loading, thread-doc, thread-comment-{i}, thread-root, thread-reply-{i}, thread-root-when, reply-{i}, thread-count.

    Composer: compose-need-identity, compose-create-identity, reply-to, reply-cancel, compose-error, reply-composer, reply-send.

    Compose sheet: compose-cancel, compose-title, compose-post, compose-as, compose-error, compose-text.

Thread screen behaviour

The first comment is the root (big). Signed-in people get a Reply button under every reply; it calls setReply(c.id). The screen's local send action posts to page.ref with the parent being the chosen reply, or the root when none is chosen. The composer's send button keeps focus (retainFocus) and the screen sets interactive-widget="resizes-content" so the keyboard resizes it. Without an identity the composer shows Create an identity to reply. and a Create button.

Root contract wiring

The routes, state, the two resources, the discussPosted mutation and the actions that feed these components are listed in Discuss: root contract wiring.

Contract tests

discuss.test.contract has 6 tests. Reads use live https://hyper.media. "The one write test switches the server to https://dev.hyper.media and signs with a throwaway BIP39 test-vector key; it never posts to hyper.media."

    A document with comments shows the summary, three threads and "See all".

    A thread (by route) shows its root, two replies and the identity prompt.

    A thread row opens the thread.

    Composing without an identity leads to the create screen.

    Post a comment, a reply, and a reply to the reply on dev.

    Comment times are relative and follow the clock (24 min. ago, 1 hr. ago, 2 days ago, then Feb 26, 2025) without asking the server again.

open-site-activity.test.contract additionally checks that a reply from an Activity thread goes to the configured server, and that a refusal reads The server refused the comment (409): Reply received by local fixture. See Contract UI tests.

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

Unsubscribe anytime

Comments