From ad480ad4a070dafa412231c4e38b1074586b316c Mon Sep 17 00:00:00 2001 From: Coracle-Bot Date: Fri, 11 Sep 2026 00:32:41 +0000 Subject: [PATCH] Tag a comment into the room the event it answers lives in (#497) --- e2e/USER_STORIES.md | 4 ++++ e2e/specs/articles-threads.spec.ts | 19 ++++++++++++++++++- src/app/components/CommentCompose.svelte | 9 +++++++++ src/app/components/EventReply.svelte | 8 ++++++++ 4 files changed, 39 insertions(+), 1 deletion(-) diff --git a/e2e/USER_STORIES.md b/e2e/USER_STORIES.md index aeaaebe8..448c202c 100644 --- a/e2e/USER_STORIES.md +++ b/e2e/USER_STORIES.md @@ -654,6 +654,8 @@ Acceptance: top-level comment. - Alice sees both and can add her own comment at the root, optionally attaching an image to it. +- Every comment on an article posted in a room is tagged into that room, so the + relay handles it as part of the group. ### US-040 — React to a post with an emoji @@ -706,6 +708,8 @@ Acceptance: appends a post and increments the reply count in the header. - "Reply" on a single post shows "Replying to" that post, which can be cleared before submitting. +- A reply to a thread in a room is tagged into that room, so the relay handles + it as part of the group. - The thread's opening post carries an "OP" badge on every page. ### US-044 — Navigate a long thread diff --git a/e2e/specs/articles-threads.spec.ts b/e2e/specs/articles-threads.spec.ts index 0beb2a5a..84f2c1e2 100644 --- a/e2e/specs/articles-threads.spec.ts +++ b/e2e/specs/articles-threads.spec.ts @@ -1,6 +1,6 @@ import * as nip19 from "nostr-tools/nip19" import {HOUR, MINUTE} from "@welshman/lib" -import {LONG_FORM, MESSAGE, NOTE, makeEvent} from "@welshman/util" +import {COMMENT, LONG_FORM, MESSAGE, NOTE, makeEvent, tagSpec, tagValue} from "@welshman/util" import type {SignedEvent} from "@welshman/util" import {Article, Comment, Thread} from "@welshman/domain" import type {Locator, Page} from "@playwright/test" @@ -325,6 +325,7 @@ test("US-039 comment on an article", async ({seed, as}) => { space .kind(Article) .writer() + .setRoom(space.url, "general") .setIdentifier("tending-the-garden") .setTitle("Tending the Garden") .setSummary("A short teaser about gardens.") @@ -349,6 +350,15 @@ test("US-039 comment on an article", async ({seed, as}) => { // relay confirms it, so for a moment the page carries this text twice. Match the rendered comment. await expect(comment(bob, "The soil chapter is the good one.")).toBeVisible() + // A comment on a room event is a room event, so it carries the room the root lives in. Without + // that tag the relay doesn't see it as part of the group, and neither its access rules nor a + // room deletion ever reach it. + await expect + .poll(() => + getPublishedEvents(bob.context(), COMMENT).map(event => tagValue(tagSpec("h"), event.tags)), + ) + .toEqual(["general"]) + const carol = await as(users.carol, articlesPath) await openArticle(carol, "Tending the Garden") @@ -747,6 +757,13 @@ test("US-043 reply to a thread and to a specific post", async ({seed, as}) => { await expect(bob.getByText("21 replies")).toBeVisible() + // The same for a thread reply, which goes out through a different composer. + await expect + .poll(() => + getPublishedEvents(bob.context(), COMMENT).map(event => tagValue(tagSpec("h"), event.tags)), + ) + .toEqual(["lounge"]) + // The thread's author is marked OP wherever their posts turn up, second page included. await bob.getByRole("button", {name: "2", exact: true}).click() await expect(bob.getByText("Page 2 of 2")).toBeVisible() diff --git a/src/app/components/CommentCompose.svelte b/src/app/components/CommentCompose.svelte index 2d68f2cc..684e9eff 100644 --- a/src/app/components/CommentCompose.svelte +++ b/src/app/components/CommentCompose.svelte @@ -1,6 +1,7 @@