Changeset e9c9ae1 in Klonkt for src/routes/posts.js


Ignore:
Timestamp:
07/19/2026 10:48:15 PM (7 weeks ago)
Author:
Robin <roboburr@…>
Branches:
main
Children:
ff3b8ce
Parents:
5190152
git-author:
Robin <roboburr@…> (07/19/2026 10:47:10 PM)
git-committer:
Robin <roboburr@…> (07/19/2026 10:48:15 PM)
Message:

Feature: mentions bar with conversation partners (klonkt-demo-u02)

Implicit mentions leave the text and become an editable "To:" bar above the
reply editor: the parent author plus the thread's ancestor authors as chips.
Removing a chip stops addressing that partner (no mention anchor, no Mention
tag, no inbox ping); explicit @mentions typed in the text keep working via the
existing resolveMentionsInText path.

  • getInteractions: each thread node gets "participants" (author + ancestor chain via the byId map, own nodes skipped, deduped, capped at 8) and carries actor_uri now.
  • reply-editor partial: the bar renders server-side with a hidden "mentions" JSON field carrying the full list, so the no-JS path addresses everyone; the JS removes chips and mirrors the remaining list into the field.
  • deliverReply({mentions}): undefined = legacy parent-only behavior; an array (possibly empty) = the kept list drives the mention prefix, the Mention tags (mentionTags reads the content anchors) and the per-actor inbox pings. to_actor/to_handle follow the kept list (parent when kept, else the first chip, else null -> the note addresses Public only).
  • deliverOutboxUpdate: an edit reuses the OLD content's leading mention anchors instead of rebuilding just to_actor, so co-mentions survive edits (legacy rows fall back as before).
  • Interact page passes the target author as the single chip. Full-screen mobile keeps the top bar above the mentions bar (flex order).

4 new tests (participant chains, multi-chip tags + to_actor, empty bar goes
Public-only, co-mentions survive edits); 97 green. Browser-verified: bar shows
@bob + @alice on a nested reply, removing @alice updates the hidden field, the
sent reply mentions and addresses only @bob; no console errors.

Co-Authored-By: Claude Opus 4.8 <noreply@…>

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/routes/posts.js

    r5190152 re9c9ae1  
    761761  let attachments = [];
    762762  try { attachments = JSON.parse(req.body.attachments || '[]'); } catch { /* geen media */ }
     763  let mentions;   // undefined = geen balk meegestuurd (legacy addressing)
     764  try { if (req.body.mentions !== undefined) mentions = JSON.parse(req.body.mentions || '[]'); } catch { mentions = undefined; }
    763765  if (site && uri && (text.trim() || html.trim() || (Array.isArray(attachments) && attachments.length))) {
    764766    // Resolve + deliver in the background so Send responds instantly.
    765767    ActivityPubService.resolveRemoteNote(uri)
    766       .then((parent) => parent && ActivityPubService.deliverReply(site, { postId: parent.localPostId || '', postSlug: null, parent, text, html, language, attachments }))
     768      .then((parent) => parent && ActivityPubService.deliverReply(site, { postId: parent.localPostId || '', postSlug: null, parent, text, html, language, attachments, mentions }))
    767769      .catch((e) => console.warn('[AP] remote reply failed:', e.message));
    768770  }
     
    13141316  let attachments = [];
    13151317  try { attachments = JSON.parse(req.body.attachments || '[]'); } catch { /* geen media */ }
     1318  let mentions;   // undefined = geen balk meegestuurd (legacy addressing)
     1319  try { if (req.body.mentions !== undefined) mentions = JSON.parse(req.body.mentions || '[]'); } catch { mentions = undefined; }
    13161320  if (parent && parent.post_id === post.id && (text.trim() || html.trim() || (Array.isArray(attachments) && attachments.length))) {
    13171321    try {
    13181322      await ActivityPubService.deliverReply(site, {
    1319         postId: post.id, postSlug: post.slug, parent, text, html, attachments,
     1323        postId: post.id, postSlug: post.slug, parent, text, html, attachments, mentions,
    13201324        language: (req.body.language || '').toString(),
    13211325      });
Note: See TracChangeset for help on using the changeset viewer.