wyuc 815cdc22fc
fix: presentation mode bubble polish and TTS timing improvements (#244)
* fix: use fixed width for normal mode speech bubble to prevent streaming jitter

Refs #236

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* feat: add click-to-pause, AudioIndicator, and play/pause icon to presentation bubbles

Refs #236

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* fix: anchor ProactiveCard to agent avatar in presentation mode dock

Refs #236

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* fix: bubble click events, ProactiveCard anchor timing, and dock sidebar overlap

- Add pointer-events-auto to presentation bubbles so clicks pass through
- Use agent avatar ref directly for ProactiveCard anchor (removes fallback)
- Shift dock left when chat sidebar is open to prevent overlap

Refs #236

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* fix: align presentation bubble icon with roundtable breathing bars and hover behavior

Refs #236

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* fix: prevent play/pause icon from overlapping bubble text

Add pr-10 padding to text area and align icon position with roundtable style.

Refs #236

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* fix: replace AudioIndicator bars with volume icon and loading spinner in presentation bubbles

Avoids visual conflict with the breathing bars play/pause icon at bottom-right.

Refs #236

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* fix: replace AudioIndicator bars with volume icon and loading spinner in roundtable bubbles

Syncs with presentation bubble style for consistency.

Refs #236

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* style: add breathing opacity animation to volume icon during TTS playback

Refs #236

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* style: use ripple wave animation for volume icon during TTS playback

Three concentric rings expand outward from the volume icon to indicate
active audio playback. Replaces the opacity breathing animation.

Refs #236

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* fix: prevent blank flash between same-agent speech segments

Only clear bubble text on agent_start when switching to a different agent.
Same-agent continuation keeps the previous text visible until the next
segment starts revealing, avoiding a lingering first bubble and blank gap.

Refs #236

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* fix: prevent TTS queue from blocking text reveal across segment boundaries

The shouldHold() callback checked both isPlaying and queue.length, which
meant the buffer stayed stuck on segment 1's text while segment 2's TTS
was generating/playing. Now shouldHold() only checks isPlaying.

Also changed queueMicrotask to setTimeout(0) in audio.ended callbacks
so the StreamBuffer's 30ms tick has a chance to observe isPlaying=false
and release its hold before processQueue sets it back to true.

Refs #236

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* fix: release StreamBuffer hold per-segment instead of waiting for entire TTS queue

Previously, shouldHold() returned a single boolean based on global TTS
state (isPlaying || queue.length > 0). When speech was split into
multiple segments by an action, the buffer would hold on Segment 1's
text even after its audio finished, because Segment 2's audio started
immediately.

Now shouldHold() returns a segmentDone counter that increments each
time a segment finishes. The buffer snapshots this counter when hold
begins and releases as soon as it changes, allowing text to advance
to the next segment even if its audio is already queued.

Refs #236

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* style: replace ripple circles with sound wave arcs on volume icon

Three SVG arcs emanate from the right side of the volume icon with
staggered opacity animation, resembling speaker sound waves.

Refs #236

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* style: simplify volume icon to static display without animation

Refs #236

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* fix: enable scrolling in presentation bubble when text overflows

Replace overflow-hidden with overflow-y-auto and scrollbar-hide to
maintain proper bottom padding when content exceeds max height.

Refs #236

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* fix: increase bottom padding and max height for presentation bubble text area

Refs #236

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* feat: pause and resume TTS audio when discussion is paused/resumed

Refs #236

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* fix: defer TTS playback when paused during generation

When discussion is paused while TTS is still fetching, the audio
element is created but not played. Resume will start it.

Refs #236

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* fix: check holding flag before segmentDone counter in TTS hold logic

The object returned by shouldHold is always truthy, so the falsy
release path was dead code. Now checks result.holding first: if
false (queue empty), release immediately. Only use segmentDone
counter comparison when holding is true.

Refs #236

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* fix: restore ProactiveCard anchor fallback to dock container

When agent avatar hasn't mounted yet, fall back to dock container
so the card can still position and render.

Refs #236

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* fix: stop TTS playback and abort active SSE stream on stage unmount

Previously, leaving a classroom while a discussion was active would
leave TTS audio playing and the API call streaming in the background.

Refs #236

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* fix: abort active SSE stream and shutdown buffers on chat sessions unmount

When navigating away from a classroom (e.g. clicking the back button),
the chat sessions hook now aborts any active API request and shuts
down all stream buffers. This prevents orphaned SSE connections and
runaway agent loops after leaving the stage.

Refs #236

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* fix: address code review feedback

- Reset pausedRef and segmentDoneCounterRef in cleanup() to prevent
  stale state on hook reuse
- Remove unused audioAgentColor prop from PresentationBubbleCard
- Capture chatAreaRef.current to local variable in Stage unmount effect

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-24 22:32:14 +08:00
..