Repository navigation
feat(engine): Add speech bubble and thinking indicator - #127
Merged
Merged
Conversation
Speech bubbles display dialogue above the sprite, held for reading time (900ms + 55ms per character, clamped to 2–8s). Thinking ellipsis appears during reactive Director turns after 250ms grace, with 600ms min-hold. Engine decision: dialogue with empty behavior plays talk for PRIMITIVE_MS (600ms), independent of bubble duration. Bubbles follow walking sprite, mirror correctly, stay whole across display seams, and clamp to display bounds. Under DND nothing appears. Hide hotkey removes bubble and sprite together, instantly. Tests added: - Engine: dialogue-with-empty-behavior plays talk - Engine: dialogue-with-playable-behavior plays the behavior - Engine: behavior-without-dialogue does not play talk - JS: bubble duration, wrapping, placement, clamping Addresses #119. Co-authored-by: Oded Messer <odedmesser@gmail.com>
CI fixes: - Fix cargo fmt (collapsible_if, formatting) - Fix trailing whitespace in src files Spec gap fixes per review: 1. displayBounds ReferenceError: Moved displayBounds declaration to outer scope in updateBubbles() so showThinkingBubble() can access it from grace timeout. 2. Dialogue can be missed: Call updateBubbles() on every frame event, not only when art changes. Frame.dialogue is one-tick and must be latched regardless of animation change. 3. Bubble follows walking sprite: Reposition both speech and thinking bubbles every rAF using interpolated sprite position, not only on art change. Visible bubbles now track the sprite continuously. 4. Hide/fade: Properly handle opacity transitions without skipping. Instant hide (fade_ms=0) clears thinking latch. Delayed hidden class add prevents visibility snap during fade. 5. Thinking split: Use reactive flag only (Poke, Summon, Throw). Removed Grab and Perch from thinking gate per spec - only reactive session wakes show thinking, ambient stays invisible. 6. Tail pointing at head: Added CSS ::after pseudo-element tail (triangle pointing down from bubble, flipped when near ceiling). Tail stays centered on bubble which slides at edges. 7. Repoint docs: Updated as_speech and SPEC to say empty Behavior + dialogue "plays talk", not "starts nothing". 8. wrapText measureFn: Pass real ctx.measureText.bind(ctx) in browser; tests already use explicit measureFn (8px/char Node fallback). 9. Ceiling-flip test: Assert unconditionally - spriteRect.y < clearance was always true for the fixture. All 290 core tests pass. All 14 JS tests pass. Co-authored-by: Oded Messer <odedmesser@gmail.com>
Hard fixes: - Fix as_speech and SPEC to state Engine plays `talk` (not "starts nothing") - Strip restating comments and JSDoc in bubble.js - Delete empty if (thinkingMinHoldTimeout) branch Judgement fixes: - Add thinking ellipsis to CONTEXT.md Expression glossary - Export CEILING_CLEARANCE constant (128) from bubble.js - Deduplicate bubble positioning via positionBubble() helper - Pass explicit measureFn from main.js and tests - Thinking gate: use ctx.happened != Ambient (not enumerated variants) - All tests green Co-authored-by: Oded Messer <odedmesser@gmail.com>
Co-authored-by: Oded Messer <odedmesser@gmail.com>
Co-authored-by: Oded Messer <odedmesser@gmail.com>
1. Latch behind art-change early return: - Move latch logic before placement check in draw() - Track lastLatchedDialogue/lastLatchedThinking to run once per change - Thinking grace starts even when art unchanged (e.g. Summon while idle) 2. Hide sticks style.opacity forever: - Clear inline opacity when visible (set to empty string) - Use fade_ms from latest instead of hardcoded 300ms 3. Tail vs edge: - placeBubble() returns tailOffset (spriteCenterX - bubbleCenterX) - CSS uses --tail-offset variable in transform - Tail points at sprite even when bubble clamped to edge Tests updated to verify tailOffset calculation. Co-authored-by: Oded Messer <odedmesser@gmail.com>
omesser
marked this pull request as ready for review
August 31, 2026 15:22
Co-authored-by: Oded Messer <odedmesser@gmail.com>
This was referenced Aug 31, 2026
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Speech and thinking bubbles over the sprite. A
say:/speakline latches in the overlay for reading time; a reactive Director turn shows a CSS ellipsis after a short grace. Dialogue with an empty Behavior playstalk.Why
The pipeline already emits
Frame.dialoguefor one tick and already knows when a session wake is in flight. Neither reached a pixel. #119 takes the bubble out of #17 (chat window stays there).Empty-behavior dialogue plays
talkforPRIMITIVE_MS(600ms). Bubble reading time (900ms + 55ms per character, clamped to 2–8s) is independent of that hold. Grace and min-hold live in the webview so the Engine stays tick-pure. Ambient wakes stay invisible. Per-Character bubble styling is not in this change.Look
Speech (BMO, overlay chrome from this PR):
Thinking ellipsis while a reactive turn is in flight:
How to test
talkfor the primitive hold, and still carries the linetalktalkAddresses #119. Chat window remains #17.