Skip to content

Conversation

@lukasmasuch
Copy link
Collaborator

@lukasmasuch lukasmasuch commented Oct 13, 2025

Describe your changes

If a custom key is passed to a st.camera_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.


Note

Use the widget key as the main identity for st.camera_input, and add unit/E2E tests (including a dynamic props scenario) to verify stable IDs and behavior.

  • Camera Input Widget
    • Use key as main identity by setting key_as_main_identity=True in lib/streamlit/elements/widgets/camera_input.py.
  • Unit Tests
    • Add test_stable_id_with_key ensuring the widget ID remains stable across rerenders with the same key.
  • E2E Demo & Tests
    • App: add a dynamic st.camera_input controlled by a toggle to change label, help, and width while preserving state (e2e_playwright/st_camera_input.py).
    • Tests: introduce NUM_CAMERA_INPUT_WIDGETS=5 and update counts; add test_dynamic_camera_input_props validating label/help updates, width, and preserved value; import/utilize helpers click_toggle, expect_help_tooltip, expect_prefixed_markdown.

Written by Cursor Bugbot for commit df67f0d. This will update automatically on new commits. Configure here.

@lukasmasuch lukasmasuch requested a review from Copilot October 13, 2025 21:08
@snyk-io
Copy link
Contributor

snyk-io bot commented Oct 13, 2025

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

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

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

@lukasmasuch lukasmasuch added security-assessment-completed Security assessment has been completed for PR change:feature PR contains new feature or enhancement implementation impact:users PR changes affect end users labels Oct 13, 2025
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 updates the st.camera_input widget to use the key parameter as the main identity when provided, allowing for dynamic parameter changes without recreating the widget in the frontend.

  • Changed key_as_main_identity from False to True in the camera input implementation
  • Added comprehensive unit tests to verify stable widget ID behavior when using keys
  • Added end-to-end tests to validate dynamic property updates while maintaining widget state

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
lib/streamlit/elements/widgets/camera_input.py Updated key_as_main_identity parameter to True for stable widget identity
lib/tests/streamlit/elements/camera_input_test.py Added unit test to verify widget ID stability with custom keys
e2e_playwright/st_camera_input_test.py Added e2e test for dynamic property updates and updated widget count constants
e2e_playwright/st_camera_input.py Added test case with dynamic camera input properties controlled by toggle

@github-actions
Copy link
Contributor

github-actions bot commented Oct 13, 2025

✅ PR preview is ready!

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

@lukasmasuch lukasmasuch marked this pull request as draft October 15, 2025 13:35
@lukasmasuch lukasmasuch changed the title Use key as main identity for st.camera_input widget [WIP] Use key as main identity for st.camera_input widget Oct 15, 2025
@lukasmasuch lukasmasuch marked this pull request as ready for review November 6, 2025 02:02
@lukasmasuch lukasmasuch changed the title [WIP] Use key as main identity for st.camera_input widget Use key as main identity for st.camera_input widget Nov 6, 2025
@lukasmasuch lukasmasuch merged commit e6c7209 into develop Nov 6, 2025
42 of 43 checks passed
@lukasmasuch lukasmasuch deleted the stable-key-identity-for-camera-input branch November 6, 2025 20:53
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 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