Live dialogue preview in the editors (reuses the real DialoguePlayer)

- DialoguePlayer gains an `inline` mode (fills its container, no window key
  capture) and a `startId` to jump the walk to a given utterance.
- New DialoguePreview: a scaled-down mini player that fetches the resolved tree
  from GET /api/admin/story-nodes/:id/dialogue (same resolver as playback).
- Mystery graph: preview appears next to a selected dialogue node.
- Utterance editor: docked preview that jumps to the clicked/selected utterance
  and refreshes after each edit.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-08-18 19:24:03 +02:00
co-authored by Claude Opus 4.8
parent f10d7584d2
commit 0b1e5e7fc7
6 changed files with 59 additions and 6 deletions
+4
View File
@@ -289,6 +289,10 @@ app.post('/api/admin/mysteries/:id/graph', requireAdmin, async (req, res, next)
app.get('/api/admin/story-nodes/:id/utterances', requireAdmin, async (req, res, next) => {
try { res.json(await storyGraph.listUtterances(String(req.params.id))) } catch (error) { next(error) }
})
// Resolved runtime dialogue tree for the editor's live preview (same resolver as play).
app.get('/api/admin/story-nodes/:id/dialogue', requireAdmin, async (req, res, next) => {
try { res.json(await narrative.resolveDialogue(String(req.params.id))) } catch (error) { next(error) }
})
app.post('/api/admin/story-nodes/:id/utterances', requireAdmin, async (req, res, next) => {
try {
if (!requireEditing(res)) return
+3
View File
@@ -43,6 +43,7 @@ export function resolvePoseAssetId(
export interface NarrativeRepository {
authorMystery(input: MysteryAuthoring): Promise<{ slug: string }>
resolveDialogue(nodeId: string): Promise<{ utterances: RuntimeUtterance[]; rootId: string | null }>
createPlaythrough(userId: string, mysterySlug?: string): Promise<PlaythroughState | null>
getCurrentPlaythrough(userId: string): Promise<PlaythroughState | null>
advancePlaythrough(userId: string, playthroughId: string, terminalKey?: string): Promise<{ ok: boolean; state?: PlaythroughState; error?: string }>
@@ -197,6 +198,8 @@ export function createNarrativeRepository(pool: Pool, objectStorage: ObjectStora
return { slug: input.slug }
},
resolveDialogue(nodeId) { return resolveDialogueGraph(nodeId) },
async createPlaythrough(userId, mysterySlug) {
const client = await pool.connect()
let playthroughId: string