Skip to content

Use key as main identity for st.audio_input widget#12720

Merged
lukasmasuch merged 13 commits intodevelopfrom
stable-key-identity-for-audio-input
Oct 8, 2025
Merged

Use key as main identity for st.audio_input widget#12720
lukasmasuch merged 13 commits intodevelopfrom
stable-key-identity-for-audio-input

Conversation

@lukasmasuch
Copy link
Copy Markdown
Collaborator

@lukasmasuch lukasmasuch commented Oct 8, 2025

Describe your changes

If a custom key is passed to the st.audio_input widget it will be used as the main identity. This allows for dynamically changing other parameters in between reruns without causing the widgets to be recreated in the frontend.

GitHub Issue Link (if applicable)

Testing Plan

  • Added unit and e2e tests.

Contribution License Agreement

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

@lukasmasuch lukasmasuch requested a review from Copilot October 8, 2025 11:48
@snyk-io
Copy link
Copy Markdown
Contributor

snyk-io bot commented Oct 8, 2025

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

security/snyk check is complete. No issues have been found. (View Details)

license/snyk check is complete. No issues have been found. (View Details)

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Oct 8, 2025

✅ PR preview is ready!

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

Copy link
Copy Markdown
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 updates the st.audio_input widget to use the key parameter as the main identity for widget ID computation. The change ensures that when a user provides a key, the widget maintains a stable ID even when non-whitelisted parameters change, while still recreating the widget when whitelisted parameters (like sample_rate) are modified.

Key Changes

  • Modified widget ID computation to treat the provided key as the main identity
  • Added sample_rate to the whitelisted parameters for ID computation
  • Added comprehensive unit and E2E tests to verify the stable ID behavior

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
lib/streamlit/elements/widgets/audio_input.py Updated widget ID computation to use key as main identity and added sample_rate to whitelisted parameters
lib/tests/streamlit/elements/audio_input_test.py Added unit test to verify stable widget ID behavior with key parameter
e2e_playwright/st_audio_input_test.py Added E2E test for dynamic audio input ID behavior
e2e_playwright/st_audio_input.py Added test app code for dynamic audio input with different configurations

@lukasmasuch lukasmasuch added security-assessment-completed change:feature PR contains new feature or enhancement implementation impact:users PR changes affect end users labels Oct 8, 2025
@lukasmasuch lukasmasuch marked this pull request as ready for review October 8, 2025 12:31
@lukasmasuch lukasmasuch merged commit 24faf53 into develop Oct 8, 2025
39 checks passed
@lukasmasuch lukasmasuch deleted the stable-key-identity-for-audio-input branch October 8, 2025 18:57
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:users PR changes affect end users

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants