Repository navigation
Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
ChatInput awaited the recorder's startRecording() and stopRecording() with no error handling, so a denied or missing microphone surfaced as an uncaught async error and the user saw nothing. Catch those errors and pass them to a new LlmChatView.onRecordingErrorCallback. By default, show the existing unableToRecordAudio snackbar, as the stop path already does when no file was recorded.
dorklein
force-pushed
the
voice-recording-error-callback
branch
from
November 5, 2026 11:11
6275a1c to
9bf29cb
Compare
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.
When the microphone can't be used (permission denied, no device, the recorder fails to start), tapping the record button does nothing visible.
ChatInputawaitsWaveformRecorderController.startRecording()andstopRecording()with no error handling, so the error escapes as an uncaught async error and the app gets no chance to tell the user.Change
ChatInputcatches errors fromstartRecording()andstopRecording()and hands them toLlmChatView.LlmChatView.onRecordingErrorCallback(BuildContext context, Object error), next toonErrorCallbackandonCancelCallbackand following the same pattern. If it isn't set, the chat shows a snackbar withstrings.unableToRecordAudio, which is what the stop path already shows when no file was recorded.Apps that want their own message, or want to log the error, pass the callback. Everyone else now gets the existing localized "Unable to record audio" message.
Test
test/voice_recording_error_test.dartmocks therecordmethod channel so the microphone permission is refused, taps Record Audio, and checks that:onRecordingErrorCallbackreceives the error and replaces the snackbar.Depends on csells/waveform_recorder#13 and #14. With waveform_recorder 1.8.1 (the current release), a failed start leaves the controller in the recording state. The next rebuild of the chat input then throws
Exception: Not recordingfromamplitudeStream, so this test fails on 1.8.1 for that reason, not because of this change. #13 leaves the controller idle after a failed start, and #14 makes a refused permission fail the start. With both (I ran it with adependency_overrideson a branch that has them), the new tests and the existing ones pass, anddart analyze --fatal-infosanddart formatare clean. Once they're released, thewaveform_recorderconstraint here can move to that version; I'm happy to add that bump to this PR.🤖 Generated with Claude Code