0.7.4 gives the Ambient pack weather. A page names one feed URL on its own site, and the pack sets data-weather from it, uses its sunrise and sunset for dawn and dusk, and never shows a stale observation. Helpers for producing the feed from Open-Meteo are included. Ambient p…
Persistent threaded-discussion container. Decorates author-rendered <article data-comment> children with header, action row, and threaded indentation. Composes <comment-box> (reply form) and bubbles <reaction-bar> events naturally.
Overview
<comment-thread> is the container primitive for a persistent, threaded discussion. Authors render comments as <article data-comment> children with metadata attributes; the component decorates each one with an author header, relative timestamp, action toolbar (Reply / Edit / Delete), and threaded indentation via data-parent.
The component is presentational with respect to persistence: action clicks emit events, and authors call addComment / updateComment / removeComment after the server confirms.
When to use which primitive
Use this
When
<comment-thread>
Threaded, persistent discussion attached to an item. Comments have authors + timestamps + replies + reactions + edit/delete.
Real-time chat (sender-grouped, ephemeral). Different interaction model from threaded comments.
Author surface
Render comments as direct <article data-comment> children. Put the rendered body in an element marked data-comment-body (any element: <section>, <div>, …). Provide a <template data-reply-form> that wraps a <comment-box> — the component clones it under whichever comment is being replied to.
Author markup
123456789101112131415161718192021
<comment-threadaria-label="Comments on issue 482"><articledata-commentid="c1"data-author="Ada Lovelace"data-time="2026-05-14T10:00:00Z"data-mine><divdata-comment-body>Looks great — ship it.</div><reaction-bar><buttondata-reaction="thumbsup"data-count="3"data-mine>👍</button><templatedata-palette><buttondata-reaction="thumbsup">👍</button><buttondata-reaction="heart">❤️</button><buttondata-reaction="rocket">🚀</button></template></reaction-bar></article><articledata-commentid="c2"data-author="Bob"data-time="2026-05-14T11:00:00Z"data-parent="c1"><divdata-comment-body>Agreed!</div></article><templatedata-reply-form><comment-boxsubmit-label="Reply"data-show-cancel></comment-box></template></comment-thread>
Optional link to the author's profile. Only http(s) and relative URLs become a link; anything else (e.g. javascript:) renders as plain text.
data-author-avatar
Optional avatar URL (renders <user-avatar>).
data-time
ISO-8601 timestamp; rendered as relative ("2 hours ago", localized with Intl.RelativeTimeFormat in the element's lang) with the absolute time on hover. An unparseable value is shown as written.
data-mine
Current user authored this — enables Edit / Delete actions and accent styling.
data-parent
Id of the parent comment for nested replies (drives indent depth).
data-edited
Optional ISO timestamp; renders an "(edited)" badge with the absolute time on hover.
Wiring the backend
Hook the events; call back via the imperative API.
const thread = document.querySelector('comment-thread');thread.addEventListener('comment-thread:reply', (e) => {const { parentId, value } = e.detail;const request = api.postComment({ parentId, body: value }).then((saved) => { thread.addComment({id: saved.id, author: saved.author, time: saved.time,bodyHtml: saved.bodyHtml, // sanitized by the component parentId, mine: true, }); });// Synchronously: keep the reply form busy until the POST settles.// Resolve closes it; reject keeps the text so the user can retry. e.detail.waitUntil(request); request.catch(() =>showToast('Reply failed — try again'));});thread.addEventListener('comment-thread:edit-request', async (e) => {const { commentId, value } = e.detail;// Render your own inline editor, then on save:const next = awaitshowEditor(value);const saved = await api.updateComment(commentId, next); thread.updateComment(commentId, { bodyHtml: saved.bodyHtml, edited: saved.editedAt });});thread.addEventListener('comment-thread:delete-request', async (e) => {if (!confirm('Delete this comment?')) return;await api.deleteComment(e.detail.commentId); thread.removeComment(e.detail.commentId);});
Reply contract
comment-thread:reply is cancelable and follows <comment-box>'s submit contract. Decide inside the handler (it is dispatched synchronously):
Do nothing — the reply form closes and focus returns to the comment's Reply button.
e.detail.waitUntil(promise) — the form stays open and busy; it closes when the promise resolves and keeps the text when it rejects.
e.preventDefault() — the form stays open with its text.
New replies are inserted after the parent's last descendant, so a thread reads in order without re-sorting.
Per-comment reactions bubble up as reaction-bar:toggle events — the thread doesn't intercept them. Wire them once at the thread level.
Read-only mode
Set data-disabled on the thread to hide all action toolbars (no Reply / Edit / Delete). Reactions still render but stay clickable unless the inner <reaction-bar> elements also carry data-disabled.
Thread:role="region" with the host's aria-label ("Comments" by default).
Comments: native <article> role, each named from its author and time via aria-labelledby (e.g. “Ada Lovelace, 2 hours ago”) so article navigation lists something meaningful. Nesting depth is visual only (indentation); the article role does not expose a level, so write reply context into the content if it matters.
Action buttons: in a labelled group (“Comment actions”), each named for its comment with author and absolute time (“Reply to Ada Lovelace from May 14, 2026, 8:00 AM”, “Edit your comment from …”), so repeated buttons are distinguishable.
Times:<time datetime> with the absolute timestamp in title; component refreshes the relative text every 60s.
Reply form: focus moves into the editor when shown; when the form closes (Cancel or a successful reply) focus returns to that comment's Reply button. The editor is named “Reply to <author>” unless the template's <comment-box> sets label. (<comment-box> handles its own keyboard.)
Read-only mode — hides the action toolbar on every comment.
Events
Event
Bubbles
Detail
comment-thread:reply
yes (cancelable)
{ parentId, value, waitUntil(promise) }
comment-thread:edit-request
yes
{ commentId, value }
comment-thread:delete-request
yes
{ commentId }
Reactions bubble naturally via reaction-bar:toggle from each per-comment <reaction-bar>.
JavaScript API
Method
Description
addComment(data)
Insert a new comment. data: { id, author, time, bodyText? | bodyHtml?, parentId?, mine?, authorHref?, authorAvatar?, edited? }. A reply goes after its parent's last descendant. Returns the <article>.