Skip to content

fix: resolve 'Processando audio...' stuck forever on audio messages#4

Open
ti-codetec wants to merge 1 commit into
ruanbarroso:mainfrom
ti-codetec:fix/audio-processing-stuck
Open

fix: resolve 'Processando audio...' stuck forever on audio messages#4
ti-codetec wants to merge 1 commit into
ruanbarroso:mainfrom
ti-codetec:fix/audio-processing-stuck

Conversation

@ti-codetec

Copy link
Copy Markdown
Contributor

Summary

Fixes the bug where "Processando áudio..." placeholder stays spinning forever when sending audio messages, requiring a page reload to clear it.

Root Causes

Three independent issues combined to cause this:

1. session-viewer.html missing transcription handler (primary cause)

The session viewer page (sub-agent sessions) had no WebSocket handler for transcription events. When audio was transcribed in web.ts, the result was sent as a role: "system" message via broadcastToSessionSubscribers, but appendMessage() silently discards system messages (if (role === 'system') return). The placeholder was never updated.

2. DOM audio URL not updated when echo is suppressed

When the user sends audio, the <audio> element is rendered with a local blob: URL. The server echo brings the persistent /audio/xxx URL, but the echo is suppressed by pendingUserEcho. The sessionMessages store was updated but the DOM was not — so when the transcription event arrived with /audio/xxx, URL matching failed. The fallback (find last .processing element) worked in some cases but was fragile.

3. Error/abort paths didn't clear the placeholder

When audio transcription failed (Gemini unavailable, transcription error, or request aborted), agent.ts returned an error message but never sent a transcription event, leaving the placeholder spinning forever.

Changes

File Change
session-viewer.html Added handleTranscription() function and 'transcription' case in WebSocket handler
web.ts Added sendSessionTranscription() method; replaced system message broadcast with proper transcription event for session viewers; also send transcription on error path
main-session-viewer.html Update <audio> src from blob: to server URL when echo is suppressed
web-ui.html Same DOM URL update when echo is suppressed
agent.ts Send transcription event on all error/abort/unavailable paths so placeholder is always cleared

Testing

  • TypeScript compiles with zero errors
  • JavaScript syntax validated for all 3 HTML files
  • Covers all scenarios: successful transcription, Gemini unavailable, transcription failure, request abort, and local blob URL mismatch

The audio transcription placeholder was never replaced in several scenarios:

1. session-viewer.html had no 'transcription' WebSocket event handler at all,
   and the transcription was sent as role:'system' which is silently discarded.

2. When the user echo was suppressed (pendingUserEcho), the DOM <audio> element
   kept its local blob: URL while the transcription event arrived with the
   server /audio/xxx URL, causing URL matching to fail.

3. On transcription failure/abort/unavailable paths in agent.ts, no transcription
   event was sent, leaving the placeholder spinning forever.

Changes:
- Add handleTranscription() and 'transcription' case to session-viewer.html
- Add sendSessionTranscription() to web.ts for session viewer broadcasts
- Replace system message broadcast with proper transcription event in web.ts
- Update <audio> src from blob: to server URL when echo is suppressed (all 3 viewers)
- Send transcription event on error/abort/unavailable paths in agent.ts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant