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 |
|---|---|---|
Network, caches, | ||
Sign and publish | ||
| ||
Pure summary and thread ordering, hrefs, reply versions | ||
Shapes and components | ||
| State, resources, mutation, actions | |
| 12 Bun tests in 2 files, one captured | the two source pages |
6 Contract tests |
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.
In this section
Do you like what you are reading? Subscribe to receive updates.
Unsubscribe anytime