diff --git a/docs/npc-dialogue-ai.md b/docs/npc-dialogue-ai.md index 299f3b6d..c51f87e4 100644 --- a/docs/npc-dialogue-ai.md +++ b/docs/npc-dialogue-ai.md @@ -55,7 +55,7 @@ the branch's open end a way onward, and where it goes depends on the caller: | Caller | The open end continues to | |---|---| -| A choice node | Back to that node, re-presenting its other buttons (a side question returns to the menu) | +| A choice node | Back to that node, re-presenting its other buttons (a side question returns to the menu). The exception is a choice marked as the start: nothing may point at the start, so it gets no return | | A dialogue, event or delay node that already led somewhere | **The step it used to lead to.** Attaching replaced that hop, so this is what keeps the rest of the conversation reachable | | A node with nothing after it, or a condition | Nowhere: the branch stays open for the author to wire. Rejoining a condition would re-evaluate the same flags and take the same branch forever | diff --git a/src/collections/game/NpcDialogues.ts b/src/collections/game/NpcDialogues.ts index 63242c51..344f8b17 100644 --- a/src/collections/game/NpcDialogues.ts +++ b/src/collections/game/NpcDialogues.ts @@ -112,7 +112,7 @@ export const NpcDialogues: CollectionConfig = { { label: "AI Drafting", description: - "How the drafting tools should sound for this conversation. The preview shows the exact instruction the model receives.", + "How the drafting tools should sound for this conversation. The preview shows the assembled instruction for a whole-conversation draft.", fields: [ { name: "voiceOverride", diff --git a/src/lib/npc-dialogue/AGENTS.md b/src/lib/npc-dialogue/AGENTS.md index 9172029b..95cd68fb 100644 --- a/src/lib/npc-dialogue/AGENTS.md +++ b/src/lib/npc-dialogue/AGENTS.md @@ -150,8 +150,10 @@ The return hop is not "back to the caller" for every caller. Attaching to a single-continuation node **overwrites its `next`**, so `returnTargetOf` sends the branch's open end to the successor that hop used to point at; returning to the caller itself would loop. A choice caller is the one case where coming back to the -caller is right (its buttons are still there). A condition gets no return at all: -re-entering re-evaluates the same flags and retakes the same branch. Return +caller is right (its buttons are still there), except a choice marked as the start: +a hop into the start is refused everywhere else, so it gets no return either. A +condition gets no return at all: re-entering re-evaluates the same flags and +retakes the same branch. Return candidates are restricted to node types that actually read `next`, since writing `next` on a choice or condition is a hop no walker follows. diff --git a/src/lib/npc-dialogue/fragmentInsert.ts b/src/lib/npc-dialogue/fragmentInsert.ts index 97db9309..66fa9c04 100644 --- a/src/lib/npc-dialogue/fragmentInsert.ts +++ b/src/lib/npc-dialogue/fragmentInsert.ts @@ -309,9 +309,14 @@ export function insertGeneratedFragment( if (options.returnToCaller && options.attachment) { if (!returnTarget) { errors.push( + // Name the rule that actually fired, so the note is actionable. A start + // dialogue with no successor has two reasons and the useful one is the + // missing successor; only a start *choice* is refused for being the start. attachmentNode?.type === "condition" ? "This attaches under a condition, which cannot be re-entered without taking the same branch again, so the branch's open end stays free." - : "The step it attaches to had nothing after it, so there is nowhere to return to and the branch's open end stays free.", + : attachmentNode?.type === "choice" && attachmentNode.data.isStart + ? "This attaches under the start node, which nothing may point at, so the branch's open end stays free." + : "The step it attaches to had nothing after it, so there is nowhere to return to and the branch's open end stays free.", ); } else { const insertedIds = new Set(placed.map((node) => node.id)); diff --git a/tests/int/npc-dialogue-fragment.int.spec.ts b/tests/int/npc-dialogue-fragment.int.spec.ts index 5c960b89..5ef84d70 100644 --- a/tests/int/npc-dialogue-fragment.int.spec.ts +++ b/tests/int/npc-dialogue-fragment.int.spec.ts @@ -200,6 +200,8 @@ describe("insertGeneratedFragment", () => { expect(result.returnedFrom).toBeNull(); expect(result.returnKind).toBeNull(); + // The note names the start rule, not "nothing came after it". + expect(result.errors.join(" ")).toMatch(/start node/i); // Only the inserted nodes matter: the existing start legitimately leads to it. const insertedPointsAtStart = result.nodes .filter((n) => n.id === "a1" || n.id === "a2")