Skip to content

Fix SolaraViz multipage rendering when renderer is absent#2966

Merged
Sahil-Chhoker merged 9 commits intomesa:mainfrom
falloficarus22:fix-solara-viz-multipage-rendering
Dec 24, 2025
Merged

Fix SolaraViz multipage rendering when renderer is absent#2966
Sahil-Chhoker merged 9 commits intomesa:mainfrom
falloficarus22:fix-solara-viz-multipage-rendering

Conversation

@falloficarus22
Copy link
Copy Markdown
Contributor

@falloficarus22 falloficarus22 commented Dec 18, 2025

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 ComponentsView component.

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-defined page_id against the internal 0-based current_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

  • Logic Correction: In mesa/visualization/solara_viz.py, updated ComponentsView to compare the current_tab_index against the enumeration index (i) of the sorted pages rather than the page_id itself. This ensures the active tab always renders the content assigned to that sequential position.

Testing

  • Reproduction Case: Created a test model with a single button component assigned to Page 1 and no renderer. Verified that without the fix, the button is missing from the active tab, and with the fix, it renders correctly.
  • Regressions: Ran pytest tests/test_solara_viz.py to 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 show CompA and Tab 1 will show CompB.

Closes #2965

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Release notes label visualisation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Components don’t render on pages other than 0 when the renderer isn’t passed.

4 participants