Discuss: comments
The discuss package: the discussion under a document, thread screens, and signing and publishing comments.

The discuss package (pkg:discuss) shows the comments on a document and lets a person with an identity on the device post a comment or a reply. Reading uses the Seed site read API. Posting signs a Comment blob with a local key and sends it to the site's PublishBlobs endpoint.

Responsibility

    The discussion section under every document: comment count, the three most recently active threads, "See all" and "Add a comment".

    The routes thread "/c/:uid/:comment", comments "/comments/:ref" and compose "/compose/:ref" in the read tab (Navigation and routes).

    Threading: replies nested under the comment they answer, capped at depth 4.

    Signing a one-paragraph comment with the current account's key from Identity through the builder in Crypto: changes, refs, comments and profiles.

Files

File

Role

Documented in

src/discuss/load.ts

Network, caches, postComment

Loading and posting

postComment

Sign and publish

Posting a comment

src/discuss/sources.ts

discussList, discussThreadList, discussPost, the epoch

Loading and posting

src/discuss/logic.ts

Pure summary and thread ordering, hrefs, reply versions

Threading logic

discuss.contract

Shapes and components

Screens and components

app.contract pkg:discuss blocks

State, resources, mutation, actions

Root contract wiring

src/discuss/__tests__/

12 Bun tests in 2 files, one captured ListComments fixture

the two source pages

discuss.test.contract

6 Contract tests

Screens and components

The package depends on Read for the API client, the id helpers and the block renderer, and read's DocDiscussionSlot renders discuss's DiscussSection.

Data flow

flowchart TD DOCS["resource docs and visible comments or compose routes"] --> T["derive discussTargets"] T --> RL["resource discussions = discussList(readContextServer, targets, epoch)"] V["visible thread route"] --> TI["derive discussThreadIds"] TI --> RT["resource discussThreads = discussThreadList(readContextServer, ids, epoch)"] RL --> LD["loadDiscussions"] RT --> LT["loadThreads"] LD --> LC["listComments: GET /api/ListComments"] LT --> FC["fetchComment: GET /api/Resource"] LT --> LC LC --> LG["logic.ts: summarize and threadRows"] LG --> UI["DiscussSection, DiscussAllScreen, DiscussThreadScreen"] UI --> POST["action discussPost"] POST --> M["mutation discussPosted = discussPost(server, account, target, parent, text, now)"] M --> PC["postComment: sign, then POST /api/PublishBlobs"] PC --> RF["refreshes discussions and discussThreads"]

Rules the package follows

    The epoch passed to both resources is discussEpoch + readEpoch, so refreshing a document also refreshes its comments.

    A post drops only its own document's cached listing; the mutation's refreshes clause then re-reads.

    Comment time comes from the action (time.epochAtZero + performanceNow()), never from a clock in the data module. See State, refresh and stale-reply patterns.

    Reads and writes go to readContextServer, the server of the visible reader, not necessarily the configured one (Read: root contract wiring).

    Private comments are filtered out everywhere.

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

Unsubscribe anytime

Comments