1
0
Fork 0
Commit graph

10 commits

Author SHA1 Message Date
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
1db89addf5 feat(npc-dialogue): hold the typing with an authored pause, and stop squashing long lines
Two things, both about the pace of a line arriving.

An author can now put a beat anywhere in a line with {1.2s} or {400ms}, clamped
to ten seconds. The marker renders nothing; the renderer records where it sat and
the pacing schedule charges that gap between the units either side. Pauses are
absolute, so matching a line to a voice clip stretches or squeezes the typed part
and leaves the authored beat alone. The editor's line help names the marker.

The speed complaint had a mechanical cause. Lines were capped at three seconds,
so anything past about 120 characters was silently compressed: 240 characters ran
at 13ms per character and 360 at 8, against a base of 30. Long lines deeper in a
conversation read as if the typing had sped up. The cap is now twenty seconds,
which only catches a wall of text, and the base unit went from 24ms to 30ms
(about 33 characters a second) because 24 measured as a blur in the app.

The duration rule moved into pacing.ts as lineDurationMs so it is testable
without a browser. One nearby bug fell out of the marker work: when a brace run
turned out not to be markup, the renderer had already spent budget on the text
inside it and then rendered the run literally, so those characters were counted
twice. It now restores what the failed attempt consumed.

Measured in the running app: a {1.2s} marker held the line 1237ms after the fourth
character and never appeared on screen; a 360 character line took 12.5s instead of
3s; a short line still lands at once. 253 tests across 24 files pass.
2026-12-01 13:00:50 -05:00
464ba2d5d4 feat(npc-dialogue): natural typing rhythm, a beat between lines, a typing sound
The reveal was one linear clock, so every character cost the same and a comma
had nowhere to breathe. It now runs off a schedule: each visible unit costs
BASE_UNIT_MS plus a pause after it, longer at a sentence end and longest at a
line or paragraph break. Pauses never stack (a break after a full stop owns the
pause) and a comma inside a number is not a clause. The schedule is built in
relative units and scaled to the target duration, so a line paced to a recorded
clip keeps the rhythm instead of flattening it.

Between two spoken lines there is now a beat with the speaker's typing dots, and
clicking during it starts the next line at once. The opening line of a cascade
gets no beat.

The typing sound is synthesized (one tick per 55ms at most) from precomputed,
seeded tick times, so a re-render cannot re-roll the rhythm. It stays silent on a
line with a recorded clip, when the header mute is on, and under reduced motion.
It follows a new account preference, users.preferences.dialogue.typewriterSound,
separate from the voice switch, with a migration.

visibleLength is now defined as visibleText(text).length, so the schedule and the
renderer cannot disagree about how long a line is.
2026-11-24 19:20:11 -05:00
66a4337ba5 feat(npc-dialogue): type conversation lines out, with unit and player control
Conversation lines appeared whole after a length-based pause with bouncing
dots. They now type themselves out, and the player can finish a line by
clicking it.

Control is two-tier: npc-dialogue-settings.presentation.typewriterDefault sets
the unit default, users.preferences.dialogue.typewriter (default/on/off) lets a
player override it either way. prefers-reduced-motion turns the animation off
regardless. Changing the unit setting does not bump the prompt revision, since
it is not prompt text.

The reveal truncates the rendered strings rather than the source, so a
half-typed line can never flash {amber} or an unclosed **. visibleLength()
gives pacing the same count, and the choice footer waits for the reveal to
land so nobody answers a line they have not seen.
2026-11-24 17:50:11 -05:00
20c70151e3 feat(npc-dialogue): rich text editor and block lists in dialogue markup
DialogueText gains line-based block lists: consecutive lines starting
with - / * render as bullets, 1. / 2) as ordered lists, with item
content running through the inline parser so markup nests inside items.

Node editing swaps plain textareas for a shared MarkupEditor (line,
narration, lead-in, closing, tooltip, lock message, event message):
a formatting toolbar (bold, italic, code, color, link, bullet and
numbered list), a right-click menu wrapping the selection in tokens,
and a live DialogueText preview on the long-form fields. Storage stays
the plain custom-markup string; the editor only wraps selections.
2026-10-14 16:33:23 -04:00
02307aa2ee fix(npc-dialogue): split countdown units into controlled-gap cells
The countdown rendered each time unit with a raw monospace space,
which reads wide and odd when inline with proportional text. Split the
value into per-unit inline-flex cells separated by a CSS gap so spacing
stays consistent, and cover the new markup in the interpolate
integration test.
2026-10-07 23:28:31 -04:00
b1168dcc38 fix(personnel): mobile layout for conversations
- Converse button no longer floats over the hero text on phones: it sits
  in the card's content flow below the status chips and only anchors to
  the hero's right edge from md up
- conversation dialog keeps a side margin on small screens instead of
  rendering edge-to-edge
- dialog titles truncate with min-w-0 so long NPC names and attachment
  urls cannot push the close buttons out
2026-10-06 17:21:26 -04:00
f595828c99 feat(npc-dialogue): stacked markup, link popups, new badges, locked choices, timed flags
- DialogueText rewritten as a recursive parser so markup accumulates
  ({green}**bold green**{/} and friends nest freely, colors close inner-first)
- [label](url) dialogue links open in an iframe popup dialog so
  conversation progress survives; only http(s)/relative urls render
- NEW badges: Converse button + choice buttons badge unread paths via a
  per-browser seen map (ptf:npc-dialogue-seen) keyed by flow hash, so GM
  edits re-flag the conversation
- choices gain lockedHint: failing conditions can show the choice disabled
  with a rich tooltip instead of hiding it (evaluateNpcDialogueChoices now
  returns ChoiceGate pass/showLocked pairs)
- player flags gain activatesAt/expiresAt time windows honored by readFlag,
  flag effects gain flagDelayMinutes for slow-burn writes, and
  {{countdown:key}} tokens tick live toward activation (done/missing states)
- migration 20261006_add_flag_time_windows; spec extended to 33 tests
2026-10-06 17:06:27 -04:00
1e0df82725 feat(npc-dialogue): render inline images in dialogue markup 2026-10-06 16:21:53 -04:00
ac6415d034 feat(npc): complete dialogue feature and fix migration snapshot base
Finish the NPC dialogue flowchart work carried over from the base commit:
- Coloured NPC dialogue text via friendly names ({red}) or hex ({#ff00ff});
  invalid names/hex render as literal text. Shared client-safe renderer
  (DialogueText.tsx) used by both the admin canvas preview and the runtime.
- Player-flags feature: condition nodes branch on flags (evaluated
  server-side), flag effects set/clear/adjust flags, PlayerFlags collection
  + migration, and event nodes can set flags.
- One-time ("once") choices: a choice flagged "Hide after picked" is hidden
  for the rest of the current conversation only (per-session, resets on
  begin()); GMs can persist across conversations with a condition flag.
- Admin editor: colour hint, once checkbox on choices, amber "once" badge.

Migration repair: the player_flags migration (20261005_185014) was sorting
before 20261006_000000, whose stale snapshot omitted player_flags, so any
future `migrate:create` re-emitted player_flags DDL. Restored 20261006_000000's
snapshot to the full current schema so it is the correct diff base.

Verified: `bun run payload migrate` clean, `migrate:create` reports no
schema changes, `tsc --noEmit` clean.
2026-10-05 16:02:53 -04:00