1
0
Fork 0
polaris-task-force/src/lib/npc-dialogue
Z8MB1E bf9fd09752 perf(npc-dialogue): stop re-parsing the markup preview on every keystroke
Typing a line in the editor felt sticky. The line box renders a live markup
preview, and that preview is a full parse and render of the authored string: it
ran on every character, so a long line with colours, bold and a link was re-parsed
per keypress while the whole edit dialog re-rendered around it.

The preview now waits 220ms after the last keystroke (the textarea itself stays
instant), and both the preview and DialogueText are memoised, so an unchanged
line never re-parses. DialogueText is shared with the canvas, which re-renders
every card on any diagram change.

Measured in the running app on a 24 node diagram and a 150 character line, 40
programmatic keystrokes through the browser's own metrics: script 319ms to 221ms
(8.0 to 5.5 per key), total main-thread task 767ms to 633ms, style recalc 386ms
to 338ms. The preview still updates 220ms after typing stops.

What is left is the dialog re-render itself: on this file a keystroke still
re-renders every section of the edit dialog. Removing that means giving the line
box its own state and committing on a debounce, which needs the Save path to
flush, and belongs after the in-progress poll work in NodeEditDialog lands.
2026-12-01 14:12:09 -05:00
..
AGENTS.md feat(npc-dialogue): choose the conversation typing pace in the admin panel 2026-12-01 13:09:17 -05:00
attachments.ts feat(npc-dialogue): voice clips on dialogue lines 2026-11-24 17:59:36 -05:00
dialogue.ts feat(npc-dialogue): hold a line until the player presses Continue 2026-11-30 18:04:02 -05:00
DialogueText.tsx perf(npc-dialogue): stop re-parsing the markup preview on every keystroke 2026-12-01 14:12:09 -05:00
flags.ts feat(npc-dialogue): add defined checks to flag conditions 2026-11-24 17:34:40 -05:00
fragmentInsert.ts docs(npc-dialogue): sync the contract with the start-node exception 2026-11-24 15:05:19 -05:00
generation.ts fix(ai): drive the structured stream and use the chat endpoint 2026-12-01 01:47:49 -05:00
generationPrompt.ts fix(npc-dialogue): keep the conversation reachable when a branch attaches 2026-11-24 14:47:08 -05:00
generationSchema.ts feat(npc-dialogue): add defined checks to flag conditions 2026-11-24 17:34:40 -05:00
generationSettings.ts feat(npc-dialogue): choose the conversation typing pace in the admin panel 2026-12-01 13:09:17 -05:00
interpolate.ts feat(npc-dialogue): voice clips on dialogue lines 2026-11-24 17:59:36 -05:00
keys.ts feat(npc-dialogue): announce lines to screen readers and pick choices by number 2026-11-24 20:17:04 -05:00
normalize.ts fix(ai): bound the structured path too, and stop the dialog overpromising 2026-11-24 15:00:30 -05:00
pacing.ts feat(npc-dialogue): choose the conversation typing pace in the admin panel 2026-12-01 13:09:17 -05:00
presentation.ts feat(npc-dialogue): type conversation lines out, with unit and player control 2026-11-24 17:50:11 -05:00
preview.ts feat(npc-dialogue): play an unsaved draft in the editor 2026-11-24 20:41:19 -05:00
reorder.ts feat(npc-dialogue): reorder choices in the dialogue editor 2026-10-07 14:01:00 -04:00
selection.ts feat(npc-dialogue): condition groups and ternary text tokens 2026-10-14 16:21:16 -04:00
states.ts feat(npc-dialogue): back NEW badges with server-side read markers 2026-10-14 15:35:47 -04:00
typeSound.ts feat(npc-dialogue): natural typing rhythm, a beat between lines, a typing sound 2026-11-24 19:20:11 -05:00
unread.ts feat(npc-dialogue): mark contacts whose conversation has unread content 2026-11-24 20:26:47 -05:00
visibility.ts feat(npc-dialogue): testing-only conversations for superusers 2026-11-24 18:29:20 -05:00