From 59f01610cad33a5a9c93847f2fbe2c2e02258243 Mon Sep 17 00:00:00 2001 From: Z8MB1E Date: Wed, 14 Oct 2026 15:15:38 -0400 Subject: [PATCH] feat(npc-dialogue): opt-in public visibility for event node effects Dialogue-emitted game events default to restricted (npc:dialogue policy) so narrative branches stay spoilable-free, which also hid announcements authors intended for everyone. Event nodes can now mark their effect's log entry public: NpcDialogueEffect gains an optional eventVisibility field, runEffect threads it into every emitGameEvent call (emit, reward, flag), and the node editor exposes a "Show this event to everyone" checkbox for those effect types. Omitted eventVisibility keeps today's behavior exactly: resolveEventVisibility falls back to the per-type restricted policy. The separate restricted flag:set audit written by the PlayerFlags hooks is untouched. Verified live on dev: two injected event nodes (with and without the flag) stored visibility "public" and "restricted" respectively; flow and probe rows cleaned up afterward. --- .../(frontend)/personnel/contacts/[id]/actions.ts | 5 +++++ .../admin/npc-dialogue/NodeEditDialog.tsx | 14 ++++++++++++++ src/lib/npc-dialogue/dialogue.ts | 7 +++++++ 3 files changed, 26 insertions(+) diff --git a/src/app/(frontend)/personnel/contacts/[id]/actions.ts b/src/app/(frontend)/personnel/contacts/[id]/actions.ts index b0bc00bf..0e76fbf4 100644 --- a/src/app/(frontend)/personnel/contacts/[id]/actions.ts +++ b/src/app/(frontend)/personnel/contacts/[id]/actions.ts @@ -107,6 +107,9 @@ async function runEffect( targetCollection: "game-npcs", targetId: npcId, data: { effect: "emit" }, + // Author override: "public" puts the entry in every member's feed; + // undefined keeps the restricted narrative default (see visibility.ts). + visibility: effect.eventVisibility, }); break; } @@ -119,6 +122,7 @@ async function runEffect( targetCollection: "game-npcs", targetId: npcId, data: { effect: "reward", unconfigured: true }, + visibility: effect.eventVisibility, }); break; } @@ -146,6 +150,7 @@ async function runEffect( targetCollection: "game-npcs", targetId: npcId, data: { effect: "flag", key, op, amount }, + visibility: effect.eventVisibility, }); break; } diff --git a/src/components/admin/npc-dialogue/NodeEditDialog.tsx b/src/components/admin/npc-dialogue/NodeEditDialog.tsx index 8025b29a..30084b6d 100644 --- a/src/components/admin/npc-dialogue/NodeEditDialog.tsx +++ b/src/components/admin/npc-dialogue/NodeEditDialog.tsx @@ -663,6 +663,20 @@ export function NodeEditDialog({ node, allNodes, open, onOpenChange, onSave }: N /> )} + {draft.effect && draft.effect.type !== "notify" && ( + + )} )} diff --git a/src/lib/npc-dialogue/dialogue.ts b/src/lib/npc-dialogue/dialogue.ts index 9ec9270b..78e9255d 100644 --- a/src/lib/npc-dialogue/dialogue.ts +++ b/src/lib/npc-dialogue/dialogue.ts @@ -93,6 +93,13 @@ export interface NpcDialogueEffect { title?: string; /** Notification / event-log body (notify, emit). */ message?: string; + /** + * Visibility of the game-event-log entry this effect writes (emit, reward, + * flag). Dialogue events default to restricted (narrative spoilers), gated + * to dialogue/flag staff; set "public" for announcements that should appear + * in every member's event feed. Omitted means "use the default policy". + */ + eventVisibility?: "public" | "restricted"; /** Flag key to write (flag). */ flagKey?: string; /** Write mode (flag). */