Skip to content

feat(web): copy a ready-to-paste Discord announcement from the Event details - #227

Merged
mwg-bender[bot] merged 2 commits into
devfrom
feat/97-announcement
Nov 25, 2026
Merged

mwg-bender[bot] merged 2 commits into
devfrom
feat/97-announcement

Conversation

@mwg-bender

@mwg-bender mwg-bender Bot commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds a Copy announcement button to the Event details dialog, next to Copy feedback link. It puts ready-to-paste Discord text for the Event on the clipboard (#97, spec #203 user stories 15 to 20, Seam 2). The text comes from a new pure builder, AnnouncementText.For(EventEntity). The button builds it from the Event as the dialog currently holds it, with no API call.

Change

  • MW-GC.EventManager.Web/Shared/Events/AnnouncementText.cs (new, 78 lines): a static builder with no clock, JS or services. It uses a fixed template:
    **Event name**
    <t:UNIX:F>
    - Game: Activity (players, duration)
    - Game: Activity 🏆 Winner
    
    UNIX is Date.ToUnixTimeSeconds(): whole seconds of the instant in UTC, so the stored offset doesn't matter and fractional seconds are dropped. The players and duration come from the Selection snapshot, worded by the existing PlayersDurationText.Players and .Duration (no second wording). Lines follow the Event's Selection order.
  • MW-GC.EventManager.Web/Shared/Events/EventDetailsDialog.razor (339 to 372 lines):
    • the button, its role="status" text and its role="alert" text;
    • one handler, CopyAnnouncement, which follows the CopyFeedbackLink clipboard pattern and checks the _details token;
    • ShowDetails now clears both messages.
  • GLOSSARY.md: the existing planned Announcement entry, rewritten to describe the shipped template. No second entry was added, because the glossary already had one for this term.
  • Tests: three new files in Web.Tests. No existing test was touched.

Nothing else in Web, and nothing in API, Shared, Api.Tests, E2E or .github/.

DISPOSITION

  • feat(events): copy-ready announcement text for an Event #97 DONE: Copy announcement on the Event details dialog, built by the pure AnnouncementText builder.
  • Winner marker: the Winner's line ends in 🏆 Winner (trophy emoji plus the word, so it still reads where emoji don't render). It goes after the players and duration, e.g. - Kart: Grand Prix (2-6 players, 45 min) 🏆 Winner. Pinned by TheWinnersLine_AndOnlyIt_IsMarked and TheWinnersLine_KeepsItsPlayersAndDuration. A Winner id that matches no Selection marks no line (AWinnerIdOfNoSelection_MarksNoLine).
  • Escaping (applied to the Event, Game and Activity names):
    • \ * _ ~ | > < are each backslash-escaped, the backslash itself included, so a name can neither style the text nor close the bold title early.
    • Every @ is followed by a zero-width space (U+200B), so @everyone, @here, <@id>, <@!id> and <@&id> cannot ping anyone. The < is also escaped.
    • A line break in a name (\r\n, \r, \n) becomes a space, so a name cannot add a line.
    • Pinned in AnnouncementTextEscapingTests (16 cases).
  • Busy choice: the button is not disabled by Busy. Copying sends nothing and changes nothing, so a running Select Winner, metrics save or Comment request has no reason to block it. Copy feedback link isn't disabled by Busy either. Pinned by WhileBusy_TheButtonStillCopies.
  • "Picks to come" wording: an Event with no Selections (an Occurrence not rolled yet) has The picks are still to come. as its only line after the date. It never throws.
  • Link line (Discord Integration #9): reserved and empty. The text ends on its last line, with no trailing line break or whitespace (TheTextEndsOnItsLastLine).
  • Messages: success shows Announcement copied. (role="status"). A JSException or JSDisconnectedException shows The announcement could not be copied: the browser refused the clipboard. (role="alert") and no status. Both clear on every press and when another Event's details open. A result that arrives after its dialog was replaced is dropped.

Sample text for the seeded Event (copied from the live clipboard, run F2)

**Announce night 471279**
<t:1796410800:F>
- AnnKart471279: Grand Prix (2-6 players, 45 min)
- AnnBrawl471279: Stock Battle 🏆 Winner
- AnnPuzzle471279: Tiles

The empty Occurrence (F4): **Weekly 471279**\n<t:1797021000:F>\nThe picks are still to come.. The *Party* @everyone Event (F5): **\*Party\* @\u200Beveryone 471279**\n<t:1796410800:F>\n- AnnKart471279: Grand Prix (2-6 players, 45 min) 🏆 Winner. It has one Selection, which the API makes its Winner.

Validation

All numbers come from cold builds (bin/obj deleted, --no-incremental) of MW-GC.EventManager.slnx:

errors warnings Api.Tests Web.Tests E2E (no stack)
baseline origin/dev 02d09f5 0 0 840 + 4 skipped 940 5 + 12 skipped = 17
after (2e8f8b3) 0 0 840 + 4 skipped 987 (940 + 47) 5 + 12 skipped = 17

Count preservation: no test was removed, renamed or split. 47 cases were added: AnnouncementTextTests 19, AnnouncementTextEscapingTests 16, AnnouncementCopyTests 12.

Break-it mutations: 29 throwaway changes, each applied, run against the announcement tests and restored. All 29 went red, and the restored control passes 47/47. They cover:

  • the timestamp: off by one hour, milliseconds, offset ignored, fractional seconds rounded up, wrong style letter;
  • the Winner marker: on every line, on the wrong lines;
  • players or duration missing; a second wording for either;
  • Selection order reversed; a trailing blank line;
  • no escaping; the backslash not escaped; mentions not inert; line breaks kept;
  • an empty Event that throws;
  • success shown on a failed copy; JSDisconnectedException not caught; not cleared on press; not cleared on another Event;
  • a late success, late error, or both applied;
  • the text built from a copy without the Winner, or from a cached earlier Event;
  • the button disabled by Busy, or named by a title.

Each mutation and the tests it turned red are in the evidence file on the Kanban card.

Live run (by the worker, with-slot.sh, Release web build behind the SWA emulator, headless Chromium with an admin cookie). The seed came through the API:

  • an Event with three Selections: one with players and duration, one the Winner;
  • an Event named *Party* @everyone …;
  • a Series with exactly one Occurrence, which has no Selections. A plain Event create refuses zero Selections, so this is the only way to get an empty Event.

Branch feat/97-announcement (worktree with the change, run 6):

PASS F1 the button is on the details dialog | buttons=1, name="Copy announcement", Copy feedback link buttons=1
PASS F2 press: status shows and the clipboard holds the exact text | status=["Announcement copied."]
PASS F3 the Winner line is marked | "- AnnBrawl471279: Stock Battle 🏆 Winner"
PASS F4 the empty Event copies the picks-to-come text
PASS F5 a name with @everyone and * copies inert text
PASS F6 clipboard permission denied: the alert shows and no status | alert="The announcement could not be copied: the browser refused the clipboard."
SUMMARY pass=6 fail=0 error=0 (console errors: none)

Control, plain origin/dev 02d09f5:

FAIL F1 the button is on the details dialog | buttons=0, dialog buttons=["Copy feedback link","Select Winner","Add Comment","Select Winner","Save metrics","Close"]
ERROR F2-F6 | locator.click: Timeout (no Copy announcement button to press)

That control result is expected, since dev has no button. F2 and F4 to F6 read the clipboard back in the browser with navigator.clipboard.readText(). F6 denies the clipboard permissions through CDP.

E2E suite on the branch against the live stack (EM_E2E_URL set): 17 of 17 passed.

api_flows.py: 10 of 10 on every stack start.

Notes

  • Refs #97, #203. Nerd closes the issues by hand.
  • Not merged.

Observations (for Nerd, not fixed here)

  1. A one-Selection Event always reads with its line marked 🏆 Winner, because the API makes the only Selection the Winner (glossary: Winner). That is correct for the data. For an Event announced before it is played, though, "Winner" on its only line may read oddly. This is a product call (the marker could be left off when there is one Selection) and the card did not ask for it.
  2. Discord timestamps show the reader's own zone, but the dialog itself shows Date.ToLocalTime(). Both are correct, so there is nothing to fix; it's noted only because an admin comparing the two will see different clock times.
  3. In live Playwright runs, getByRole('dialog', { name }) scoped to a Fluent dialog finds none of its slotted content, because the role sits in the shadow root. getByRole('button') matches the inner native <button>, whose textContent is empty. The repo E2E suite already uses page-level locators. This could be worth a line in the E2E helpers' comments.

…details

The Event details dialog gets a Copy announcement button beside Copy
feedback link. It puts Discord text for the Event, as the dialog holds it,
on the clipboard with no API call: the Event name as a bold title, the date
as a Discord timestamp in the full date-and-time style (<t:UNIX:F>, whole
UNIX seconds of the instant, so each reader sees their own time zone), then
one line per Selection in the Event's order, "- Game: Activity", with the
players and duration the Selection snapshot carries in the
PlayersDurationText wording, and the Winner's line ending in " 🏆 Winner".
An Event with no Selections yet (an Occurrence not rolled) says "The picks
are still to come." The line reserved for a future link (#9) is empty, so
the text ends on its last line.

AnnouncementText is a pure builder (no clock, no JS, no services). Names
are made safe: Discord markdown characters (\ * _ ~ ` | > <) are
backslash-escaped, every "@" is followed by a zero-width space so
@everyone, @here and <@id> never ping, and a line break in a name becomes
a space.

The button shows "Announcement copied." (role=status) or, when the
browser refuses (JSException or JSDisconnectedException), an alert that
copying failed. Both clear on every press and when another Event's details
open; a result that arrives after its dialog was replaced is dropped
(DialogSession token, as Copy feedback link does). Copying changes nothing,
so Busy does not disable it. GLOSSARY.md: the Announcement entry now
describes the shipped template.

Refs #97, #203
@mwg-bender

mwg-bender Bot commented Nov 25, 2026

Copy link
Copy Markdown
Contributor Author

DISPOSITION

Item Disposition
#97 DONE: Copy announcement on the Event details dialog, built by the pure AnnouncementText builder
Winner marker DONE: the line ends in 🏆 Winner, after the players and duration; pinned by TheWinnersLine_AndOnlyIt_IsMarked
Escaping DONE: \ * _ ~ `
Busy DONE: not disabled by Busy (copying changes nothing; Copy feedback link isn't disabled either); pinned by WhileBusy_TheButtonStillCopies
Picks to come DONE: one fixed line, The picks are still to come., never throws
Link line (#9) DONE: reserved and empty, and the text ends on its last line
Web files beyond the card's list none

Sample text for the seeded Event (live clipboard, F2)

**Announce night 471279**
<t:1796410800:F>
- AnnKart471279: Grand Prix (2-6 players, 45 min)
- AnnBrawl471279: Stock Battle 🏆 Winner
- AnnPuzzle471279: Tiles

Observations for Nerd (not fixed)

  1. A one-Selection Event's only line is marked 🏆 Winner, because the API makes the only Selection the Winner. That is correct for the data but may read oddly in a pre-play announcement. Product call.
  2. The dialog shows Date.ToLocalTime(), while the Discord timestamp shows each reader's own zone. Both are correct; they just differ.
  3. In Playwright, a Fluent dialog's role sits in its shadow root, so locators scoped to getByRole('dialog') find none of its content. Page-level locators work, which is what the repo E2E suite uses.

@mwg-bender

mwg-bender Bot commented Nov 25, 2026

Copy link
Copy Markdown
Contributor Author

Narrow independent mutation-probe disposition

On exact PR head 2e8f8b304dc2c64d93e28f9dd8b54baa50869a95, the Web.Tests probe ran 54 distinct mutations: 53 made tests fail; one (M19c text from the page list (FindEvent)) stayed green. I disposition M19c as equivalent in the current reachable page flow, not a product defect: EventList opens details with the same Event instance held in the page list; selecting a Winner mutates that instance in place; after a successful refresh, FindEvent returns the refreshed Event, and after a failed refresh the page retains the original list/object. The existing CopyAnnouncement comment documents why the clipboard text comes from the dialog-owned Event without another API call.

An earlier duplicate attempt at M3c failed to compile, but the intended M3c mutant later compiled and made one Web test fail; it is not a surviving mutant.

This comment records only the mutation disposition. It is not the full independent Standards/Spec review or Nerd cold-build/live gate.

…e announcement

Review of #227 found three gaps in the Copy announcement text and button.

A name such as "[x](https://example.com)" stayed a clickable masked link in
Discord, because [ ] ( ) were not escaped. They now join the backslash-escaped
markdown characters.

A Selection line starts "- {Game}", so a name starting with "#", "-#", "-" or
"1." rendered as a heading, subtext or a nested or numbered list inside its
bullet. The marker a name starts with (after any leading space) is now
escaped: a leading "#" or "-", or the dot after a leading run of digits. The
same characters inside a name open nothing in Discord and stay as typed, so
names that need no change are not double-escaped.

Two overlapping presses of Copy announcement could show "Announcement
copied." and the refusal alert together. A second press while the dialog's
copy runs is now ignored, as Copy feedback link does. The guard holds the
dialog token, so a copy left running in a closed dialog never blocks the
next Event's button.

GLOSSARY.md: the Announcement entry names what is escaped.

Refs #97, #203
@github-actions

Copy link
Copy Markdown

Summary

Tests 📝 Passed ✅ Failed ❌ Skipped ⏭️ Other ❓ Flaky 🍂 Duration ⏱️
1881 1877 0 0 4 0 57.0s

🎉 No failed tests in this run.

Github Test Reporter by CTRF 💚

@mwg-bender

mwg-bender Bot commented Nov 25, 2026

Copy link
Copy Markdown
Contributor Author

Review fix for #227: new head cde1a8f4e0c7a461e7c42d7d63081f5a13d9e290

One new commit on 2e8f8b3 (fix(web): keep names from rendering as links, headings or lists in the announcement, Refs #97, #203). It was pushed as a fast-forward with no amend, rebase or force-push. dev was not merged in, and the PR is not merged. GitHub shows MWG Bender[bot] as both author and committer of cde1a8f, with parent 2e8f8b3.

DISPOSITION

Item Disposition Proof
R1 masked links DONE: [ ] ( ) are escaped like the other markdown characters AnnouncementText.cs:36 (the Markdown constant gains [, ], (, )); test AnnouncementTextEscapingTests.cs:39-43 (5 new DataRows on EachMarkdownCharacter_IsEscaped_InEveryName, including [x](https://example.com) → \[x\]\(https://example.com\))
R2 line-start markers DONE: a leading # or -, or the dot after a leading run of digits (after any leading space), is escaped in the Event, Game and Activity names. The same characters inside a name stay as typed, so names that need no change are not double-escaped. AnnouncementText.cs:39 (LineStart = "#-"), :75-86 (marker index, escaped once); tests ALineStartMarker_IsEscaped_InEveryName (:61, 7 rows: # Big→\# Big, ## H2→\## H2, -# small→\-# small, - item→\- item, 1. item→1\. item, 12. item→12\. item, \n# Big→ \# Big) and AHeadingOrListCharacter_InsideAName_StaysAsTyped (:76, 6 rows: Game #2, Kart 8 - Deluxe, Version 2.0, 1v1 night, 3-2-1 Go, Day 1. Start)
O1 double press DONE: _copyingAnnouncement guard, like CopyFeedbackLink's. A second press while this dialog's copy runs is ignored. The guard holds the dialog token, so a copy left running in a closed dialog never blocks the next Event's button, and it never frees that dialog's own running copy either. EventDetailsDialog.razor:290, 295-296, 309; tests AnnouncementCopyTests.ASecondPress_WhileTheFirstRuns_IsIgnored (:186) and APendingCopy_DoesNotHoldTheNextEventsButton (:212)
GLOSSARY DONE: only the Announcement entry changed. It now names what is escaped (markdown characters, the brackets of a link, a leading #, - or 1.; @ made inert; a line break becomes a space). GLOSSARY.md:132-136
R7, O2, O3 OBSERVATION, not changed: R7 (a one-Selection Event always shows Winner) is a product call. O2: the razor header comment still omits #97. O3: the razor file is now 379 lines (was 372), so split it before the next addition.

Tests first: on 2e8f8b3 the new tests failed 14 of 67 announcement cases (5 bracket rows, 7 line-start rows, both guard tests). The 6 stays-as-typed rows passed there, which shows they guard against double-escaping rather than test the fix.

Mutations (one at a time, announcement tests, 67 cases; restored control 67/67)

# Mutation Red Failing
E1 [ not escaped 2 EachMarkdownCharacter ([x](…), Open[)
E2 ] not escaped 2 EachMarkdownCharacter ([x](…), Close])
E3 ( not escaped 2 EachMarkdownCharacter ([x](…), Left()
E4 ) not escaped 2 EachMarkdownCharacter ([x](…), Right))
E5 leading # not escaped 3 ALineStartMarker (# Big, ## H2, \n# Big)
E6 leading - not escaped 2 ALineStartMarker (-# small, - item)
E7 digit-dot not escaped 2 ALineStartMarker (1. item, 12. item)
E8 marker only at index 0 (leading space ignored) 1 ALineStartMarker (\n# Big)
E9 #/- escaped everywhere (double escape) 6 ALineStartMarker ×2, StaysAsTyped ×3, ALineBreakInAName_BecomesASpace
E10 every . escaped 3 EachMarkdownCharacter ([x](…)), StaysAsTyped (Version 2.0, Day 1. Start)
E11 digit run escaped without a dot 2 StaysAsTyped (1v1 night, 3-2-1 Go)
G1 guard removed 2 ASecondPress_WhileTheFirstRuns_IsIgnored, APendingCopy_DoesNotHoldTheNextEventsButton
G2 guard not keyed to the dialog (any running copy blocks the button) 1 APendingCopy_DoesNotHoldTheNextEventsButton
G3 guard never released 3 ASecondPress…, PressingAgain_ClearsTheOldMessage, TheText_FollowsTheDialogsEvent_AfterSelectWinner
G4 release clears another dialog's copy 1 APendingCopy_DoesNotHoldTheNextEventsButton

All 15 went red; no mutation survived.

Numbers (cold clean build, full solution)

Baseline 2e8f8b3 After (uncommitted edits, then committed as cde1a8f)
Errors / warnings 0 / 0 0 / 0
Api.Tests 840 + 4 skipped 840 + 4 skipped
Web.Tests 987 1007 (+20: 5 + 7 + 6 DataRow cases, 2 bUnit tests)
E2E 5 + 12 skipped 5 + 12 skipped

No test was removed or renamed, and no existing assertion changed. The FakeClipboard test double now queues held calls (oldest first), so a test can hold two copies at once; existing single-hold use behaves the same.

Live run (headless Chromium through SWA, clipboard read back)

On cde1a8f: F1-F9 all PASS (F1-F6 as before; F7, F8 and F9 are new). On 2e8f8b3 (control): F1-F6 PASS, F7 FAIL, F8 FAIL, F9 PASS.

Clipboard text on cde1a8f:

F7: **\[x\]\(https://example.com\)**
<t:1796410800:F>
- AnnKart859735: Grand Prix (2-6 players, 45 min) 🏆 Winner

F8: **\# Big**
<t:1796410800:F>
- \# Big: 1\. item
- AnnKart859735: Grand Prix (2-6 players, 45 min) 🏆 Winner

Clipboard text on the control 2e8f8b3 (the bug):

F7: **[x](https://example.com)**   …
F8: **# Big** … - # Big: 1. item …

F9 (double-click on Copy announcement) shows one status on both heads: in a real browser writeText resolves too fast for two presses to overlap, which matches the review's "practically unreachable". The O1 proof is the two bUnit tests with a held clipboard.

@mwg-bender

mwg-bender Bot commented Nov 25, 2026

Copy link
Copy Markdown
Contributor Author

Independent validation — November 25, 2026

PR head cde1a8f4e0c7a461e7c42d7d63081f5a13d9e290 remains open. All 7 available exact-head CI checks pass; GitHub reports mergeable_state=clean. No reviews, inline comments, or requested reviewers are present.

dev advanced from the PR's recorded base 02d09f5 to aafbcb57eb9bcbce386e881dfa0c10f359a1178f. I independently trial-merged current dev with the PR head in a separate local worktree. Trial commit 0d648972cdbbe47dfc7159c97bd5777d8a9f61a5 has tree 91c334cbac3ce9d5062882dfd89ff5c4d84bdf71; it was not pushed.

  • Cold full-solution build: 0 errors, 0 warnings. git diff --check clean.
  • Full solution tests: API 870 passed / 4 skipped, Web 1007 passed, E2E 5 passed / 12 skipped; 0 failures. The 12 E2E cases require the separate E2E stack.
  • Focused changed test classes: AnnouncementCopyTests 14/14, AnnouncementTextEscapingTests 34/34, AnnouncementTextTests 19/19.
  • Running-stack pass on the merged trial: API flows 10/10; UI flows F1–F9 9/9, including clipboard read-back for [x](https://example.com) and # Big / 1. item; no console errors. The stack was stopped and its ports are down.

Standards

0 hard, 5 soft. Worst: possible duplicated clipboard UI/state/handler logic in the 379-line EventDetailsDialog.razor; it remains below the AGENTS.md ~400-line guidance. Other soft notes cover local naming/test-fixture clarity, glossary wording and a stale summary comment. No documented standards breach.

Spec

0 hard, 3 soft. Worst: while the clipboard request is pending, there is no visible pending state and another press is ignored. The required success/error messages still appear on completion. Other soft notes concern the JSDisconnectedException wording and documenting the exact escaping/line-break rule. No missing required behavior or scope creep found.

I filed the non-blocking review follow-ups as issue #229 in milestone 0.6.0 (needs-triage). The PR body remains unchanged as the fix-up card required; this comment records the current head's independent validation. No merge or deployment was performed.

@mwg-bender
mwg-bender Bot merged commit b4d825e into dev Nov 25, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants