Skip to content

Minor Refactoring in solara_viz#3059

Merged
Sahil-Chhoker merged 6 commits intomesa:mainfrom
codebreaker32:refactor
Jan 9, 2026
Merged

Minor Refactoring in solara_viz#3059
Sahil-Chhoker merged 6 commits intomesa:mainfrom
codebreaker32:refactor

Conversation

@codebreaker32
Copy link
Copy Markdown
Collaborator

@codebreaker32 codebreaker32 commented Jan 2, 2026

Description

This PR handles the dependences elegantly in SpaceRendererComponent by extending the newer dependencies to the required ones.

The Issue

Previously, the component used dependencies.append(...) directly on the list passed from the parent. In reactive frameworks like Solara (and React), input props should be treated as read-only. Modifying them causes side effects where the parent's local state is unexpectedly altered by the child component. This can lead to hard-to-debug issues where dependency lists grow indefinitely or contain stale data across re-renders in the parent scope.

The Fix

I have replaced the in-place mutation with a safe concatenation strategy. The component now creates a new, transient list for the current render cycle, leaving the parent's data untouched.

Before:

if dependencies:
    dependencies.append(update_counter.value)
else:
    dependencies=[update_counter.value]

After:

viz_dependencies = [update_counter.value]
if dependencies:
    viz_dependencies.extend(dependencies)

Updated by @Sahil-Chhoker to match the PR functionality.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Jan 2, 2026

Performance benchmarks:

Model Size Init time [95% CI] Run time [95% CI]
BoltzmannWealth small 🔵 -0.6% [-1.6%, +0.3%] 🔵 +0.2% [+0.1%, +0.4%]
BoltzmannWealth large 🔵 +0.3% [-0.7%, +1.2%] 🔵 +0.0% [-3.7%, +3.6%]
Schelling small 🔵 +0.7% [-0.6%, +2.0%] 🔵 +1.5% [+0.7%, +2.3%]
Schelling large 🔵 -0.4% [-0.9%, +0.1%] 🔵 +1.1% [-1.4%, +3.8%]
WolfSheep small 🔵 +0.3% [+0.2%, +0.5%] 🔵 -0.1% [-0.3%, +0.1%]
WolfSheep large 🔵 +0.9% [-3.4%, +5.9%] 🔵 -0.2% [-1.3%, +1.1%]
BoidFlockers small 🔵 -0.9% [-1.3%, -0.6%] 🔵 -0.2% [-0.5%, +0.0%]
BoidFlockers large 🔵 -0.6% [-1.3%, -0.0%] 🔵 -0.2% [-0.7%, +0.2%]

@quaquel quaquel added the bug Release notes label label Jan 3, 2026
@EwoutH EwoutH requested a review from Sahil-Chhoker January 9, 2026 10:16
Copy link
Copy Markdown
Collaborator

@Sahil-Chhoker Sahil-Chhoker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!, But this is not what I meant by managing dependencies properly, just keep that line as it is @codebreaker32.

@Sahil-Chhoker Sahil-Chhoker merged commit 9420561 into mesa:main Jan 9, 2026
14 checks passed
@codebreaker32 codebreaker32 deleted the refactor branch January 10, 2026 13:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Release notes label

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants