Repository navigation
feat(web): copy a ready-to-paste Discord announcement from the Event details - #227
Conversation
…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
DISPOSITION
Sample text for the seeded Event (live clipboard, F2)Observations for Nerd (not fixed)
|
Narrow independent mutation-probe dispositionOn exact PR head 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
Summary
🎉 No failed tests in this run. Github Test Reporter by CTRF 💚 |
Review fix for #227: new head
|
| 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.
Independent validation — November 25, 2026PR head
Standards0 hard, 5 soft. Worst: possible duplicated clipboard UI/state/handler logic in the 379-line Spec0 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 I filed the non-blocking review follow-ups as issue #229 in milestone 0.6.0 ( |
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:UNIXisDate.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 existingPlayersDurationText.Playersand.Duration(no second wording). Lines follow the Event's Selection order.MW-GC.EventManager.Web/Shared/Events/EventDetailsDialog.razor(339 to 372 lines):role="status"text and itsrole="alert"text;CopyAnnouncement, which follows theCopyFeedbackLinkclipboard pattern and checks the_detailstoken;ShowDetailsnow 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.Nothing else in Web, and nothing in API, Shared, Api.Tests, E2E or
.github/.DISPOSITION
AnnouncementTextbuilder.🏆 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 byTheWinnersLine_AndOnlyIt_IsMarkedandTheWinnersLine_KeepsItsPlayersAndDuration. A Winner id that matches no Selection marks no line (AWinnerIdOfNoSelection_MarksNoLine).\ * _ ~| > <are each backslash-escaped, the backslash itself included, so a name can neither style the text nor close the bold title early.@is followed by a zero-width space (U+200B), so@everyone,@here,<@id>,<@!id>and<@&id>cannot ping anyone. The<is also escaped.\r\n,\r,\n) becomes a space, so a name cannot add a line.AnnouncementTextEscapingTests(16 cases).WhileBusy_TheButtonStillCopies.The picks are still to come.as its only line after the date. It never throws.TheTextEndsOnItsLastLine).Announcement copied.(role="status"). AJSExceptionorJSDisconnectedExceptionshowsThe 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)
The empty Occurrence (F4):
**Weekly 471279**\n<t:1797021000:F>\nThe picks are still to come.. The*Party* @everyoneEvent (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) ofMW-GC.EventManager.slnx:origin/dev02d09f5Count preservation: no test was removed, renamed or split. 47 cases were added:
AnnouncementTextTests19,AnnouncementTextEscapingTests16,AnnouncementCopyTests12.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:
JSDisconnectedExceptionnot caught; not cleared on press; not cleared on another Event;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:*Party* @everyone …;Branch
feat/97-announcement(worktree with the change, run 6):Control, plain
origin/dev02d09f5:That control result is expected, since
devhas no button. F2 and F4 to F6 read the clipboard back in the browser withnavigator.clipboard.readText(). F6 denies the clipboard permissions through CDP.E2E suite on the branch against the live stack (
EM_E2E_URLset): 17 of 17 passed.api_flows.py: 10 of 10 on every stack start.Notes
Refs #97, #203. Nerd closes the issues by hand.Observations (for Nerd, not fixed here)
🏆 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.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.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>, whosetextContentis empty. The repo E2E suite already uses page-level locators. This could be worth a line in the E2E helpers' comments.