Skip to content

Add audio-mode button with shared Waveform primitives#666

Merged
bdart merged 9 commits into
mainfrom
feat/audio-mode-button
May 10, 2026
Merged

Add audio-mode button with shared Waveform primitives#666
bdart merged 9 commits into
mainfrom
feat/audio-mode-button

Conversation

@bdart
Copy link
Copy Markdown
Contributor

@bdart bdart commented May 10, 2026

This pull request adds comprehensive support and tests for an audio transcription mode button in the ChatInput component. The changes introduce a dedicated button for starting and stopping audio transcription, ensure it appears or is disabled under the correct conditions, and add thorough test coverage for its behavior. The implementation also refactors dictation button rendering for clarity and maintainability.

Audio Transcription Mode Button Implementation:

  • Introduced the ChatInputAudioModeButton and integrated it into ChatInput, displaying it when audio transcription is enabled, the input is empty, and the user is in compose mode. The button toggles recording and updates its state based on recording status and other conditions. [1] [2] [3] [4]

  • Added logic to disable or hide the audio transcription button when dictation is active, an attachment is present or transcribing, or other relevant states (e.g., loading, token limits). [1] [2]

Testing Enhancements:

  • Added extensive tests to ChatInput.test.tsx covering all major behaviors of the audio transcription mode button, including visibility, toggling, disabling, and interactions with dictation and attachments.

  • Mocked the new useAudioTranscriptionRecorder hook and ensured its behavior is properly simulated in tests. [1] [2] [3]

Dictation Button Refactor:

  • Refactored the dictation button rendering in ChatInput to use a dedicated WaveformButton component when dictation is active, improving code clarity and separating concerns between dictation and transcription UI. [1] [2]

Code Cleanup:

  • Removed unused constant DICTATION_WAVEFORM_MAX_BAR_HEIGHT_PX as part of the dictation button refactor.

@bdart bdart self-assigned this May 10, 2026
@bdart bdart added the enhancement New feature or request label May 10, 2026
bdart added 8 commits May 10, 2026 17:53
Drop misused aria-pressed on WaveformButton (one-shot stop, not a toggle), add role=status announcement for active recording/dictation, gate animations on motion-safe.
Discriminated union on isRecording forces recordingBars to be passed when recording — no more silent fallback.
Three sibling testId props collapse to a single testIds object — same DOM ids, easier to read at the call site.
Waveform now takes pixel heights directly; new audioLevelsToBarHeights helper handles the analyser-value-to-px conversion. Restores the 'pure visual primitive' framing — non-audio consumers can use Waveform without inheriting the audio scale.
Same handler runs in both states; the new name says so.
Replace three copies of the sine-drive boilerplate with one hook in stories/helpers.
@bdart bdart merged commit 3bc0987 into main May 10, 2026
28 checks passed
@bdart bdart deleted the feat/audio-mode-button branch May 10, 2026 18:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant