feat(audio): add accept/discard buttons to audio recording#2907
Open
alejandro-workpath wants to merge 6 commits intoChainlit:mainfrom
Open
feat(audio): add accept/discard buttons to audio recording#2907alejandro-workpath wants to merge 6 commits intoChainlit:mainfrom
alejandro-workpath wants to merge 6 commits intoChainlit:mainfrom
Conversation
When recording audio, the single X button (which always sent the audio) is replaced with two distinct actions: a checkmark to accept and send, and an X to discard without sending. This adds an `audio_discard` socket event and `@cl.on_audio_discard` callback so backend apps can clean up resources (e.g. streaming transcription sessions) when audio is discarded. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
2 issues found across 8 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="backend/chainlit/socket.py">
<violation number="1" location="backend/chainlit/socket.py:474">
P2: `audio_discard` can skip emitting `audio_connection="off"` when `on_audio_discard()` raises, causing stale audio connection state.</violation>
</file>
<file name="libs/react-client/src/useAudio.ts">
<violation number="1" location="libs/react-client/src/useAudio.ts:33">
P2: Discard notification is skipped if local stop fails, so backend audio cleanup may never be triggered.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
Adds English fallback strings for "Send recording" and "Discard recording" to all 22 non-English translation files. Native speakers can update these in follow-up PRs. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
10 issues found across 22 files (changes from recent commits).
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="backend/chainlit/translations/ko.json">
<violation number="1" location="backend/chainlit/translations/ko.json:86">
P2: Korean locale adds new audio action labels in English, causing mixed-language UI for `ko` users.</violation>
</file>
<file name="backend/chainlit/translations/ja.json">
<violation number="1" location="backend/chainlit/translations/ja.json:72">
P2: Japanese locale adds new speech action labels in English, causing mixed-language UI for `ja` users.</violation>
</file>
<file name="backend/chainlit/translations/it.json">
<violation number="1" location="backend/chainlit/translations/it.json:86">
P2: New Italian speech-action translations were added in English, causing mixed-language UI in the `it` locale.</violation>
</file>
<file name="backend/chainlit/translations/da-DK.json">
<violation number="1" location="backend/chainlit/translations/da-DK.json:85">
P2: Danish locale adds English strings for new audio actions, causing mixed-language UI in `da-DK`.</violation>
</file>
<file name="backend/chainlit/translations/fr-FR.json">
<violation number="1" location="backend/chainlit/translations/fr-FR.json:86">
P2: French locale adds new speech action labels in English, causing mixed-language UI for fr-FR users.</violation>
</file>
<file name="backend/chainlit/translations/pt-PT.json">
<violation number="1" location="backend/chainlit/translations/pt-PT.json:86">
P2: Portuguese locale includes untranslated English strings for new speech actions, causing mixed-language UI.</violation>
</file>
<file name="backend/chainlit/translations/es.json">
<violation number="1" location="backend/chainlit/translations/es.json:86">
P2: Spanish locale adds `chat.speech.accept` and `chat.speech.discard` in English, causing mixed-language UI in `es` translations.</violation>
</file>
<file name="backend/chainlit/translations/hi.json">
<violation number="1" location="backend/chainlit/translations/hi.json:72">
P2: New Hindi locale keys for audio actions are left in English, causing mixed-language UI in `hi` localization.</violation>
</file>
<file name="backend/chainlit/translations/zh-CN.json">
<violation number="1" location="backend/chainlit/translations/zh-CN.json:72">
P2: New zh-CN speech action labels are untranslated English strings, causing mixed-language UI for Chinese users.</violation>
</file>
<file name="backend/chainlit/translations/el-GR.json">
<violation number="1" location="backend/chainlit/translations/el-GR.json:86">
P2: New Greek locale entries for audio actions are untranslated English strings, causing mixed-language UI in `el-GR`.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
Move update_audio_connection("off") to finally block so backend audio
state resets even if on_audio_discard raises. On frontend, wrap
stopRecording in try/finally so discardAudioStream always fires.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Replace English fallback strings with proper translations for all 22 non-English locales. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Preserve three comments that were inadvertently stripped during an earlier refactor: the form-field guard intent, the early-return purpose, and the preventDefault rationale. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Author
|
Hey guys, I would love to have this in production to improve some clients UX overall since the current setup is confusing for most of them. Can I ask for a review so I can refine if anything needs more work and merge it? @hayescode @asvishnyakov @sandangel Thank you so much! |
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.
Summary
audio_discardsocket event and@cl.on_audio_discardcallback so backend apps can clean up resources when audio is discarded (e.g. close streaming transcription sessions)on_audio_discardhandler work unchangedWhy
Clicking X sends the audio instead of discarding it, which is confusing UX. There is no way to cancel a recording without sending it to the backend.
What was considered
audio_discardevent so the backend knows to discard accumulated chunks and clean up. The frontend stops the recorder/player without emittingaudio_end.Test plan
on_audio_endfires,on_audio_discardfires insteadon_audio_endfires, transcription workson_audio_discardhandler works without errorsSummary by cubic
Add accept and discard controls to audio recording so users can cancel without sending. Adds
audio_discardand the@cl.on_audio_discardhook so backends can clean up; apps without it keep working.New Features
audio_discard; stops local recorder/player and turns audio off withoutaudio_end.Bug Fixes
audio_discardeven if local stop fails.Written for commit ee511a0. Summary will update on new commits.