Skip to content

Conversation

@mayagbarnes
Copy link
Collaborator

@mayagbarnes mayagbarnes commented Oct 16, 2025

Describe your changes

Part 2 of StreamlitContextProvider updates
Adds new ScriptRunContext with the following:

  • scriptRunState
  • scriptRunId
  • fragmentIdsThisRun

Adds new ThemeContext with the following:

  • activeTheme
  • setTheme
  • availableThemes

Testing Plan

  • JS Unit Tests: ✅ Updated

@snyk-io
Copy link
Contributor

snyk-io bot commented Oct 16, 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.

Copy link
Collaborator Author

mayagbarnes commented Oct 16, 2025

@github-actions
Copy link
Contributor

github-actions bot commented Oct 16, 2025

✅ PR preview is ready!

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

This was referenced Oct 16, 2025
@mayagbarnes mayagbarnes changed the title Add & use new ScriptRunContext Add ScriptRunContext Oct 16, 2025
@mayagbarnes mayagbarnes changed the title Add ScriptRunContext Add ScriptRunContext & ThemeContext Oct 16, 2025
@mayagbarnes mayagbarnes added security-assessment-completed Security assessment has been completed for PR change:refactor PR contains code refactoring without behavior change impact:users PR changes affect end users labels Oct 16, 2025
@github-actions
Copy link
Contributor

github-actions bot commented Oct 20, 2025

📈 Frontend coverage change detected

The frontend unit test (vitest) coverage has increased by 0.0200%

  • Current PR: 86.0500% (49820 lines, 6946 missed)
  • Latest develop: 86.0300% (49740 lines, 6944 missed)

✅ Coverage change is within normal range.

📊 View detailed coverage comparison

@mayagbarnes mayagbarnes marked this pull request as ready for review October 27, 2025 18:18
@mayagbarnes mayagbarnes requested a review from Copilot October 27, 2025 18:18
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 refactors the context provider architecture by extracting theme-related and script run-related properties from LibContext into two new specialized contexts: ThemeContext and ScriptRunContext. This separation improves performance by allowing components to subscribe only to the context values they actually need, reducing unnecessary re-renders.

Key Changes

  • Created ThemeContext with theme management properties (activeTheme, setTheme, availableThemes)
  • Created ScriptRunContext with script execution state properties (scriptRunState, scriptRunId, fragmentIdsThisRun)
  • Updated LibContext to remove the migrated properties
  • Updated all consuming components to use the appropriate new contexts
  • Modified test utilities to support the new context structure with proper nesting order

Reviewed Changes

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

Show a summary per file
File Description
frontend/lib/src/components/core/ThemeContext.tsx New context for theme configuration and management
frontend/lib/src/components/core/ScriptRunContext.tsx New context for script execution state
frontend/lib/src/components/core/LibContext.tsx Removed theme and script run properties
frontend/lib/src/test_util.tsx Updated test utilities to support new contexts with proper nesting order
frontend/lib/src/index.ts Exported new contexts and their types
frontend/app/src/components/StreamlitContextProvider.tsx Integrated new contexts into provider hierarchy
frontend/app/src/util/useThemeManager.ts Improved theme update logic with functional state update
frontend/app/src/hooks/useViewportSize.ts Updated to consume ThemeContext instead of LibContext
frontend/app/src/components/Sidebar/ThemedSidebar.tsx Updated to consume ThemeContext instead of LibContext
frontend/app/src/components/Header/Header.tsx Updated to consume ThemeContext instead of LibContext
frontend/app/src/components/AppView/AppView.tsx Updated to consume ThemeContext instead of LibContext
frontend/app/src/components/StreamlitDialog/SettingsDialog.tsx Updated to consume ThemeContext instead of LibContext
frontend/lib/src/components/widgets/Form/Form.tsx Updated to consume ScriptRunContext instead of LibContext
frontend/lib/src/components/elements/Tabs/Tabs.tsx Updated to consume ScriptRunContext instead of LibContext
frontend/lib/src/components/core/Block/Block.tsx Updated to consume ScriptRunContext instead of LibContext
frontend/lib/src/components/core/Block/ElementNodeRenderer.tsx Updated to consume ScriptRunContext instead of LibContext
Multiple test files Updated test cases to provide new context overrides in correct nesting order

Base automatically changed from forms-context-fix to develop October 30, 2025 00:39
@mayagbarnes mayagbarnes merged commit 7f8c28f into develop Oct 30, 2025
36 of 37 checks passed
@mayagbarnes mayagbarnes deleted the script-theme-context branch October 30, 2025 01:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

change:refactor PR contains code refactoring without behavior change 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