Fix SolaraViz multipage rendering when renderer is absent#2966
Merged
Sahil-Chhoker merged 9 commits intomesa:mainfrom Dec 24, 2025
Merged
Fix SolaraViz multipage rendering when renderer is absent#2966Sahil-Chhoker merged 9 commits intomesa:mainfrom
Sahil-Chhoker merged 9 commits intomesa:mainfrom
Conversation
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes a bug where visualization components assigned to any page number other than 0 failed to render when no space renderer was provided. It also resolves a Solara hook validation warning in the
ComponentsViewcomponent.Bug / Issue
In
SolaraViz, if a user provides custom components and assigns them to a page other than 0 (e.g.,components[(MyComponent, 1)])while omitting the renderer argument, the components never appear. The UI comparison logic was incorrectly matching the user-definedpage_idagainst the internal 0-basedcurrent_tab_index.Expected: The active tab should display the components assigned to the page representing that tab. Actual: Tab 0 attempted to find a component with
page_id == 0. If none existed (because the user started at Page 1), the screen remained blank.Implementation
mesa/visualization/solara_viz.py, updatedComponentsViewto compare thecurrent_tab_indexagainst the enumeration index (i) of the sorted pages rather than thepage_iditself. This ensures the active tab always renders the content assigned to that sequential position.Testing
pytest tests/test_solara_viz.pyto ensure that standard visualizations (where renderer is Page 0) still function correctly.Additional Notes
This change makes the page numbering more robust; for example, if a user passes
[(CompA, 5), (CompB, 10)], Tab 0 will now correctly showCompAand Tab 1 will showCompB.Closes #2965