-
Notifications
You must be signed in to change notification settings - Fork 4k
Add ScriptRunContext & ThemeContext
#12789
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
Conversation
✅ 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. |
This stack of pull requests is managed by Graphite. Learn more about stacking. |
✅ PR preview is ready!
|
8542499 to
b8a25c9
Compare
0f4bc7a to
62b6dc4
Compare
62224e6 to
46085a1
Compare
62b6dc4 to
9ee3f05
Compare
46085a1 to
bd2f963
Compare
9ee3f05 to
0a8b7fa
Compare
📈 Frontend coverage change detectedThe frontend unit test (vitest) coverage has increased by 0.0200%
✅ Coverage change is within normal range. |
46ed607 to
e0e69c0
Compare
bd2f963 to
8f45c0a
Compare
e0e69c0 to
51c39dc
Compare
8f45c0a to
5c4a28d
Compare
There was a problem hiding this 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
ThemeContextwith theme management properties (activeTheme,setTheme,availableThemes) - Created
ScriptRunContextwith script execution state properties (scriptRunState,scriptRunId,fragmentIdsThisRun) - Updated
LibContextto 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 |
5c4a28d to
91407b6
Compare
51c39dc to
82c26a7
Compare
82c26a7 to
4b7aa49
Compare
91407b6 to
f1c3295
Compare
f1c3295 to
f1903ca
Compare
4b7aa49 to
18e4daf
Compare
f1903ca to
751c098
Compare
18e4daf to
d7551c7
Compare

Describe your changes
Part 2 of
StreamlitContextProviderupdatesAdds new
ScriptRunContextwith the following:scriptRunStatescriptRunIdfragmentIdsThisRunAdds new
ThemeContextwith the following:activeThemesetThemeavailableThemesTesting Plan