A 5e storytelling engine with an LLM DM

Trim narration before insert, pack tool lines into one block master

The model often ends a round's narration with a trailing blank line before calling a tool; flush and finish inserted the live buffer untrimmed, so those newlines stacked blank transcript rows on top of the blank row every insert already appends. Both now trim leading and trailing whitespace first, keeping interior newlines. Every insert also appended its own trailing blank row, so four consecutive dice rolls showed a blank row between each. Screen now tracks whether the last transcript insert was a tool line; a tool line no longer adds a trailing blank, and the next non-tool insert (prose, the player's line, an aside, a failure) puts one blank row back in first. A block of tool lines now packs tight, with one blank row opening and closing it, matching the approved rendering. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01CUXjWo1zGFhdJUig1hcQGf


+148 -19
2 changed files