Skip to content

Conversation

@sfc-gh-nbellante
Copy link
Contributor

@sfc-gh-nbellante sfc-gh-nbellante commented Nov 13, 2025

Describe your changes

I noticed yesterday during the demos that there was a slight visual regression on st.audio_input. The waveform would fill 100% of the height of the component. Luckily, we haven't released this yet, and it is resolved in this PR.

Why was it not caught by snapshot tests? Because getting a deterministic screenshot of a moving waveform (or even just a waveform) is a difficult challenge.

Before fix

image

After fix

image

Contribution License Agreement

By submitting this pull request you agree that all contributions to this project are made under the Apache 2.0 license.

- Added `waveformPadding` parameter to `useWaveformController` for customizable padding.
- Updated height calculation in waveform rendering to account for padding.
- Integrated `waveformPadding` in `AudioInput` component for consistent usage.
- Removed unnecessary padding styles from `StyledWaveSurferDiv` to streamline layout.
@snyk-io
Copy link
Contributor

snyk-io bot commented Nov 13, 2025

Snyk checks have passed. No issues have been found so far.

Status Scanner Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues
Licenses 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@github-actions
Copy link
Contributor

github-actions bot commented Nov 13, 2025

✅ PR preview is ready!

Name Link
📦 Wheel file https://core-previews.s3-us-west-2.amazonaws.com/pr-13010/streamlit-1.51.0-py3-none-any.whl
📦 @streamlit/component-v2-lib Download from artifacts
🕹️ Preview app pr-13010.streamlit.app (☁️ Deploy here if not accessible)

Restores 4px vertical padding that was lost during the refactor to
useWaveformController. The padding is now handled programmatically
by reducing the WaveSurfer height rather than CSS padding, since
absolutely positioned children ignore parent padding.

Changes:
- Add optional waveformPadding parameter to useWaveformController
- When padding > 0: calculate height = container height - (2 × padding)
- When padding = 0 (default): use height="auto" for edge-to-edge fill
- AudioInput passes waveformPadding: 4 for proper spacing
- ChatInput uses default (0) to maintain edge-to-edge behavior
- Add waveformPadding to useCallback dependency array (fixes ESLint)

This approach:
- Fixes AudioInput waveform padding without affecting ChatInput
- Preserves the critical CSS for stacking recording/playback instances
- Avoids CSS-based padding that doesn't work with absolute positioning
@sfc-gh-nbellante sfc-gh-nbellante added security-assessment-completed Security assessment has been completed for PR change:bugfix PR contains bug fix implementation impact:users PR changes affect end users labels Nov 13, 2025
@sfc-gh-nbellante sfc-gh-nbellante changed the title Enhance waveform controller with padding support [fix] Fixes visual regression with st.audio_input waveform Nov 13, 2025
@sfc-gh-nbellante sfc-gh-nbellante marked this pull request as ready for review November 13, 2025 22:32
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes a visual regression in st.audio_input where the waveform was filling 100% of the container height, causing it to touch the edges. The fix changes the approach from CSS padding on the container to calculating a reduced height for the WaveSurfer instance itself.

Key Changes:

  • Removed CSS paddingTop and paddingBottom from StyledWaveSurferDiv that was causing incorrect waveform sizing
  • Added a new waveformPadding parameter to useWaveformController hook to control vertical padding programmatically
  • Modified WaveSurfer height calculation to subtract padding when specified, using convertRemToPx to convert theme values to pixels

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
frontend/lib/src/components/widgets/AudioInput/styled-components.ts Removed CSS padding properties from StyledWaveSurferDiv that were incorrectly applied
frontend/lib/src/components/widgets/AudioInput/AudioInput.tsx Added waveformPadding: 4 parameter when initializing the waveform controller
frontend/lib/src/components/audio/core/useWaveformController.ts Added waveformPadding parameter and logic to calculate WaveSurfer height with padding subtracted, included waveformPadding in dependency array

sfc-gh-nbellante and others added 2 commits November 14, 2025 08:46
Updated the AudioInput component to include a descriptive comment for the waveformPadding property, clarifying its purpose in preventing the waveform from touching the edges. This improves code readability and maintainability.
@sfc-gh-nbellante sfc-gh-nbellante enabled auto-merge (squash) November 17, 2025 17:18
@sfc-gh-nbellante sfc-gh-nbellante merged commit 1f2538c into develop Nov 17, 2025
39 checks passed
@sfc-gh-nbellante sfc-gh-nbellante deleted the nico/fix-waveform-height branch November 17, 2025 18:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

change:bugfix PR contains bug fix implementation impact:users PR changes affect end users security-assessment-completed Security assessment has been completed for PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants