-
Notifications
You must be signed in to change notification settings - Fork 4k
[feat] Improve frontend audio infrastructure for chat integration #12833
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Conversation
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
Contributor
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
Contributor
Author
This stack of pull requests is managed by Graphite. Learn more about stacking. |
This was referenced Oct 20, 2025
Contributor
✅ PR preview is ready!
|
Contributor
📉 Python coverage change detectedThe Python unit test coverage has decreased by 0.0050%
✅ Coverage change is within normal range. Coverage by files
|
12d807c to
a28875d
Compare
356976d to
0646ce4
Compare
Contributor
📉 Frontend coverage change detectedThe frontend unit test (vitest) coverage has decreased by 0.0300%
💡 Consider adding more unit tests to maintain or improve coverage. |
0646ce4 to
c3d5122
Compare
7d59987 to
22d8d70
Compare
c3d5122 to
ba14e2a
Compare
22d8d70 to
0cee413
Compare
ce4fa86 to
53dba69
Compare
frontend/lib/src/components/audio/core/useWaveformController.ts
Outdated
Show resolved
Hide resolved
frontend/lib/src/components/audio/core/useWaveformController.ts
Outdated
Show resolved
Hide resolved
frontend/lib/src/components/audio/core/useWaveformController.ts
Outdated
Show resolved
Hide resolved
0caad17 to
8ddc29b
Compare
1a1f8d6 to
fa00074
Compare
5bcbbef to
dc6bbd0
Compare
9acade9 to
6fbbc3e
Compare
sfc-gh-bnisco
approved these changes
Oct 31, 2025
6fbbc3e to
73aa243
Compare
dc6bbd0 to
2f6226e
Compare
73aa243 to
11a99ff
Compare
2f6226e to
244738a
Compare
- Update WaveformControllerEvents type to allow Promise<void> return - Await onApprove callback in useWaveformController
- Mark all onApprove callback invocations with void operator - Ensures promises are explicitly handled per linting rules
Change the onApprove callback signature from `void | Promise<void>` to always return `Promise<void>` for API consistency. Changes: - Update WaveformControllerEvents type signature - Make AudioInput onApprove implementation async with await - Update test type annotations This provides a consistent async interface and prevents bugs from assuming synchronous behavior when the callback may be async.
Remove the internalMountRef fallback and make containerRef required in useWaveformController to maintain architectural consistency with ChatInput. Changes: - Remove internalMountRef and fallback logic - Make containerRef required in UseWaveformControllerParams - Replace all mountRef references with containerRef - Return containerRef as mountRef in the controller interface This maintains API compatibility while enforcing consistent ref management patterns across the codebase.
Add vertical padding to StyledWaveSurferDiv to restore spacing that was previously baked into the height calculation when switching from explicit height to 'auto'. Changes: - Add paddingTop and paddingBottom using theme.spacing.threeXS - Replaces the previous approach where WAVEFORM_PADDING was included in the height calculation (height = WAVEFORM_HEIGHT + WAVEFORM_PADDING) This properly separates concerns - WaveSurfer handles waveform dimensions while CSS handles spacing.
Remove the throw and .catch() pattern that was causing errors to be reported twice - once in initializeWaveSurfer's catch block and again in the useEffect's catch handler. Changes: - Remove throw from initializeWaveSurfer catch block - Remove .catch() from useEffect - Handle errors once in initializeWaveSurfer where they occur This creates a single, clear error handling point and prevents duplicate error reporting to the onError callback.
All WaveformControllerEvents callbacks now consistently return Promise<void> instead of mixing void and Promise<void> return types. This provides a more predictable API and aligns with modern async/await best practices where "always async" is preferred over "sometimes async".
The lastStopResultRef was caching stop results as a defensive fallback for: 1. Returning cached results when stop() called repeatedly 2. Providing fallback blob in approve() when state is cleared This is overly defensive and hides bugs in state management. If stop() is called when not recording, that's a bug. If approve() can't find the blob, that's also a bug. Both should fail loudly rather than return stale data. Simplified approach: - stop() now throws immediately if not recording - approve() uses blob parameter or currentBlob only - Removed all lastStopResultRef cleanup code This forces proper state management and makes bugs visible.
Replaced all `MockRecordPluginClass as any` assertions with `MockRecordPluginClass as unknown as typeof RecordPlugin` to be more explicit about the type we're casting to. While still a type assertion, this is more specific and documents what type the mock is pretending to be, rather than completely bypassing type safety with 'as any'. Also removed the eslint-disable-next-line comments that were suppressing the no-explicit-any rule, since we're no longer using 'as any'.
Add missing RecordPlugin type import to WaveSurferRecordBackend.test.ts. The type was referenced in type assertions (typeof RecordPlugin) but never imported, causing CI type check failures.
Resolves 25 ESLint violations that were blocking CI: **AudioInput.tsx (8 fixes):** - Add return Promise.resolve() to async callbacks that don't await - Satisfies @typescript-eslint/require-await rule - Callbacks: onPermissionDenied, onError, onRecordStart, onRecordReady, onCancel, onProgressMs, onPlaybackPause, onPlaybackFinish - Maintains Promise<void> interface contract while avoiding unnecessary async overhead **AudioInput.test.tsx (17 fixes):** - Add void operator to unhandled promise calls - Satisfies @typescript-eslint/no-floating-promises rule - Makes explicit that promises are intentionally not awaited - Matches pattern used in useWaveformController implementation These changes maintain the architectural decision (commit 56221c8d0) to have all WaveformControllerEvents callbacks return Promise<void> for API consistency, while satisfying linting requirements. No behavior changes - callbacks already worked correctly.
Only onApprove is truly async (handles encoding/uploading), so it's the only callback that should return Promise<void>. All other callbacks are synchronous (just set React state) and now correctly return void. This eliminates unnecessary async wrappers and Promise.resolve() calls.
244738a to
41b2ef3
Compare
11a99ff to
209efa5
Compare
- Replace useEffect with useExecuteWhenChanged in useWaveformController to follow React best practices for adjusting state on prop changes - Update temporal comment wording in AudioInput styled-components to improve long-term code maintainability
41b2ef3 to
e45c02d
Compare
Contributor
Author
Merge activity
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
change:feature
PR contains new feature or enhancement implementation
impact:internal
PR changes only affect internal code
security-assessment-completed
Security assessment has been completed for PR
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.

Describe your changes
This PR improves the audio recording component by adding proper TypeScript types and enhancing the WaveformController API. Key changes include:
destroy()method for proper cleanupmountRefproperty to allow the component to manage its own containerstop()method, now returning metadata along with the blobonApproveevent handler support async operationsTesting Plan
Contribution License Agreement
By submitting this pull request you agree that all contributions to this project are made under the Apache 2.0 license.